If you're reffering to the little code snippet, I said "It (reffering to my C++ program) does what this can do:"
The real code is right here
/**********************************************************
** DirectX example program **
**********************************************************/
//Include windows stuff
#include <windows.h>
//Include DX9 stuff
#include <d3d9.h>
//Windows stuff
HINSTANCE hInst; //handle to an instance
HWND wndHandle; //handle to a window
//DX9 stuff
LPDIRECT3D9 pD3D; //the Direct3D object
LPDIRECT3DDEVICE9 pd3dDevice; //the Direct3D device
//Declare windows functions
bool initWindow( HINSTANCE hInstance );
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
//Declare DX9 functions
bool initDirect3D( void );
void render( void );
void cleanUp( void );
//WinMain function
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nShowCMD )
{
if ( !initWindow( hInstance ) )
{
MessageBox( NULL, "Window could not be initiated.", "ERROR", MB_OK );
return false;
}
if ( !initDirect3D( ) )
{
MessageBox( NULL, "DirectX could not be initiated.", "ERROR", MB_OK );
return false;
}
MSG msg;
ZeroMemory( &msg, sizeof( msg ) );
while( msg.message!=WM_QUIT )
{
if ( PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
render( );
};
};
cleanUp( );
return (int) msg.wParam;
}
//InitWindow function
bool initWindow( HINSTANCE hInstance )
{
WNDCLASSEX wcex;
//Fill the windows class structure
wcex.cbSize = sizeof(WNDCLASSEX); //Size of the WNDCLASSEX structure
wcex.style = CS_HREDRAW | CS_VREDRAW; //style of it
wcex.lpfnWndProc = (WNDPROC)WndProc; //the window procedure callback
wcex.cbClsExtra = 0; //do not allocate any extra bytes for this class
wcex.cbWndExtra = 0; //do not allocate any extra bytes for this instance
wcex.hInstance = hInstance; //handle to the application instance
wcex.hIcon = 0; //icon to associate with the application
wcex.hCursor = LoadCursor(NULL, IDC_ARROW); //default cursor
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); //instance's background color
wcex.lpszMenuName = NULL; //the resource name for the menu
wcex.lpszClassName = "DirectXExample"; //the class name being created
wcex.hIconSm = 0; //handle to a small icon
RegisterClassEx(&wcex);
//create the window
wndHandle = CreateWindow(
"DirectXExample", //window class to use
"DirectXExample", //window's caption
WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE, //window style
CW_USEDEFAULT, //starting x coord
CW_USEDEFAULT, //starting y coord
640,480, //resolution
NULL, //parent window; NULL for desktop
NULL, //menu for the application; NULL for none
hInstance, //handle to the application instance
NULL); //no values passed to the window
//is the window handle valid
if ( !wndHandle )
return false;
//show the window on the screen
ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);
return true;
}
//WndProc function
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
//Check any available messages from the queue
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
}
//Always return the message to the default window
//procedure for further processing
return DefWindowProc(hWnd, message, wParam, lParam);
}
//initDirect3D function
bool initDirect3D ( void )
{
pD3D = NULL;
pd3dDevice = NULL;
//Create the DirectX object
if ( NULL == ( pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
{
return false;
}
//Fill the presentation parameters structure
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof( d3dpp ) );
d3dpp.Windowed = FALSE; //This app will (not) be windowed
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; //Page flipping effect
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; //Set the backbuffer format
d3dpp.BackBufferCount = 1; //There is only 1 backbuffer
d3dpp.BackBufferHeight = 480; //Set the vertical resolution
d3dpp.BackBufferWidth = 640; //Set the horizontal resolution
d3dpp.hDeviceWindow = wndHandle; //The window handle to render on
//Create a default DirectX device
if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, //Use the default adapter
D3DDEVTYPE_REF, //Set the device type
wndHandle, //The window handle to render on
D3DCREATE_SOFTWARE_VERTEXPROCESSING, //Set the thingy
&d3dpp, //Give it that thingy
&pd3dDevice ) ) ) //And that thingy
{
return false;
}
return true;
}
//Render
void render( void )
{
//Is the DX9 device valid
if ( NULL == pd3dDevice )
return;
//Clear the back buffer to blue
pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_XRGB( 0,0,255 ), 1.0f, 0 );
//Render
pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
//Cleany!!
void cleanUp ( void )
{
//Release the device
if( pd3dDevice != NULL )
pd3dDevice->Release( );
//Release the Direct3D object
if( pD3D != NULL )
pD3D->Release( );
}
made in MSVC++ 2005 Express edition
But this is more updated cuz it's now in full skreen ^
BTW the code looks almost exactly like in the book cause I just typed what it told me to
I think I'll understand the datatypes more after I get farther through the book...or atleast memorize the functions and their parameters well o.O
/me should learn windoze programming after teh skinny book is done
FunkyStickmen: Battle of the Races (1%)