Jump to content
  • Advertisement
Sign in to follow this  
Solance

OpenGL Little C++ opengl help please :)

This topic is 4797 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

Could i get a example of how to use this say i have a image drawn like so.
glBegin(GL_QUADS);
				glTexCoord2f(0.0f, 0.0f),		glVertex3f(-1.0f, -1.0f, 0.0f);
				glTexCoord2f(1.0f, 0.0f),		glVertex3f(1.0f, -1.0f, 0.0f);
				glTexCoord2f(1.0f, 1.0f),		glVertex3f(1.0f, 1.0f, 0.0f);
				glTexCoord2f(0.0f, 1.0f),		glVertex3f(-1.0f, 1.0f, 0.0f);
	glEnd();



how would i grab say a 16x16 portion from 32x32 using glCopyTexSubImage2D()? [Edited by - Solance on May 26, 2005 5:32:17 PM]

Share this post


Link to post
Share on other sites
Advertisement
I have tried this

glCopyTexSubImage2D(
GL_TEXTURE_2D,
0,
(x - CLIENTHBUF) * TILESIDE,
(y - CLIENTVBUF) * TILESIDE,
0,
0,
TILESIDE,
TILESIDE
);



but all it draws is white... could i get a example of how you guys have used this?

Share this post


Link to post
Share on other sites
The simpler and faster method is to use different texture coordinates,
e.g.

// displays the upper left quarter of a given texture
glBegin(GL_QUADS);

glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);

glTexCoord2f(0.5f, 0.0f);
glVertex3f(1.0f, -1.0f, 0.0f);

glTexCoord2f(0.5f, 0.5f);
glVertex3f(1.0f, 1.0f, 0.0f);

glTexCoord2f(0.0f, 0.5f);
glVertex3f(-1.0f, 1.0f, 0.0f);

glEnd();



HTH,
Pat

Share this post


Link to post
Share on other sites
Yes thanks for that but why does it, only draw white? could i get a example of the function in use?

Share this post


Link to post
Share on other sites
Have you made sure the texure loading routine was successful, and that you have bound it before using glTexCoord with glBindTexture? You could also try disabling any lighting if that's enabled, just to make sure the lighting isn't the problem?

Share this post


Link to post
Share on other sites
yes i can draw the texture to the screen fine, but when i draw it the copy just gets white, using x=0 y=0 still just white everything is just white.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!