well.. let me show u the layout of the code..im basically doing the following
BeginScene();
CreateRenderTarget( with MSAA enabled );
SaveOldRenderTargers();
SetRenderTarget();
RenderFewLines();
CreateTexture();
StretchRect( from MSAA rendertarget to the texture )
Restore Original BackBuffer and ZBuffer
Draw a screen aligned quad with the texture
EndScene();
Present();
The the DX doc says that StretchRect doesn't work between BeginScene() and EndScene() pair.. but i have seem examples where StretchRect are put between BeginScene() and EndScene();
Could someone clear me up here
implementing antialiasing
How exactly are you doing your StretchRect?
You need to create the texture, then use GetSurfaceLevel() to retrieve the top-level surface. That's the surface you need to stretchrect to.
For example:
PS: You should never create textures like that every frame. It means that every frame your program has to go through the slow process of creating textures, and the ramifications of forgetting to release the textures are massive if you're creating them each frame.
You need to create the texture, then use GetSurfaceLevel() to retrieve the top-level surface. That's the surface you need to stretchrect to.
For example:
IDirect3DTexture9* LineTexture;IDirect3DSurface9* LineSurface;D3D9DeviceInterface->CreateTexture(ScreenWidth,ScreenHeight,1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT,&LineTexture, NULL);LineTexture->GetSurfaceLevel(0,&LineSurface);D3D9DeviceInterface->StretchRect(MSAALineSurface, NULL, LineSurface, NULL, D3DTEXF_NONE);// Now draw LineTexture using a screen-aligned quad
PS: You should never create textures like that every frame. It means that every frame your program has to go through the slow process of creating textures, and the ramifications of forgetting to release the textures are massive if you're creating them each frame.
I read in a blog that when u change render target, the old render target's contents may become undefined and may not retain its data. If that is the case then i will run into a problem. Specifically, the blog said that itz true for XBox renderers. Comments ?
Hasn't happened to me. However, are you remembering to clear the MSAA line RenderTarget before rendering to it? Just creating the texture doesn't clear it, and it's filled with garbage data.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement