Jump to content
  • Advertisement
Sign in to follow this  
iceman90289

Was working fine until...

This topic is 3497 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello whoever is reading this i am going through the excersises in Wendy Jone's book "Begining DirectX 9" now i have been looing at this off and on but i always gave up when i couldnt fix something. Now thats going to change. I had a working window and when i added directX code to it i got all these errors and the error report took me to windows.h and im sure there is nothing wrong with that file... but anyways i used VS2k5 Proffessional Edition and DirectX 9.0 If you can, go ahead and take a look at this and tell me where i messed up. thanks very much // Include windows header #include<windows.h> #include<d3d9.h> HINSTANCE hInst; HWND wndHandle; LPDIRECT3D9 pD3D; LPDIRECT3DDEVICE9 pd3dDevice; // Prototypes bool initWindow( HINSTANCE hInstance ); bool initDirect3D(void); void render(void); void cleanUp(void); LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); // Entry point int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) { // Init window if( !initWindow(hInstance)) return false; // Called after initializing window if(!initDirect3D() ) return false; // Message loop MSG msg; ZeroMemory( &msg, sizeof( msg) ); while( msg.message!=WM_QUIT ) { // Check the msg queue if( PeekMessage( &msg, NULL, OU, OU, PM_REMOVE ) ) { TranslateMessage(&msg); DispatchMessage(&msg); } else { render(); } } return (int)msg.wParam; } bool initWindow( HINSTANCE hInstance ) { WNDCLASSEX wcex; // Fill in the wndclassex struct wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = "DirectXExample"; wcex.hIconSm = 0; RegisterClassEx(&wcex); // Create the window wndHandle = CreateWindow( "DirectXExample", "DirectXExample", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL); if(!wndHandle) return false; // Display window ShowWindow(wndHandle, SW_SHOW); UpdateWindow(wndHandle); return true; } bool initDirect3D(void) { pD3D = NULL; pd3dDevice = NULL; // Create the DX Obj if( NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION ) ) ) { return false; } // Fill presParams D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof( d3dpp ) ); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = 480; d3dpp.BackBufferWidth = 640; d3dpp.hDeviceWindow = wndHandle; //Create the default DX device if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, wndHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice ) ) ) { return false; } return true; } void render(void) { // Check validity of D3D device if( NULL == pd3dDevice ) return; pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 ); // Pres params pd3dDevice->Present( NULL, NULL, NULL, NULL ); } void cleanUp(void) { // Release device and d3d obj. if( pd3dDevice != NULL ) pd3dDevice->Release( ); if( pD3D != NULL ) pD3D->Release( ); } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { // Check any available msgs switch(message) { case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, message, wParam, lParam); }

Share this post


Link to post
Share on other sites
Advertisement
It would help if you editing your post and put the code in ([)source(])([/)source(]) tags, and also posted the error messages.

Scott

Share this post


Link to post
Share on other sites
Quote:
Original post by CodaKiller
You should delete you other 3 post fast, I don't think the mods will like that...

Took care of it.

Share this post


Link to post
Share on other sites
Quote:
Original post by CodaKiller
You should delete you other 3 post fast, I don't think the mods will like that...

Yeah and post the exact error message you are getting.
I went through that book several years ago and there are some minor changes you needed to make to get some of the code to compile I remeber that. There were some simple and easy fixes for the most part.

Share this post


Link to post
Share on other sites
sorry about that. I actually didnt know i was a member here so whatever i posted... i never saw again. anyways here it is in source brackets


// Include windows header
#include<windows.h>
#include<d3d9.h>

HINSTANCE hInst;
HWND wndHandle;
LPDIRECT3D9 pD3D;
LPDIRECT3DDEVICE9 pd3dDevice;

// Prototypes
bool initWindow( HINSTANCE hInstance );
bool initDirect3D(void);
void render(void);
void cleanUp(void);
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );

// Entry point
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )
{
// Init window
if( !initWindow(hInstance))
return false;

// Called after initializing window
if(!initDirect3D() )
return false;

// Message loop
MSG msg;
ZeroMemory( &msg, sizeof( msg) );
while( msg.message!=WM_QUIT )
{
// Check the msg queue
if( PeekMessage( &msg, NULL, OU, OU, PM_REMOVE ) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
render();
}
}
return (int)msg.wParam;
}

bool initWindow( HINSTANCE hInstance )
{
WNDCLASSEX wcex;

// Fill in the wndclassex struct
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "DirectXExample";
wcex.hIconSm = 0;
RegisterClassEx(&wcex);

// Create the window
wndHandle = CreateWindow(
"DirectXExample",
"DirectXExample",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
480,
NULL,
NULL,
hInstance,
NULL);

if(!wndHandle)
return false;

// Display window
ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);
return true;
}

bool initDirect3D(void)
{
pD3D = NULL;
pd3dDevice = NULL;

// Create the DX Obj
if( NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION ) ) )
{
return false;
}

// Fill presParams
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof( d3dpp ) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferHeight = 480;
d3dpp.BackBufferWidth = 640;
d3dpp.hDeviceWindow = wndHandle;

//Create the default DX device
if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT,
D3DDEVTYPE_REF,
wndHandle,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&pd3dDevice ) ) )
{
return false;
}
return true;
}

void render(void)
{
// Check validity of D3D device
if( NULL == pd3dDevice )
return;
pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 );

// Pres params
pd3dDevice->Present( NULL, NULL, NULL, NULL );
}

void cleanUp(void)
{
// Release device and d3d obj.
if( pd3dDevice != NULL )
pd3dDevice->Release( );

if( pD3D != NULL )
pD3D->Release( );
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// Check any available msgs
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}




and the error messages say...

syntax error missing ; before identifier PVOID64 in winnt.h line 222

missing type specifier int assumed- winnt.h line 222

missing ; before identifier "Buffer" in winnt.h line 5940

missing type specifier in assumed winnt line 5940

missing type specifier int assumed winnt.h line 5940

********************************************************
im sure anyone would have gotten the same error messages if they compiled this.]

and where might i be able to find the changes to this code?

Share this post


Link to post
Share on other sites
Sounds to me like the platform SDK isn't installed or set up correctly. Have you downloaded and installed the platform SDK?

Aside from that, there's a couple of problems with your code:
  • You don't use AdjustWindowRect to get the correct window size, so your backbuffer will be slightly smaller than it should be, which will cause rendering artifacts and will slightly reduce performance.
  • You're creating a reference device, which isn't hardware accelerated, and will render in the order of seconds per frame, rather than frames per second. Is this what you intend?

    Share this post


    Link to post
    Share on other sites
    im just trying to get the example from the book working. its kind of frustrating to hear the books code is wrong... i mean what did i pay 30 dollars for?

    my goal here is to know what to change in the code so it wont have any errors.

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by Evil Steve
    Sounds to me like the platform SDK isn't installed or set up correctly. Have you downloaded and installed the platform SDK?

    Share this post


    Link to post
    Share on other sites
    Sign in to follow this  

    • Advertisement
    ×

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    We are the game development community.

    Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

    Sign me up!