Advertisement

glBindTexture() and pointers

Started by February 09, 2002 12:08 AM
5 comments, last by akudoi 23 years ago
hey all, I just have a quick question. can glBindTexture accept a pointer? everything in my engine was working great. untill i started a sprite class. in the sprite rendering code i have this.

	glBegin(GL_QUADS);

		glBindTexture(GL_TEXTURE_2D, skin->ID);

		glColor4ub(color[0], color[1], color[2], color[3]);

		glTexCoord2f(texX,		  texY);			glVertex2i(x,       y);
		glTexCoord2f(repX + texX, texY);			glVertex2i(x+width, y);
		glTexCoord2f(repX + texX, repY + texY);		glVertex2i(x+width, y+height);	
		glTexCoord2f(texX,        repY + texY);		glVertex2i(x,       y+height);

	glEnd();
 
everything renders proberly otherwise. and if i bind the texture from main without using pointers and then call the render function it works.. i pass the pointer to the class properly. i''ve narrowed it down to glBindTexture(GL_TEXTURE_2D, skin->ID); is this possible? any suggestions? thanks -akudoi
post the relavant part of the class that skin is derived from, and the code that declares it.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
Advertisement
hey, i was just about to post the code to the entire class when i noticed that you created your own post where you said

The redbook lists glBindTexture as an invalid command for use inbetween glBegin and glEnd function.

i must have forgot that, but i switched glBegin(GL_QUADS); and glBindTexture(GL_TEXTURE_2D, skin->ID); so that its outside the glBegin and it all works perfectly now cool..

thank you!
Good, how can I fix my problem where I cant move it outside the glBegin and glEnd statements?
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
You have to move it outside glBegin()...glEnd(). So I suggest putting multiple textures in to one big texture and changing the texture coords,this way you don't have to call glBindTexture all the time and you can change texture within glBegin() ..glEnd() by altering the texture coords.

Edited by - George2 on February 10, 2002 3:44:17 AM
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
My project works with runtime generated textures, So that wont work for me.

Im going to have to use Vertex Arrays.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
Advertisement
EVERYONE should be using vertex arrays anyway..

This topic is closed to new replies.

Advertisement