Sign in to follow this  
CodeZero

Loading sprites from a large image.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this