Jump to content
  • Advertisement
Sign in to follow this  
TurnX

d3dx9.h - No such file

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

Having a small issue with getting d3dx9.h to load in Visual Studio 2008. I went into the project properties, then linker settings and added d3dx9.lib to the additional dependencies. I already have d3d9.lib in the additional dependencies and loading d3d9.h works just fine. Is there something I am missing?

Share this post


Link to post
Share on other sites
Advertisement
Does d3dx9.h exist in the same directory as d3d9.h? What version of the DirectX SDK have you installed? (Or if you've not, there's your problem [smile])

Share this post


Link to post
Share on other sites
using the March 2008 SDK. I looked into the library and include folders and the files are in the same folder respectively.

Share this post


Link to post
Share on other sites
Quote:
Original post by TurnX
using the March 2008 SDK. I looked into the library and include folders and the files are in the same folder respectively.
Can we see some code? Are you just #include'ing it? Are you using angled brackets rather than double quotes?
It should be:
#include <d3dx9.h>

Share this post


Link to post
Share on other sites
under tools preferences... have you added the sdk directories to your vc++ dirs ??

Share this post


Link to post
Share on other sites

// Beginning Game Programming
// Chapter 6

//header files to include
#include <d3d9.h>
#include <d3dx9.h>
#include <time.h>

//application title
#define APPTITLE "Direct3D Bitmap Test"

//screen resolution
#define SCREEN_WIDTH 1600
#define SCREEN_HEIGHT 1200

//macros tor ead keyboard
#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)

//function prototypes (forward declarations)
ATOM MyRegisterClass(HINSTANCE);
LRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM);
int Game_Init(HWND);
void Game_Run(HWND);
void Game_End(HWND);

//Direct3D Objects
LPDIRECT3D9 d3d = NULL;
LPDIRECT3DDEVICE9 d3ddev = NULL;
LPDIRECT3DSURFACE9 surface = NULL;
LPDIRECT3DSURFACE9 backbuffer = NULL;

//the window event callback function
LRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

switch (message)
{
case WM_DESTROY:
Game_End(hWnd);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}

//helper function to set up the window properties
ATOM MyRegisterClass(HINSTANCE hInstance)
{
//create the window class structure
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;
wc.hIconSm = NULL;

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

//entry point for a Windows program
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// declare variables
MSG msg;

// register the class
MyRegisterClass(hInstance);

//windows handle variable
HWND hWnd;

//create a new window
hWnd = CreateWindow(
APPTITLE, //window class
APPTITLE, //title bar
WS_EX_TOPMOST | WS_VISIBLE | WS_POPUP, //window style
CW_USEDEFAULT, //x position of window
CW_USEDEFAULT, //y position of window
SCREEN_WIDTH, //width of the window
SCREEN_HEIGHT, //height of the window
NULL, //parent window
NULL, //menu
hInstance, //application instance
NULL); //window parameters

//was there an error creating the window?
if (!hWnd)
return FALSE;

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

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

//game loop
int done = 0;

while (!done)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
//look for quit message
if (msg.message == WM_QUIT)
{
MessageBox(hWnd, "Recived Quit message", "WinMain", MB_OK);
done = 1;
}

//decode and pass message to WinProc
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
//process the game loop
Game_Run(hWnd);
}

return msg.wParam;
}

int Game_Init(HWND hwnd)
{
HRESULT result;

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

//set Direct3D presentation parameters
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));

d3dpp.Windowed = FALSE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.hDeviceWindow = hwnd;

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

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

//set random number seed
srand(time(NULL));

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

//get pointer to the backbuffer
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);

//create surface
result = d3ddev->CreateOffscreenPlainSurface(640, 480, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL);

if(result != D3D_OK)
return 1;

//load surface from file
result = D3DXLoadSurfaceFromFile(surface, NULL, NULL, "legotron.bmp", NULL, D3DX_DEFAULT, 0, NULL);

//see if file was loaded okay
if(result != D3D_OK)
return 1;

//draw surface to backbuffer
d3ddev->StretchRect(surface, NULL, backbuffer, NULL, D3DTEXF_NONE);

//everything went okay
return 1;
}

void Game_Run(HWND hwnd)
{
//make sure we have a valid Direct3D device
if (d3ddev == NULL)
return;

//start rendering
if (d3ddev->BeginScene())
{
//get pointer to the backbuffer
d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);

//draw surface to backbuffer
d3ddev->StretchRect(surface, NULL, backbuffer, NULL, D3DTEXF_NONE);

//stop rendering
d3ddev->EndScene();
}

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

if (KEY_DOWN(VK_ESCAPE))
{
PostMessage(hwnd, WM_DESTROY, 0, 0);
}
}

void Game_End(HWND hwnd)
{
//release the surface
if (surface != NULL)
{
surface->Release();
}

//release the Direct3D device
if (d3ddev != NULL)
{
d3ddev->Release();
}

//release Direct3D object
if (d3d != NULL)
{
d3d->Release();
}
}


thats the code I am using. Just a simpel test function to load bitmaps on put them onscreen.

Share this post


Link to post
Share on other sites
And what's the exact error you get? What happens if you right click on the "d3dx9.h" part of the line and select "Open d3dx9.h"?

Share this post


Link to post
Share on other sites
Quote:
Original post by mystb
under tools preferences... have you added the sdk directories to your vc++ dirs ??


This was the problem. The book I am following seemed to have skipped over that step when runing me through the sdk setup. Thanks for the help.

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!