How to display only part of texture

Started by
2 comments, last by Shmuel 19 years, 3 months ago
I'm porting my engine's renderer from SDL to OpenGL. In SDL, I would use srcrect in the SDL_BlitSurface function and could specify what part of image to blit. How would I do this with OpenGL? I only want to have one texture for all of the tiles.
case ShmuelPosted:StupidPosts++;
Advertisement
You'll just need to change the texture coords you pass ogl. For example if you have a textured quad and you want to display one quarter of the texture you could have the texture coords for the 4 verts of the quad run from 0 to 0.5. You'll want to look at glTexCoord and glTexCoordPointer for details.
glTexSubImage2D should do what you want.

EDIT: Description from MSDN.
Quote:Original post by Nemesis2k2
glTexSubImage2D should do what you want.

EDIT: Description from MSDN.


Thanks, that was exactly what I wanted. Rating++
case ShmuelPosted:StupidPosts++;

This topic is closed to new replies.

Advertisement