Original Post
Hello, i am new to C++, and bought the book "Programming Role Playing Games with Directx" by Jim Adams. for some reason none of the code works on my compiler. I was hoping that some one in this sight could help me. the code that i transfered straight from the book went like this... idirect3d9 *direct3dcreate9( uint sdkversion); //d3d_sdk_version idirect3d9 g_d3d // global idirect3d9 object if ((g_d3d= direct3dcreate9(d3d_sdk_version))==null){ //error occurred } typedef struct _d3ddisplaymode { uint width; //screen width in pixels uint height; //screen heigth in pixels uint refreshrate; //refresh rate (0=default) d3dformat format; //color format } d3ddisplaymode; d3ddisplaymode d3ddm; d3ddm.width=640; d3ddm.height=480; d3ddm.refreshrate=0; //use default d3ddm.format=d3dfmt_r5g6b5; //g_pd3d=pre-initialized direct3d object //d3df=pre-initialized d3dformat structure // check if display mode exists if (failed(g_pd3d->checkdevicetype(d3dadapter_default, d3ddevtype_hal, &d3df, &d3df, false))){ //error occurred-color mode not supported } typedef struct _d3dpresent_parameters { uint dackbufferwidth; //width of backbuffer uint backbufferheigth; //heigth of backbuffer d3dformat backbufferformat; //same as display mode format uint backbuffercount; //1 d3dmultisample_type multisampletype; //0 d3dswapeffect swapeffect; //how to display backbuffer hwnd hndevicewindow; //null dool windowed; //true for windowed mode //false for fullscreen mode bool enableautodepthstencil; //false d3dformat autodepthstencilformat; //0 dword flags; //0 uint fullscreen_refreshrateinhz; //0 uint presentationinterval; //0 } d3dpresent_parameters; //d3ddm=pre-initialized d3ddisplaymode structure d3dpresent_parameters d3dpp; //clear out the structure zeromemory(&d3dpp, sizeof(d3dpresent_parameters)); dedpp.swapeffect=d3dswapeffect_discard; d3dpp.backbufferformat=d3ddm.format; //use same color mode //for fullscreen mode, use; d3dpp.windowed=false; d3dpp.swapeffect=d3dswapeffect_flip; d3dpp.fullscreen_refreshrateinhz=d3dpresent_internal_default; d3dpp.presentationinterval=d3dpresent_interval_default; d3dpp.backbufferformat=d3ddm.format; //use same color mode //for both windowed and fullscreen, specify the width and heigth d3dpp.backbufferwidth=1000; //supply your own width d3dpp.backbufferheight=1000; //supply your own heigth this gave me these errors... ------ Build started: Project: Game, Configuration: Debug Win32 ------ Compiling... Game.cpp g:\programing\myprograms\game\game\Game.h(6) : error C2143: syntax error : missing ';' before '*' g:\programing\myprograms\game\game\Game.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(7) : error C2061: syntax error : identifier 'uint' g:\programing\myprograms\game\game\Game.h(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(7) : warning C4183: 'direct3dcreate9': missing return type; assumed to be a member function returning 'int' g:\programing\myprograms\game\game\Game.h(9) : error C2146: syntax error : missing ';' before identifier 'g_d3d' g:\programing\myprograms\game\game\Game.h(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(9) : error C2143: syntax error : missing ';' before 'if' g:\programing\myprograms\game\game\Game.h(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(9) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body g:\programing\myprograms\game\game\Game.h(13) : error C2146: syntax error : missing ';' before identifier 'width' g:\programing\myprograms\game\game\Game.h(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(14) : error C2146: syntax error : missing ';' before identifier 'height' g:\programing\myprograms\game\game\Game.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(15) : error C2146: syntax error : missing ';' before identifier 'refreshrate' g:\programing\myprograms\game\game\Game.h(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(16) : error C2146: syntax error : missing ';' before identifier 'format' g:\programing\myprograms\game\game\Game.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(20) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(20) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(21) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(21) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(21) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(22) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(22) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(22) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(23) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(23) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(23) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(28) : error C2059: syntax error : 'if' g:\programing\myprograms\game\game\Game.h(29) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body g:\programing\myprograms\game\game\Game.h(35) : error C2146: syntax error : missing ';' before identifier 'dackbufferwidth' g:\programing\myprograms\game\game\Game.h(35) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(35) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(36) : error C2146: syntax error : missing ';' before identifier 'backbufferheigth' g:\programing\myprograms\game\game\Game.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(37) : error C2146: syntax error : missing ';' before identifier 'backbufferformat' g:\programing\myprograms\game\game\Game.h(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(38) : error C2146: syntax error : missing ';' before identifier 'backbuffercount' g:\programing\myprograms\game\game\Game.h(38) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(38) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(40) : error C2146: syntax error : missing ';' before identifier 'multisampletype' g:\programing\myprograms\game\game\Game.h(40) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(40) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(41) : error C2146: syntax error : missing ';' before identifier 'swapeffect' g:\programing\myprograms\game\game\Game.h(41) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(41) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(43) : error C2146: syntax error : missing ';' before identifier 'hndevicewindow' g:\programing\myprograms\game\game\Game.h(43) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(43) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(44) : error C2146: syntax error : missing ';' before identifier 'windowed' g:\programing\myprograms\game\game\Game.h(44) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(44) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(46) : error C2146: syntax error : missing ';' before identifier 'autodepthstencilformat' g:\programing\myprograms\game\game\Game.h(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(48) : error C2146: syntax error : missing ';' before identifier 'flags' g:\programing\myprograms\game\game\Game.h(48) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(48) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(50) : error C2146: syntax error : missing ';' before identifier 'fullscreen_refreshrateinhz' g:\programing\myprograms\game\game\Game.h(50) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(50) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(51) : error C2146: syntax error : missing ';' before identifier 'presentationinterval' g:\programing\myprograms\game\game\Game.h(51) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(51) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(56) : error C2146: syntax error : missing ';' before identifier 'd3dpresent_parameters' g:\programing\myprograms\game\game\Game.h(59) : error C2059: syntax error : '&' g:\programing\myprograms\game\game\Game.h(60) : error C2059: syntax error : ')' g:\programing\myprograms\game\game\Game.h(60) : error C2143: syntax error : missing ')' before ';' g:\programing\myprograms\game\game\Game.h(60) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(60) : warning C4183: 'zeromemory': missing return type; assumed to be a member function returning 'int' g:\programing\myprograms\game\game\Game.h(62) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(62) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(62) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(63) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(63) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(63) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(66) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(66) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(66) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(67) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(67) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(67) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(68) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(68) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(68) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(69) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(69) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(69) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(70) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(70) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(70) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(73) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(73) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(73) : error C2238: unexpected token(s) preceding ';' g:\programing\myprograms\game\game\Game.h(74) : error C2143: syntax error : missing ';' before '.' g:\programing\myprograms\game\game\Game.h(74) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\programing\myprograms\game\game\Game.h(74) : error C2238: unexpected token(s) preceding ';' .\Game.cpp(2) : error C2143: syntax error : missing ';' before '*' .\Game.cpp(2) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(3) : error C2065: 'uint' : undeclared identifier .\Game.cpp(3) : error C2146: syntax error : missing ')' before identifier 'sdkversion' .\Game.cpp(3) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(3) : error C2059: syntax error : ')' .\Game.cpp(5) : error C2146: syntax error : missing ';' before identifier 'g_d3d' .\Game.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(5) : error C2086: 'int idirect3d9' : redefinition .\Game.cpp(2) : see declaration of 'idirect3d9' .\Game.cpp(5) : error C2143: syntax error : missing ';' before 'if' .\Game.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(5) : error C2143: syntax error : missing ';' before '{' .\Game.cpp(5) : error C2447: '{' : missing function header (old-style formal list?) .\Game.cpp(9) : error C2146: syntax error : missing ';' before identifier 'width' .\Game.cpp(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(10) : error C2146: syntax error : missing ';' before identifier 'height' .\Game.cpp(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(11) : error C2146: syntax error : missing ';' before identifier 'refreshrate' .\Game.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(12) : error C2146: syntax error : missing ';' before identifier 'format' .\Game.cpp(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(16) : error C2143: syntax error : missing ';' before '.' .\Game.cpp(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(16) : error C2371: 'd3ddm' : redefinition; different basic types .\Game.cpp(15) : see declaration of 'd3ddm' .\Game.cpp(17) : error C2143: syntax error : missing ';' before '.' .\Game.cpp(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(17) : error C2371: 'd3ddm' : redefinition; different basic types .\Game.cpp(15) : see declaration of 'd3ddm' .\Game.cpp(18) : error C2143: syntax error : missing ';' before '.' .\Game.cpp(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(18) : error C2371: 'd3ddm' : redefinition; different basic types .\Game.cpp(15) : see declaration of 'd3ddm' .\Game.cpp(19) : error C2143: syntax error : missing ';' before '.' .\Game.cpp(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(19) : error C2371: 'd3ddm' : redefinition; different basic types .\Game.cpp(15) : see declaration of 'd3ddm' .\Game.cpp(24) : error C2059: syntax error : 'if' .\Game.cpp(25) : error C2143: syntax error : missing ';' before '{' .\Game.cpp(25) : error C2447: '{' : missing function header (old-style formal list?) .\Game.cpp(31) : error C2146: syntax error : missing ';' before identifier 'dackbufferwidth' .\Game.cpp(31) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(31) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(32) : error C2146: syntax error : missing ';' before identifier 'backbufferheigth' .\Game.cpp(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(33) : error C2146: syntax error : missing ';' before identifier 'backbufferformat' .\Game.cpp(33) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(33) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(34) : error C2146: syntax error : missing ';' before identifier 'backbuffercount' .\Game.cpp(34) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(34) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(36) : error C2146: syntax error : missing ';' before identifier 'multisampletype' .\Game.cpp(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(36) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(37) : error C2146: syntax error : missing ';' before identifier 'swapeffect' .\Game.cpp(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(39) : error C2146: syntax error : missing ';' before identifier 'hndevicewindow' .\Game.cpp(39) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(39) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(40) : error C2146: syntax error : missing ';' before identifier 'windowed' .\Game.cpp(40) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(40) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(42) : error C2146: syntax error : missing ';' before identifier 'autodepthstencilformat' .\Game.cpp(42) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(42) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(44) : error C2146: syntax error : missing ';' before identifier 'flags' .\Game.cpp(44) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(44) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(46) : error C2146: syntax error : missing ';' before identifier 'fullscreen_refreshrateinhz' .\Game.cpp(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(47) : error C2146: syntax error : missing ';' before identifier 'presentationinterval' .\Game.cpp(47) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(47) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(52) : error C2146: syntax error : missing ';' before identifier 'd3dpresent_parameters' .\Game.cpp(56) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(56) : error C2078: too many initializers .\Game.cpp(58) : error C2143: syntax error : missing ';' before '.' .\Game.cpp(58) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(59) : error C2143: syntax error : missing ';' before '.' .\Game.cpp(59) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(59) : error C2371: 'd3dpp' : redefinition; different basic types .\Game.cpp(52) : see declaration of 'd3dpp' .\Game.cpp(62) : error C2143: syntax error : missing ';' before '.' .\Game.cpp(62) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(62) : error C2371: 'd3dpp' : redefinition; different basic types .\Game.cpp(52) : see declaration of 'd3dpp' .\Game.cpp(63) : error C2143: syntax error : missing ';' before '.' .\Game.cpp(63) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(63) : error C2371: 'd3dpp' : redefinition; different basic types .\Game.cpp(52) : see declaration of 'd3dpp' .\Game.cpp(64) : error C2143: syntax error : missing ';' before '.' .\Game.cpp(64) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int .\Game.cpp(64) : error C2371: 'd3dpp' : redefinition; different basic types .\Game.cpp(52) : see declaration of 'd3dpp' .\Game.cpp(65) : error C2143: syntax error : missing ';' before '.' .\Game.cpp(65) : fatal error C1003: error count exceeds 100; stopping compilation Build log was saved at "file://g:\Programing\MyPrograms\Game\Game\Debug\BuildLog.htm" Game - 198 error(s), 2 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Thank you for any and all help recieved.