#include #include #include #define BUFFWIDTH 50 #define BUFFHEIGHT 50 enum projectiontype {orthographic, perspective }; /* possible modes of program */ enum colors {black, white, red, blue, green}; /* available colors */ enum axis {xaxis, yaxis, zaxis}; /* axes of rotation */ enum menuitems {Morthographic, Mperspective, Mwhite, Mred, Mblue, Mgreen, Mtranslate, Mrotate, Mscale, Mredraw, Mclear}; /* the global variables */ int fb[BUFFWIDTH][BUFFHEIGHT]; /* the simulated frame buffer*/ int width=500,height=500; /* initial window size */ float pixwidth = (float) width/BUFFWIDTH; /* simulated pixel width */ float pixheight = (float) height/BUFFHEIGHT; /* simulated pixel height */ int currprojection=orthographic; /* type of projection */ int currcolor=white; /* drawing color */ float CTM[4][4], CPM[4][4]; /* modeling and projection matrices*/ int mainmenu, colormenu, projectionmenu; void translate(int dx, int dy, int dz); void rotate(int angle, int rotateaxis); void scale(int dx, int dy, int dz); round(float x) { if (x>0) return (int) x+0.5; else return (int) x-0.5; } void drawPolygon() { // Insert code here } void setWindowTitle() { // Insert code here if (currprojection == orthographic) { switch (currcolor) { case black: glutSetWindowTitle("Settings: Orthographic, Black"); break; case white: glutSetWindowTitle("Settings: Orthographic, White"); break; case red: glutSetWindowTitle("Settings: Orthographic, Red"); break; case blue: glutSetWindowTitle("Settings: Orthographic, Blue"); break; case green: glutSetWindowTitle("Settings: Orthographic, Green"); break; } } else { switch (currcolor) { case black: glutSetWindowTitle("Settings: Perspective, Black"); break; case white: glutSetWindowTitle("Settings: Perspective, White"); break; case red: glutSetWindowTitle("Settings: Perspective, Red"); break; case blue: glutSetWindowTitle("Settings: Perspective, Blue"); break; case green: glutSetWindowTitle("Settings: Perspective, Green"); break; } } } void init() { FILE *fp, *fopen(const char*, const char*); int i,j, numvertices; int x,y; glClearColor(0.0,0.0,0.0,0.0); /* clear color is black */ for (i=0; i