Sign in to follow this  
Ramanathan

Antialiasing through backbuffer

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this