• Advertisement
Sign in to follow this  

DirectX9 - Need some direction with Textures/Surfaces

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

I am attempting to create a map to present to the user.

I have several tiles that are in PNG format which I need to use to piece together the map.

I have considered using Textures, but with it only being 2 dimensional I'm thinking I should just stick with Surfaces.

Question is this:

In my Main I have a reference to a DX9 class which has everything I need initiated, a primary surface/texture, and a secondary surface/texture which I plan to use to swap with the primary surface after the tiles have been rendered.

I have a MapTile class that has a DX9 Surface/Texture, as well as my image location information and positional arrangement.

I am reading through my tiles and creating a new Surface/Texture for each tile. After which I need to place the individual map tiles accordingly to the Secondary surface. And then I need to swap this with the primary. This was the older approach of doing this in older versions of DirectX.

In older DirectX this required blt'ing the surface onto the other surface, is this done the same way? Or has this method been improved/modified? And am I taking the right approach? Also, would I be better off using Textures or dealing with Surfaces?

Share this post


Link to post
Share on other sites
Advertisement
Can anyone point me to a nice tutorial? I'm having trouble finding any resources that don't conflict with each other.

Share this post


Link to post
Share on other sites
Texture are composed of one/more surface so they are kinda the same. Textures are uploaded to the videocard and not surfaces. A surface is just a region of memory, whether in video, AGP or system memory.

Share this post


Link to post
Share on other sites
So how would I go about loading multiple surfaces/textures from files and then composing them to the screen?

Sounds like if I use textures I won't need to do any combining, but then how do you position it?

Say I call the
CreateTextureFromFile( Device, SrcFile)

I now have the texture Created. How do I display it then? And say I have 2 256x256 pngs, how would I display them side by side?

I thought I'd have to create a backdrop surface/texture and then load the individual ones into this. Is that not right?

Share this post


Link to post
Share on other sites
Looking at the post here I might have found a solution:
http://www.gamedev.net/community/forums/topic.asp?topic_id=141253

If I understand this correctly these should be my steps:

CreateOffscreenPlainSurface to initialize my new surface.
D3DXLoadSurfaceFromFile will load the PNG into the newly created Surface.
Retrieve the Surface from my Texture by Callin gthe GerSurfaceLevel at level 0 of my Backdrop Texture;
Then call D3DXLoadSurfaceFromSurface loading the newly created Surface into the Surface I retrieved from the Backdrop Texture.
I can then use the destRect and srcRect properties passed in this method to load the newly craeted Surface to the correct position in the Backdrop Texture's Surface.

Is this right?

Share this post


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

  • Advertisement