• Advertisement


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

Drawing primitives to an off screen surface

This topic is 5641 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m attempting to generate large (256x256 pixels) random textures offscreen to be used in rendering terrain. This is done once before the terrain is rendered and the terrain itself is very small. Using D3DXRenderToSurface, is it possible to draw textured trianglestrips to an off screen surface? If not, can I instead draw several textures to this surface and still have them blend together as if they were rendered to trianglestrips? Basically that''s just asking if I can generate a large texture on any surface, but I''m not sure how that''s done either because I''m only used to blending textures directly onto the mesh.

Share this post

Link to post
Share on other sites
Yes, by setting the render target to your surface you render your geometry as normal, being scene - render - end scene. Also you can create and write to textures on a pixel basis quite easily. Use CreatTexture of the size you want. Lock it, which gives you a pointer to the bits and the stride amount (width of a row in bytes- may not equal texture width) and you can party on the bits to your hearts content. Remember to unlock the texture aftward and dont do too much of htis each frame

Share this post

Link to post
Share on other sites
It looks like I''m on the right track, then. Thanks for your response.

The only problem now is that I am getting a flicker apparently where the viewport would be whenever I call setrendertarget, but everything else draws fine in spite of that. I''m assuming I am not sending the right parameters, so here''s my code (it''s in vb):

Dim tRenderTarget As Direct3DTexture8
Set tRenderTarget = d3dx.CreateTexture(d3dDevice, 256, 256, _

Dim sRenderTarget As Direct3DSurface8
Set sRenderTarget = tRenderTarget.GetSurfaceLevel(0&)

d3dDevice.SetRenderTarget sRenderTarget, Nothing, 0

Dim sRTS As D3DXRenderToSurface
Set sRTS = d3dx.CreateRenderToSurface(d3dDevice, 256, 256, DispMode.Format, 0&, D3DFMT_UNKNOWN)

Dim ViewPort As D3DVIEWPORT8
With ViewPort
.height = 256
.Width = 256
.MaxZ = 1!
End With

Any help would be appreciated.

Share this post

Link to post
Share on other sites

  • Advertisement