Jump to content
  • Advertisement
Sign in to follow this  
Uphoreum

OpenGL [OGL] Use Part of Texture

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

Is there a way, in OpenGL, to use only a part of a texture? Right now, I'm using glTexCoord2i for drawing the textures. The reason I want to do this is, I have a button image, with an up and a down image in one file. When I was using SDL, I would just keep them as one image and only draw the part that I wanted. Can I do this sort of thin in OpenGL?

Share this post


Link to post
Share on other sites
Advertisement
By using glTexCoord2f you can also use fractional values for the texture coordinates. By changing, for example, glTexCoord2i( 1, 1 ) to glTexCoord2f( 0.5f, 1.0f ) only the left half of the texture is used.

Share this post


Link to post
Share on other sites
Yes, use glTexCoord2f and specify the parts of the texture you want.
There are loads of tutorials out there, I suggest next time you have a question like this you use google first.

But here you are, he is a tutorial on how to do texture mapping:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06

If you understand that you'll understand how to solve your problem.

Share this post


Link to post
Share on other sites
One of the more helpful things I've found for understanding how a number of opengl things work is Nate Robins' opengl tutors, found here. There are older versions of this (1999) in the resources section here, but they don't work. The one's I've linked to do.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!