void Redisplay(void) { int win = glutGetWindow(); int viewport[4]; if (win==nWindow) { glClearColor(.2f,0.f,0.f,0.f); glColor3f(1,1,1); } else { /* child window */ glClearColor(.0f,.2f,0.f,0.f); glColor3f(.5,.5,.5); glutPostWindowRedisplay(nWindow); } glClear(GL_COLOR_BUFFER_BIT); DrawQuad(); if (win==nWindow) { glColor3f(1, 1, 0); glGetIntegerv(GL_VIEWPORT, viewport); glRasterPos2i(2, -glutBitmapHeight(GLUT_BITMAP_9_BY_15)+3+viewport[3]); glutBitmapString(GLUT_BITMAP_9_BY_15, (unsigned char*)"press f/r/m/d/c/i/h/p"); } glutSwapBuffers(); glutPostWindowRedisplay(win); }
void myidle ( void ) { t += dt; glutPostWindowRedisplay(mainWindow); glutPostWindowRedisplay(subWindow1); glutPostWindowRedisplay(window2); }
void spinDisplay(void){ theta += 1.0; while (theta > 360.0) theta -= 360; glutSetWindow(singleb); glutPostWindowRedisplay(singleb); glutSetWindow(doubleb); glutPostWindowRedisplay(doubleb); }
/* * This is a sample idle function */ void SampleIdle( void ) { if( g_LeaveGameMode == 1 ) { /* One could do all this just as well in SampleGameModeKeyboard... */ printf("leaving gamemode...\n"); glutLeaveGameMode( ); g_LeaveGameMode = 0; g_InGameMode = 0; glutPostWindowRedisplay(g_mainwin1); glutPostWindowRedisplay(g_mainwin2); glutPostWindowRedisplay(g_sw1); glutPostWindowRedisplay(g_sw2); } }
//----------------------------------------------------------------------------- // reshape a sub-window //----------------------------------------------------------------------------- void GlutDisplay::reshapeSubWindow() { if (mainWinId >= 0) { const GlutDisplay* pMainWin = findRegisteredGlutDisplay(mainWinId); if (pMainWin != nullptr) { GLint mainWinX = 0, mainWinY = 0; GLsizei mainWinWidth = 0, mainWinHeight = 0; pMainWin->getViewport(&mainWinX, &mainWinY, &mainWinWidth, &mainWinHeight); // we have our new viewport width and height // multiply it by our ratio and reset our width and height const int newX = static_cast<int>(swPosition.x() * static_cast<double>(mainWinWidth) + 0.5); const int newY = static_cast<int>(swPosition.y() * static_cast<double>(mainWinHeight) + 0.5); const int newWidth = static_cast<int>(swSize.x() * static_cast<double>(mainWinWidth) + 0.5); const int newHeight = static_cast<int>(swSize.y() * static_cast<double>(mainWinHeight) + 0.5); setViewport(newX, newY, newWidth, newHeight); //std::cout << "reshapeSubWindow(void) winID = " << winId; //std::cout << "; mainWinID = " << mainWinId; //std::cout << "; pos(" << newX << ", " << newY << ")"; //std::cout << "; size(" << newWidth << ", " << newHeight << ")"; //std::cout << std::endl; // now resize glutSetWindow(winId); glutPositionWindow(newX, newY); glutReshapeWindow(newWidth, newHeight); reshapeIt(newWidth, newHeight); glutPostWindowRedisplay( winId ); } } }
void draw_output (char *strOutputName, char *strInputName) { OUTPUT_DESC *output; char strFileName[256]; FILE *pFile = NULL; int class_cnae; output = get_output_by_name (strOutputName); sprintf (strFileName, "%s%d.cnae", (g_nDataBaseId == CNAE_TABLE_ID)? CNAE_TABLE_PATH: OBJETOS_SOCIAIS_PATH, g_nDocNumber); if ((pFile = fopen (strFileName, "r")) != NULL) { fscanf (pFile, "%d", &class_cnae); printf ("class_cnae = %d\n", class_cnae); fclose (pFile); } else { printf ("Could not read file %s\n", strFileName); return; } set_neurons (output->neuron_layer->neuron_vector, 0, output->wh * output->ww, class_cnae); update_output_image (output); glutSetWindow(output->win); glutPostWindowRedisplay (output->win); }
void LSidle() { switch (LoadingProgress++) { case 0: initLogo();break; case 1: initializeBallTables(BallResolution); break; //table init case 2: Ball[0].Init(0,TextureSize,BallResolution,Shadow); break; //ball0 init case 3: Ball[1].Init(1,TextureSize,BallResolution,Shadow); break; case 4: Ball[2].Init(2,TextureSize,BallResolution,Shadow); break; case 5: Ball[3].Init(3,TextureSize,BallResolution,Shadow); break; case 6: Ball[4].Init(4,TextureSize,BallResolution,Shadow); break; case 7: Ball[5].Init(5,TextureSize,BallResolution,Shadow); break; case 8: Ball[6].Init(6,TextureSize,BallResolution,Shadow); break; case 9: Ball[7].Init(7,TextureSize,BallResolution,Shadow); break; case 10: Ball[8].Init(8,TextureSize,BallResolution,Shadow); break; case 11: Ball[9].Init(9,TextureSize,BallResolution,Shadow); break; case 12: Ball[10].Init(10,TextureSize,BallResolution,Shadow); break; case 13: Ball[11].Init(11,TextureSize,BallResolution,Shadow); break; case 14: Ball[12].Init(12,TextureSize,BallResolution,Shadow); break; case 15: Ball[13].Init(13,TextureSize,BallResolution,Shadow); break; case 16: Ball[14].Init(14,TextureSize,BallResolution,Shadow); break; case 17: Ball[15].Init(15,TextureSize,BallResolution,Shadow); break; case 18: Table.Init(TableTextureSize); break; case 19: Lighting.Init(AmbientLighting,TableLamps,GreenLamp,Reflections); break; case 20: ShotStrength.Init(); break; case 21: Menu.Init(DisplayTextureSize); break; case 22: Menu.LoadLanguage(900); break; case 23: Menu.LoadLanguage(901); break; case 24: Menu.LoadLanguage(999); break; case 25: Menu.Init(DisplayTextureSize); break; case 26: BoardLayout(); break; case 27: Judge.NewGame(GameType); break; case 28: runGame(); break; } glutPostWindowRedisplay(CurrentWindow); }
void Timer(int value __attribute__ ((unused))) { carmen_ipc_sleep(0.01); glutPostWindowRedisplay(ultrasonic_window_id); glutTimerFunc(redraw_update_period, Timer, 1); }
static void hugsprim_glutPostWindowRedisplay_6(HugsStackPtr hugs_root) { HsInt32 arg1; arg1 = hugs->getInt32(); glutPostWindowRedisplay(arg1); hugs->returnIO(hugs_root,0); }
void dobutton(int button, int state) { if(button <= numbuttons) { buttons[button-1] = (state == GLUT_DOWN); glutPostWindowRedisplay(bw); } }
// functie de update (se apeleaza constant, independent de Draw() ) void update(void) { Sleep(20); sideCounter++; translationTimer++; //Actualizeaza masina jucatorului bool carMoved=false; if(rightKeyPressed) player->move(CAR_RIGHT),carMoved=true; if(leftKeyPressed) player->move(CAR_LEFT),carMoved=true; if(downKeyPressed) player->move(CAR_BACKWARD),carMoved=true; if(upKeyPressed) player->move(CAR_FORWARD),carMoved=true; //Actualizeaza obiectele animate //Rotatia objects[rotatingObject]->SetRotation(&(objects[rotatingObject]->GetRotation()+Vector3D(0,10,0))); if(objects[rotatingObject]->rotation.y > 360) objects[rotatingObject]->rotation.y=0; //Translatia objects[translatingObject]->SetPosition(&(objects[translatingObject]->GetPosition()+Vector3D(0,translationSpeed,0))); if(translationTimer>20) { translationTimer=0; translationSpeed=-translationSpeed; } // redeseneaza scena glutPostWindowRedisplay(mainWindow); if(sideCounter==7) { if(sideWindow!=-1 && fullscreen==false) { glutPostWindowRedisplay(sideWindow); } sideCounter=0; } }
void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective( 45.0, w*1.0/h, 0.5, 200); glMatrixMode(GL_MODELVIEW); glutSetWindow(main_window); glutPostWindowRedisplay(main_window); }
void receiveOscilloscopeData(void) { int i,j,r; int count; if (!osc_enabled) return; #ifdef __XENO__ // we want to be in real-time mode here //printf("..\n"); #if (CONFIG_XENO_VERSION_MAJOR < 2) || (CONFIG_XENO_VERSION_MAJOR == 2 && CONFIG_XENO_VERSION_MINOR < 6) // we are on xenomai version < 2.6 rt_task_set_mode(0,T_PRIMARY,NULL); #else // we are on xenomai version < 2.6 rt_task_set_mode(0,T_CONFORMING,NULL); #endif #endif // try to take semaphore with very short time-out -- we don't care if we // cannot copy the data to shared memory every time, as this is not a time // critical operation if (semTake(sm_oscilloscope_sem,ns2ticks(TIME_OUT_SHORT_NS)) == ERROR) { #ifdef __XENO__ // we want to be in secondary mode here //rt_task_set_mode(T_PRIMARY,0,NULL); #endif return; } // copy first-in-first-out data from shared memory into ring buffer count = sm_oscilloscope->n_entries; for (i=1; i<=count; ++i) addOscData(sm_oscilloscope->entries[i]); sm_oscilloscope->n_entries = 0; // give back semaphore semGive(sm_oscilloscope_sem); #ifdef __XENO__ // we want to be in secondary mode here //rt_task_set_mode(T_PRIMARY,0,NULL); #endif // update the oscilloscope window if (pause_flag || stand_alone_flag) return; else if (count > 0) glutPostWindowRedisplay(openGLId_osc); }
void reshape(int w, int h) { glViewport(0, 0, w, h); float aspect = w*1.0/h; glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, aspect, 0.5, 200.0); glMatrixMode(GL_MODELVIEW); glutSetWindow(main_window); glutPostWindowRedisplay(main_window); }
void draw_output (char *strOutputName, char *strInputName) { OUTPUT_DESC *output; output = get_output_by_name (strOutputName); set_neurons (output->neuron_layer->neuron_vector, 0, output->wh * output->ww, g_nPersonUniqueID - 1); update_output_image (output); glutSetWindow(output->win); glutPostWindowRedisplay (output->win); }
void idle(void) { int time, delta; time = glutGet(GLUT_ELAPSED_TIME); if (resuming) { lastTime = time; resuming = 0; } if (left) { delta = time - leftTime; angle = angle + delta * 0.4; leftTime = time; } if (right) { delta = time - rightTime; angle = angle - delta * 0.4; rightTime = time; } if (thrust) { delta = time - thrustTime; v = delta * 0.00004; xv = xv + cos(angle*M_PI/180.0) * v; yv = yv + sin(angle*M_PI/180.0) * v; thrustTime = time; } delta = time - lastTime; x = x + xv * delta; y = y + yv * delta; x = x / MAX_X; x = (x - floor(x))*MAX_X; y = y / MAX_Y; y = (y - floor(y))*MAX_Y; lastTime = time; advanceRocks(delta); advanceBullets(delta, time); collideBullets(); glutPostWindowRedisplay(currentWindow); /* let's not waste time running at eccessive framerates */ if (delta > 1.0/(float)MAX_FRAMERATE) { sleeptime -= 1; if (sleeptime < 1) sleeptime = 0; } else { sleeptime += 1; if (sleeptime > MAX_SLEEPTIME) sleeptime = MAX_SLEEPTIME; } #if 0 usleep(sleeptime); #endif }
static void menu(int value) { switch(value) { case 1: if ((lighton[0] = !lighton[0])) glEnable(GL_LIGHT0); else glDisable(GL_LIGHT0); break; case 2: if ((lighton[1] = !lighton[1])) glEnable(GL_LIGHT1); else glDisable(GL_LIGHT1); break; case 3: if ((lighton[2] = !lighton[2])) glEnable(GL_LIGHT2); else glDisable(GL_LIGHT2); break; case 4: freeze = !freeze; if (!freeze || spinning) { glutIdleFunc(idle); } else { glutIdleFunc(NULL); } break; case 5: if (obj) objecton = !objecton; else exit(1); break; case 6: spin = !spin; break; case 7: normson = !normson; break; case 8: performance = !performance; break; case 9: exit(0); break; } glutPostWindowRedisplay(window); make_menu(); }
void get_new_char(INPUT_DESC *input, int direction) { g_label = (int) read_char_input(input, char_label_file, char_image_file, direction); check_input_bounds(input, input->wx + input->ww / 2, input->wy + input->wh / 2); update_input_image(input); glutSetWindow(input->win); glBindTexture(GL_TEXTURE_2D,(GLuint) input->tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, input->tfw, input->tfh, 0, GL_RGB, GL_UNSIGNED_BYTE, input->image); glutPostWindowRedisplay(input->win); }
void keyboard_window2( unsigned char key, int x, int y ) { switch ( key ) { case 'r': objectColor_window2 = RED; break; case 'g': objectColor_window2 = GREEN; break; case 'b': objectColor_window2 = BLUE; break; case 'y': objectColor_window2 = YELLOW; break; case 'o': objectColor_window2 = ORANGE; break; case 'p': objectColor_window2 = PURPLE; break; case 'w': objectColor_window2 = WHITE; break; } glutPostWindowRedisplay(window2); }
void MainWindowWrapper::MainReshape(int width, int height) { m_params.w = width; m_params.h = height; m_params.ReCalcSimuWindow(); glViewport(0,0, m_params.w, m_params.h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, m_params.w, m_params.h, 0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glutPostWindowRedisplay(m_SimuWindow); }
/* Fonction de rappel: fonction appelee lorsqu'une entree du menu du modeler a ete selectionnee. */ void menuSelectionModeler(int value) { if( value == Reset ) { nbPointsOnSilhouette=0; glutPostRedisplay(); } else if ( value == Quit ) exit(0); else CurrentAction = value; glutPostWindowRedisplay(windowViewerIndex); }
/* Fonction de rappel: La souris vient d'etre bougee dans le fenetre 'modeler' avec un de ses boutons enfonce. La position de la souris est (x,y) */ void mouseMoveModeler(int x, int y) { /* Bouton gauche : rotation, Bouton droit : translation */ if( gLastMouseEvt.button == GLUT_MIDDLE_BUTTON && indexSeclectedPoint>=0 ) { silhouettePointArray[indexSeclectedPoint].x += x-gLastMouseEvt.x; silhouettePointArray[indexSeclectedPoint].y -= y-gLastMouseEvt.y; } gLastMouseEvt.y=y; gLastMouseEvt.x=x; glutPostRedisplay(); glutPostWindowRedisplay(windowViewerIndex); }
void draw_output(char *output_name, char *input_name) { OUTPUT_DESC *output; if ((g_label >= 0) && (g_label <= 9)) { output = get_output_by_name(output_name); set_neurons(output->neuron_layer->neuron_vector, 0, output->ww * output->wh, 0); // user_set_neurons(output->neuron_layer->neuron_vector, output, g_label, NUM_COLORS - 1); fill_in_all_neurons_output_with_label(output->neuron_layer->neuron_vector, output, g_label); update_output_image(output); glutSetWindow(output->win); glutPostWindowRedisplay(output->win); } }
/* Fonction de rappel: un bouton de la souris a ete enfonce dans la fenetre 'Modeler' */ void mouseButtonModeler( int button, int state, int x, int y ) { int i; float dist; gLastMouseEvt.button = button; gLastMouseEvt.stateButton = state; if(button == GLUT_MIDDLE_BUTTON) { indexSeclectedPoint=-1; if(state == GLUT_DOWN) { for(i=0;i<nbPointsOnSilhouette;i++) { dist=sqrt(pow(x-silhouettePointArray[i].x-500/2.0,2.0)+pow(-y-silhouettePointArray[i].y+500/2.0,2.0)); if(dist<15.0) { indexSeclectedPoint=i; i=nbPointsOnSilhouette; } } } gLastMouseEvt.x = x; gLastMouseEvt.y = y; } else if(button == GLUT_LEFT_BUTTON) { /* Enregistrer le point de controle (x,y) */ if(nbPointsOnSilhouette<NB_MAX_POINTS && state==GLUT_DOWN) { silhouettePointArray[nbPointsOnSilhouette].x=(int)(x-500/2.0); silhouettePointArray[nbPointsOnSilhouette].y=(int)(500-y-500/2.0); nbPointsOnSilhouette++; } } glutPostRedisplay(); glutPostWindowRedisplay(windowViewerIndex); }
void WindowsManager::idle() { time_t now = time(NULL); time_t dt = (now-m_previous); if(dt>=1) { //printf("FPS:%i\n",m_frameCounter); m_previous = now; m_frameCounter=0; } else { m_frameCounter++; } m_dt.idle(); glutPostWindowRedisplay(m_window1); //glutPostWindowRedisplay(m_window2); }
void processMenuEvents_subWindow1(int menuChoice) { switch(menuChoice) { case MENU_CHOICE_WHITE: bg_subWindow1 = WHITE; break; case MENU_CHOICE_BLACK: bg_subWindow1 = BLACK; break; case MENU_CHOICE_RED: bg_subWindow1 = RED; break; case MENU_CHOICE_BLUE: bg_subWindow1 = BLUE; break; case MENU_CHOICE_GREEN: bg_subWindow1 = GREEN; break; } glutPostWindowRedisplay(subWindow1); }
void processMenuEvents_mainWindow(int menuChoice) { switch(menuChoice) { case MENU_CHOICE_STOP: glutIdleFunc( NULL ); break; case MENU_CHOICE_START: glutIdleFunc( myidle ); break; case MENU_CHOICE_WHITE: squareColor_mainWindow = WHITE; break; case MENU_CHOICE_RED: squareColor_mainWindow = RED; break; case MENU_CHOICE_GREEN: squareColor_mainWindow = GREEN; break; } glutPostWindowRedisplay(mainWindow); }
void draw_output(char *output_name, char *input_name) { OUTPUT_DESC *output; output = get_output_by_name(output_name); if (strcmp(output_name, "character_label_out") == 0) { if ((g_label >= 0) && (g_label <= 9)) { set_neurons(output->neuron_layer->neuron_vector, 0, output->ww * output->wh, 0); // user_set_neurons(output->neuron_layer->neuron_vector, output, g_label, NUM_COLORS - 1); fill_in_all_neurons_output_with_label(output->neuron_layer->neuron_vector, output, g_label); update_output_image(output); #ifndef NO_INTERFACE glutSetWindow(output->win); glutPostWindowRedisplay(output->win); #endif } } }
void GLWindow::Visible(int vis) { glutPostWindowRedisplay(app->main); };
void GLWindow::Resize(int w, int h) { app->resize(w, h); glutPostWindowRedisplay(app->main); };