Setting up a D3D app in Visual C++ .NET 2003

I have a small 3D app I am coding as I am learning. I am trying to implement some DirectX fonts to display stats to the screen but am having trouble at compile time.


c:\dxsdk\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(48) : error C2146: syntax error : missing ';' before identifier 'FontDesc'
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(48) : error C2501: 'D3DGame::D3DXFONT_DESC' : missing storage-class or type specifiers
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(48) : error C2501: 'D3DGame::FontDesc' : missing storage-class or type specifiers
D3DGame.cpp
c:\dxsdk\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(48) : error C2146: syntax error : missing ';' before identifier 'FontDesc'
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(48) : error C2501: 'D3DGame::D3DXFONT_DESC' : missing storage-class or type specifiers
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(48) : error C2501: 'D3DGame::FontDesc' : missing storage-class or type specifiers
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.cpp(26) : error C2065: 'FontDesc' : undeclared identifier
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.cpp(26) : error C2059: syntax error : '{'
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.cpp(26) : error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.cpp(26) : error C2143: syntax error : missing ';' before '}'
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.cpp(27) : error C2059: syntax error : '{'
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.cpp(27) : error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.cpp(27) : error C2143: syntax error : missing ';' before '}'
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.cpp(392) : error C3861: 'FontDesc': identifier not found, even with argument-dependent lookup
c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.cpp(533) : error C2660: 'ID3DXFont::DrawTextA' : function does not take 6 arguments

 


I don't believe its an error in my code as much as its an error in my setup of the project. I have the C:/DXSDK/Includes directory set, as well as some lib files linked in the project, but I can't find any info on what else I need to add to get this to work.

TIA for any help!

G.I.


Answer this question

Setting up a D3D app in Visual C++ .NET 2003

  • Paweł

    I solved the problem by downloading the August 2005 SDK update. The code compiles perfectly now, since it now understands what those variable types are.

    So you were right, I recently installed the SDK about a week ago on this machine and just assumed it would be the most updated version available, but apprently you have to download the latest updates as well.

    Thanks for your help!

    G.I.

  • Xtreme Developer

    If your other dx stuff compiles then I doubt if it’s the includes, but just in case you haven't make sure the library directory is at the top as well, but I doubt its this from what you say, the sdk sets them at the top anyway.

    The only thing I can think of at the moment is the sdk version you're using. I'm using the December 2004 version because that's the last one usable with win2k and that uses D3DXFONT_DESC but I noticed whilst working through a few books that some of the earlier dx9 sdks use LOGFONT instead. Can't say about the latest sdk. I've been doing a bit of updating.

    If you're allowed to compile a program with ID3DXFont, then declare one, just for a test, then right-click on the declaration and select "Go To Declaration" from the popup menu, this should take you to the font class declaration in d3dx9core.h. Right above the class declaration is where D3DXFONT_DESC is declared. If its there then you have some kind of include problem and you might have to restructure the include files. If it isn't there, check the font class and it's member functions to see if it uses LOGFONT instead.

    If that fails, try right-clicking the d3dx9.h include declaration and select "Open Document <d3dx9.h>" from the popup menu, this should open up d3dx9.h. Let your mouse hover on the documents tab, just at the top, this should show what directory the file is in, this is just to make sure you're in the right place. Look for "d3dx9core.h" near the bottom, right-click it and follow the same procedure to open it up, this is where D3DXFONT_DESC should be defined. If it's there then it sounds like a linker problem.


  • Teetime

    I got similar errors too while compiling a vc++ 6 project in .net. I am using MS 2000 and the directx update seems to support XP onwards. Is there any other way I could solve this problem

  • Todd D

    Make sure the sdk is shown in the main project options, check for all the directories:

    Tools->options->projects->vc++ directories

    Also make sure that it comes at the top of the lists otherwise you might reference different versions.

    You should then be able to add references to the dx libraries:

    Project properties->linker->input->additional dependencies

    Or by adding pragmas:

    #include <d3d9.h>
    #include <d3dx9.h>

    #pragma comment (lib, "d3d9.lib")  // D3D library
    #pragma comment (lib, "d3dx9.lib") // D3DX library


  • S.Paul

    Thanks for the reply.

    In the Options->Projects->VC++ Directories, I do have the first one in the list set for:

    C:\DXSDK\Include
     


    In the Project Properties->Linker->Input->Additional Dependencies has these libraries listed:

    d3d9.lib
    d3dx9.lib
    winmm.lib
    dinput8.lib
    dxguid.lib

     


    In the same file, D3DGame.h, these header files are included:

    #include <Windows.h>
    #include <mmsystem.h>
    #include <d3d9.h>
    #include <d3dx9.h>
    #include <dinput.h>

     


    I've commented out all the code that has to do with fonts, except this line from my program:

    D3DXFONT_DESC FontDesc;
     


    This is the latest error I get if this line is not commented out:

    c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(49) : error C2146: syntax error : missing ';' before identifier 'FontDesc'
    c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(49) : error C2501: 'D3DGame::D3DXFONT_DESC' : missing storage-class or type specifiers
    c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(49) : error C2501: 'D3DGame::FontDesc' : missing storage-class or type specifiers
    D3DGame.cpp
    c:\dxsdk\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
    c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(49) : error C2146: syntax error : missing ';' before identifier 'FontDesc'
    c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(49) : error C2501: 'D3DGame::D3DXFONT_DESC' : missing storage-class or type specifiers
    c:\Documents and Settings\Joe\My Documents\Visual Studio Projects\Designer\D3DGame.h(49) : error C2501: 'D3DGame::FontDesc' : missing storage-class or type specifiers

     


    If I comment out that particular line of code, the program compiles as expected.

    Any other ideas

    joe...

  • Setting up a D3D app in Visual C++ .NET 2003