From d8c9066b78efcb2cd430e3aa90eac0ba80693d08 Mon Sep 17 00:00:00 2001 From: Guillaume Sarthou Date: Fri, 16 Aug 2024 12:30:52 +0200 Subject: [PATCH] [GLFW] add icon --- src/Engine/Graphics/GLFW/Window.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Engine/Graphics/GLFW/Window.cpp b/src/Engine/Graphics/GLFW/Window.cpp index cd094667..60c8b101 100644 --- a/src/Engine/Graphics/GLFW/Window.cpp +++ b/src/Engine/Graphics/GLFW/Window.cpp @@ -1,5 +1,8 @@ #include "overworld/Engine/Graphics/GLFW/Window.h" +#include "overworld/Compat/ROS.h" +// should be first + #include #include @@ -7,6 +10,12 @@ #include "overworld/Engine/Graphics/OpenGL/Camera.h" #include "overworld/Engine/Graphics/OpenGL/Renderer.h" +#ifndef STB_IMAGE_IMPLEMENTATION +#define STB_IMAGE_IMPLEMENTATION +#define STB_IMAGE_STATIC +#include "stb_image.h" +#endif + // Should be last #define GLFW_EXPOSE_NATIVE_X11 #include @@ -24,6 +33,12 @@ namespace owds { // glfwWindowHint(GLFW_SAMPLES, 4); glfw_window_ = glfwCreateWindow(640, 480, name.c_str(), nullptr, nullptr); + GLFWimage icons[1]; + std::string icon_path(owds::compat::owds_ros::getShareDirectory("overworld") + "/docs/images/overworld_light.png"); + icons[0].pixels = stbi_load(icon_path.c_str(), &icons[0].width, &icons[0].height, 0, 4); // rgba channels + glfwSetWindowIcon(glfw_window_, 1, icons); + stbi_image_free(icons[0].pixels); + glfwMakeContextCurrent(glfw_window_); glfwSetWindowUserPointer(glfw_window_, this); glfwSetWindowSizeCallback(glfw_window_, [](GLFWwindow* window, const int width, const int height) {