#### Archived

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

# How to do layering with DirectDraw surfaces on top of Direct3D scene?

This topic is 6597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I''m trying to develop an isometric engine prototype based on Bracket''s "3D in 2D article" available in the downloads section here. For those familiar with the original code, I''ve converted all the interfaces to DirectX 7 from the old ones and included DirectInput keyboard support. The next step for me is to do some layering with surfaces and I''d like to know the general way (pseudocode perhaps) of how to go about doing this. I''ve gathered quite a lot of techniques on bitmap loading from the net but I can''t seem to get them to work correctly although I''ve managed to code a standalone DirectX app that just loads some pictures. Basically, the game starts rendering a D3D scene by loading numerous textures to form the terrain layer. Now I want to put objects like units, weapons, buildings etc. on top of this terrain layer. I think the best way to do this is to create offscreen DirectDraw surfaces that contain all my objects and then blit them using a coordinate system. Is this the correct approach or is there something missing here? Or perhaps a simpler way of doing layering? Any links to an engine similar to mine or relevant code would be highly appreciated. I believe this technique is actually quite common as I''ve heard that most games that use the isometric view support 3d-acceleration. Another issue: Is it best to load a whole layer (as in full screen) then followed by the next layer or is it better to render all the layers for the first tile then proceed to the second tile and so on? Thanx in advance for any help.

##### Share on other sites
I think it would be much simpler to create a square polygon and texture map your 2d-sprites onto it. It would simplify problems between D3D and DDraw alot.

##### Share on other sites
Well, right now the terrain tiles are rectangular bitmaps that get mapped into isometric diamonds by the texture loading function. I don''t see how I can continue to do this for the 2d sprites because they will definitely get warped upon loading. Unless you''re saying that I draw the diamond-shaped tiles in a paint program but I read some article that says this is very time-consuming work. Of course I could have interpreted your post wrongly.....if so don''t hesitate to clear things up.

##### Share on other sites
To render your units as square polygons, just change the vertexs to the top left and bottom right of your square (not diamond) shape, then call your procedure to set the unit texture and then call DrawPrimitive();

I played around with brackets engine, and have added walls to it, and I''m currently trying to get a zoom function to work correctly.

If you look at how the diamond is created in the vertex[] structures you will see that by simply moving the positions of the corners you will achive the square end product.

  Bracket does the following: 1 /\ / \ / \0/ \3 \ / \ / \ / \/ 2change the points so that they are like this:1 3 +----+ |\ | | \ | | \ | | \| +----+ 0 2if this is wrong ( I think I may have to points labels wrong) then try moving the points around.

Don''t forget to render your units inside of a StartScene() and EndScene() block

##### Share on other sites
hi Steven,

are you saying I should convert all the vertices to form squares instead of diamonds? wouldn''t i then have to draw diamonds (not an easy task according to some articles)? or did you try layering squares on top of diamonds - in other words keep Bracket''s code but extend it further by rendering squares for subsequent layers. Does that work?

Well, right now it''s the marriage of D3D and DDraw that I can''t seem to get working. I thought i''d be better off just using DDraw and blit from offscreen surfaces to the backbuffer b4 flipping. But I get an unknown error from BltFast(), it''s none of the HRESULT values that are returned as stated in the SDK. The problem is in function Layer1Render() right after Demo4Render(). What I''m I doing wrong here? Please feel free to take a look at my code at

http://www.geocities.com/epic709

it''s a mess right now but just try to ignore all the commented out stuff.

##### Share on other sites
well, the problem above has been solved. Thanks anyway.

##### Share on other sites
I''ve just checked this message again, and relised I may not have been clear (from your reply i do not think I was)

You can still draw your iso tiles as diamonds, and when you go to draw your units change the vertex structs to make a square and set the texture to the unit texture.

One thing I noticed from your code is your textures are the same size as the texture bracket used, you do not need to set them to that size, unless you need the extra details.

if you want to see what I''ve done with the engine check out my site:

www.stevesprogpage.f2s.com

1. 1
2. 2
frob
16
3. 3
4. 4
5. 5

• 13
• 13
• 61
• 14
• 15
• ### Forum Statistics

• Total Topics
632125
• Total Posts
3004250

×