stbi_load
failed to load your image. pixels
is null, and width
, height
and channels
are uninitialized. Their contents are undefined.
The error is reported in windows.c
, line 552, because the provided image dimensions contain a negative number, or zero.
m_Icon[0].width = width;
m_Icon[0].height = height;
You are initializing the image with data that was not initialized by STB; the data is read from the stack's memory, and this data is undefined in this context.
You need to do proper error handling:
bool loadIcon(void) {
int width, height, channels;
unsigned char* pixels = stbi_load("resources/slika1.png", &width, &height, &channels, 4);
if (!pixels) {
return false;
}
GLFWimage image;
image.width = width;
image.height = height;
image.pixels = pixels;
glfwSetWindowIcon(m_Window, 1, &image);
stbi_image_free(pixels);
return true;
}
Side note: you're assigning pixels
to an outer variable, m_Icon
, but then immediately deallocating this data with stbi_image_free(m_Icon[0].pixels)
. You can not use this data after freeing it.