Archived

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

how can d3d9 provide something like overlay in ddraw7?

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

What I want to implement is: The application writes texts on a window using GDI as usual, and sets the color key. The inside blends the window content onto a d3d9 surface and show in that window. When using ddraw7, I can easily set the color key and overlay to realize this. Now I want to use pixel shader, so it should be a d3dsurface9. I don''t want to change the code to d3d DrawText. I can use Id3dsurface9->GetDC() and provide the dc to the application. But to be able to getdc, the surface should not be A8R8G8B8, it should be X8R8G8B8, etc., so I can not alpha blend it directly. I can copy from X8R8G8B8 to A8R8G8B8, but that''s slow. I can blend it in the shader program, that''s the only solution I''ve found, it increases the shader length. Any better solution?

Share this post


Link to post
Share on other sites
quote:
Original post by softimage
Now I want to use pixel shader, so it should be a d3dsurface9.

I don''t want to change the code to d3d DrawText.


Why? ID3DXFont is very efficient nowadays, and beats raw GDI hands down in performance.

quote:

I can blend it in the shader program, that''s the only solution I''ve found, it increases the shader length.




By one instruction - copy some of the color components to alpha channel. If your target specs include pixel shader capability anyway, this doesn''t really matter.

D3D doesn''t support hardware color keying, period. You''ll need to use some kind of blending if you are to emulate it, and alpha channel is the most straight-forward of these.

One optimization you could do, if I didn''t convert you to ID3DXFont: draw the text to a texture, and use that texture to transfer the text to the backbuffer. You don''t presumably fill the screen with text, do you?

Kind rgds,
-Nik

Share this post


Link to post
Share on other sites
quote:
Original post by Nik02
One optimization you could do, if I didn''t convert you to ID3DXFont: draw the text to a texture, and use that texture to transfer the text to the backbuffer. You don''t presumably fill the screen with text, do you?

Kind rgds,
-Nik



What do you mean by using the texture to transfer the text to the backbuffer?
Do you mean setting the texture with the text onto a small object, instead of changing the format and blend onto the full screen?
But it''s a pity that the position of the text is not fixed.
A full screen covering is better.

Share this post


Link to post
Share on other sites