Sign in to follow this  

Having problem with directx program!

This topic is 2550 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

I'm new to directx programming and I'm going through a book on the subject. I had an error about not finding the d3dx9.lib file but I'm pretty sure I set up visual studio 2010 right and fix that but now I'm getting these errors.

'Direct3D_Windowed.exe': Loaded 'C:\Users\Admin\Documents\Visual Studio 2010\Projects\Direct3D_Windowed\Debug\Direct3D_Windowed.exe', Symbols loaded.
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\d3d9.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\d3d8thk.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'Direct3D_Windowed.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
The program '[1408] Direct3D_Windowed.exe: Native' has exited with code 49776 (0xc270).

Also here is the code!

/*
Beginning Game Programming, Third Edition
Chapter 3
Direct3D_Windowed program
*/

#include <windows.h>
#include <d3d9.h>
#include <time.h>
#include <iostream>
using namespace std;



// program settings
const string APPTITLE = "Direct3D_Windowed";
const int SCREENW = 1024;
const int SCREENH = 768;

// Direct3D objects
LPDIRECT3D9 d3d = NULL;
LPDIRECT3DDEVICE9 d3ddev = NULL;

bool gameover = false;

// macro to detect key presses
#define KEY_DOWN(vk_code)((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)

/**
** Game initialization function
**/
bool Game_Init(HWND window)
{
MessageBox(window, "Game_Init", "BREAKPOINT", 0);

// initialize Direct3D
d3d = Direct3DCreate9(D3D_SDK_VERSION);
if (d3d == NULL)
{
MessageBox(window, "Error initializing Direct3D", "Error", MB_OK);
return 0;
}

// set Direct3D presentation parameters
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = SCREENW;
d3dpp.BackBufferHeight = SCREENH;
d3dpp.hDeviceWindow = window;

// create Direct3D device
d3d->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
window,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);

if (d3ddev == NULL)
{
MessageBox(window, "Error creating Direct3D device", "Error", MB_OK);
return 0;
}

return true;
}

/**
** Game update function
**/
void Game_Run(HWND hwnd)
{
// make sure the Direct3D device is valid
if (!d3ddev)return;

// clear the backbuffer to bright green
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 255, 0), 1.0f, 0);

// start rendering
if (d3ddev->BeginScene())
{
// do something?

// stop rendering
d3ddev->EndScene();

// copy back buffer on the screen
d3ddev->Present(NULL, NULL, NULL, NULL);
}

// check for escape key (to ecit program)
if (KEY_DOWN(VK_ESCAPE))
PostMessage(hwnd, WM_DESTROY, 0, 0);
}

/**
** Game shutdown function
**/
void Game_End(HWND hwnd)
{
// display close message
MessageBox(hwnd, "Program is about to end", "Game_End", MB_OK);

// free memory
if (d3ddev) d3ddev->Release();
if (d3d) d3d->Release();
}

/**
** Windows event handling function
**/
LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_DESTROY:
gameover = true;
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}

/**
** Main Windows entry function
**/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpcmdLine, int nCmdShow)
{
// set the new window's properties
// previously found in the MyRegisterClass function
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
// Fill the struct with info
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WinProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = APPTITLE.c_str();
wc.hIconSm = NULL;

// set up the window with the class info
return RegisterClassEx(&wc);

// create a new window
// previously found in the InitInstance function
HWND window = CreateWindow(
APPTITLE.c_str(), // window class
APPTITLE.c_str(), // title bar
WS_OVERLAPPEDWINDOW, // window styple
CW_USEDEFAULT, CW_USEDEFAULT, // position of window
SCREENW, SCREENH, // dimensions of the window
NULL, // parent window (not used)
NULL, // menu (not used)
hInstance, // application instance
NULL); // window parameters (not used)


// was there an error creating the window?
if (window == 0)return 0;

// display the window
ShowWindow(window, nCmdShow);
UpdateWindow(window);

// initialize the game
if (!Game_Init(window))return 0;

// main message loop
MSG message;
while (!gameover)
{
// process Windows events
if (PeekMessage(&message, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&message);
DispatchMessage(&message);
}

// process game loop
Game_Run(window);
}

// free game resources
Game_End(window);
return message.wParam;
}

Can anyone help me? I'm not sure whats wrong.

Share this post


Link to post
Share on other sites
Quote:
The program '[1408] Direct3D_Windowed.exe: Native' has exited with code 49776 (0xc270).

That's the only message that's a problem. The other lines about PDB files just means debugging symbols weren't found for the dlls noted.

Your WinMain function ( which is the entry point for your app ) is the problem:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpcmdLine, int nCmdShow)
{
// set the new window's properties
// previously found in the MyRegisterClass function
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
// Fill the struct with info
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WinProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = APPTITLE.c_str();
wc.hIconSm = NULL;

// set up the window with the class info
return RegisterClassEx(&wc);


You terminate the app by returning the ATOM from RegisterClassEx.

Share this post


Link to post
Share on other sites
Thanks I fix that but now I'm getting an error about not being able to open the d3dx9.libkernel32.lib. I think that is because the book is for visual studio 2008 and I have 2010 and I can't find any good tutorials on how to set it up directx. Can anyone help me with setting up directx in 2010?

Share this post


Link to post
Share on other sites
Quote:
Original post by kogo50
Thanks I fix that but now I'm getting an error about not being able to open the d3dx9.libkernel32.lib.

If that is the exact error then you are just missing a whitespace in your linker setup somewhere. d3dx9.lib and kernel32.lib are two separate (non-related) libraries. Double check your included libraries in the project settings.



Share this post


Link to post
Share on other sites
Quote:
Original post by Promethium
Quote:
Original post by kogo50
Thanks I fix that but now I'm getting an error about not being able to open the d3dx9.libkernel32.lib.

If that is the exact error then you are just missing a whitespace in your linker setup somewhere. d3dx9.lib and kernel32.lib are two separate (non-related) libraries. Double check your included libraries in the project settings.


I personally hate messing around with VS's Project Settings.

#pragma comment( lib, "d3dx9.lib" )

Is quite easier and causes less headaches.

Share this post


Link to post
Share on other sites

This topic is 2550 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this