Texture Mapping Question! ARGH

Started by
7 comments, last by akudoi 22 years, 7 months ago
i cant seem to figure out why this isnt working its for my sprite class for an engine im writing.
  
void eSprite::render()
{

	// SETUP AN ORTHO SCREEN FOR RENDERING

	glMatrixMode(GL_PROJECTION);					//Select the projection matrix

	glPushMatrix();									//Store the projection matrix

	glLoadIdentity();								//Reset the projection matrix

	glOrtho(0,800,0,600,-1,1);	//Set up an ortho screen


	
	glBindTexture(GL_TEXTURE_2D, image.ID); 

	glBegin(GL_QUADS);					// Start Drawing Our Quads

		glTexCoord2i(1,0);		glVertex2i(x,y);				// Bottom Left

		glTexCoord2i(1,1);		glVertex2i(x,y+h);				// Bottom Right	

		glTexCoord2i(0,1);		glVertex2i(x+w,y+h);			// Top Right

		glTexCoord2i(0,0);		glVertex2i(x+w,y);				// Top Left

	glEnd();

	// DESTROY THE ORTHO SCREEN

	glMatrixMode(GL_PROJECTION);					//Select the projection matrix

	glPopMatrix();									//Restore the old projection matrix

	glMatrixMode(GL_MODELVIEW);						//Select the modelview matrix

}
  
i dont know how to include links and images so here is a screenshot of the problem. www.avalonstudios.ca/eve/problem.jpg the images are always fliped... argh why? thanks
Advertisement
Your answer to the flipping problem is glRotatef() 180 degrees

"I''ve sparred with creatures from the nine hells themselves... I barely plan on breaking a sweat here, today."~Drizzt Do''Urden
------------------------------Put THAT in your smoke and pipe it
actually i dont think the answer is glRotatef() 180. WHen you map your coords you have a slight error i think. It should be this:

glBegin(GL_QUADS);
// Start Drawing Our Quads

glTexCoord2i(0,0); glVertex2i(x,y);


glTexCoord2i(1,1); glVertex2i(x+w,y+h);


glTexCoord2i(0,1); glVertex2i(x,y+h);


glTexCoord2i(1,0); glVertex2i(x+w,y);


glEnd();

try that

Edited by - taybrin on September 5, 2001 8:14:25 PM
"PC Load Letter, what the F*Ck's that" ~Office Space
Uhh... not for QUADS. You''re drawing corner to corner with the above code...

Keep the vertices in the same order, but invert the "s" coordinates. Where you''ve currently got a 0, put a 1, where it''s 1, put a 0...

...(0,0) ...(x,y)
...(0,1) ...(x,y+h)
...(1,1) ...(x+w, y+h)
...(1,0) ...(x+w, y)




Woohoo

thanks a lot.. i got it fixed

back to hardcore coding
miles -were you referring to my solution or the original posters???

Edited by - taybrin on September 5, 2001 9:37:13 PM
"PC Load Letter, what the F*Ck's that" ~Office Space
actually miles code helped. when i used yous taybrin''s code. it twisted the quad into 2 triangles.
my fault, i have never actually texture mapped anything i was just trying to line up your coorindates correctly. You had the coordinates mismatched but in order, i put them matched correctly but out of order!! we both learned something . . .
"PC Load Letter, what the F*Ck's that" ~Office Space
lol yep.. its all good.. its working

we both learnt something new.

This topic is closed to new replies.

Advertisement