void glut_overlay_display_func(void) { struct glut_event_t *event; event = glut_event_create(glut_event_overlay_display); event->u.keyboard.win = glutGetWindow(); glut_event_enqueue(event); }
void myGlutIdle(void) { // make sure the main window is active if (glutGetWindow() != main_window) glutSetWindow(main_window); // just keep redrawing the scene over and over glutPostRedisplay(); }
void ae_really_reshape(int w, int h) { assert(glutGetWindow() == ae_win); ae_width = w; ae_height = h; glMatrixMode(GL_PROJECTION); glViewport(0, 0, w, h); glutPostRedisplay(); glutSetWindow(disp_win); }
static void _motion(int x, int y) { if (!get_callback(glutGetWindow(), "mousedrag")) return; // TODO: get mouse buttons lua_pushinteger(LUA, x); lua_pushinteger(LUA, y); lua_call(LUA, 2, 0); }
static void _passiveMotion(int x, int y) { if (!get_callback(glutGetWindow(), "mousemove")) return; lua_pushinteger(LUA, x); lua_pushinteger(LUA, y); lua_call(LUA, 2, 0); }
static int l_window___index(lua_State* L) { luaL_getmetatable(L, INTERNAL_NAME); lua_pushvalue(L, 2); lua_gettable(L, -2); if (!lua_isnoneornil(L, -1)) return 1; if (!lua_isstring(L, 2)) return 0; const char* key = lua_tostring(L, 2); Window* win = l_toWindow(L, 1); if (get_callback(win->id, key)) return 1; int current = glutGetWindow(); glutSetWindow(win->id); if (0 == strcmp("pos", key)) { lua_createtable(L, 2, 0); lua_pushinteger(L, glutGet(GLUT_WINDOW_X)); lua_setfield(L, -2, "x"); lua_pushinteger(L, glutGet(GLUT_WINDOW_Y)); lua_setfield(L, -2, "y"); } else if (0 == strcmp("x", key)) { lua_pushinteger(L, glutGet(GLUT_WINDOW_X)); } else if (0 == strcmp("y", key)) { lua_pushinteger(L, glutGet(GLUT_WINDOW_Y)); } else if (0 == strcmp("size", key)) { lua_createtable(L, 2, 0); lua_pushinteger(L, glutGet(GLUT_WINDOW_WIDTH)); lua_setfield(L, -2, "width"); lua_pushinteger(L, glutGet(GLUT_WINDOW_HEIGHT)); lua_setfield(L, -2, "height"); } else if (0 == strcmp("width", key)) { lua_pushinteger(L, glutGet(GLUT_WINDOW_WIDTH)); } else if (0 == strcmp("height", key)) { lua_pushinteger(L, glutGet(GLUT_WINDOW_HEIGHT)); } else { lua_pushnil(L); } glutSetWindow(current); return 1; }
static void * glut_OverlayDisplayFuncCallback(void) { VALUE func = rb_ary_entry(OverlayDisplayFunc, glutGetWindow()); if (!NIL_P(func)) rb_funcall(func, call_id, 0); return NULL; }
static void _keyboard(unsigned char key, int x, int y) { if (!get_callback(glutGetWindow(), "keyboard")) return; lua_pushlstring(LUA, (const char*)(&key), 1); lua_pushinteger(LUA, x); lua_pushinteger(LUA, y); lua_call(LUA, 3, 0); }
void idle() { if(glutGetWindow() != mainWindow) { glutSetWindow(mainWindow); } prepareScene(); glutPostRedisplay(); }
void GLUTIdle(void) { // Set current window if ( glutGetWindow() != GLUTwindow ) glutSetWindow(GLUTwindow); // Redraw glutPostRedisplay(); }
status_t GlutGameMode::Enter() { display_mode* mode = _FindMatchingMode(); if (!mode) return B_BAD_VALUE; BScreen screen; if (!fActive) { // First enter: remember this workspace original mode... fGameModeWorkspace = current_workspace(); screen.GetMode(fGameModeWorkspace, &fOriginalMode); } // Don't make it new default mode for this workspace... status_t status = screen.SetMode(fGameModeWorkspace, mode, false); if (status != B_OK) return status; // Retrieve the new active display mode, which could be // a sligth different than the one we asked for... screen.GetMode(fGameModeWorkspace, &fCurrentMode); if (!fGameModeWindow) { // create a new window fPreviousWindow = glutGetWindow(); fGameModeWindow = glutCreateWindow("glutGameMode"); if (!fGameModeWindow) return Leave(); } else // make sure it's the current window glutSetWindow(fGameModeWindow); BDirectWindow *directWindow = dynamic_cast<BDirectWindow*>(gState.currentWindow->Window()); if (directWindow == NULL) // Hum?! return B_ERROR; // Give it some useless title, except for debugging (thread name). BString name; name << "Game Mode " << fCurrentMode.virtual_width << "x" << fCurrentMode.virtual_height << ":" << _GetModePixelDepth(&fCurrentMode) << "@" << _GetModeRefreshRate(&fCurrentMode); // force the game mode window to fullscreen directWindow->Lock(); directWindow->SetTitle(name.String()); directWindow->SetFullScreen(true); directWindow->Unlock(); fDisplayChanged = true; fActive = true; return B_OK; }
void gfnhDrawCompleteDataLogLTrace(void) { glColor3fv(gWindowsSettings[glutGetWindow()]->ColorScheme->Series[0]); gfduDrawSlidingTrace(gCompleteDataLogLike); gfmDrawXYAxes(); }
// Redraw on expose events. void expose_cb(void) { glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); scenemanager[winid2idx(glutGetWindow())]->render(); glutSwapBuffers(); }
void mui_glutmotion(int x, int y) { Window win = &winList[glutGetWindow()-1]; muiSetActiveUIList(win->uilist); if (win->mbleft == 0) return; muiHandleEvent(MUI_DEVICE_DOWN, 0, x, win->mui_ysize-y); glutPostRedisplay(); }
Window::Ptr getCurrentWindow() { WindowsBimap::left_map::iterator found = windows.left.find(glutGetWindow()); if (found == windows.left.end() || found->second->getState() != Window::CREATED) { return Window::Ptr(); } else { return found->second; } }
// Find the current WindowData SubWindowData *GetCurrentSubWindowData() { int i, currWinID; currWinID = glutGetWindow(); for (i = 0; i < 2; i++) if (g_SubWindowData[i].WinID == currWinID) return &g_SubWindowData[i]; return NULL; }
void oak::Window::resizeCb(int width, int height) { Window* window = _windowMap[glutGetWindow()]; glViewport(0, 0, width, height); window->resizeEvent(width, height); if (window->_resizeFunc) window->_resizeFunc(window, width, height); }
inline GlutWindow* GlutWindow::current() { int id = glutGetWindow(); for (unsigned int i = 0; i < mWinIDs.size(); i++) { if (mWinIDs.at(i) == id) { return mWindows.at(i); } } std::cout << "An unknown error occured!" << std::endl; exit(0); }
void myGlutIdle(void) { /* According to the GLUT specification, the current window is undefined during an idle callback. So we need to explicitly change it if necessary */ if (glutGetWindow() != main_window) glutSetWindow(main_window); glutPostRedisplay(); }
// Reconfigure on changes to window dimensions. void reshape_cb(int w, int h) { int idx = winid2idx(glutGetWindow()); scenemanager[idx]->setWindowSize(SbVec2s(w, h)); scenemanager[idx]->setSize(SbVec2s(w, h)); scenemanager[idx]->setViewportRegion(SbViewportRegion(w, h)); scenemanager[idx]->scheduleRedraw(); }
void VCGLUTNativeWindow::motion(int x, int y) { int id = glutGetWindow(); VCGLUTNativeWindow *window = findWindow(id); if(window) { window->sendMouseWindowEvent(x, y, -1, 0); glutPostRedisplay(); } }
inline GlutWindow *GlutWindow::getGlutWindow() { int gWindowID = glutGetWindow(); if (gWindowID < MAX_GLUT_WINDOWS && gWindowID >= 0 && glutWindows[gWindowID] != NULL) { return glutWindows[gWindowID]; } else { std::cerr << "Invalid GLUT Window ID: " << gWindowID << std::endl; return NULL; } }
void glWindow::queryFrame() { if ( !ipc.isNewFrameAvailable() ) return; /* We have a new frame. Let glut now that this window needs repainting. */ if ( win_id != glutGetWindow() ) glutSetWindow( win_id ); glutPostRedisplay(); }
void displayGLUT() { if (glutGetWindow() != g_window_handle){ return; } glClearColor(0.f, 0.5f, 0.5f, 1.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); drawGLUT(); glutSwapBuffers(); }
/* Calculates the time taken to render the previous frame and uses the calculation to calculate the fps. Afterward it puts it in the titlestring and gives it to GLUT for the window. */ void updateFPS(void) { if(!c->fullscr && glutGetWindow() != 0) { currentTime = glutGet(GLUT_ELAPSED_TIME); sprintf(titleString, "FPS: %2.2f", (1000/float(currentTime-previousTime))); glutSetWindowTitle(titleString); previousTime = currentTime; } }
void keypress(unsigned char key, int x, int y) { switch (key) { case 27: /*ESC*/ glutDestroyWindow(glutGetWindow()); exit(0); break; } }
void GLUTWindow::activate(void) { if((_sfDrawMode.getValue() & PartitionDrawMask) == SequentialPartitionDraw) { if(glutGetWindow() != getGlutId()) glutSetWindow(getGlutId()); Inherited::doActivate(); } }
static void mui_Reshape(int width, int height) { Window win = &winList[glutGetWindow()-1]; win->mui_xorg = glutGet(GLUT_WINDOW_X); win->mui_yorg = glutGet(GLUT_WINDOW_Y); win->mui_xsize = width; win->mui_ysize = height; glViewport(0, 0, win->mui_xsize, win->mui_ysize); }
GLView* GLView::GetActiveGLView() { const int handle = glutGetWindow(); const unsigned size = inherited_views_.size(); for (unsigned i = 0; i < size; ++i) { if (inherited_views_[i]->window_handle_ == handle) { return inherited_views_[i]; } } return 0; }
void MeshGui::idle( void ) { // According to the GLUT specification, the current window is undefined during an idle callback. So we need to explicitly change it if necessary if ( glutGetWindow() != main_window ) { glutSetWindow(main_window); } // GLUI_Master.sync_live_all(); -- not needed - nothing to sync in this application glutPostRedisplay(); }