void setOther(int value) { switch (value) { case OPTION_FULLSCREEN: glutFullScreen(); break; case OPTION_WINDOWDISPLAY: glutReshapeWindow(512, 512); glutInitWindowPosition(0, 0); break; } glutPostRedisplay(); }
/*----------------------------------------------------------------------------*/ window_t::window_t(int w, int h, const char *name, GLfloat *pos, GLfloat *at) { width = w; height = h; memcpy(position, pos, sizeof(GLfloat)*3); memcpy(lookat, at, sizeof(GLfloat)*3); attached = false; glutInitWindowSize(width,height); glutCreateWindow(name); glutDisplayFunc(windows_t::display); glutReshapeFunc(windows_t::reshape); glutReshapeWindow(width,height); }
void GlutReshape(int w, int h) { if( w != camera.imgWidth || h != camera.imgHeight ) { glutReshapeWindow( camera.imgWidth, camera.imgHeight); } else { glViewport( 0, 0, w, h ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); float r = (float) w / float (h); gluPerspective( camera.fov, r, 0.02, 1000.0); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); } }
void fullscreen(){ int nMode = 0; DEVMODE devMode; HWND hWnd; hWnd = GetActiveWindow(); if(Change){ glClearColor( 1.0f, 1.0f, 0.0f, 1.0f ); ChangeDisplaySettings( &devMode, CDS_FULLSCREEN ); glutFullScreen(); }else{ glClearColor( 0.0f, 1.0f, 0.0f, 1.0f ); ChangeDisplaySettings(NULL, 0); glutPositionWindow(100,100); glutReshapeWindow(1280,800); } }
int main( int argc, char **argv ) { glutInit( &argc, argv ); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ); glutCreateWindow( argv[0] ); glutReshapeFunc( on_reshape ); glutDisplayFunc( on_display ); glutKeyboardFunc( on_key_press ); glutSpecialFunc( on_special_key_press ); glutReshapeWindow( 600,400 ); #ifndef __APPLE__ glewExperimental = GL_TRUE; GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ fprintf( stderr, "Error: %s\n", glewGetErrorString(err) ); exit( EXIT_FAILURE ); } fprintf( stderr, "Using GLEW %s\n", glewGetString(GLEW_VERSION) ); #endif console = console_new(); console_print( console, L"OpenGL Freetype console\n" L"Copyright 2011 Nicolas P. Rougier. All rights reserved.\n \n" ); console_connect( console, "activate", console_activate ); console_connect( console, "complete", console_complete ); console_connect( console, "history-prev", console_history_prev ); console_connect( console, "history-next", console_history_next ); glClearColor( 1.00, 1.00, 1.00, 1.00 ); glDisable( GL_DEPTH_TEST ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable( GL_TEXTURE_2D ); glEnable( GL_BLEND ); shader = shader_load("shaders/v3f-t2f-c4f.vert", "shaders/v3f-t2f-c4f.frag"); mat4_set_identity( &projection ); mat4_set_identity( &model ); mat4_set_identity( &view ); glutMainLoop(); return 0; }
fileData* MacOSXDirScanner::saveFileDialog() { //XXX not finished yet. fprintf(stderr, "start OSX File Save Dialog\n"); OSStatus err; NavDialogRef saveDialog; NavDialogCreationOptions dialogAttributes; int n = 0; if ( savefD ) { delete savefD; savefD = NULL; } if( AudicleWindow::our_fullscreen ) { glutReshapeWindow( AudicleWindow::main()->m_w, AudicleWindow::main()->m_h ); glutPostRedisplay(); AudicleWindow::our_fullscreen = FALSE; return NULL; } err = NavGetDefaultDialogCreationOptions( &dialogAttributes ); dialogAttributes.modality = kWindowModalityAppModal; gNavEventHandlerPtr = NewNavEventUPP( dialogFileCallback ); err = NavCreatePutFileDialog( &dialogAttributes, 'ChuK', kNavGenericSignature, gNavEventHandlerPtr, NULL, &saveDialog ); if ( !AudicleGfx::cursor_on ) { ShowCursor(); AudicleGfx::cursor_on = true; } err = NavDialogRun( saveDialog ); if ( err != noErr ) { NavDialogDispose( saveDialog ); DisposeNavEventUPP( gNavEventHandlerPtr ); return NULL; } return savefD; }
void keyboardFunc(unsigned char key, int x, int y) { if (keyBindings.find(key) != keyBindings.end()) { keyBindings[key](key, x, y); return; } key_pressed(key); switch (key) { case 'f' : if (g_fullscreen) { g_fullscreen = false; glutReshapeWindow(g_window_width,g_window_height); } else { g_fullscreen = true; g_window_width = g_width; g_window_height = g_height; glutFullScreen(); } break; case 'c' : { std::cout.precision(10); std::cout << "-vp " << g_camera.from.x << " " << g_camera.from.y << " " << g_camera.from.z << " " << "-vi " << g_camera.to.x << " " << g_camera.to.y << " " << g_camera.to.z << " " //<< "-vd " << g_camera.to.x-g_camera.from.x << " " << g_camera.to.y-g_camera.from.y << " " << g_camera.to.z-g_camera.from.z << " " << std::endl << "-vu " << g_camera.up.x << " " << g_camera.up.y << " " << g_camera.up.z << " " << "-fov " << g_camera.fov << std::endl; break; } //case 'a' : g_camera.rotate(-0.02f,0.0f); break; //case 'd' : g_camera.rotate(+0.02f,0.0f); break; //case 'w' : g_camera.move(0.0f,0.0f,+g_speed); break; //case 's' : g_camera.move(0.0f,0.0f,-g_speed); break; //case ' ' : g_display = !g_display; break; case '+' : g_debug=clamp(g_debug+0.01f); PRINT(g_debug); break; case '-' : g_debug=clamp(g_debug-0.01f); PRINT(g_debug); break; case '\033': case 'q': case 'Q': cleanup(); glutDestroyWindow(g_window); #if defined(__MACOSX__) exit(1); #endif break; } }
//------------------------------------------------------------------------------ void webcam_t::start() { printf("Webcam initialisation (GLUT)... "); fflush(stdout); info -> current_webcam = this; glutReshapeWindow(W,H); reshaped = false; done = false; printf("ok\n"); fflush(stdout); glutDisplayFunc(webcam_t::display); glutReshapeFunc(webcam_t::reshape); }
///////////////////////////////////////////////////////// // dimensionsMess // ///////////////////////////////////////////////////////// void gemglutwindow :: dimensionsMess(unsigned int width, unsigned int height) { if (width <= 0) { error("width must be greater than 0"); return; } if (height <= 0 ) { error ("height must be greater than 0"); return; } m_width = width; m_height = height; if(makeCurrent()){ glutReshapeWindow(m_width, m_height); } }
/* Callback handler for special-key event */ void specialKeys(int key, int x, int y) { switch (key) { case GLUT_KEY_F1: // F1: Toggle between full-screen and windowed mode fullScreenMode = !fullScreenMode; // Toggle state if (fullScreenMode) { // Full-screen mode windowPosX = glutGet(GLUT_WINDOW_X); // Save parameters for restoring later windowPosY = glutGet(GLUT_WINDOW_Y); windowWidth = glutGet(GLUT_WINDOW_WIDTH); windowHeight = glutGet(GLUT_WINDOW_HEIGHT); glutFullScreen(); // Switch into full screen } else { // Windowed mode glutReshapeWindow(windowWidth, windowHeight); // Switch into windowed mode glutPositionWindow(windowPosX, windowPosX); // Position top-left corner } break; } }
void PtexViewer::toggleFullScreen() { static bool fullscreen = false; static int win[2]; if (!fullscreen) { win[0] = glutGet(GLUT_WINDOW_WIDTH); win[1] = glutGet(GLUT_WINDOW_HEIGHT); glutFullScreen(); fullscreen = true; } else { glutReshapeWindow(win[0],win[1]); fullscreen = false; } }
void Window::size(uword &width, uword &height) { PRIV(WindowData, wd) select(); if (width || height) { if (!width) width = wd->width; if (!height) height = wd->height; glutReshapeWindow(width, height); return; } width = wd->width; height = wd->height; }
void KeyPressed(unsigned char key, int x, int y) { static const int ESCAPE = 27; const int keynum = atoi((char*)&key); switch (key) { case ESCAPE: case 'q': glutDestroyWindow(WindowID); exit(0); break; case 'f': if (FullScreenMode) { glutReshapeWindow(WindowWidth, WindowHeight); glutPositionWindow(0,0); FullScreenMode = 0; } else { glutFullScreen(); FullScreenMode = 1; } break; case '+': currentScale += 5e-4; printf("Current Scale: %f\n",currentScale); break; case '-': currentScale = fabs(currentScale - 5e-4); printf("Current Scale: %f\n",currentScale); break; case ',': MIN_KEYWORD_COUNT = (MIN_KEYWORD_COUNT == 0 ? 0 : MIN_KEYWORD_COUNT-1); printf("MIN_KEYWORD_COUNT: %d\n", MIN_KEYWORD_COUNT); break; case '.': MIN_KEYWORD_COUNT += 1; printf("MIN_KEYWORD_COUNT: %d\n", MIN_KEYWORD_COUNT); break; } glutPostRedisplay(); }
void toggleFullscreen (void) { if (dset.fullscreen) { glutReshapeWindow (dset.old_w, dset.old_h); glutPositionWindow (dset.old_x, dset.old_y); } else { dset.old_x = glutGet ((GLenum) GLUT_WINDOW_X); dset.old_y = glutGet ((GLenum) GLUT_WINDOW_Y); dset.old_w = glutGet ((GLenum) GLUT_WINDOW_WIDTH); dset.old_h = glutGet ((GLenum) GLUT_WINDOW_HEIGHT); glutFullScreen (); } dset.fullscreen = dset.fullscreen == 0 ? 1 : 0; }
// This function prevents users from resizing the window into sizes that are // unrelated to one another, creating distortion. void Dimension_Reshape(int X_Size, int Y_Size) { // Figure out which is smaller, the (appropriate) height or width auto New_Size=X_Size>5*Y_Size?5*Y_Size:X_Size; // Change the size Dimension_Window_Size=New_Size; glutReshapeWindow(Dimension_Window_Size, Dimension_Window_Size/5.0); // Remake the view glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0, Dimension_Window_Size, 0, Dimension_Window_Size/5.0); glViewport(0, 0, Dimension_Window_Size, Dimension_Window_Size/5.0); glMatrixMode(GL_MODELVIEW); }
// Window creation function void Dimension_Window(int Dimension, std::array<Color_p, 6> Color_List) { Dimension_Color_List=Color_List; // Figure out what dimension is being changed, and get ready to // use it when the Cube is resized switch(Dimension) { case 0: Old_Length=Current_Cube[0].length(); Dimension_Side='w'; break; case 1: Old_Length=Current_Cube[0].height(); Dimension_Side='h'; break; case 2: Old_Length=Current_Cube[1].length(); Dimension_Side='d'; break; default: break; } Current_Length=1; Dimension_Window_ID=glutCreateWindow("Size Picker"); Dimension_Window_Size=400; glutReshapeWindow(Dimension_Window_Size, Dimension_Window_Size/5.0); glutPositionWindow(250, 300); // Declare GLUT callbacks glutDisplayFunc(Dimension_Display); glutMouseFunc(Dimension_Mouse); glutPassiveMotionFunc(Dimension_Passive_Motion); glutReshapeFunc(Dimension_Reshape); // Set up an orthographic viewing matrix glViewport(0, 0, Dimension_Window_Size, Dimension_Window_Size/5.0); glMatrixMode(GL_PROJECTION); gluOrtho2D(0, Dimension_Window_Size, 0, Dimension_Window_Size/5.0); gluLookAt(0, 0, 1, 0, 0, 0, 0, 1, 0); glMatrixMode(GL_MODELVIEW); glClearColor(.6, .6, .6, 0); }
void game::timerCallback() { if (firstResize) { glutReshapeWindow(640,480); firstResize=0; printf("First Reshape"); } object::activGame->gameTime += 1; if (noBlockGeneration <= 0){ if (rand() % 100000 > (int) (99990-score)){ spawnHoleRow(); noBlockGeneration = 600; } else if (rand() % 1000 >(int) 995-(score/10)) otherObjects.push_back( new block (((rand() % 18+1)*5)-2.5, 80, 5,rand()%4)); // otherObjects.push_back( new block ((rand() % 18+1)*2.5, 80, 5.0,rand()%3)); } else noBlockGeneration--; if (score % 50 == 0) { otherObjects.push_back(new addon (rand() % 100, 80, 2.0, score / 50)); score++; } if (rand() % 1000 > 996) { otherObjects.push_back (new erdnuss ((rand() %18+1)*5, 80, 1.5)); } list<object *>::iterator it; // thePlayer-> timerCallback(0.5); for (it = otherObjects.begin(); it != otherObjects.end(); it ++) if (!(*it)->timerCallback(0.1)){ delete *it; it = otherObjects.erase (it); //score++; } handleCollisions(); }
svg::SVGDocument* createSampleDoc() { svg::SVGDocument * doc = new svg::SVGDocument(); svg::SVGSVGElement * thesvgelt = new svg::SVGSVGElement(doc); thesvgelt->setWidth(450); thesvgelt->setHeight(450); doc->appendChild(thesvgelt); // add a new "layer" // there can be another "layer" for tools, widgets which may not be zoomable... svg::SVGGElement * view = new svg::SVGGElement(doc); thesvgelt->appendChild(view); panTransform = new svg::SVGTranslateTransform; zoomTransform = new svg::SVGScaleTransform; svg::SVGTransformList& l = const_cast<svg::SVGTransformList&>(view->getTransform()); l.appendItem(zoomTransform); l.appendItem(panTransform); svg::SVGRectElement * rect = new svg::SVGRectElement(doc); double w=100,h=100; double x = 100; double y = 100; rect->setX(-w/2); rect->setY(-h/2); rect->setWidth(w); rect->setHeight(h); rect->setFill(0,0,1); rect->setStroke(0,0,0); rect->setStrokeWidth(2); // order independant //rect->scale(.5); //rect->rotate(20); rect->translate(x,y); view->appendChild(rect); glutReshapeWindow(450, 450); return doc; }
fileData* MacOSXDirScanner::openFileDialog() { OSStatus err; NavDialogRef openDialog; NavDialogCreationOptions dialogAttributes; int n = 0; if ( openfD ) { delete openfD; openfD = NULL; } if( AudicleWindow::our_fullscreen ) { glutReshapeWindow( AudicleWindow::main()->m_w, AudicleWindow::main()->m_h ); glutPostRedisplay(); AudicleWindow::our_fullscreen = FALSE; return NULL; } err = NavGetDefaultDialogCreationOptions( &dialogAttributes ); dialogAttributes.modality = kWindowModalityAppModal; gNavEventHandlerPtr = NewNavEventUPP( dialogFileCallback ); err = NavCreateGetFileDialog( &dialogAttributes, NULL, gNavEventHandlerPtr, NULL, NULL, NULL, &openDialog ); if ( !AudicleGfx::cursor_on ) { ShowCursor(); AudicleGfx::cursor_on = true; } err = NavDialogRun( openDialog ); if ( err != noErr ) { NavDialogDispose( openDialog ); DisposeNavEventUPP( gNavEventHandlerPtr ); return NULL; } return openfD; }
void ToggleFullscreen() { if ( frame.fullscreen == 0 ) { frame.fullscreen=1; frame.windowX=glutGet(GLUT_WINDOW_X); frame.windowY=glutGet(GLUT_WINDOW_Y); frame.windowWidth=glutGet(GLUT_WINDOW_WIDTH); frame.windowHeight=glutGet(GLUT_WINDOW_HEIGHT); glutFullScreen(); } else if ( frame.fullscreen == 1 ) { frame.fullscreen=0; glutPositionWindow(frame.windowX,frame.windowY); glutReshapeWindow(frame.windowWidth,frame.windowHeight); } }
//================================================================== void RibRendToy::renderFile_HandleDisplays( const RRL::DisplayList &pDisplays ) { // be happy with the first display found for (size_t i=0; i < pDisplays.size(); ++i) { DSAFE_DELETE( mpDispDriverFBuff ); mpDispDriverFBuff = DNEW DispDriverFBuffOGL( "Default Disp Driver", pDisplays[i]->mImage ); mLastUsedWd = (int)pDisplays[i]->mImage.mWd; mLastUsedHe = (int)pDisplays[i]->mImage.mHe; // actually resize the window ! glutReshapeWindow( mLastUsedWd, mLastUsedHe ); break; } }
// This function prevents users from resizing the window into sizes that are // unrelated to one another, creating distortion. void Color_Reshape(int X_Size, int Y_Size) { // Find the smaller of the two sizes double New_Size=X_Size>Y_Size?Y_Size:X_Size; // The smaller size defines the new edge of the window Color_Window_Size=New_Size; // Resize the window glutReshapeWindow(Color_Window_Size, Color_Window_Size); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); // Redefine the viewing matrix gluOrtho2D(0, Color_Window_Size, 0, Color_Window_Size); glViewport(0, 0, Color_Window_Size, Color_Window_Size); glMatrixMode(GL_MODELVIEW); }
void set_fullscreen() { if( fullscreen ) { // << if the space bar is held down the // window can get stuck in fullscreen mode >> win_pos[0] = glutGet(GLUT_WINDOW_X); win_pos[1] = glutGet(GLUT_WINDOW_Y); win_size[0] = glutGet(GLUT_WINDOW_WIDTH); win_size[1] = glutGet(GLUT_WINDOW_HEIGHT); glutFullScreen(); } else { glutPositionWindow( win_pos[0], win_pos[1] ); glutReshapeWindow( win_size[0], win_size[1] ); } }
void keyboard(unsigned char key, int x, int y) { renderer->keyboard(key, x, y); switch(key) { case 27: exit(0); break; case '1': printf("you pressed the number 1!\n"); glutFullScreen(); break; case '2': glutReshapeWindow(400,400); break; } printf("done pressing...\n"); }
void keyboard(unsigned char key, int x, int y){ switch (key){ case ('x'): exit(0); break; case ('f'): if (!fullscreen){ glutFullScreen(); fullscreen = true; } else { glutReshapeWindow(1100, 600); glutPositionWindow(0,0); fullscreen = false; } break; } }
/* * Activates a menu pointed by the function argument */ static void fghActivateMenu( SFG_Window* window, int button ) { int max_x, max_y; /* We'll be referencing this menu a lot, so remember its address: */ SFG_Menu* menu = window->Menu[ button ]; SFG_Window* current_window = fgStructure.CurrentWindow; /* If the menu is already active in another window, deactivate it there */ if ( menu->ParentWindow ) menu->ParentWindow->ActiveMenu = NULL ; /* Mark the menu as active, so that it gets displayed: */ window->ActiveMenu = menu; menu->IsActive = GL_TRUE; fghSetMenuParentWindow ( window, menu ); fgState.ActiveMenus++; /* Set up the initial menu position now: */ fghGetVMaxExtent(menu->ParentWindow, &max_x, &max_y); fgSetWindow( window ); menu->X = window->State.MouseX + glutGet( GLUT_WINDOW_X ); menu->Y = window->State.MouseY + glutGet( GLUT_WINDOW_Y ); if( menu->X + menu->Width > max_x ) menu->X -=menu->Width; if( menu->Y + menu->Height > max_y ) menu->Y -=menu->Height; menu->Window->State.MouseX = window->State.MouseX + glutGet( GLUT_WINDOW_X ) - menu->X; menu->Window->State.MouseY = window->State.MouseY + glutGet( GLUT_WINDOW_Y ) - menu->Y; fgSetWindow( menu->Window ); glutPositionWindow( menu->X, menu->Y ); glutReshapeWindow( menu->Width, menu->Height ); glutPopWindow( ); glutShowWindow( ); menu->Window->ActiveMenu = menu; fghCheckMenuStatus( menu ); fgSetWindow( current_window ); }
void menuSelect(int value) { switch (value) { // enable full screen display case OPTION_FULLSCREEN: glutFullScreen(); break; // reshape window to original size case OPTION_WINDOWDISPLAY: glutReshapeWindow(WINDOW_SIZE_W, WINDOW_SIZE_H); break; // show the dynamic skeleton of the object case OPTION_SHOWSKELETON: if(USE_SKELETON_MODEL) { defObject->m_showSkeletonModel = true; defObject->setWireMode(true, true); } else { defObject->m_showMassParticleModel = true; } break; // hide the dynamic skeleton of the object case OPTION_HIDESKELETON: if(USE_SKELETON_MODEL) { defObject->m_showSkeletonModel = false; defObject->setWireMode(false, true); } else { defObject->m_showMassParticleModel = false; } defObject->setTransparencyLevel(1.0, true, true); break; } }
/** * glutrib, a RIB file loader. Displays a RIB scene into a window, using GLUT. * Synopsis: glutrib [ribfile] */ int main(int argc, char **argv) { // const char *searchPath = ".:&"; // RiCPPControl("searchpath", "renderer", &searchPath, RI_NULL); #if defined (_DEBUG) drawNormals = 1; #endif storedArgc = argc; storedArgv = argv; glutInit(&argc, argv); glutInitDisplayMode ((unsigned int)(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)); glutInitWindowSize (width, height); glutInitWindowPosition (100, 100); glutCreateWindow(argc <= 1 ? "GLUT RIB" : argv[1]); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMouseFunc(mouse); glutMotionFunc(motion); glutKeyboardFunc(keyboard); // std::cerr << "BEGIN" << std::endl; // Print errors RiErrorHandler(RiErrorPrint); RiBegin("glrenderer"); { if ( argc <= 1 ) { testScene(); } else { loadScene(argv[1]); } // std::cerr << "MainLoop" << std::endl; glutReshapeWindow(width, height); // Hack, display did not work on my laptop until window was resized... glutMainLoop(); } RiEnd(); // std::cerr << "END" << std::endl; return 0; }
void keyboardDownFunction(unsigned char key, int p1, int p2) { if (key == VK_ESCAPE) { glutDestroyWindow(g_main_window_id); exit(0); } if (key == 'f') { if (!g_fullscreen) { glutFullScreen(); g_fullscreen = true; } else if (g_fullscreen) { glutLeaveGameMode(); glutLeaveFullScreen(); glutReshapeWindow(g_renderer->_ScreenWidth, g_renderer->_ScreenWidth); glutPositionWindow(0, 0); g_fullscreen = false; } } if (key == 'q') QDown = true; if (key == 's') SDown = true; if (key == 'd') DDown = true; if (key == 'z') ZDown = true; if (key == 'g') g_fast_time = !g_fast_time; if (key == 'c') camera = !camera; if (key == VK_SPACE) avatar->Jump = true; }
void GlutViewer::fullScreen() { static int savewidth, saveheight; fullscreen = fullscreen ? 0 : 1; if (fullscreen) { savewidth = width; saveheight = height; glutFullScreen(); } else { glutFullScreen(); glutReshapeWindow(savewidth, saveheight); glutPositionWindow(100,100); //self->resize(savewidth, saveheight); } debug_print("fullscreen %d sw %d sh %d\n", fullscreen, savewidth, saveheight); }