Skip to main content
gamedev.net
🔒 Locked

Clipper

Started by NightZero Dec 13, 2002 at 3:47 PM 1 replies 250+ views
Original Post
NightZero
NightZero
Hello! I''m getting crazy here... :-) I would like to scroll sprites and pictures smooth over the edge of my window. But if they are painted outside the window the whole sprite or picture disapper. I have tried to use a clipper but without success. The clipper is used on my window and primary buffer, but it does not help. If I use the backbuffer instead the window gets all black! I do like this: HRESULT CDisplay::InitClipper() { LPDIRECTDRAWCLIPPER pClipper; HRESULT hr; // Create a clipper when using GDI to draw on the primary surface if( FAILED( hr = m_pDD->CreateClipper( 0, &pClipper, NULL ) ) ) return hr; pClipper->SetHWnd( 0, m_hWnd ); if( FAILED( hr = m_pddsFrontBuffer->SetClipper( pClipper ) ) ) return hr; // We can release the clipper now since g_pDDSPrimary // now maintains a ref count on the clipper SAFE_RELEASE( pClipper ); return S_OK; } /Mattias
jdawg2
jdawg2
just upping your post because I have the same problem...I remember when I used a global procedure it worked, but once I tried copy/pasting my code to a wrapper class, for some reason it didn''t (even though it''s the same code!)

NightZero
NightZero
Hey,

I solved it by adding a clipper to the backbuffer instead of the frontbuffer. Another problem vas that I used the BltFast() method instead of the Blt() method. The BltFast does not support clippers. It did _not_ work so good with:

pClipper->SetHWnd( 0, m_hWnd );

The clipper worked, but I got a black frame around the surface. Anyone knows way? Anyway, instead of the SetHWnd, I added a cliplist with a RECT that had the size of my window. It worked excellet!

/Mattias

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.