Difficulty using SOIL library with Qt



  • Alright so after a painful extravaganza trying to build a 64bit flavor of SOIL, I managed to link to the library in my .pro file (in Qt Creator) and establish 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?


  • Moderators

    Hi,

    I don't know how SOIL works, but the 1st thing I'd do is check that the image file can be loaded.

    Try do display ":/gfx/gfx/back.png" in a QLabel -- does it show up?



  • Good thought, so I did I created a QLabel and set the internal pixmap (using Qt Creator's gui) as this image and sure enough it showed up. So it seems the resource is fine, I wonder if anyone has had experience using SOIL in Qt?


  • Lifetime Qt Champion

    Hi,

    Are you sure SOIL supports reading files from Qt's resources ?
    You should first try to load your file from the hard drive to ensure SOIL works correctly.

    Also, I would rather do that in the initializeGL function since it's the function dedicated to all the OpenGL setup

    Hope it helps


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.