Game Development Reference
In-Depth Information
RECT Rect;
Rect.left = 0;
Rect.top = 0;
3.
The size of the window client area is predeined as ImageWidth and ImageHeight
constants. However, the WinAPI function CreateWindowA() accepts not the size of
the client area, but the size of the window, which includes caption, borders, and other
decorations. We need to adjust the window rectangle to set the client area to the
desired size through the following code:
Rect.right = ImageWidth;
Rect.bottom = ImageHeight;
DWORD dwStyle = WS_OVERLAPPEDWINDOW;
AdjustWindowRect( &Rect, dwStyle, false );
int WinWidth = Rect.right - Rect.left;
int WinHeight = Rect.bottom - Rect.top;
HWND hWnd = CreateWindowA( WinName, "App3", dwStyle,
100, 100, WinWidth, WinHeight,
0, NULL, NULL, NULL );
ShowWindow( hWnd, SW_SHOW );
HDC dc = GetDC( hWnd );
4.
Create the offscreen device context and the bitmap, which holds our offscreen
framebuffer through the following code:
hMemDC = CreateCompatibleDC( dc );
hTmpBmp = CreateCompatibleBitmap( dc,
ImageWidth, ImageHeight );
memset( &BitmapInfo.bmiHeader, 0,
sizeof( BITMAPINFOHEADER ) );
BitmapInfo.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );
BitmapInfo.bmiHeader.biWidth = ImageWidth;
BitmapInfo.bmiHeader.biHeight = ImageHeight;
BitmapInfo.bmiHeader.biPlanes = 1;
BitmapInfo.bmiHeader.biBitCount = 32;
BitmapInfo.bmiHeader.biSizeImage = ImageWidth*ImageHeight*4;
UpdateWindow( hWnd );
 
Search WWH ::




Custom Search