Sprite class and solid textures
Is there a way to do solid or gradient textures with the sprite class in managed directx9? various examples i''ve seen that just draw their own vertexes could set the color of each one etc and it would do the nice gradients, but I haven''t seen a way to do this with Sprite. Reason is simply that i want some black blocks (or wahtever) flying around and it seems a waste to have a large bitmap texture just for this.
llloyd
I''m actually trying to figure this one out myself. Maybe it could be done by Clear()''ing to a texture, but I''ll need to check if that''s possible.
Stay Clausal,
Red Sodium
Stay Clausal,
Red Sodium
It *is* possible but I'm having a lot of trouble with it, you need to get the texture's surface level, then you need to set the render target to that surface, then clear it, then set render target back to the device. And it's still not working for me!
Stay Clausal,
Red Sodium
[edited by - red_sodium on April 11, 2004 6:12:13 PM]
Stay Clausal,
Red Sodium
[edited by - red_sodium on April 11, 2004 6:12:13 PM]
Yup, got it. Do this:
This gives you a completely black rectangle texture. Change the last 3 params inside the D3DCOLOR_ARGB macro to change your colour.
pD3DTexture9 is a pointer to your initialized texture object and pD3DDevice9 is your device. Look up ColorFill() in the DX docs or on MSDN.
Also, make sure your texture''s usage flag contains D3DUSAGE_RENDERTARGET and the pool is D3DPOOL_DEFAULT, or it won''t work.
Actually, I learnt a lot just by researching this. I''m a relative n00b @ Direct3D.
PS: Don''t know about gradients, you''d probably need to use an FVF, vertex buffer and DrawPrimitive and do it the 3D way...
Stay Clausal,
Red Sodium
IDirect3DSurface9* surface = NULL; pD3DTexture9->GetSurfaceLevel( 0, &surface ); surface->LockRect( &lockedRect, NULL, 0 ); pD3DDevice9->ColorFill( surface, NULL, D3DCOLOR_ARGB( 255, 0, 0, 0 ) );
This gives you a completely black rectangle texture. Change the last 3 params inside the D3DCOLOR_ARGB macro to change your colour.
pD3DTexture9 is a pointer to your initialized texture object and pD3DDevice9 is your device. Look up ColorFill() in the DX docs or on MSDN.
Also, make sure your texture''s usage flag contains D3DUSAGE_RENDERTARGET and the pool is D3DPOOL_DEFAULT, or it won''t work.
Actually, I learnt a lot just by researching this. I''m a relative n00b @ Direct3D.
PS: Don''t know about gradients, you''d probably need to use an FVF, vertex buffer and DrawPrimitive and do it the 3D way...
Stay Clausal,
Red Sodium
Hey, nice, didn''t know abou that function =D
Thanks for sharing
---------------------------------------------------------
There are 10 kinds of people: those who know binary and those who don''t
Thanks for sharing
---------------------------------------------------------
There are 10 kinds of people: those who know binary and those who don''t
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement