• Advertisement
Sign in to follow this  

Problem Rendering Mesh to Surface

This topic is 4474 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

Hello, I want to render a mesh to surface (for something like a Status display of the actual viewd Spaceship) What I'am doing is the following:
IDirect3DSurface9* surface_;
DXUTGetD3DDevice()->CreateOffscreenPlainSurface( 200, 150, D3DFMT_X8R8G8B8, 
		D3DPOOL_DEFAULT, &surface_, NULL );
RECT DstRect;
DstRect.left = 0;
DstRect.top = 0;
DstRect.right = 200;
DstRect.bottom = 150;
DXUTGetD3DDevice()->ColorFill( surface_, &DstRect, D3DCOLOR_XRGB(0, 0, 30) );
DXUTGetD3DDevice()->SetRenderTarget( 0, surface_ );

// rendering of the mesh

DstRect.left = 400;
DstRect.top = 400;
DstRect.right = 600;
DstRect.bottom = 550;				

IDirect3DSurface9* backBuffer = NULL;

if( !FAILED( DXUTGetD3DDevice()->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer ) ) )

  DXUTGetD3DDevice()->StretchRect( surface_, NULL, backBuffer, &DstRect, D3DTEXF_NONE );

It works aso far as I see the surface and also my mesh, but my mesh is not placed on the surface, so what do I wrong? Thanks a lot!

Share this post

Link to post
Share on other sites
No, I don't want to render to a texture...
all I want is a second surface, exactly like the backbuffer, to which I can render
and then, when done copy the content of this surface to the backbuffer for displaying, just like my code shows you.

A texture seems much to complicated for this, as I than need a vertexbuffer to draw this texture...

Share this post

Link to post
Share on other sites
There is a good reason for using textures - performance. Whilst it may not be a problem, and isn't always the case, rendering a texture to the screen is a lot quicker than copying a surface to the backbuffer.

Also, it's not clear from the documentation - but you might want to use IDirect3DDevice9::CreateRenderTarget() as it implicitely specifies D3DUSAGE_RENDERTARGET. Your later call to SetRenderTarget() will fail without it:
The new render-target surface must have at least D3DUSAGE_RENDERTARGET specified.

You can also eliminate the ColorFill() operation - Set the render target first, then use a regular Clear() operation.

Finally, have you run the application against the debug runtimes? it's possible you aren't getting any output due to an error...


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement