Note that there are some explanatory texts on larger screens.

plurals
  1. POEnable AntiAliasing in Direct3D9 (MultiSample Render Target)
    text
    copied!<p>I am trying to enable AA in a D3D9 application, but am not sure how to set up the surfaces correctly. So far, I have:</p> <pre><code>IDirect3DDevice9* m_pd3dDevice; IDirect3DSurface9* screen; IDirect3DSurface9* msaasurf; D3DPRESENT_PARAMETERS m_presentationParameters; </code></pre> <p>Initialization:</p> <pre><code>m_presentationParameters.Windowed = TRUE; m_presentationParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; m_presentationParameters.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; m_presentationParameters.MultiSampleQuality = 0; m_presentationParameters.BackBufferFormat = D3DFMT_UNKNOWN; m_presentationParameters.EnableAutoDepthStencil = TRUE; m_presentationParameters.AutoDepthStencilFormat = D3DFMT_D16; m_presentationParameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // create d3d device m_pD3D-&gt;CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &amp;m_presentationParameters, &amp;m_pd3dDevice ) // save screen surface m_pd3dDevice-&gt;GetRenderTarget(0, &amp;screen); D3DSURFACE_DESC desc; screen-&gt;GetDesc(&amp;desc); // Create multisample render target m_pd3dDevice-&gt;CreateRenderTarget( 800, 600, D3DFMT_A8R8G8B8, desc.MultiSampleType, desc.MultiSampleQuality, false, &amp;msaasurf, NULL ); </code></pre> <p>And then, for each frame:</p> <pre><code>// render to multisample surface m_pd3dDevice-&gt;SetRenderTarget(0, msaasurf); m_pd3dDevice-&gt;Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 0, 0, 0 ), 1.0f, 0 ); m_pd3dDevice-&gt;BeginScene(); // render stuff here m_pd3dDevice-&gt;EndScene(); m_pd3dDevice-&gt;SetRenderTarget(0, screen); // get back buffer IDirect3DSurface9* backBuffer = NULL; m_pd3dDevice-&gt;GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &amp;backBuffer); // copy rendertarget to backbuffer m_pd3dDevice-&gt;StretchRect(msaasurf, NULL, backBuffer, NULL, D3DTEXF_NONE); backBuffer-&gt;Release(); // Present the backbuffer contents to the display m_pd3dDevice-&gt;Present(NULL, NULL, NULL, NULL); </code></pre> <p>However, nothing is appearing on my screen (all black). No errors are occuring (I check the return value of all d3d calls). What am I doing wrong? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload