this is what you have to change
// windows.cpp
Code: Select all
#define WINDOWSIZEX 800
#define WINDOWSIZEY 600
int winSizeX = WINDOWSIZEX;
int winSizeY = WINDOWSIZEY;
int WINAPI wWinMain( HINSTANCE hInst,HINSTANCE,LPWSTR,INT )
{
.
..
...
RECT wr;
wr.left = 650;
wr.right = winSizeX + wr.left;
wr.top = 150;
wr.bottom = winSizeY + wr.top;
.
..
...
Game theGame( hWnd,kServ,mServ, winSizeX, winSizeY);
.
..
...
Code: Select all
class Game
{
public:
Game( HWND hWnd,const KeyboardServer& kServer,const MouseServer& mServer, int& winSizeX, int& WinSizeX );
.
..
...
/********************************/
/* User Variables */
int& windowSizeX; // references
int& windowSizeY;
Code: Select all
Game::Game( HWND hWnd,const KeyboardServer& kServer,const MouseServer& mServer, int& winSizeX, int& winSizeY )
: gfx( hWnd, winSizeX /* pass the window size X reference */, winSizeY /* pass the window size Y reference */ ),
audio( hWnd ),
kbd( kServer ),
mouse( mServer ),
lastMouseX(0),
lastMouseY(0),
windowSizeX(winSizeX), // save the window rect for future use
windowSizeY(winSizeY) // save the window rect for future use
.
..
...
Code: Select all
class D3DGraphics
{
public:
D3DGraphics( HWND hWnd, int& winSizeX, int& winSizeY );
.
..
...
D3DCOLOR* sysBuffer; // <-- remember this one
int& windowSizeX;
int& windowSizeY;
// D3DGraphics.cpp
Code: Select all
#include <assert.h>
D3DGraphics::D3DGraphics( HWND hWnd, int& winSizeX, int& winSizeY )
{
.
..
...
sysBuffer = new D3DCOLOR[winSizeX * winSizeY]; // <--- problem solved!
}
.
..
...
void D3DGraphics::PutPixel( int x,int y,int r,int g,int b )
{
assert( x >= 0 );
assert( y >= 0 );
assert( x < windowSizeX );
assert( y < windowSizeY );
pSysBuffer[ x + windowSizeX * y ] = D3DCOLOR_XRGB( r,g,b );
}
void D3DGraphics::PutPixel( int x,int y,D3DCOLOR c )
{
assert( x >= 0 );
assert( y >= 0 );
assert( x < windowSizeX );
assert( y < windowSizeY );
pSysBuffer[ x + windowSizeX * y ] = c;
}
D3DCOLOR D3DGraphics::GetPixel( int x,int y)
{
assert( x >= 0 );
assert( y >= 0 );
assert( x < windowSizeX );
assert( y < windowSizeY );
return pSysBuffer[ x + windowSizeX * y ];
}
void D3DGraphics::BeginFrame()
{
//HRESULT result;
memset(pSysBuffer, 0x00, sizeof(D3DCOLOR) * windowSizeX * windowSizeY);
}
void D3DGraphics::EndFrame()
{
HRESULT result;
result = pBackBuffer->LockRect( &backRect,NULL,NULL );
assert( !FAILED( result ) );
for( int y = 0; y < windowSizeY; y++)
{
memcpy( &((BYTE*)backRect.pBits)[backRect.Pitch * y], &pSysBuffer[windowSizeX * y], sizeof( D3DCOLOR ) * windowSizeX);
}
result = pBackBuffer->UnlockRect();
assert( !FAILED( result ) );
result = pDevice->Present( NULL,NULL,NULL,NULL );
assert( !FAILED( result ) );
}
.
..
...
i'm a selftauched programmer ... with electrical backgroun ... electrician : )
Like mentioned before ... i have some fair amount of c# knowlegde.
i tried c++ ... before : (