[solved] Adding image resource files to a C++ None-QT Project
-
I really like the IDE, but can't seem to find any article on how to add image files to a C++ None-QT project. I'm currently trying to load a BMP image using SDL, and similar to adding nested folders in QT, I'm pretty sure I have to write something into my .pro file indicating the exisistence of the image folder.
I assumed I could just create a new folder in my project folder and point towards that folder location, but it's not working.
I also found this article: http://qt-project.org/doc/qt-5.0/qtcore/resources.html but it seems to focus on QT Projects, maybe I'm reading wrong.
Thanks in advance!
-
I'm not sure what you are talking about. If you just want your image files to show up in Qt Creator, you can do this by adding this to your .pro file:
@
OTHER_FILES += path/to/the/file
@If you want to use resources as in Qt Resource System, you do need to use Qt in the project, too (at least Qt Core module; you do not need the rest for QResource to work).
Or you could just use rcc (resource compiler) and then include the resulting .cpp files. That would be a lot of work, however. to make it work.
-
Thanks for the response sierdzio. I'm using SDL in order to load BMP files on to the video card (among other things) since OpenGL doesn't do that.
I just wanted to verify if there was anything else I needed to do in order to use my image files within my project.
I'm using the Resource Compiler, I've edited the file in a text editor and I can see the images within the editor....but unfortunately SDL_Surface() returns NULL. My game runs perfectly if I comment out the line where I add the filename for the bmp texture. I can't get my image to load and I have a feeling I'm doing something wrong within QTCreator...I might be wrong. Since the image doesn't load the function breaks and program stops.
I also made sure my bmp is 16bits R5 G6 B5.
Here's the code if anybody wants to take a look at it:
[quote author="sierdzio" date="1388955260"]I'm not sure what you are talking about. If you just want your image files to show up in Qt Creator, you can do this by adding this to your .pro file:
@
OTHER_FILES += path/to/the/file
@If you want to use resources as in Qt Resource System, you do need to use Qt in the project, too (at least Qt Core module; you do not need the rest for QResource to work).
Or you could just use rcc (resource compiler) and then include the resulting .cpp files. That would be a lot of work, however. to make it work.[/quote]
-
Nevermind, I solved my issue. For those of you who run into the same problem, it doesn't have to do with using the QT Resource System or anything complicated. I made a newbie mistake of NOT adding my images in the Debug Folder. In my case: "build-Forge-Desktop_Qt_5_1_1_GCC_32bit-Debug".
After that my SDL_GetError() message changed from "Can't open file.bmp" to "Unknown pixel format". Now we see the file without using the Resourse System, just dumping the images in the correct folder.
In order to fix the Unknown pixel format issue. Open the BMP in your favorite image editor, and save the BMP to 24bits R8 G8 B8. It worked for me. Good luck.