PDA

View Full Version : Qt and SOIL library



Zamaster
4th March 2014, 05:26
Alright so after building a 64bit flavor of SOIL, I linked to the library in my .pro file (in Qt Creator) and established the include directory. I have hit a problem. This is with my image resources:

I have a png in an image resource and used the resource editor "Copy Resource Path to Clipboard" feature to grab the path. I then dropped the path into a SOIL_load_OGL_texture function call within a GLWidget constructor. Heres the code:


MyGLWidget::MyGLWidget(QWidget *parent) :
QGLWidget(parent)
{
tex = SOIL_load_OGL_texture(":/gfx/gfx/back.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
qDebug() << tex;
}


My issue here is that 0 is always being spit back to the console, which I know means the function failed. Anybody notice anything I missed? (I have verified that the image resource is indeed working by loading it in a QLabel)

anda_skoa
4th March 2014, 10:41
That SOIL API doesn't look like if SOIL is a Qt library, it looks more like a plain C library instead.

Only Qt based file access, e.g. using QFile, understands Qt's resource paths.

If the library can work with the data directly then you can use QResource to get access to the built-in data.
If it can only deal with files, write the data to a QTemporaryFile and pass its filename to the external API.

Cheers,
_

Zamaster
6th March 2014, 22:50
Ah, duh, exactly what I needed. Thanks!