Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


DirectX 8 Clipper help

This topic is 6077 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can any one help me with this? In DirectX 8.1 they have made some classes to help with handling DirectDraw. But I don''t see how you can use these classes with a clipper. I have added the code beginning with // Added by Jamie to the row of ******''s to the /common/src/ddutil.cpp file that comes with the DX 8.1 SDK: HRESULT CDisplay::CreateFullScreenDisplay( HWND hWnd, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP ) { HRESULT hr; LPDIRECTDRAWCLIPPER lpddClipper = NULL; // Cleanup anything from a previous call DestroyObjects(); // DDraw stuff begins here if( FAILED( hr = DirectDrawCreateEx( NULL, (VOID**)&m_pDD, IID_IDirectDraw7, NULL ) ) ) return E_FAIL; // Set cooperative level hr = m_pDD->SetCooperativeLevel( hWnd, DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN ); if( FAILED(hr) ) return E_FAIL; // Set the display mode if( FAILED( m_pDD->SetDisplayMode( dwWidth, dwHeight, dwBPP, 0, 0 ) ) ) return E_FAIL; // Create primary surface (with backbuffer attached) DDSURFACEDESC2 ddsd; ZeroMemory( &ddsd, sizeof( ddsd ) ); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_3DDEVICE; ddsd.dwBackBufferCount = 1; if( FAILED( hr = m_pDD->CreateSurface( &ddsd, &m_pddsFrontBuffer, NULL ) ) ) return E_FAIL; // Get a pointer to the back buffer DDSCAPS2 ddscaps; ZeroMemory( &ddscaps, sizeof( ddscaps ) ); ddscaps.dwCaps = DDSCAPS_BACKBUFFER; if( FAILED( hr = m_pddsFrontBuffer->GetAttachedSurface( &ddscaps, &m_pddsBackBuffer ) ) ) return E_FAIL; m_pddsBackBuffer->AddRef(); m_hWnd = hWnd; m_bWindowed = FALSE; UpdateBounds(); //************************************************************************* // This code added by Jamie. // Create the clipper. if (FAILED( hr = m_pDD->CreateClipper(0, &lpddClipper, NULL))) return E_FAIL; // Create and set the clip list. LPRGNDATA lpClipList = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER) + sizeof(RECT)); RECT rcBoundary = {0, 0, 320, 240}; // FIX THIS! SHOULD BE ABLE TO SET SIZE! memcpy(lpClipList->Buffer, &rcBoundary, sizeof(RECT)); // set list lpClipList->rdh.dwSize = sizeof(RGNDATAHEADER); // structure size lpClipList->rdh.iType = RDH_RECTANGLES; // bound type lpClipList->rdh.nCount = 1; // num of bounds lpClipList->rdh.nRgnSize = sizeof(RECT); // size of Buffer lpClipList->rdh.rcBound = rcBoundary; // bounding RECT if (FAILED(lpddClipper->SetClipList(lpClipList, 0))) { // Always free the mallocs! free(lpClipList); return E_FAIL; } // Attach clipper to back buffer. if (FAILED( hr = m_pddsBackBuffer->SetClipper(lpddClipper))) { free(lpClipList); return E_FAIL; } // Free the memory. free(lpClipList); //************************************************************************* return S_OK; } Shouldn''t this attach a clipper to the backbuffer? Does anyone know what I''m doing wrong or a better way to do this? Thanks, Zaephen.

Share this post

Link to post
Share on other sites
you should move data from thr rect to RGNDATA.Buffer
before SetClipList, i.e.
memmove(&(lpClipList->Buffer[0]), &rcBoundary, sizeof(RECT));
why do you alloc sizeof(RGNDATAHEADER)+sizeof(RECT) for the RGNDATA*? the size of RGNDATA is sizeof(RGNDATAHEADER)+sizeof(char[1]).

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!