c++ - `xxxx' : looks like a function definition, but there is no parameter list; skipping apparent body -
i have code below bowling game. code working in eclipse moved microsoft visual studio express 2012 windows desktop, gives following error.
error 1 error c2470: 'cone1' : looks function definition, there no parameter list; skipping apparent body c:\users\rocckky\documents\visual studio 2012\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 26 1 consoleapplication1
note: - not pasting errors, gives same error type cones defined.
#include "stdafx.h" #include "cstdlib" #include "gl/glut.h" #include "gl/glu.h" #include "stdlib.h" #include "vector" using namespace std; int refreshmillis = 30; // refresh period in milliseconds int windowwidth = 640; // windowed mode's width int windowheight = 480; // windowed mode's height int windowposx = 50; // windowed mode's top-left corner x int windowposy = 50; // windowed mode's top-left corner y bool fullscreenmode = false; // full-screen or windowed mode? glfloat ballspeed = 0.150f; // ball's speed in y directions glfloat speedline; glfloat ballmaxspeed = 0.550f, ballminspeed = 0.150f; bool moveballup = false, moveballdown = false, iscollision = false, resetcall = false, moveright = false, moveleft = false, ballinright = false, ballinmiddle = true, ballinleft = false; glfloat vp_x = 2.0f, vp_y = 10.0f, vp_z = 25.0f, vt_x = 2.0f, vt_y = 20.0f, vt_z = 0.0f, vu_x = 0.0f, vu_y = 0.0f, vu_z = 1.0f; //eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz /* cones in center */ vector<glfloat> cone1 { 0.0f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0f, 0.0f }; vector<glfloat> cone2 { 1.6f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0 }; vector<glfloat> cone3 { -1.6f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0 }; /* cones in left */ vector<glfloat> cone4 { -4.9f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0 }; vector<glfloat> cone5 { -6.7f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0 }; vector<glfloat> cone6 { -8.3f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0 }; /* right cones */ vector<glfloat> cone7 { 4.9f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0 }; vector<glfloat> cone8 { 6.6f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0 }; vector<glfloat> cone9 { 8.3f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0 }; vector<glfloat> ball {/* x */0.0f, /* y */0.0f, /* z */-3.0f, /*sphere*/0.85f, 50.0, 50.0 }; // void resetgame() { resetcall = true; cone1 = {0.0f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0f, 0.0f};; cone2= {1.6f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0}; cone3= {-1.6f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0}; /* cones in left */ cone4 = {-4.9f,0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0}; cone5 = {-6.7f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0}; cone6 = {-8.3f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0}; /* right cones */ cone7= {4.9f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0}; cone8 = {6.6f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0}; cone9= {8.3f, 0.0f, -21.0f, /*rotated*/60.0f, -1.5f, 0.0, 0.0}; ball = {/* x */0.0f, /* y */0.0f, /* z */-3.0f, /*sphere*/0.85f, 50.0, 50.0}; } float ar; const glfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f }; const glfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; const glfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f }; const glfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f }; const glfloat mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f }; const glfloat mat_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f }; const glfloat mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f }; const glfloat high_shininess[] = { 100.0f }; /* called when timer expired */ void timer(int value) { if (moveballup) { // ball[1] += ballspeed; ball[2] -= ballspeed; if (ballinright) ball[0] += 0.08; if (ballinleft) ball[0] -= 0.08; } if (moveright) { if (ball[0] >= 4.0) { moveright = false; ballinmiddle = false; ballinleft = false; ballinright = true; } ball[0] += 0.156; if (ball[0] >= -0.02 && ball[0] <= 0.02) { moveright = false; ballinleft = false; ballinright = false; ballinmiddle = true; } } if (moveleft) { if (ball[0] <= -4.0) { moveleft = false; ballinright = false; ballinmiddle = false; ballinleft = true; } ball[0] -= 0.156; if (ball[0] >= -0.02 && ball[0] <= 0.02) { moveleft = false; ballinleft = true; } } /* if ball reaches z coordinates of cones */ if (ball[2] <= cone1[2]) { /* check ball's x axis set of cones has hit */ /* check middle set of cones */ if (ball[0] >= cone3[0] && ball[0] <= cone2[0]) { if (!iscollision /* iscollision ! = true */) { cone1[0] -= 0.5; cone1[4] -= 10.0; cone1[5] += 10.0; cone1[2] += -0.3; cone2[0] += 0.5; cone2[4] -= 10.0; cone2[5] -= 10.0; cone2[2] += -0.4; cone3[0] += 0.5; cone3[4] -= 10.0; cone3[5] -= 10.0; cone3[2] += -0.4; } iscollision = true; moveballup = false; // stop moving ball } /* check if ball in range of x axis of right set of cones */ if (ball[0] >= cone6[0] && ball[0] <= cone4[0]) { if (!iscollision /* iscollision ! = true */) { cone4[0] -= 0.5; cone4[4] -= 10.0; cone4[5] += 10.0; cone4[2] += -0.3; cone5[0] += 0.5; cone5[4] -= 10.0; cone5[5] -= 10.0; cone5[2] += -0.4; cone6[0] += 0.5; cone6[4] -= 10.0; cone6[5] -= 10.0; cone6[2] += -0.4; } iscollision = true; moveballup = false; // stop moving ball } if (ball[0] >= cone7[0] && ball[0] <= cone9[0]) { if (!iscollision /* iscollision ! = true */) { cone7[0] -= 0.5; cone7[4] -= 10.0; cone7[5] += 10.0; cone7[2] += -0.3; cone8[0] += 0.5; cone8[4] -= 10.0; cone8[5] -= 10.0; cone8[2] += -0.4; cone9[0] += 0.5; cone9[4] -= 10.0; cone9[5] -= 10.0; cone9[2] += -0.4; } iscollision = true; moveballup = false; // stop moving ball } } if (resetcall) { if (ball[2] >= -3.0f) { resetcall = false; iscollision = false; } else { if (ballinright) ball[0] -= 0.08; if (ballinleft) ball[0] += 0.08; ball[2] -= ballspeed; } } glutpostredisplay(); // post paint request activate display() gluttimerfunc(refreshmillis, timer, 0); // subsequent timer call @ milliseconds } void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: // esc key exit(0); break; case 'r': resetgame(); break; case 'i': vp_x += 0.5; break; case 'i': vp_x -= 0.5; break; /*glfloat vp_x = 3.0f, vp_y = 10.0f, vp_z = 10.0f, vt_x = 0.0f, vt_y = 0.0f, vt_z = 0.0f, vu_x = 0.0f, vu_y = 0.0f, vu_z = -1.0f;*/ case 'o': vp_y += 0.5; break; case 'o': vp_y -= 0.5; break; case 'p': vp_z += 0.5; break; case 'p': vp_z -= 0.5; break; case 'j': vt_x += 0.5; break; case 'j': vt_x -= 0.5; break; case 'k': vt_y += 0.5; break; case 'k': vt_y -= 0.5; break; case 'l': vt_z += 0.5; break; case 'l': vt_z -= 0.5; break; case 'b': vu_x += 0.5; break; case 'b': vu_x -= 0.5; break; case 'n': vu_y += 0.5; break; case 'n': vu_y -= 0.5; break; case 'm': vt_z += 0.5; break; case 'm': vu_z -= 0.5; break; } glutpostredisplay(); } void specialkeys(int key, int x, int y) { switch (key) { case glut_key_f1: // f1: toggle between full-screen , windowed mode fullscreenmode = !fullscreenmode; // toggle state if (fullscreenmode) { // full-screen mode windowposx = glutget(glut_window_x ); // save parameters restoring later windowposy = glutget(glut_window_y ); windowwidth = glutget(glut_window_width ); windowheight = glutget(glut_window_height ); glutfullscreen(); // switch full screen } else { // windowed mode glutreshapewindow(windowwidth, windowheight); // switch windowed mode glutpositionwindow(windowposx, windowposx); // position top-left corner } break; case glut_key_up: if (!iscollision) moveballup = true; break; case glut_key_page_up: if (ballspeed >= ballmaxspeed) break; ballspeed *= 1.1f; break; case glut_key_page_down: if (ballspeed <= ballminspeed) break; ballspeed *= 0.95f; break; case glut_key_right: if (ball[0] >= 4.0) break; moveright = true; break; case glut_key_left: if (ball[0] <= -4.0) break; moveleft = true; break; } } static void display(void) { int const width = glutget(glut_window_width ); int const height = glutget(glut_window_height ); const float ar = (float) width / (float) height; glviewport(0, 0, width, height); glmatrixmode(gl_projection); glloadidentity(); glfrustum(-ar, ar, -ar, ar, 1.0, 100.0); glmatrixmode(gl_modelview); glloadidentity(); glulookat(vp_x, vp_y, vp_z, vt_x, vt_y, vt_z, vu_x, vu_y, vu_z); glclearcolor(1, 1, 1, 1); glclear(gl_color_buffer_bit | gl_depth_buffer_bit); glenable(gl_cull_face); glcullface(gl_back); glenable(gl_depth_test); gldepthfunc(gl_less); glenable(gl_light0); glenable(gl_normalize); glenable(gl_color_material); glenable(gl_lighting); gllightfv(gl_light0, gl_ambient, light_ambient); gllightfv(gl_light0, gl_diffuse, light_diffuse); gllightfv(gl_light0, gl_specular, light_specular); gllightfv(gl_light0, gl_position, light_position); glmaterialfv(gl_front, gl_ambient, mat_ambient); glmaterialfv(gl_front, gl_diffuse, mat_diffuse); glmaterialfv(gl_front, gl_specular, mat_specular); glmaterialfv(gl_front, gl_shininess, high_shininess); /* center */ glcolor3d(1, 1, 0); glpushmatrix(); gltranslated(cone1[0], cone1[1], cone1[2]); glrotated(cone1[3], cone1[4], cone1[5], cone1[6]); glutsolidcone(0.8, 2, 50, 50); glpopmatrix(); glcolor3d(1, 0, 1); glpushmatrix(); gltranslated(cone2[0], cone2[1], cone2[2]); glrotated(cone2[3], cone2[4], cone2[5], cone2[6]); glutsolidcone(0.8, 2, 50, 50); glpopmatrix(); glcolor3d(0, 0, 1); glpushmatrix(); gltranslated(cone3[0], cone3[1], cone3[2]); glrotated(cone3[3], cone3[4], cone3[5], cone3[6]); glutsolidcone(0.8, 2, 50, 50); glpopmatrix(); /************************************************************/ /* left cones */ glcolor3d(1, 1.5, 0.6); glpushmatrix(); gltranslated(cone4[0], cone4[1], cone4[2]); glrotated(cone4[3], cone4[4], cone4[5], cone4[6]); glutsolidcone(0.8, 2, 50, 50); glpopmatrix(); glcolor3d(1, 1.5, 0.6); glpushmatrix(); gltranslated(cone5[0], cone5[1], cone5[2]); glrotated(cone5[3], cone5[4], cone5[5], cone5[6]); glutsolidcone(0.8, 2, 50, 50); glpopmatrix(); glcolor3d(1, 1.5, 0.6); glpushmatrix(); gltranslated(cone6[0], cone6[1], cone6[2]); glrotated(cone6[3], cone6[4], cone6[5], cone6[6]); glutsolidcone(0.8, 2, 50, 50); glpopmatrix(); /*******************************************************/ /* right cones */ glcolor3d(1, 1.5, 0.6); glpushmatrix(); gltranslated(cone7[0], cone7[1], cone7[2]); glrotated(cone7[3], cone7[4], cone7[5], cone7[6]); glutsolidcone(0.8, 2, 50, 50); glpopmatrix(); glcolor3d(1, 1.5, 0.6); glpushmatrix(); gltranslated(cone8[0], cone8[1], cone8[2]); glrotated(cone8[3], cone8[4], cone8[5], cone8[6]); glutsolidcone(0.8, 2, 50, 50); glpopmatrix(); glcolor3d(1, 1.5, 0.6); glpushmatrix(); gltranslated(cone9[0], cone9[1], cone9[2]); glrotated(cone9[3], cone9[4], cone9[5], cone9[6]); glutsolidcone(0.8, 2, 50, 50); glpopmatrix(); /****************************/ /* balling ball */ glcolor3d(1, 0, 0); glpushmatrix(); gltranslated(ball[0], ball[1], ball[2]); glutsolidsphere(ball[3], ball[4], ball[5]); glpopmatrix(); /******* floor ********/ //glpushmatrix(); glcolor3d(0.4, 1, 0.20); glbegin(gl_quads); glvertex3f(21.0, -1.0, -25.0); glvertex3f(-21.0, -1.0, -25.0); glvertex3f(-20.0, -1.0, -4.0); glvertex3f(20.0, -1.0, -4.0); glend(); /** wall @ **/ glcolor3d(0, 1, 1); glbegin(gl_quads); glvertex3f(21.0, 10.0, -25.0); glvertex3f(-21.0, 10.0, -25.0); glvertex3f(-21.0, -1.0, -25.0); glvertex3f(21.0, -1.0, -25.0); glend(); /* // speed line glcolor3d(1.0f, 1.0f, 1.0f); glbegin(gl_quads); glvertex3f(7.0, 7.0, -24.9999); glvertex3f(7.5, 7.0, -24.9999); glvertex3f(6.0, -4.0, -4.9999); glvertex3f(6.0, -4.0, -4.9999); glend(); lines between 3 glcolor3d(0.0f, 1.0f, 1.0f); glbegin(gl_quads); glvertex3f(-7.5, 7.0, -24.9999); glvertex3f(-7.0, 7.0, -24.9999); glvertex3f(-2.0, -4.0, -4.9999); glvertex3f(-1.5, -4.0, -4.9999); glend(); speed line gllinewidth(8.0f); glcolor3d(1.0f, 0.0f, 0.0f); glbegin(gl_line_strip); %age range of speed current speed speedline = (100 / (ballmaxspeed - ballminspeed)) * ballspeed; speedline = (3.0 / 100) * speedline; glvertex3f(6.0, speedline, -5.0); glvertex3f(6.0, 0.0, -4.999); glend(); */ //glpopmatrix(); glutswapbuffers(); } /* program entry point */ int main(int argc, char *argv[]) { glutinit(&argc, argv); glutinitwindowsize(windowwidth, windowheight); // initial window width , height glutinitwindowposition(windowposx, windowposy); // initial window top-left corner (x, y) glutinitdisplaymode(glut_rgb | glut_double | glut_depth); glutcreatewindow("balling game 3d"); glutdisplayfunc(display); gluttimerfunc(0, timer, 0); // first timer call glutspecialfunc(specialkeys); // register callback handler special-key event glutkeyboardfunc(keyboard); // register callback handler special-key event glutmainloop(); return 1; }
visual studio 2012 not have list-initialization yet standard containers.
take here , here see features supported vs. (or here vs2013).
Comments
Post a Comment