Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Can someone Interpret texture methods and/or uniforms into QT OpenGL



  • The problem I have with textures is this:

    string filename = string( path );
        filename = directory + '/' + filename;
        GLuint textureID;
        glGenTextures( 1, &textureID );
        
        int width, height;
        
        unsigned char *image = SOIL_load_image( filename.c_str( ), &width, &height, 0, SOIL_LOAD_RGB );
        
        // Assign texture to ID
        glBindTexture( GL_TEXTURE_2D, textureID );
        glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image );
        glGenerateMipmap( GL_TEXTURE_2D );
        
        // Parameters
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glBindTexture( GL_TEXTURE_2D, 0 );
        SOIL_free_image_data( image );
        
        return textureID;
    

    the problem I have with uniforms is that with OpenGL you can pass a name. How would I do this with QT

    glUniform1i( glGetUniformLocation( program, ( name + number ).c_str( ) ), i );
    
    //and
    
    glUniform1f( glGetUniformLocation( shader.Program, "material.shininess" ), 16.0f );
    
    

    if there is no equivalent method is there some kind of work around?


Log in to reply