Click here to Skip to main content
14,932,748 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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

<pre lang="c++">
warning: C4005: 'CALLBACK': macro redefinition

this line gives the macro warning and the file is minwindef.h:
#define CALLBACK    __stdcall


The codes:

C++
void loadGLTextures()
    {
        QImage t;
        QImage b;

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

            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, 3, t.width(), t.height(), 0, GL_RGBA, 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 );
    }


After running the code, QMessage pops saying 'Could not load file', I am not sure if what's wrong.

What I have tried:

tried changing some original code but still error bmp file cannot be loaded
Posted
Updated 3-Aug-18 15:29pm
v2
Comments
Jochen Arndt 27-Jul-18 4:15am
   
Please try to be more specific on what is not working.
Does the b.load() call fail?
If so, does the file nehe.png exist (is an embedded resource)?
If it exists, is it a valid image file (the extension indicates a PNG, not a BMP)?

Regarding the macro redifinition:
Check where it is defined (both places). The warning message should contain this information. Then check why it happened. We can't help without knowing about the definitions and which files contain them. It might a conflict of different versions or a conflict between unrelated modules.
Member 13927363 3-Aug-18 20:45pm
   
Hi, I have updated again the question. Regarding your question, I am really not sure what part fails, since it's working. The only problem is that the texture didn't loaded which if the image .bmp file.

While regarding the macro redefinition, I clicked the error and from this part '#define CALLBACK __stdcall' gives the warning with the file minwindef.h

Hope you can help. THANK YOU

1 solution

That doesn't look like a valid file name to me :
if ( !b.load( ":/images/nehe.bmp" ) )
You need to either remove the colon or insert a drive letter.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900