LoadBMP doesnt work


I just started OpenGL coding under MSVC++, learning from the NeHe Tuts. I’m on Texture mapping now and want to load a bitmap. The problem is, I always get an C3861 Error at compiling the Code. The part of the Code looks following, please forgive the german in it :wink: :

int LoadGLTextures() { //Bitmaps laden und in Texturen konvertieren
	int Status = FALSE;

	AUX_RGBImageRec *TextureImage[1]; //Speicherplatz für die Textur anlegen
	memset(TextureImage,0,sizeof(void *)*1); //...aber vorher lieber schauen ob der auch leer ist ;-)

	if (TextureImage[0]=LoadBMP("cronk_cube.bmp")) { //Grafik laden
		Status = TRUE; //Alles klar :-)

		glGenTextures(1, &texture[0]); //Textur erstellen
		glBindTexture(GL_TEXTURE_2D, texture[0]); //Als 2D Textur deklarieren
		glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX,TextureImage[0]->sizeY, 0, GL_RGB,GL_UNSIGNED_BYTE, TextureImage[0]->data); //Diverses über die Textur
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //parameter

	if (TextureImage[0]) {
		if (TextureImage[0]->data) {

well, i don’t have all error codes in my head, but looking at google output, C3861 seems to be “identifier not found”.

this means you try to use a variable that is nowhere defined. can you post the whole error message?

My VC says about C3861: ‘identifier’: identifier not found, even with argument-dependent lookup

Make sure you have defined all functions and variables in the source or included the correct headers with the defines.

If that code is taken from a tutorial, that’s bad teaching.
I would have structured it more like this:

BOOL LoadGLTextures(void)
    BOOL Status = FALSE;
    AUX_RGBImageRec *TextureImage = NULL;

    if ((TextureImage = LoadBMP("cronk_cube.bmp")) != NULL)
        if (TextureImage->data)
            // Is this texture array defined in your code?
            glGenTextures(1, &texture[0]);
            if (texture[0])
                glBindTexture(GL_TEXTURE_2D, texture[0]);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
                // Watch out RGB unsigned bytes is not aligned to the default of 4 
                // with sizes < 4! Happens with mipmaps a lot! 
                glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
                // Add code to make sure sizes are power-of-two or 
                // EXT_texture_non_power_of_two is supported!
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, // specify precise internalFormat
                            TextureImage->sizeX, TextureImage->sizeY, 0,
                            GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);

                Status = TRUE; 
        // Code looks like this needs to be freed.
        // Check the LoadBMP implementation how the pointer is filled. 
    return Status;

(I have not tried to compile that.)

Looks like we really have to get all the new lessons up and running, they have a whole new way of loading textures, and we do expect them to become somewhat of a standard. :slight_smile:

About this code, maybe AUX_RGBImageRec is not complete.
Check all your code once again against lesson06 to see if you have it all typed in correctly.
Also check and see if you have glAux installed on your system, if not i have a replacement code available on the nehe forum, just check for a thread that contains a post by lc_overlord (me if you didn’t know) and look in the signature.

OK, I got it to work, it was my stupid fault.
I declared “LoadBitmap” a view lines above, I changed that to “LoadBMP” and what happened? It works! Thanks for your support!