469,336 Members | 5,592 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

No d3dx9.h? -What The Heck?-

Ajm113
161 100+
Ok, I am trying to create a window using this book called "Introduction To 3D Game Programming with DirectX 9.0c A shader Approach." By Frank D Luna. I used that hole script on page 98 to where it starts talking about Direct X debuging on one hole script. I got Visual Studios C++, DirectX, DirectX SDK. So whats going on?

Expand|Select|Wrap|Line Numbers
  1. #include <d3dx8.h>
  2. #include <iostream.h>
  3.  
  4. using namespace std;
  5.  
  6. class HelloD3DApp : public D3DApp
  7. {
  8. public:
  9.     HelloD3DApp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD, requestedVP);
  10.     -HelloD3DApp();
  11.  
  12.     bool checkDeviceCaps();
  13.     void onLostDevice();
  14.     void updateScene(float dt);
  15.     void drawScene();
  16.  
  17. private:
  18.  
  19.     ID3DXFont* mFont;
  20. };
  21.  
  22. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, prevInstance, PSTR cmdLine, int showCmd)
  23. (
  24.     //Enable run-time memory check for debug builds.
  25. #if defined(DEBUG) | DEFINED(_DEBUG) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEMDF |_CRTDBG_LEAK_CHECK_DF );
  26.  
  27. #endif
  28.  
  29. HelloApp app(hInstance);
  30. gd3dApp = &app;
  31.  
  32.  return gd3dApp->run();
  33. }
  34.  
  35. HelloD3DApp::HelloD3DApp(HINSTANCE, hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP): D3DApp(hInstance, winCaption, devType, requestedVP)
  36. {
  37.     srand(time_t(0));
  38.  
  39.     //Check the memory and make sure their are no errors other wise then make a error and shutdown.
  40.     if(!checkDeviceCaps())
  41.     {
  42.     MessageBox(0, "CheckDeviceCaps() Failed", 0, 0);
  43.     PostQuitMessage(0);
  44.     }
  45.     D3DXFONT_DESC fontDesc;
  46.     fontDesc.Height = 80;
  47.     fontDesc.Width = 40;
  48.     fontDesc.MipLevels = 0;
  49.     fontDesc.Italic = true;
  50.     fontDesc.CharSet = DEFAULT_CHARSET;
  51.     fontDesc.OutputPrecision = OUT_DEFAULT_PRECIS;
  52.     fontDesc.Quality = DEFAULT_QUALITY;
  53.     fontDesc.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
  54.     _tcscpy(fontDesc.FaceName, _T("Times New Roman"));
  55.  
  56.     HR(D3DXCreateFontIndirect(gd3dDevice, &fontDesc, &mFont));
  57. }
  58.  
  59. HelloD3DApp::~HelloD3DApp()
  60. {
  61. releaseCOM(mFont);
  62. }
  63.  
  64. #define ReleaseCOM(x) { if(x){x->Release();x = 0;}}
  65.  
  66. bool HelloD3DApp::checkDeviceCaps()
  67. {
  68.     //Nothing to check
  69.     return true;
  70. }
  71.  
  72. void HelloD3DApp::updateScene(float dt)
  73. {
  74.  
  75. }
  76.  
  77. void HelloD3DApp::onLostDevice()
  78.  
  79. {
  80.     HR(mFont->OnLostDevice());
  81. }
  82.  
  83. void HelloD3DApp::onResetDevice()
  84. {
  85. HR(mFont->OnResetDevice());
  86. }
  87.  
  88. void HelloD3DApp::drawScene()
  89. {
  90.     HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_xRGB(225, 225, 255), 1.0f, 0);
  91.  
  92.     RECT formatRect;
  93.     GetClientRect(mMainWnd, &formatRect);
  94.     HR(gd3dDevice->BeginScene());
  95.  
  96.     mFont->DrawText(0, _T("Hello Direct3D"), -1, &formatRect, DT_CENTER | DT_VCENTER, D3DCOLORXRGB(rand() % 256, rand() % 256));
  97.  
  98.     HR(gd3dDevice->EndScene());
  99.     HR(gd3dDevice->Present(0,0,0,0));
  100. }
  101.  
Jun 16 '07 #1
7 16394
weaknessforcats
9,208 Expert Mod 8TB
What was your question?

If you have trouble with Windows code, start reading "Programming Windows" by Charles Petzold for the background.
Jun 17 '07 #2
Ajm113
161 100+
The compiler is telling me it can't find d3dx9.h. Even the windows.h file. Is there something else I must download to continue my DirectX project? I have been playing around with it, but so far it keeps showing the same error that it can't find it.
Jun 17 '07 #3
The catch is the compiler doesn't necessarily *know* where the Windows and DirectX headers are at. While you didn't specify what compiler you use, there should be a set of options for your current project along the lines of "Additional Include Directories" (VC2005) or similar. Tell it the location of said headers in there. What I prefer to do (and this also makes your code a bit more release-friendly) is copy the main folders of any and all APIs used in my program into my working directory, keeping the dir structure, obviously. Anyhow all you have to do at that point is put the directory your header resides in before the name and you're golden. Even works for libraries too. If you're more visual, here's how my DX9 renderer class works/looks:

Expand|Select|Wrap|Line Numbers
  1. #pragma once
  2.  
  3. #include "Renderer.h"
  4.  
  5. // DirectX stuff
  6. #include "DirectX\d3d9.h"
  7. #pragma comment (lib, "DirectX/libs/d3d9.lib")
  8.  
  9. class CRendererDX9 : public Renderer...
  10. yada yada yada
  11.  
I remember this kind of problem really used to drive me nuts before I started using that little trick.
Jun 17 '07 #4
Ajm113
161 100+
I'm using the 2005 version. I thought there was something I had to download, but then I'll try that and see what happens.
Jun 17 '07 #5
Is there somewhere I can download all the necessary include files (all the ones referenced by d3dx9.h) in a small (not 400mb) package???

Thanks
Oct 18 '10 #6
Your best bet would be the sdks. If you dont want to dl a 400mb file. I dont have anything i cant help with
Oct 19 '10 #7
Samishii23
246 100+
Your best bet is to find the headers and download them directly, and place them in your project folder if you don't want to download a large installer...

But your probably better off doing the installer, and setting up your compiler to look into a SDK header include folder so you don't have to remember to copy/paste a header file into your project every time you need one.

Food for thought.
Oct 19 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Ducati916 | last post: by
4 posts views Thread by Alerion | last post: by
3 posts views Thread by dragonslayer008 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.