Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

akudoi

Texture Mapping Question! ARGH

This topic is 6277 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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)




Share this post


Link to post
Share on other sites
miles -were you referring to my solution or the original posters???

Edited by - taybrin on September 5, 2001 9:37:13 PM

Share this post


Link to post
Share on other sites
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 . . .

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!