Archived

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

n0ob

Drawing to a texture surface... or..

Recommended Posts

I''m trying to make a d3d program that does the kind of stuff you see in the Windows Media Player visualizations. I want to use D3D, cuz I just learned how to blit geometry with different alpha blending modes.. which led me to thinking about those visualizations. Soo.. I was thinking that if I could draw the screen''s current state to a texture, then I could redraw that texture over the screen again, with blending, rotation, etc. I''d really like some advice. Does anyone know of a good sample somewhere that uses this method, of drawing to a texture''s data? I''ve been trying and trying, and I think i''m getting screwed up in the different memory formats... or something. I''m pretty lost... so a good sample would help. I was looking in the d3d samples for something like this too, but no luck :S Thanks!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
http://msdn.microsoft.com/library/en-us/dndrive/html/directx09182000.asp

is this any good

Share this post


Link to post
Share on other sites
that''s kindof good... I didn''t actually even get to look at the fekking thing because I don''t have the gay D3DFrame.cpp crap it needs. If someone can tell me where the heck to get these from.. I''d be very happy. I don''t quite feel like trying to copy/paste vital sections, just to see if this is the effect i''m looking for..
I was looking at it anyway, and it didn''t quite look like what I want.. This one just draws the sprites scaled up right? It looked like it just cleared the backbuffer each loop. What I want is more of a ''dirty'' backbuffer effect.. kind of like the rotoblitter in winamp''s vis studio. That''s really all I''m trying to do. I''m not convinced that the visualizations just use many layered sprites for all their effects. Even the old ambience set does what I want to do. Basic lines or circles are drawn onto the swirling background, and their ''footprints'' fade out as they swirl around. Thanks for the help so far though.

Share this post


Link to post
Share on other sites
Use a renderable texture as your "drawing surface", and in each frame, draw a full-screen quad with your "drawing surface" as a texture. That way, if you have multiple backbuffers, the last frame is still available at every next frame.

Also, i suppose you already know this, but remember to enable alpha blending and set the dest&src factors!

-Nik

PS. D3DFrame.cpp is in the sdk samples common folder, if i remember correctly. It''s only a helper class, but for a d3d beginner, i suppose it can be very useful.

Share this post


Link to post
Share on other sites
Ain''t no D3DFrame.cpp there for me (using dx9). I spose it might be nice if you could elaborate a smidge on the ''renderable texture''. I''m pretty much asking for some sample code here. I''ve already made a texture and tried accessing it''s surface, and copying my display surface there, but no luck. Also, my program is single buffered right now.. I can change that if I need too though. Thanks i spose..

Share this post


Link to post
Share on other sites
Hi,


  1. Use D3DUSAGE_RENDERTARGET flag when creating the renderable texture.


  2. Use IDirect3DDevice9::SetRenderTarget, with your texture pointer as the target parameter. (Remember to store the pointer to your backbuffer first!)


  3. Render stuff here, to your heart's content! All goes to your texture. Don't forget to Present the scene to your texture.


  4. Restore the original back buffer with the pointer you (hopefully) saved at step 2.


  5. Draw a quad (two triangles) covering the screen, using your rendered texture. Present.



Now, don't clear the renderable texture every frame, if you want "feedback" effects. You could also, for example, clear it partially using alpha-blended quad.

-Nik

PS. The feedback effect achieved using this method doesn't depend on the number of the back buffers.
That's the point of rendering the scene to the texture in the first place.



[edited by - Nik02 on October 14, 2003 6:04:56 AM]

Share this post


Link to post
Share on other sites