Skip to main content
GameDev.net gamedev.net
🔒 Locked

glBindTexture() inside of glBegin()

Started by JodoKaast Mar 3, 2002 at 8:42 PM 1 replies 6.5k views
Original Post
JodoKaast
JodoKaast
I've got a "GLuint texture[6]" globally declared and in my init function I've got a "AUX_RGBImageRec *TextureImage[6]" declared. I obviously want to load in 6 different textures and then later apply them to various quads. so I say
	for( i = 0; i < 6; i++ )
	{
        if( TextureImage[ i ] = LoadBMP( makeFilename( fgets( buffer, 80, file ) ) ) )
		{
			glGenTextures( 1, &texture[ i ] );
			glBindTexture( GL_TEXTURE_2D, texture[ i ] );
			glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage[ i ]->sizeX, TextureImage[ i ]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[ i ]->data );
			glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
			glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
		}
		if( TextureImage[ i ] )
		{
			if( TextureImage[ i ]->data )
			{
				free( TextureImage[0]->data );
			}
			free( TextureImage[ i ] );
		}
	}    
presuming this will load my 6 textures (from my text file) into texture[ i ], from 0 to 5. It appears to, because when I am in my display function and I say "glBindTexture( GL_TEXTURE_2D, texture[0] );" or any other texture[num] it displays the right texture, BUT only if the glBindTexture() function is outside of my glBegin() - glEnd() block. If I try to glBindTexture() inside of glBegin() it automatically uses the 6th texture, no matter what value I give it. I need to draw multiple quads, each with a different texture, in my glBegin() - glEnd() block, but it's not working... Help? Edited by - JodoKaast on March 3, 2002 9:44:31 PM
benjamin bunny
benjamin bunny
From MSDN (and presumably the OpenGL 1.1 Man pages) under glBegin()/glEnd()

quote:

You can use only a subset of OpenGL functions between glBegin and glEnd. The functions you can use are:
glVertex
glColor
glIndex
glNormal
glTexCoord
glEvalCoord
glEvalPoint
glMaterial
glEdgeFlag



From the glBindTexture page in the error codes section:

GL_INVALID_OPERATION glBindTexture was called between a call to glBegin and the corresponding call to glEnd.

Perhaps you should try reading the manual in future


www.elf-stone.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.