• Advertisement
Sign in to follow this  

Sprite reading through Opengl

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

Hi, I am trying to read a sprite from sprite sheet and want to display it using opengl(c++).I am not able to get a proper logic for extracting a particular sprite and display it using a quad in opengl.If anyone one can give me any suggestions it will be very helpfull. Thanks in advance...

Share this post


Link to post
Share on other sites
Advertisement
You need to bind a texture for your sprite sheet image and then draw a textured quad, with texture coordinates describing the correct part of the image. The way you find the correct part will depend on the sprite sheet, you may need to load a separate file describing the frame rectangles explicitly, or if your sprites are arranged in a regular grid you may be able to compute an offset based on the frame your on and a constant frame size.

Share this post


Link to post
Share on other sites
Quote:
Original post by Somnia
You need to bind a texture for your sprite sheet image and then draw a textured quad, with texture coordinates describing the correct part of the image. The way you find the correct part will depend on the sprite sheet, you may need to load a separate file describing the frame rectangles explicitly, or if your sprites are arranged in a regular grid you may be able to compute an offset based on the frame your on and a constant frame size.


Hi,
I will be using sprite sheet of sizes power of 2 like 512x512 or 1024x768 etc.
The sprite sizes if that too if i take it as power of 2 then whats the logic can you please elaborate.

Share this post


Link to post
Share on other sites
Sorry I'm not sure what your question is. Do you know how to load an image, bind a texture, draw a quad and use texture cordinates? If not there are lots of tutorials about, here for example: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06

If so then the only problem is knowing the correct texture coordinates that describe the image sub region for the frame you want to draw. There are lots of ways of handling this, usually involving some kind of meta-data file loaded along with the animation that contains this information.

Share this post


Link to post
Share on other sites
I created a video tutorial on this which you can download here:
http://www.marek-knows.com/downloadSection.php?Topic=OpenGL&pg=1

Share this post


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

  • Advertisement