Archived

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

jollyjeffers

D3D9 & C++ : Render Targets / how to use them...

Recommended Posts

jollyjeffers    1570
hi, I''ve knocked up what I thought was a good example of using render targets... all it does is render the scene to a texture, then render the texture to the screen (using a TL quad). However something isn''t working right - the sizing is a bit off and it wont allow anything other than a 1024x1024 texture to be used (1024x768 res) properly. can anyone point me towards a working example of SetRenderTarget( ) and so on in D3D9/C++. Google hasn''t been able to help me. Jack DirectX 4 VB: All you need for multimedia programming in Visual Basic Formula 1 Championship Manager, My Game Project.

Share this post


Link to post
Share on other sites
Raloth    379
Why on Earth are you rendering to a texture and then rendering the texture to fit the entire screen? Setting the render target is used for special effects, like rendering something to a texture and then texture mapping something. You can also use it to change the window you are rendering to.

If you really insist on doing this, or maybe I just misinterpreted it, then here''s your problem: You need to either use pre-transformed vertices or an orthogonal projection to get a 1:1 mapping of world space to screen pixels. If you can''t make a texture larger than 1024x1024 then that''s probably as high as your video card supports.

Share this post


Link to post
Share on other sites
jollyjeffers    1570
hehe, there is a perfectly logical reason for what I''m doing... if you alpha blend the final stage then you get free temporal anti aliasing (motion blur), which when done correctly looks extremely cool

I''m using a Radeon 9800 pro, which goes upto 2048x2048 targets, and anyway, its caps locked so the code wont allow itself to go any higher than the driver allows it..

any ideas anyone?!
Jack

DirectX 4 VB: All you need for multimedia programming in Visual Basic
Formula 1 Championship Manager, My Game Project.

Share this post


Link to post
Share on other sites
glassJAw    128
Your card likely can't support non-power-of-2 textures (hence the rounding up from 768 to the nearest power of 2 -- i.e. 1024)

I've had trouble using render targets in the past. When I tried to use them in my game, it rendered to the texture fine, then rendered on screen, but I could not create any new textures afterwards, and it crashed when I tried to go back to the menu. Weird.

So if anyone has some working code for rendering to a texture it could help me out too.

[edited by - glassJAw on August 17, 2003 1:57:25 AM]

Share this post


Link to post
Share on other sites
jollyjeffers    1570
I found some useful info in Kelly Dempski''s D3D book, chapter 33, if anyones interested. It''s for D3D8 but seems to work a treat in D3D9 as well...

I''ve got my temporal anti-aliasing stuff working now, and it looks pretty damn sweet

Jack

DirectX 4 VB: All you need for multimedia programming in Visual Basic
Formula 1 Championship Manager, My Game Project.

Share this post


Link to post
Share on other sites