Sign in to follow this  
nlraley

DirectX9 - Need some direction with Textures/Surfaces

Recommended Posts

nlraley    126
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
cgrant    1827
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
nlraley    126
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
nlraley    126
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

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