Antialiasing through backbuffer

Started by
2 comments, last by Hodgman 16 years, 1 month ago
Hi Guys I am new to DirectX and I am working on saving / printing images for a graphics engine which produces 3D graphs. I am trying to fetch DC from backbuffer and use StretchDIBits to inject into a print DC. But the lines and text I get are full of "jaggies". A portion of my prototype code is shown below. ************************************************ HRESULT hr; D3DDISPLAYMODE mode; if (FAILED(hr=m_pDevice->GetDisplayMode(D3DADAPTER_DEFAULT,&mode))) return ; IDirect3DSurface9* ipSurface = NULL; IDirect3DSurface9* origTarget = NULL; IDirect3DSurface9* ipBackSurface = NULL; HRESULT hrO = m_pDevice->GetRenderTarget( 0, &origTarget); D3DSURFACE_DESC obSurfaceDesc; origTarget->GetDesc(&obSurfaceDesc); HRESULT hrReAA = m_pDevice->CreateRenderTarget( obSurfaceDesc.Width, obSurfaceDesc.Height/*756,472*/, mode.Format, obSurfaceDesc.MultiSampleType, obSurfaceDesc.MultiSampleQuality,FALSE, &ipBackSurface, NULL ); HRESULT hrReBB = m_pDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&ipBackSurface); HRESULT hrReCC = m_pDevice->CreateOffscreenPlainSurface(obSurfaceDesc.Width, obSurfaceDesc.Height/*756, 472*/, mode.Format, D3DPOOL_SYSTEMMEM, &ipSurface, NULL); HRESULT hrReDD = m_pDevice->GetRenderTargetData(ipBackSurface,ipSurface);//>GetFrontBufferData(1, ipSurface); D3DXSaveSurfaceToFile(_T("c:\\Test\\Surface3.bmp"),D3DXIFF_BMP,ipSurface,NULL,NULL); HDC hDC_BackSurface = NULL; HRESULT hrRetVal = ipBackSurface->GetDC(&hDC_BackSurface); ******The device creation was done this way*********** D3DPRESENT_PARAMETERS oD3dpp; oD3dpp.BackBufferWidth = nWidth; oD3dpp.BackBufferHeight = nHeight; oD3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; oD3dpp.BackBufferCount = 1; oD3dpp.MultiSampleType = D3DMULTISAMPLE_4_SAMPLES; oD3dpp.MultiSampleQuality = 0; oD3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; oD3dpp.hDeviceWindow = hWnd; oD3dpp.Windowed = true; // fullscreen oD3dpp.EnableAutoDepthStencil = true; oD3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; // depth format oD3dpp.Flags = 0; oD3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; oD3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; HRESULT result = m_pD3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING,&oD3dpp,&m_pDevice); ************************************************ Can somebody please help. I am stuck here and not able to proceed. Thanks in advance... Ram
Advertisement
Quote:IDirect3DDevice9::GetFrontBufferData():
The buffer pointed to by pDestSurface will be filled with a representation of the front buffer, converted to the standard 32 bits per pixel format D3DFMT_A8R8G8B8.

This method is the only way to capture an antialiased screen shot.

This function is very slow, by design, and should not be used in any performance-critical path.


hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Hi
Thx for the reply. I tried this earlier but it is capturing the whole screen. If I have a print status message box in front of the window on which I have rendered, even that message box is captured and sent to printer. Hence GetFrontBufferData function doesnt help me much. My requirement is to remove jaggies in the line and text when I print. Since I am doing it through StretchDIBits and not through the GDI defaults, the print looks shaken. Is there an alternate way in directx to get a clean print of the scene that gets rendered in the view?

Thx
Ram
Quote:Original post by Ramanathan
If I have a print status message box in front of the window on which I have rendered, even that message box is captured and sent to printer.

Can you capture the contents of the front-buffer directly BEFORE displaying the print status message box?

This topic is closed to new replies.

Advertisement