int main(int argc, char** argv) { // GLUT Window Initialization: glutInit (&argc, argv); glutInitWindowSize (g_Width, g_Height); glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow ("CS248 GLUT example"); // Initialize OpenGL graphics state InitGraphics(); // Register callbacks: glutDisplayFunc (display); glutReshapeFunc (reshape); glutKeyboardFunc (Keyboard); glutMouseFunc (MouseButton); glutMotionFunc (MouseMotion); glutIdleFunc (AnimateScene); // Create our popup menu BuildPopupMenu (); glutAttachMenu (GLUT_RIGHT_BUTTON); // Get the initial time, for use by animation gettimeofday (&last_idle_time, NULL); // Turn the flow of control over to GLUT glutMainLoop (); return 0; }
/* The main program */ int main(int argc, char** argv) { /* create a window, position it, and name it */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); glutInitWindowSize(imageWidth, imageHeight); glutInitWindowPosition(200, 200); glutCreateWindow("Assignment - 1"); /* create a callback routine for when the mouse is clicked */ glutMouseFunc(myMouse); /* create a callback routine for when the program is idle */ glutIdleFunc(animation); /* create a callback routine for (re-)display */ glutDisplayFunc(display); BuildPopupMenu (); //This is going to be a function you write to initialize the menu glutAttachMenu (GLUT_RIGHT_BUTTON); //This attaches the menu to the right mouse click button /* init some states */ init(); /* entering the event loop */ glutMainLoop(); /* code here will not be executed */ }
// Builds a new window, initializes the variables and event handler and builds // the menu. SVPaint::SVPaint(const char *server_name) { window_ = new ScrollView("ScrollView Paint Example", // window caption 0, 0, // x,y window position 500, 500, // window size 500, 500, // canvas size false, // whether the Y axis is inversed. // this is included due to legacy // reasons for tesseract and enables // us to have (0,0) as the LOWER left // of the coordinate system. server_name); // the server address. // Set the start modes to point-to-point and line drawing. click_mode_ = 1; drag_mode_ = 4; has_start_point_ = false; // Bild our menus and add them to the window. The flag illustrates whether // this is a menu bar. SVMenuNode* popup_menu = BuildPopupMenu(); popup_menu->BuildMenu(window_,false); SVMenuNode* bar_menu = BuildMenuBar(); bar_menu->BuildMenu(window_,true); // Set the initial color values to White (could also be done by // passing (rgb[0], rgb[1], rgb[2]). window_->Pen(ScrollView::WHITE); window_->Brush(ScrollView::WHITE); // Adds the event handler to the window. This actually ensures that Notify // gets called when events occur. window_->AddEventHandler(this); // Set the window visible (calling this is important to actually render // everything. Without this call, the window would also be drawn, but the // menu bars would be missing. window_->SetVisible(true); // Rest this thread until its window is destroyed. // Note that a special eventhandling thread was created when constructing // the window. Due to this, the application will not deadlock here. window_->AwaitEvent(SVET_DESTROY); // We now have 3 Threads running: // (1) The MessageReceiver thread which fetches messages and distributes them // (2) The EventHandler thread which handles all events for window_ // (3) The main thread which waits on window_ for a DESTROY event (blocked) }
void initializeGraphics() { //Build Pop Up Menu BuildPopupMenu(); glutAttachMenu (GLUT_RIGHT_BUTTON); //inittextures for(int i=0;i<MAXTEXTURES;i++) textures[i]=0; // disable Lighting glDisable( GL_LIGHTING ); glClearColor (0.0f, 0.0f, 0.0f, 0.0f); glEnable( GL_DEPTH_TEST ); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glGetFloatv( GL_MODELVIEW_MATRIX, modelViewMatrix ); // save MY copy in modelViewMatrix glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 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); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //Load Textures textures[SIRENID] = loadtextures(sirenFile, 52,45); textures[VEHICLEID] = loadtextures(vehicleFile, 207,177); textures[WALLID] = loadtextures(wallFile, 512,512); textures[FLOORID] = loadtextures(floorFile, 512,512); textures[CARROTID] = loadtextures(carrotFile, 52,45); textures[BUTTONID] = loadtextures(buttonFile, 52,45); textures[PARTICLEID]=textures[VEHICLEID]; textures[PONDID] = loadtextures(marbleFile,225,225); textures[WATERID] = loadtextures(waterFile,393,385); //snow drifts snowcave.resetPoints(snowCavePoints); snowcave.setBoundingBoxes(driftBuffer); snowcave2.resetPoints(snowCavePoints2); // snowcave2.setBoundingBox(-50,-27, //min max X // -50,-30, //min max Y // -50,10); //min max z snowcave2.setBoundingBoxes(driftBuffer); //snowman snowman = Snowman(snowmanOrigin, SNOWMANID, snowmanSize, textures[FLOORID], textures[CARROTID], textures[BUTTONID]); snowman2 = Snowman(snowmanOrigin2, SNOWMANID, snowmanSize, textures[FLOORID], textures[CARROTID], textures[BUTTONID]); snowman3 = Snowman(snowmanOrigin3, SNOWMANID, snowmanSize, textures[FLOORID], textures[CARROTID], textures[BUTTONID]); //Pond pond = Pond(pondOrigin,PONDID,pondRadius,pondHeight); pond.setSpaceDimensions(Point(10,10,10)); pond.setBoundingBox(pondOrigin.x-10,pondOrigin.x+10,-50,pondOrigin.y+5,pondOrigin.z-10,pondOrigin.z+10); //Gifts gifts[0] = Gift(giftOrigin1,GIFT1ID,giftSize); gifts[1] = Gift(giftOrigin2,GIFT2ID,giftSize); gifts[2] = Gift(giftOrigin3,GIFT3ID,giftSize); gifts[3] = Gift(giftOrigin4,GIFT4ID,giftSize); gifts[4] = Gift(giftOrigin5,GIFT5ID,giftSize); //enemy npc.setSpeed(npcSpeed); npc.setSpaceDimensions(Point(bodyRadius/2,bodyRadius/2,bodyRadius/2)); npc.setThrowRange(20); npc.setInDanger(true); //vehicle vehicle.setDamage(0); vehicle.setMaxDamage(100); vehicle.setIsAlive(true); vehicle.setStrikeRange(30); //init shadow paramteres glEnable(GL_COLOR_MATERIAL); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glShadeModel (GL_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //this is defined //bool (*fp_processCollision)(Obstacle); fp_processCollision = &processCollision; //Map Creation assessment currMap.createMap(minCoords, maxCoords, npc, gifts, giftCount, fp_processCollision ); currMap.printState(); //setup the controller controller = PathController(&currMap,&npc,&vehicle); controller.setNextTarget(); //set the target controller.setMaxPath(100); }