Make it a compile time choice, whether you want to use a clipper or not, because our ddraw does not support it yet.

svn path=/trunk/; revision=25130
This commit is contained in:
Maarten Bosma 2006-12-12 17:51:50 +00:00
parent 8d383c3bad
commit e564de2bbd

View file

@ -1,15 +1,15 @@
#include <windows.h> #include <windows.h>
#include <ddraw.h> #include <ddraw.h>
LPDIRECTDRAW7 DirectDraw; LPDIRECTDRAW7 DirectDraw = NULL;
LPDIRECTDRAWSURFACE7 FrontBuffer; LPDIRECTDRAWSURFACE7 FrontBuffer = NULL;
LPDIRECTDRAWCLIPPER Clipper; LPDIRECTDRAWCLIPPER Clipper = NULL;
PCHAR DDErrorString (HRESULT hResult); PCHAR DDErrorString (HRESULT hResult);
LONG WINAPI WndProc (HWND hwnd, UINT message, UINT wParam, LONG lParam); LONG WINAPI WndProc (HWND hwnd, UINT message, UINT wParam, LONG lParam);
bool Fullscreen, Running; bool Fullscreen, Running;
//#define USE_CLIPPER
bool Init (HWND hwnd) bool Init (HWND hwnd)
{ {
@ -69,6 +69,7 @@ bool Init (HWND hwnd)
return 0; return 0;
} }
#ifdef USE_CLIPPER
// Set up the clipper // Set up the clipper
OutputDebugString("=> DDraw->CreateClipper\n"); OutputDebugString("=> DDraw->CreateClipper\n");
@ -94,13 +95,16 @@ bool Init (HWND hwnd)
MessageBox(0,DDErrorString(hResult), "FrontBuffer->SetClipper", 0); MessageBox(0,DDErrorString(hResult), "FrontBuffer->SetClipper", 0);
return 0; return 0;
} }
#endif
return true; return true;
} }
void Draw (void) void Draw (HWND hwnd)
{ {
// Make the fronbuffer pink // Make the frontbuffer pink
RECT rect;
GetWindowRect(hwnd, &rect); // this is not necessary when clippper is used
DDBLTFX ddbltfx; DDBLTFX ddbltfx;
ddbltfx.dwSize = sizeof(DDBLTFX); ddbltfx.dwSize = sizeof(DDBLTFX);
@ -108,8 +112,8 @@ void Draw (void)
OutputDebugString("=> Surface->Blt (DDBLT_COLORFILL)\n"); OutputDebugString("=> Surface->Blt (DDBLT_COLORFILL)\n");
FrontBuffer->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); FrontBuffer->Blt(&rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
} }
void CleanUp (void) void CleanUp (void)
{ {
@ -158,7 +162,11 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
HWND hwnd = CreateWindow("DDrawDemo", HWND hwnd = CreateWindow("DDrawDemo",
"ReactOS DirectDraw Demo", "ReactOS DirectDraw Demo",
Fullscreen ? WS_POPUP :WS_OVERLAPPEDWINDOW, #ifdef USE_CLIPPER
Fullscreen ? WS_POPUP : WS_OVERLAPPEDWINDOW,
#else
WS_POPUP,
#endif
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
800, 800,
@ -179,7 +187,7 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
while (Running) while (Running)
{ {
if(Fullscreen) if(Fullscreen)
Draw(); Draw(hwnd);
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{ {
@ -203,7 +211,7 @@ LONG WINAPI WndProc (HWND hwnd, UINT message,
case WM_PAINT: case WM_PAINT:
{ {
if(!Fullscreen) if(!Fullscreen)
Draw(); Draw(hwnd);
} break; } break;
case WM_KEYDOWN: case WM_KEYDOWN: