Archived

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

Equivalent to DDSurfaces in DirectX 8?

This topic is 5336 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''m sure this has been asked many times but my search didn''t find anything so I apologize in advance. I''m still a DX noob as I started learning it with DX8. I''ve never fully understood what surfaces are as I''ve never had to use one before. I''m working off a sample that uses procedural textures which uses LPDIRECTDRAWSURFACE7. I am trying to keep this DX8 and newer and without these surfaces, I have no idea how to finish coding my special effect. I know that they did away with DirectDraw for DX8 so what''s the equivalent to a DirectDrawSurface in 8? My guess is ID3DXRenderToSurface. If so, is it problematic to port DD7 code to this (what gotchas should I look out for?) or will it be fairly straightforward? Thanks

Share this post


Link to post
Share on other sites
I guess what I should ask at this point is where I can find the similar functionality to DD7 surfaces in these D3D8 surfaces. For example, the demo I am looking at is using gets the DDSURFACEDESC2 then locks the surface and then fills in each pixel data (using data in the DDSURFACEDESC2 to shift bits around) then unlocks the surface. All I can see that this D3D8 surface can do is Lock and Unlock rects. Where''s all the functionality to actually manipulate the surface? Where''s the Blt function?

I think I have this RenderToSurface thing figured out with textures and surfaces but I just can''t find any useful functions. I know they gotta be around here somewhere. Please help me!

Share this post


Link to post
Share on other sites
I was going to reply earlier but I didn''t because I didn''t know what your example was doing. Now that I do I''ll continue with my original reply.


First, DirectDraw 7 has not gone anywhere, its just as usable and compatible under DirectX9 as it was under DirectX 7, this is because COM ensures its always there So any reason for changing your code seems to be mute.

Now as for using a D3D9 Surface instead of a DD7 surface. What do you hope to gain by this? Yet a D3D9 surface can most likely do everything a DD7 surface can do and more, but if your example only needs basic pixel plotting capabilities why should change it?

The key here is that Directdraw is merely a layer around a set of memory copying functions. Thus is very fast at pure pixel manipulation. So if you can get away with raw pixel manipulation why added in another layer of complexity?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
DirectX7 was the last version of DirectX to have the 2d graphics stuff. In version 8 and later, DirectDraw has been integrated into Direct3d, and there is no more 2d functionality. If you don''t want to use the 3d stuff and want access to the ordinary 2d stuff, stay with DirectX7.

And the word is "moot", not "mute" >_<

Share this post


Link to post
Share on other sites
I am using the Procedural Cloud tutorial ( [URL]http://cedar.intel.com/cgi-bin/ids.dll/content/content.jsp?cntKey=Generic%20Editorial::clouds&cntType=IDS_EDITORIAL[/URL] ) (bah, I can't figure out how to hyperlink it)

The only reason I wanted to move away from DD7 was to try to stay current (when I ship my game 87 years from now, I don't want to still be using DX7 lol). And I figured trying to port this code would be a good learning opportunity instead of copy and pasting.

Are you guys saying that D3D8/9 doesn't have all the 2D functionality that DD7 has? And if so, then you're forced to use DD7? That would explain why the DXUtil classes in the samples still use it (that or they are too lazy to upgrade ).

I'm thinking there's gotta be a way to do these procedural clouds in D3D8 because the water sample is doing something similar using D3D8Surfaces and RenderTos. All I know is that looking at all this spaghetti code and stuff I don't understand is giving me a headache. :|

thanks for the replys


[edited by - beoch on May 8, 2003 9:48:51 PM]

[edited by - beoch on May 8, 2003 9:49:37 PM]

[edited by - beoch on May 8, 2003 9:50:04 PM]

Share this post


Link to post
Share on other sites
AP thanks for that correction. I knew the word jsut not the spelling. (I''m spelling impaired LOL)

If a card supports DirectX9 it must support DirectX7, such is the nature of COM. There is no TRUE 2D functionality in Direct3D, thus you use DirectDraw. The most up to date interfaces of DirectDraw were released with DirectX7, thus if you want pure pixel manipulation, you should stick with DirectDraw.

The only reason DirectDraw hasn''t been updated is because THERE IS NOTHING TO UPDATE. LOL. DD merely provides pixel based manipulation, which is what I''m assuming procedural clouds require. In DirectDraw7 (and earlier) you can see they were begining to add things such as rotation and alpha blending to DirectDraw, but they realized this fell outside of the vision of DirectDraw. This is why they added alot of 2D in 3D functionality to Direct3D in version 8.

But Direct3D 8''s 2D functions aren''t truely 2D, they use the 3D pipeline and renderstates, etc (As far as I know). Thus they are ideal for when you want to use the GPU and need cool effects like alphablending.

For simply plotting pixels to a texture you want to use a pure 2D API like DirectDraw7, because it provides fast acess directly to memory.

In my opinion it makes more sense to use an API suited for the task at hand.

Share this post


Link to post
Share on other sites
I know that I can use older interfaces, I was just under the impression that they moved direct draw into D3D. I don''t have any problem using DD7 if there''s no newer equivalent so it sounds like that''s the plan now. I''m glad I spent the last two days destroying working code for nothing!

I guess I''ll stick with DD7 surfaces but use the RenderTo interface instead (as I am more familiar with that method of doing things).

Thanks for the tips, that clears up all my confusion.

Share this post


Link to post
Share on other sites
quote:

Where''s all the functionality to actually manipulate the surface? Where''s the Blt function?



This is something that seems to change completely with every version of DX these days. In DX8 i think you had the CopyRect function in place of Blt. In DX9 you have to go via the IDirect3DDevice9::UpdateSurface/UpdateTexture methods I think.

To access the bits of the surface you should use IDirect3DSurface9::LockRect.

Share this post


Link to post
Share on other sites
quote:
Original post by treething
To access the bits of the surface you should use IDirect3DSurface9::LockRect.


I found LockRect but I don''t see any other functions of any use except something about private data but it didn''t really seem too useful. What do I do after locking it?

Share this post


Link to post
Share on other sites
I''m just guessing, LockRect should return a pointer, or you pass it a double pointer which it makes point to the right place.

You then use this pointer to modify the data on the surface.

Share this post


Link to post
Share on other sites