RTS Game Programming with MS Dx 6
has anyone here read this book? I know it is kind of old, but im trying to find an update to the code, (it wont compile under VC++ 6.0) Ive seen reader reviews on amazon.com etc, saying that they are having the same problem, but i havnt been able to find any solutions. Ive e-mailed the publisher, and ive emailed Mickey Kawick, but i havnt gotten a response from either one. Can somone please help me?
Yeah, i like the book, but i cant figure out how to get it to compile, these are the errors, and i checked the help file, but it didnt really help,
dirdraw.cpp
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(86) : error C2440: '=' : cannot convert from 'long (__stdcall *)(void *,unsigned int,unsigned int,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(89) : error C2440: '=' : cannot convert from 'void *' to 'struct HINSTANCE__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(90) : error C2664: 'LoadIconA' : cannot convert parameter 1 from 'void *' to 'struct HINSTANCE__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(114) : error C2664: 'CreateWindowExA' : cannot convert parameter 11 from 'void *' to 'struct HINSTANCE__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(132) : error C2664: 'CreateWindowExA' : cannot convert parameter 11 from 'void *' to 'struct HINSTANCE__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Error executing cl.exe.
//
Probly just something dumb that i cant figure out how to fix =(
Edited by - asaari on July 5, 2001 4:06:10 PM
dirdraw.cpp
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(86) : error C2440: '=' : cannot convert from 'long (__stdcall *)(void *,unsigned int,unsigned int,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(89) : error C2440: '=' : cannot convert from 'void *' to 'struct HINSTANCE__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(90) : error C2664: 'LoadIconA' : cannot convert parameter 1 from 'void *' to 'struct HINSTANCE__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(114) : error C2664: 'CreateWindowExA' : cannot convert parameter 11 from 'void *' to 'struct HINSTANCE__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(132) : error C2664: 'CreateWindowExA' : cannot convert parameter 11 from 'void *' to 'struct HINSTANCE__ *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
Error executing cl.exe.
//
Probly just something dumb that i cant figure out how to fix =(
Edited by - asaari on July 5, 2001 4:06:10 PM
July 05, 2001 03:10 PM
Looks like some casting might fix this. Let''s look at the first error:
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(86) : error C2440: ''='' : cannot convert from ''long (__stdcall *)(void *,unsigned int,unsigned int,long)'' to ''long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)''
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
I think the program is calling a function with incorrectly typed parameters. The function "signature" it wants looks like:
long FunctionName(struct HWND__*, unsigned int, unsigned it, long);
Basically the program is calling the function with a "void*" as the first parameter instead of a "HWND__*". To fix it, go to line 86 in dirdraw.cpp and put (HWND__*) in front of the first variable passed. That should fix it. Do similar things to fix the rest.
Thankyou!
I followed your advice, and ended up with this, and i didnt get any compile errors on that line,
wc.lpfnWndProc = (long (__stdcall *)(HWND__*,unsigned int,unsigned int,long)) MessageLoop;
but on line 89 i still have the problem:
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(89) : error C2440: ''='' : cannot convert from ''void *'' to ''struct HINSTANCE__ *''
and all line 89 is is this!
wc.hInstance = hInst;
this seems really strange
I followed your advice, and ended up with this, and i didnt get any compile errors on that line,
wc.lpfnWndProc = (long (__stdcall *)(HWND__*,unsigned int,unsigned int,long)) MessageLoop;
but on line 89 i still have the problem:
G:\Microsoft Visual Studio\RTS\RTS\dirdraw.cpp(89) : error C2440: ''='' : cannot convert from ''void *'' to ''struct HINSTANCE__ *''
and all line 89 is is this!
wc.hInstance = hInst;
this seems really strange
I just changed
HWND CreateMainWindow (const int w, const int h,
const char* ClassName,
void* MessageLoop, void* hInst, const bool FullScreen = true);
//
to
//
HWND CreateMainWindow (const int w, const int h,
const char* ClassName,
void* MessageLoop, HINSTANCE hInst,
const bool FullScreen = true);
and this fixed all of the remaining errors!! thankyou anomynous
Edited by - asaari on July 5, 2001 4:43:27 PM
Edited by - asaari on July 5, 2001 7:16:52 PM
HWND CreateMainWindow (const int w, const int h,
const char* ClassName,
void* MessageLoop, void* hInst, const bool FullScreen = true);
//
to
//
HWND CreateMainWindow (const int w, const int h,
const char* ClassName,
void* MessageLoop, HINSTANCE hInst,
const bool FullScreen = true);
and this fixed all of the remaining errors!! thankyou anomynous
Edited by - asaari on July 5, 2001 4:43:27 PM
Edited by - asaari on July 5, 2001 7:16:52 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement