• Advertisement

Archived

This topic is now archived and is closed to further replies.

Newbie + DirectInput = This Topic

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

Hey all, I''m trying to create my own 3d engine (like the rest of us ) but suffer from complete newbieism. Every time I try to compile my program, I get the same error messages from DirectInput. I''m sure there is a really simple fix for this, but right now it is beyond me! Any help would be greatly appriciated This is the compile error I keep getting, well a section of it anyway:
input.cpp
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(646) : error C2501: ''UINT_PTR'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(646) : error C2146: syntax error : missing '';'' before identifier ''uAppData''
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(646) : error C2501: ''uAppData'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(658) : error C2501: ''UINT_PTR'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(658) : error C2146: syntax error : missing '';'' before identifier ''uAppData''
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(658) : error C2501: ''uAppData'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1056) : error C2501: ''UINT_PTR'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1056) : error C2146: syntax error : missing '';'' before identifier ''uData''
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1056) : error C2501: ''uData'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1209) : error C2501: ''UINT_PTR'' : missing decl-specifiers
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1209) : error C2146: syntax error : missing '';'' before identifier ''uAppData''
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h(1209) : error C2501: ''uAppData'' : missing decl-specifiers
 

Share this post


Link to post
Share on other sites
Advertisement
Just for the record, I am having this same exact problem. I thought it was my compiler (I am using MSVC++ 4.0), but now that someone else has this problem, there must be a setting that I am overlooking (unless sledge also has an older compiler).

And I am sure it is not my code, because I have tried compiling both ShiningKnight''s game tutorials and the game from "OpenGL Game Programming."

Share this post


Link to post
Share on other sites
Okay. Where is the DXSDK installed on your system? It looks as though it''s grabbing header files from your VC Include directory. That might be the way you intentionally have it set up, but if the most recent DX headers are anywhere else, put the directory first on your directory list for Include Files within the VC IDE.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

Share this post


Link to post
Share on other sites
No, it''s not a DX include problem, it''s your old compiler. Include this file: <basetsd.h> and you should be fine.

Share this post


Link to post
Share on other sites
I'm not sure if it is the old compiler, because I'm using MSVC++ 5.0 (yes, i guess that is still old to, but hey ) and it just wont work. I tried including basetsd.h and though it fixed the previous problem I had, now it gives me unresolved external symbols.

Here is exactly what went wrong:

--------------------Configuration: engine - Win32 Debug--------------------
Compiling...
main.cpp
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
engine.cpp
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
input.cpp
C:\Program Files\DevStudio\VC\INCLUDE\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800
Linking...
input.obj : error LNK2001: unresolved external symbol _c_dfDIKeyboard
input.obj : error LNK2001: unresolved external symbol _GUID_SysKeyboard
input.obj : error LNK2001: unresolved external symbol _c_dfDIMouse
input.obj : error LNK2001: unresolved external symbol _GUID_SysMouse
input.obj : error LNK2001: unresolved external symbol _DirectInput8Create@20
input.obj : error LNK2001: unresolved external symbol _IID_IDirectInput8A
...\bin\debug\engine.exe : fatal error LNK1120: 6 unresolved externals
Error executing link.exe.

engine.exe - 7 error(s), 0 warning(s)


[edited by - sledge on May 31, 2002 10:55:32 PM]

Share this post


Link to post
Share on other sites
To fix the DIRECTINPUT_VERSION errors, add this before you include dinput.h:
#define DIRECTINPUT_VERSION 0x0800

To fix the other errors, add dinput8.lib to the linker''s list of libraries.

Share this post


Link to post
Share on other sites
IndirectX: Thanks, "basetsd.h" did it for me.

Also, does anyone know where the sinf, cosf, and sqrtf functions are located? ShiningKnight uses them in his tutorials but I am getting undeclared indentifier errrors.

And are there any other header files I should include when using an older compiler. It seems like I always get errors when I use code made for 6.0.

Share this post


Link to post
Share on other sites
The floating point trig functions are not included in VC''s math.h AFAIK. You can use the following substitutes (BTW, they''re considerably faster than the standard versions):

//modified Taylor series sine approximation
inline float sinf(float angle)
{
float sq = angle*angle;
float cu = sq*angle;
float pe = cu*sq;
float se = pe*sq;
float no = se*sq;
float el = no*sq;

return angle-
0.166666666666f*cu+
0.008333333333f*pe-
0.000198412698f*se+
0.000002755732f*no-
0.000000025052f*el;
}

//modified Taylor series cosine approximation
inline float cosf(float angle)
{
float sq = angle*angle;
float qu = sq*sq;
float he = qu*sq;
float oc = he*sq;
float de = oc*sq;

return 1-
0.500000000000f*sq+
0.041666666666f*qu-
0.001388888888f*he+
0.000024801587f*oc-
0.000000275573f*de;
}

inline float tan(float angle)
{
return sinf(angle)/cosf(angle);
}


Later,
ZE.

PS: Let me know if there are any issues with those. They''re pinpoint accurate except around the edges (+-180), and BE SURE that your input is in radians and is within the range of -180 to 180 (-2pi to 2pi).



//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

Share this post


Link to post
Share on other sites
Zealous,

Thanks for the code. Where are the standard ones at? I am wondering why ShiningKnight would put them in his tutorial but forget to include the header for them.

Also, do you have a sqrtf function?

Share this post


Link to post
Share on other sites

inline float sqrtf(float x)
{
static float error = 0.0001f;
float guess = x;
float result = x;

while(absval(x-guess*guess) > error)
{
guess = result;
result = 0.5f*(guess+x/guess);
}

return result;
}


If the floating point functions aren''t in math.h, they aren''t anywhere. Some implementations simply don''t include them. You can always use
int Root = (float)sin((float)Angle);
but that can be slow.

Hope that helps.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

Share this post


Link to post
Share on other sites
Thanks again for all the code, Zealous. I will assume they work wonders, but I won''t be able to see for myself until I get this code to compile. Check out this error:


  
--------------------Configuration: Shining3D - Win32 Debug--------------------
Linking...
LINK : fatal error LNK1000: unknown error; consult documentation for technical support options
Error executing link.exe.
Shining3D.exe - 1 error(s), 0 warning(s)


At first I was getting an error that it could not open "dxguid.lib," so I changed the project options to include the MSSDK library folder. Then the error changed into the one above. Any ideas?

Share this post


Link to post
Share on other sites
Try rewriting your code. Simplify complex statements, use temporary variables or typedefs, break large functions into smaller ones.

Share this post


Link to post
Share on other sites
those sin/cos/tan approximations look quite interesting..
just wondering if they require the input value to be in the 0-2pi range?

alo..

I was under the impression that the generic cos/sin/tan calls were already fairly fast as they used lookup tables.. (since the real sin/cos forumlas are infinite... - well. I think they are)

or am I missing something?

Share this post


Link to post
Share on other sites
quote:
Original post by RipTorn
those sin/cos/tan approximations look quite interesting..
just wondering if they require the input value to be in the 0-2pi range?

quote:
Previously, I said,
PS: Let me know if there are any issues with those. They''re pinpoint accurate except around the edges (+-180), and BE SURE that your input is in radians and is within the range of -180 to 180 (-2pi to 2pi).

quote:
Said RipTorn,
I was under the impression that the generic cos/sin/tan calls were already fairly fast as they used lookup tables.. (since the real sin/cos forumlas are infinite... - well. I think they are)
or am I missing something?


Many sines are irrational. However, both the standard functions and my implementations generate very accurate approximations. Mine are marginally faster, and no, the standard versions do NOT use lookup tables.

Later,
ZE.



//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

Share this post


Link to post
Share on other sites
I''ve been thinking about upgrading, so I guess now is the time. I would buy VC++.NET but it needs NT (or XP, I think), while I am using Windows ME. Can you still purchase VC++ 6.0 new?

Share this post


Link to post
Share on other sites

  • Advertisement