Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

juggerp

loading textures multiple times?

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

Hello, I have a question regarding textures. I currently have a game board that is 10x12 using hexagons as tiles. As it stands currently, I have exactly one IDirect3DTexture8 pointer that is initialized using the CreateTextureFromFileEx() function, grabbing a bitmap called grass01.bmp. Since I plan to have many different textures to serve as terrain, units, etc., do I have to load each bitmap separately, say into an array of texture pointers? I was originally going to have a large bitmap (640x640) that would hold 100 64x64 texture graphics, which would get loaded from the CreateSurfaceImage() function into a IDirect3DSurface8* pointer. However, there doesn't seem to be a way to transfer a subset of pixels from the large bitmap to a texture. So pretty much right now I load the texture using CreateTextureFromFileEx(), then call SetTexture(), then DrawPrimitive() in a nested while loop that goes through each tile on my board and calls the functions. Does anyone have a better way of doing this? Thanks, Greg [edited by - juggerp on June 9, 2004 1:52:29 AM]

Share this post


Link to post
Share on other sites
Advertisement
IDirect3DDevice9::StretchRect can be used to copy subsets of video memory surfaces to another ones.

However...

The optimal way in terms of efficiency is to pack all the small textures into one large texture (a "texture atlas" in common terms), set it as current texture, and using texture coordinates to control which geometry uses which part of the large texture.
This way, you don''t have to call SetTexture and/or DrawPrimitive* all that often, thus reducing state changes which is generally good for various reasons.

-Nik

Share this post


Link to post
Share on other sites

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