Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 615293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:12:17+00:00 2026-05-13T18:12:17+00:00

I am trying to enable AA in a D3D9 application, but am not sure

  • 0

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:

IDirect3DDevice9* m_pd3dDevice;
IDirect3DSurface9* screen;
IDirect3DSurface9* msaasurf;
D3DPRESENT_PARAMETERS m_presentationParameters;

Initialization:

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->CreateDevice(
  D3DADAPTER_DEFAULT, 
  D3DDEVTYPE_HAL, 
  hWnd,
  D3DCREATE_HARDWARE_VERTEXPROCESSING,
  &m_presentationParameters, &m_pd3dDevice 
)


// save screen surface
m_pd3dDevice->GetRenderTarget(0, &screen);
D3DSURFACE_DESC desc;
screen->GetDesc(&desc);

// Create multisample render target
m_pd3dDevice->CreateRenderTarget(
    800, 600, 
    D3DFMT_A8R8G8B8,
    desc.MultiSampleType, desc.MultiSampleQuality,
    false,
    &msaasurf,
    NULL
  );

And then, for each frame:

// render to multisample surface
m_pd3dDevice->SetRenderTarget(0, msaasurf);

m_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 0, 0, 0 ), 1.0f, 0 );
m_pd3dDevice->BeginScene();

// render stuff here

m_pd3dDevice->EndScene();

m_pd3dDevice->SetRenderTarget(0, screen);

// get back buffer
IDirect3DSurface9* backBuffer = NULL;
m_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);

// copy rendertarget to backbuffer
m_pd3dDevice->StretchRect(msaasurf, NULL, backBuffer, NULL, D3DTEXF_NONE);
backBuffer->Release();

// Present the backbuffer contents to the display
m_pd3dDevice->Present(NULL, NULL, NULL, NULL);

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:12:17+00:00Added an answer on May 13, 2026 at 6:12 pm

    You don’t need the extra surface, you can render directly to the multisampled backbuffer. For me, the only reason to use StretchRect() like this is to get a non-multisampled copy of the scene for use with postprocessing (because multisampled render targets are bad textures, so you need the scene data in a resolved texture). If you want to do this, you don’t need to specify multisampling for the backbuffer. A multisampled render target to render the scene to is sufficient then.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to enable Filestream in SQL Server 2008 and I Do not have
I am trying to enable transparency antialiasing in my Ogre-Direct3D application, but it just
I'm trying to enable SqlCacheDependency through my StructureMap IoC, I'm using LinqToSql I have
I'm trying to enable .htaccess files on a Ubuntu server I set up. I
I'm trying to enable Expires headers for images as recommended by YSlow. I'm sure
I am trying to enable mod_write's rewrite URL and am not able to get
I'm trying to enable Game Center Leaderboard to my iPad game and I have
I'm trying to enable AirPlay support in my app. I'm not doing video; I
I am trying to enable a disabled tab in Jquery but it doesn't work.
When I'm trying to enable auto_increment on a column in phpmyadmin, but I always

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.