Icon Resource into a GLFWImage



Thank you for allowing me to join… glad I found your website.

Im completely new to Opengl and Ive created a window 740 x 450, I have a Icon in the resources and when compiled the exe file has the correct icon attached. However, when the window is running I do not see the icon on the window itself and on the taskbar.

Ive created a GLFWImage but can’t seem to work out how to read the Icon from the resources into the GLFWImage so I can assign the icon using:

GLFWimage appIcon;
**// ----- need to read resource icon into appIcon here**
glfwSetWindowIcon(window, 0, appIcon);

I can read in the icon using a HICON and LoadIcon but I cant get my head around loading the icon into the GLFWImage, or am I completely wrong in what I’m doing here?


GLFWimage is 32-bit RGBA raw pixel data. You can simply store image as .bmp/png whatever format image file. Then load with anything you want (like stb_image.h), then fill image width/height/pixels in GLFWimage struct and pass it to the function.

If you want to get raw RGBA pixel values from HICON then this is not really glfw question anymore, but win32 api question. Here’s an information how to do that: https://stackoverflow.com/questions/40907703/how-to-get-rgb-byte-array-for-the-mouse-cursor-in-win32