c++ - having some issues when i am compiling my code -


i not know why having these compiling issues here when compiled program yesterday compiled nicely today not,the code shows how ro create shapes ball , cone , map shadows im getting these errors

1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(125): error c2065: 'rgbimage' : undeclared identifier 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(125): error c2146: syntax error : missing ';' before identifier 'thetexmap' 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(125): error c3861: 'thetexmap': identifier not found 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(126): error c2065: 'texture' : undeclared identifier 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(127): error c2065: 'texture' : undeclared identifier 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(135): error c2065: 'thetexmap' : undeclared identifier 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(135): error c2228: left of '.getnumcols' must have class/struct/union 1>          type ''unknown-type'' 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(135): error c2065: 'thetexmap' : undeclared identifier 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(135): error c2228: left of '.getnumrows' must have class/struct/union 1>          type ''unknown-type'' 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(135): error c2065: 'thetexmap' : undeclared identifier 1>c:\users\soft\documents\visual studio 2010\projects\cows\cows\www.cpp(135): error c2228: left of '.imagedata' must have class/struct/union 1>          type ''unknown-type'' 

and code sorry paste everything

#include <windows.h> #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <math.h> #define gl_glext_prototypes #ifdef __apple__ #include <glut/glut.h> #else #include <gl/glut.h> #endif #include <gl/glut.h>    glfloat *make_texture(int maxs, int maxt) {     int s, t;     static glfloat *texture;      texture = (glfloat *)malloc(maxs * maxt * sizeof(glfloat));     for(t = 0; t < maxt; t++) {         for(s = 0; s < maxs; s++) {             texture[s + maxs * t] = ((s >> 4) & 0x1) ^ ((t >> 4) & 0x1);         }     }     return texture; }  enum {sphere = 1, cone, light, leftwall, floor};   /* create matrix project desired shadow */ void shadowmatrix(glfloat shadowmat[4][4],              glfloat groundplane[4],              glfloat lightpos[4]){   glfloat dot;    /* find dot product between light position vector , ground plane normal */   dot = groundplane[0] * lightpos[0] +         groundplane[1] * lightpos[1] +         groundplane[2] * lightpos[2] +         groundplane[3] * lightpos[3];    shadowmat[0][0] = dot - lightpos[0] * groundplane[0];   shadowmat[1][0] = 0.f - lightpos[0] * groundplane[1];   shadowmat[2][0] = 0.f - lightpos[0] * groundplane[2];   shadowmat[3][0] = 0.f - lightpos[0] * groundplane[3];    shadowmat[0][1] = 0.f - lightpos[1] * groundplane[0];   shadowmat[1][1] = dot - lightpos[1] * groundplane[1];   shadowmat[2][1] = 0.f - lightpos[1] * groundplane[2];   shadowmat[3][1] = 0.f - lightpos[1] * groundplane[3];    shadowmat[0][2] = 0.f - lightpos[2] * groundplane[0];   shadowmat[1][2] = 0.f - lightpos[2] * groundplane[1];   shadowmat[2][2] = dot - lightpos[2] * groundplane[2];   shadowmat[3][2] = 0.f - lightpos[2] * groundplane[3];    shadowmat[0][3] = 0.f - lightpos[3] * groundplane[0];   shadowmat[1][3] = 0.f - lightpos[3] * groundplane[1];   shadowmat[2][3] = 0.f - lightpos[3] * groundplane[2];   shadowmat[3][3] = dot - lightpos[3] * groundplane[3];  }  enum {x, y, z}; enum {a, b, c, d}; /* find plane equation given 3 points */ void findplane(glfloat plane[4],           glfloat v0[3], glfloat v1[3], glfloat v2[3]) {   glfloat vec0[3], vec1[3];    /* need 2 vectors find cross product */   vec0[x] = v1[x] - v0[x];   vec0[y] = v1[y] - v0[y];   vec0[z] = v1[z] - v0[z];    vec1[x] = v2[x] - v0[x];   vec1[y] = v2[y] - v0[y];   vec1[z] = v2[z] - v0[z];    /* find cross product a, b, , c of plane equation */   plane[a] = vec0[y] * vec1[z] - vec0[z] * vec1[y];   plane[b] = -(vec0[x] * vec1[z] - vec0[z] * vec1[x]);   plane[c] = vec0[x] * vec1[y] - vec0[y] * vec1[x];    plane[d] = -(plane[a] * v0[x] + plane[b] * v0[y] + plane[c] * v0[z]); }  void sphere(void) {     glpushmatrix();     gltranslatef(60.f, -50.f, -360.f);     glcalllist(sphere);     glpopmatrix(); }  void cone(void) {     glpushmatrix();     gltranslatef(-40.f, -40.f, -400.f);     glcalllist(cone);     glpopmatrix();  }  enum {none, shadow};  int rendermode = none;  void menu(int mode) {   rendermode = mode;   glutpostredisplay(); }   void loadtexturefromfile(char *filename) {       glclearcolor (0.0, 0.0, 0.0, 0.0);    glshademodel(gl_flat);    glenable(gl_depth_test);    rgbimage thetexmap( filename );       glgentextures(1, &texture[0]);                  // create texture         glbindtexture(gl_texture_2d, texture[0]);    gltexparameteri(gl_texture_2d, gl_texture_wrap_s, gl_repeat);    gltexparameteri(gl_texture_2d, gl_texture_wrap_t, gl_repeat);    gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_nearest);    gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_nearest);          // typical texture generation using data bitmap          glteximage2d(gl_texture_2d, 0, 3, thetexmap.getnumcols(), thetexmap.getnumrows(), 0, gl_rgb, gl_unsigned_byte, thetexmap.imagedata() );  }    glfloat leftwallshadow[4][4]; glfloat floorshadow[4][4];  glfloat lightpos[] = {50.f, 50.f, -320.f, 1.f};   /* render while jittering shadows */ void render(glfloat dx, glfloat dy, glfloat dz) {      /* material properties objects in scene */     static glfloat wall_mat[] = {1.f, 1.f, 1.f, 1.f};     static glfloat sphere_mat[] = {1.f, .5f, 0.f, 1.f};     static glfloat cone_mat[] = {0.f, .5f, 1.f, 1.f};      glclear(gl_depth_buffer_bit|gl_color_buffer_bit|gl_stencil_buffer_bit);      /*     ** note: wall verticies ordered front facing     ** lets me face culling speed things up.     */      glmaterialfv(gl_front, gl_ambient_and_diffuse, wall_mat);          /* floor */     /* make floor textured */     glenable(gl_texture_2d);      /*     ** since want turn texturing on floor only, have     ** make floor separate glbegin()/glend() sequence. can't     ** turn texturing on , off between begin , end calls     */     glbegin(gl_quads);     glnormal3f(0.f, 1.f, 0.f);     gltexcoord2i(0, 0);     glvertex3f(-100.f, -100.f, -320.f);     gltexcoord2i(1, 0);     glvertex3f( 100.f, -100.f, -320.f);     gltexcoord2i(1, 1);     glvertex3f( 100.f, -100.f, -520.f);     gltexcoord2i(0, 1);     glvertex3f(-100.f, -100.f, -520.f);     glend();      gldisable(gl_texture_2d);        gldisable(gl_depth_test);     gldisable(gl_lighting);     glcolor3f(0.f, 0.f, 0.f); /* shadow color */      glpushmatrix();     glmultmatrixf((glfloat *)floorshadow);     gltranslatef(dx, dy, dz);     cone();     glpopmatrix();      glpushmatrix();     glmultmatrixf((glfloat *)floorshadow);     gltranslatef(dx, dy, dz);     sphere();     glpopmatrix();     glenable(gl_depth_test);     glenable(gl_lighting);      /* walls */       glenable(gl_stencil_test);     glstencilfunc(gl_always, 1, 0);     glstencilop(gl_keep, gl_keep, gl_replace);      glbegin(gl_quads);     /* left wall */     glnormal3f(1.f, 0.f, 0.f);     glvertex3f(-100.f, -100.f, -320.f);     glvertex3f(-100.f, -100.f, -520.f);     glvertex3f(-100.f,  100.f, -520.f);     glvertex3f(-100.f,  100.f, -320.f);     glend();      glstencilfunc(gl_equal, 1, 1);     gldisable(gl_depth_test);     gldisable(gl_lighting);     glcolor3f(0.f, 0.f, 0.f); /* shadow color */     gldisable(gl_depth_test);     glpushmatrix();     glmultmatrixf((glfloat *)leftwallshadow);     gltranslatef(dx, dy, dz);     cone();     glpopmatrix();     glenable(gl_depth_test);     gldisable(gl_stencil_test);     glenable(gl_depth_test);     glenable(gl_lighting);       glbegin(gl_quads);     /* right wall */     glnormal3f(-1.f, 0.f, 0.f);     glvertex3f( 100.f, -100.f, -320.f);     glvertex3f( 100.f,  100.f, -320.f);     glvertex3f( 100.f,  100.f, -520.f);     glvertex3f( 100.f, -100.f, -520.f);      /* ceiling */     glnormal3f(0.f, -1.f, 0.f);     glvertex3f(-100.f,  100.f, -320.f);     glvertex3f(-100.f,  100.f, -520.f);     glvertex3f( 100.f,  100.f, -520.f);     glvertex3f( 100.f,  100.f, -320.f);      /* wall */     glnormal3f(0.f, 0.f, 1.f);     glvertex3f(-100.f, -100.f, -520.f);     glvertex3f( 100.f, -100.f, -520.f);     glvertex3f( 100.f,  100.f, -520.f);     glvertex3f(-100.f,  100.f, -520.f);     glend();      glpushmatrix();     gltranslatef(lightpos[x], lightpos[y], lightpos[z]);     gldisable(gl_lighting);     glcolor3f(1.f, 1.f, .7f);     glcalllist(light);     glenable(gl_lighting);     glpopmatrix();       glmaterialfv(gl_front, gl_ambient_and_diffuse, cone_mat);     cone();      glmaterialfv(gl_front, gl_ambient_and_diffuse, sphere_mat);     sphere();  }  void redraw(void) {   int dx, dy, dz;    dy = 0;   /* jitter light around */   if(rendermode == shadow) {     glclear(gl_accum_buffer_bit);     for(dz = -4; dz < 5; dz += 2) {       for(dx = -4; dx < 5; dx += 2) {         render((glfloat)dx, (glfloat)dy, (glfloat)dz);         glaccum(gl_accum, 1.f/25);       }     }     glaccum(gl_return, 1.f);   } else     render(0.f, 0.f, 0.f);    glfinish();   glutswapbuffers(); }  void key(unsigned char key, int x, int y) {     if(key == '\033')         exit(0); }    const int texdim = 256; /* parse arguments, , set interface between opengl , window system */ int main(int argc, char *argv[]) {     glfloat *tex;     gluquadricobj *sphere, *cone, *base;     glfloat plane[4];     glfloat v0[3], v1[3], v2[3];      glutinit(&argc, argv);     glutinitwindowsize(512, 512);     glutinitdisplaymode(glut_rgba|glut_depth|glut_stencil|glut_single);     (void)glutcreatewindow("soft shadows");     glutdisplayfunc(redraw);     glutkeyboardfunc(key);      glutcreatemenu(menu);     glutaddmenuentry("hard shadow", none);     glutaddmenuentry("soft shadow", shadow);     glutattachmenu(glut_right_button);       /* draw perspective scene */     glmatrixmode(gl_projection);     glfrustum(-100., 100., -100., 100., 320., 640.);      glmatrixmode(gl_modelview);      /* make shadow matricies */        /* 3 points on floor */       v0[x] = -100.f; v0[y] = -100.f; v0[z] = -320.f;       v1[x] =  100.f; v1[y] = -100.f; v1[z] = -320.f;       v2[x] =  100.f; v2[y] = -100.f; v2[z] = -520.f;        findplane(plane, v0, v1, v2);       shadowmatrix(floorshadow, plane, lightpos);        /* 3 points on left wall */       v0[x] = -100.f; v0[y] = -100.f; v0[z] = -320.f;       v1[x] = -100.f; v1[y] = -100.f; v1[z] = -520.f;       v2[x] = -100.f; v2[y] =  100.f; v2[z] = -520.f;        findplane(plane, v0, v1, v2);       shadowmatrix(leftwallshadow, plane, lightpos);      /* turn on features */     glenable(gl_depth_test);     glenable(gl_lighting);     glenable(gl_light0);      /* place light 0 in right place */     gllightfv(gl_light0, gl_position, lightpos);      /* remove faces speed things */     glcullface(gl_back);      gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_nearest);      /* make display lists sphere , cone; efficiency */      glnewlist(sphere, gl_compile);     sphere = glunewquadric();     glusphere(sphere, 20.f, 20, 20);     gludeletequadric(sphere);     glendlist();       glnewlist(light, gl_compile);     sphere = glunewquadric();     glusphere(sphere, 5.f, 20, 20);     gludeletequadric(sphere);     glendlist();      glnewlist(cone, gl_compile);     cone = glunewquadric();     base = glunewquadric();     glrotatef(-90.f, 1.f, 0.f, 0.f);     gludisk(base, 0., 20., 20, 1);     glucylinder(cone, 20., 0., 60., 20, 20);     gludeletequadric(cone);     gludeletequadric(base);     glendlist();      glnewlist(floor, gl_compile);     glendlist();      glnewlist(leftwall, gl_compile);     glendlist();      /* load pattern current 2d texture */     tex = make_texture(texdim, texdim);     glteximage2d(gl_texture_2d, 0, 1, texdim, texdim, 0, gl_red, gl_float, tex);     free(tex);      glutmainloop(); } 

rgbimage not built-in class, must add appropriate #include @ top of file. you'll need link library containing if aren't doing so.

as far can tell, rgbimage class part of the texturebmp example accompanying book "3d computer graphics: mathematical introduction opengl" samuel r. buss. can download rgbimage.cpp , rgbimage.h there. can include rgbimage.cpp project , add #include "rgbimage.h" rest of includes @ top of file.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -