Qt5 OpenGL cannot load bmp file as texture to cube

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Qt5 OpenGL cannot load bmp file as texture to cube



I found this sample project based on NEHE Tutorial but doesn't work on my Qt version 5, tried editing some code but this the file cannot be loaded. And warning exists also



warning: C4005: 'CALLBACK': macro redefinition



The codes:


void loadGLTextures()
{
QImage t;
QImage b;

//../images/nehe.bmp //original file path
if ( !b.load( ":/nehe.png" ) )
{
//b = QImage( 16, 16, 32 );
//b.fill( Qt::green.rgb() );

QMessageBox::information(this, "Error", "Could not load file");

QImage b(16, 16, QImage::Format_RGB32); //******
b.fill(Qt::green); //*************
}

t = QGLWidget::convertToGLFormat( b );

if(t.isNull())
{
QMessageBox::information(this, "Error", "IMAGE IS NULL");
}

glGenTextures( 1, texture );// Create The Texture

glBindTexture( GL_TEXTURE_2D, texture[0] ); //assign a texture name to texture data.

glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, t.width(), t.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, t.bits() );

//Linear Filtering
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived