opengl/texture.cpp
//Untested
/**
 * Loads the texture from the given file name (file name sets by the constructor).
 * Texture is converted to 8bits 3 channels.
 * @brief Texture::load_8UC3
 * @return
 */
Untested
Loads the texture from the given file name (file name sets by the constructor).
Texture is converted to 8bits 3 channels.
Untested Loads the texture from the given file name ( file name sets by the constructor ) . Texture is converted to 8bits 3 channels .
bool Texture::load_8UC3()
{
    QString imagePath = QString("%1").arg(m_filePath.c_str());
    QImage texture = QImage(imagePath);
    if (texture.isNull())
    {
        cout << "Could not load the texture : " << QDir::currentPath().toStdString() + m_filePath << endl;
        return false;
    }
    else
    {
        QImage mirroredTexture = texture.mirrored();
        m_width = mirroredTexture.width();
        m_height = mirroredTexture.height();
        mirroredTexture.convertToFormat(QImage::Format_RGB888);
        glGenTextures(1, &m_textureId);
        glBindTexture(GL_TEXTURE_2D, m_textureId);
        QImage textureOpenGL = QGLWidget::convertToGLFormat(mirroredTexture);
        m_numberOfComponents = 4;
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureOpenGL.bits());
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
        glBindTexture(GL_TEXTURE_2D, 0);
    }
    m_isTextureLoaded = true;
    return true;
}
bool Texture :: load_8UC3 ( ) { QString imagePath = QString ( " " ) . arg ( m_filePath . c_str ( ) ) ; QImage texture = QImage ( imagePath ) ; if ( texture . isNull ( ) ) { cout << " " << QDir :: currentPath ( ) . toStdString ( ) + m_filePath << endl ; return false ; } else { QImage mirroredTexture = texture . mirrored ( ) ; m_width = mirroredTexture . width ( ) ; m_height = mirroredTexture . height ( ) ; mirroredTexture . convertToFormat ( QImage :: Format_RGB888 ) ; glGenTextures ( 1 , & m_textureId ) ; glBindTexture ( GL_TEXTURE_2D , m_textureId ) ; QImage textureOpenGL = QGLWidget :: convertToGLFormat ( mirroredTexture ) ; m_numberOfComponents = 4 ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , m_width , m_height , 0 , GL_RGBA , GL_UNSIGNED_BYTE , textureOpenGL . bits ( ) ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , GL_REPEAT ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , GL_REPEAT ) ; glBindTexture ( GL_TEXTURE_2D , 0 ) ; } m_isTextureLoaded = true ; return true ; }
Untested
 Loads the texture from the given file name (file name sets by the constructor).
Untested Loads the texture from the given file name ( file name sets by the constructor ) .
//Load the texture in BGR format //If the texture cannot be loaded //The texture has to be inverted as the coordinate system for the (u,v) coordinates and the QImage are different //Convert image to pixels [in 0;255] //Generate the texture id //Bind a texture 2D to the texture //Send the data to the memory //The first GL_RGB says that the data used will be in the RGB format // !!!!!!!!!!!!!!!!!!!!!! GL_RGB clamps the texture between 0 and 1 range. // To use floats above 1 : use GL_RGB32F //The second one says that texture.data is stored in BGR format (OpenCV) //Smooth close textures //Do not smooth textures that are far away (performance optimisation) //Repeat the texture //Unbind //Texture correctly loaded