Polytonic / Glitter

Dead Simple OpenGL
http://polytonic.github.io/Glitter/
2.46k stars 416 forks source link

Can't load/open image files #83

Closed dr-e-young closed 8 months ago

dr-e-young commented 8 months ago

I've been trying to load in an image but it keeps failing to load.

My code is: ` int image_width, image_height, n; unsigned char * grassImage = stbi_load("container.jpg", &image_width, &image_height, &n, 0);

if (grassImage == NULL) { fprintf(stderr, "Ground::Initialize: Couldn't load grass.tga\n"); std::cout << stbi_failure_reason() << std::endl; } `

I am compiling using cmake on linux terminal and the file is placed in the same directory as the source file with the above code. The error given is always "can't fopen". I have tried a few different images with different formats with no change (the "container.jpg" file is directly from https://learnopengl.com/Getting-started/Textures). I tried to fopen the file myself and that also didn't work.

Am I just doing something wrong? Is there something else I should check? I'd really appreciate any help anyone could offer.

dr-e-young commented 8 months ago

Based on what I read in another issue, I tried putting the image file in the Build directory which worked. I've made a textures subdirectory in the Build directory, then created a symbolic link to the directory in the Glitter/Sources directory which makes it easier to work with. If anyone else is also struggling with this, I hope this helps.