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

Started by
4 comments, last by jollyjeffers 20 years, 8 months ago
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.

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Advertisement
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.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
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.

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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]
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.

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Decribe ''a little off''...

You need to offset your vertices by -1/width, -1/height to get the texels to line up right.
EvilDecl81

This topic is closed to new replies.

Advertisement