![]() ![]() as 3 or 4 channels and the only thing that matter is how you allocate your textures on the GPU.Īnyway, do you still have a copy of container.jpg that will load correctly? If so, can you try making a copy of it and seeing if the copy will load? If the copy will load, try opening it in MS Paint or anything else, and then just overwriting it with itself, and then try to get it to load in your program again. The number of channels you request be returned in the image data shouldn't matter when it comes to the image type, by which I mean you can have it return a PNG, JPG, BMP, PPM, etc. I assume you're on Windows, and I assume when you say "VS" that you mean Visual Studio, and not VSCode. ![]() Std::cout << "Failed to load image: " << failureReason << GlTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, Unsigned char* data2 = stbi_load("engineer.jpg", &width, &height, &nrChannels, 0) Std::cout << "Failed to load image: " << failureReason << std::endl GlTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data1) Ĭonst char* failureReason = stbi_failure_reason() Unsigned char* data1 = stbi_load("container.jpg", &width, &height, &nrChannels, 0) Stbi_set_flip_vertically_on_load(true) // tell stb_image.h to flip loaded textures on the y-axis load image, create texture and generate mipmap GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) Here's my code, but just as an fyi I also tried the solution code and had the same problem so I'm not really sure where to go from here.ĮDIT: Forgot to mention this but width, height, and nrChannels all return 0 and data is set to null when an image other than container.jpg is sent to stbi_load. I've tried dozens of other png/jpg files and the only one that does not return null is container.jpg. I've been working through the textbook and I've run into a problem where stbi_load refuses to load anything other than the container.jpg image provided by the online textbook. loadFromFile ( "mirrorlakedawn.SOLVED: I made the mistake of adding the files VIA the solution explorer instead of directly adding them to the project files so the imgs were treated as links to the img file locations in my PC's download folder. Then i got the same error "failed to load image", so I search in the internet, put the file (a jpg and a png) in every posible directory (really), put relative paths, absolute paths, implement "/" "//" "\" "\\" and all you can imagine. I've download the 64 bit library for Visual Studio 2015, setting up everything like the tutorial page said. Ok, I moved from codeblocks to Visual Studio. At first I used the codeblocks version (in codeblocks of course) and was great, no bugs, from one moment to another, "Failed to load image!" in one of my classes, in the main function works like a charm, still dont know why. My project consist of a bunch of classes that interacts each other making and managing different objects (sprites, text, sounds, etc) with differents manager classes (Object, resource, scene, etc), some call that an engine, doesnt matter. I know that there are a lot of this kind of post, specially with the "failed to load image" problem, but in those post the solution was, "_hey man check if the working directory is the right one _ Oohhh now it works thanks! " well, this is not the case (I guess). First of all, Hello community!, (my English is bad), This is my first post: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |