diff --git a/.gitignore b/.gitignore index 5acb669..5b06f29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build +release-build .vscode diff --git a/inc/native.h b/inc/native.h new file mode 100644 index 0000000..9731480 --- /dev/null +++ b/inc/native.h @@ -0,0 +1,34 @@ +#ifndef NATIVE_H +#define NATIVE_H + +#include +#include +#include +#include +#include + +// A temprary .desktop needed under wayland +std::string desktop_file = + "[Desktop Entry]\n" + "Name=jungle\n" + "Icon={cwd}/icon.png\n" + "Type=Application\n" + "Categories=Game;\n"; +std::string desktop_path = "{home}/.local/share/applications/jungle.desktop"; +std::string home_path = std::getenv("HOME"); + +void nativeSetIcon() +{ + // setting desktop file + std::string cwd = "{cwd}"; + int pos = desktop_file.find(cwd); + desktop_file.replace(pos, cwd.length(), std::filesystem::current_path()); + std::string home = "{home}"; + pos = desktop_path.find(home); + desktop_path.replace(pos, home.length(), home_path); + std::ofstream desktop(desktop_path); + desktop << desktop_file; + desktop.close(); +} + +#endif diff --git a/src/main.cpp b/src/main.cpp index 9197982..51b43d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,13 +10,14 @@ #include "shader_m.h" #include "camera.h" #include "cube_model.h" +#include "native.h" #include #include #ifdef __GNUC__ - //#include - //#include +// #include +// #include #endif #ifdef _MSC_VER @@ -24,7 +25,7 @@ #endif #ifdef __linux__ - + #endif #ifdef _WIN32 @@ -68,13 +69,17 @@ int curr_x; int curr_y; // monitors controlling -int monitor_count; +// int monitor_count; // GLFWmonitor **monitors; GLFWimage icon; int main() { +#ifdef __linux__ + nativeSetIcon(); +#endif + // std::cout << "debug"; // glfw: initialize and configure // ------------------------------ @@ -132,7 +137,6 @@ int main() // ------------------------------------ Shader ourShader("demo.vs", "demo.fs"); - unsigned int VBO, VAO; glGenVertexArrays(1, &VAO); glGenBuffers(1, &VBO); @@ -180,7 +184,6 @@ int main() } stbi_image_free(data); - // tell opengl for each sampler to which texture unit it belongs to (only has to be done once) // ------------------------------------------------------------------------------------------- ourShader.use(); @@ -256,13 +259,14 @@ int main() glfwPollEvents(); timer += deltaTime; - if(timer > 0.3f){ + if (timer > 0.3f) + { glfwSetWindowTitle(window, ("fps:" + std::to_string(int(1.0f / deltaTime)) + " X:" + std::to_string(camera.Position.x) + " Y:" + std::to_string(camera.Position.y) + " Z:" + std::to_string(camera.Position.z)).c_str()); timer -= 0.3f; } - //double renderTime = glfwGetTime() - lastFrame; - // delay_fps(fps, (int)(renderTime * 1000 * 1000)); + // double renderTime = glfwGetTime() - lastFrame; + // delay_fps(fps, (int)(renderTime * 1000 * 1000)); } running = false; @@ -396,8 +400,8 @@ void focus_callback(GLFWwindow *window, int focused) } } - -void glfwDump(GLFWwindow *window){ +void glfwDump(GLFWwindow *window) +{ int clientAPI = glfwGetWindowAttrib(window, GLFW_CLIENT_API); int contextAPI = glfwGetWindowAttrib(window, GLFW_CONTEXT_CREATION_API); int contextVersionMajor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR); @@ -424,7 +428,10 @@ void glfwDump(GLFWwindow *window){ std::cout << "Forward compatibility: " << forwardCompat << std::endl; std::cout << "Debug context: " << debugContext << std::endl; - std::cout << "Window size: " << " width-" << windowSizeWidth << " height-" << windowSizeHeight << std::endl; - std::cout << "FrameBuffer size: " << " width-" << bufferSizeWidth << " height-" << bufferSizeHeight << std::endl; - std::cout << "Window Scale: " << " X-" << bufferSizeWidth << " Y-" << bufferSizeHeight << std::endl; + std::cout << "Window size: " + << " width-" << windowSizeWidth << " height-" << windowSizeHeight << std::endl; + std::cout << "FrameBuffer size: " + << " width-" << bufferSizeWidth << " height-" << bufferSizeHeight << std::endl; + std::cout << "Window Scale: " + << " X-" << bufferSizeWidth << " Y-" << bufferSizeHeight << std::endl; } \ No newline at end of file