Archived

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

softimage

how to do the color keying in d3d9?

Recommended Posts

In ddraw, I can set a color key for the overlay. How can I do the same thing in d3d9? I want to use the color, not the alpha channel to determine which pixel should be displayed.

Share this post


Link to post
Share on other sites
D3d don''t support colorkeys so you have to use the alpha channel, but it''s really simple. Just enable alpha, lock the texture you want a colorkey on. Scan trough the pixels and set the alpha bits to zero where you find the color you want to be transparent.

Share this post


Link to post
Share on other sites
quote:
Original post by Nik02
It is also worth noting that most D3DX loader functions do that part automatically.


You mean the ID3DX interface?
What I want to do is to write text onto a window using GDI,
then blend a d3d9 surface decoded from a video file onto that window,
overlaying the text on the surface.
It''s simple when using ddraw overlay.

1.
But what''s the fastest way when using d3d9?
Locking the texture and changing pixel-by-pixel seems not efficient.

2.
What''s the fastest way to get the content of the window into a texture?

Share this post


Link to post
Share on other sites
1: Not using GDI at the speed critical phase, instead rendering the font to a texture and drawing the text as quads. You can of course use GDI to make the texture font, as at load time you don''t have so much performance pressure.
Again, D3D has the ID3DXFont interface which does the optimized drawing and caching automatically.

2: Not recommended at all. Try to figure out a way in which all possible data stays in video memory (textures, multiple render targets and pixel shaders help here).

-Nik

Share this post


Link to post
Share on other sites
but isn''t ddraw7 overlay done in this way?
it should be efficient enough for ddraw7.

the problem is that i want to use my new code of d3d9 while leaving the old source unchanged.

Share this post


Link to post
Share on other sites