Jump to content
  • Advertisement
Sign in to follow this  
CodeZero

Loading sprites from a large image.

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

What would be the easiest way to go about accessing the individual 32 X 32 sprites that are contained in a single, large BMP?

Share this post


Link to post
Share on other sites
Advertisement
What API are you using? It pretty much differs per API. On DirectX you can supply a RECT from where the texture will be blit.

Toolmaker

Share this post


Link to post
Share on other sites
OpenGL is what I'm using. In the past I've loaded all my images in RAW format. The fact that it's a BMP shouldn't matter though, since I can convert it into RAW. I'm guessing that there are OpenGL specific routines that will access certain areas of the data once it's loaded in.

Share this post


Link to post
Share on other sites
LOAD INTO MEMORY
Load the bitmap into memory using auxDIBImageLoad (found in glaux.h). Note that you may be restricted to only using bitmap files whose dimensions are powers of 2. This depends on your machine and the version of OpenGL you are using.

GENERATE TEXTURE
You can generate a texture which provides access to the whole bitmap using glGenTextures and glTexImage2D. glIsTexture is a useful function if you would like to see if texture generation was successful.

BIND TEXTURE COORDINATES TO VERTICES
You can then bind regions of your bitmap to a vertex using glTexCoord. (NOTE: I find it better to use glTexCoord3f because the integer version will differ depending on filesize whereas floats always range from 0 to 1 and don't depend on file-size)

Mark

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!