int APIENTRY glutGet (GLenum type) { switch (type) { case GLUT_WINDOW_X: return _glut_current->xpos; case GLUT_WINDOW_Y: return _glut_current->ypos; case GLUT_WINDOW_WIDTH: return _glut_current->width; case GLUT_WINDOW_HEIGHT: return _glut_current->height; case GLUT_WINDOW_STENCIL_SIZE: return _glut_visual.stencil; case GLUT_WINDOW_DEPTH_SIZE: return _glut_visual.depth; case GLUT_WINDOW_RGBA: return !(_glut_default.mode & GLUT_INDEX); case GLUT_WINDOW_COLORMAP_SIZE: return (_glut_default.mode & GLUT_INDEX) ? (256 - RESERVED_COLORS) : 0; case GLUT_SCREEN_WIDTH: return _glut_visual.geometry[0]; case GLUT_SCREEN_HEIGHT: return _glut_visual.geometry[1]; case GLUT_INIT_WINDOW_X: return _glut_default.x; case GLUT_INIT_WINDOW_Y: return _glut_default.y; case GLUT_INIT_WINDOW_WIDTH: return _glut_default.width; case GLUT_INIT_WINDOW_HEIGHT: return _glut_default.height; case GLUT_INIT_DISPLAY_MODE: return _glut_default.mode; case GLUT_ELAPSED_TIME: #if FREQUENCY if (!timer_installed) { timer_installed = GL_TRUE; LOCKDATA(ticks); LOCKFUNC(ticks_timer); pc_install_int(ticks_timer, NULL, FREQUENCY); } return ticks * 1000 / FREQUENCY; #else if (!timer_installed) { timer_installed = GL_TRUE; gettimeofday(&then, NULL); return 0; } else { struct timeval now; gettimeofday(&now, NULL); return (now.tv_usec - then.tv_usec) / 1000 + (now.tv_sec - then.tv_sec) * 1000; } #endif default: return -1; } }
int _glfwInitEvents( void ) { int fifosize; // Allocate memory for the event FIFO buffer fifosize = _GLFW_EVENT_BUFFER_SIZE * sizeof(_GLFWdosevent); _glfwEventBuffer.Event = malloc( fifosize ); if( !_glfwEventBuffer.Event ) { return 0; } // Lock data & functions LOCKBUFF( _glfwEventBuffer.Event, fifosize ); LOCKDATA( _glfwEventBuffer ); LOCKFUNC( _glfwPostDOSEvent ); // Initialize event FIFO _glfwEventBuffer.Start = _glfwEventBuffer.End = 0; _glfwEventsInitialized = 1; return 1; }