//---------------------------------------------------------------------------- // Callback method called when system is idle. void Window::idleCallback(void) { delta_time = calculateDeltaTime(); root->update(delta_time); displayCallback(); // call display routine to redraw cube }
void DemoApplication::moveAndDisplay() { if (!m_idle) clientMoveAndDisplay(); else displayCallback(); }
void bulletBaseApp::moveAndDisplay() { if (!m_idle) clientMoveAndDisplay(); else displayCallback(); }
//---------------------------------------------------------------------------- // Callback method called when system is idle. void Window::idleCallback(void) { // Process Mouse input glutMouseFunc(Window::onLButtonDown); glutMotionFunc(Window::motionTracker); displayCallback(); // call display routine to re-draw cube }
//---------------------------------------------------------------------------- // Callback method called when system is idle. // This is called at the start of every new "frame" (qualitatively) void Window::idleCallback() { //Set up a static time delta for update calls Globals::updateData.dt = 1.0/60.0;// 60 fps //Call the display routine to draw the sphere displayCallback(); }
void reshapeCallback(GLsizei w, GLsizei h) { resolution.x = w; resolution.y = h; glViewport(0, 0, w, h); updateProjection(); displayCallback(); }
void reshapeCallback(GLsizei w, GLsizei h) { resolution.x = w; resolution.y = h; glViewport(0, 0, w, h); #ifndef TEST_PROJECTION_MORPHING updateProjection(); #endif displayCallback(); }
//---------------------------------------------------------------------------- // Callback method called when system is idle. // This is called at the start of every new "frame" (qualitatively) void Window::idleCallback() { //Set up a static time delta for update calls Globals::updateData.dt = 1.0/60.0;// 60 fps //Rotate cube; if it spins too fast try smaller values and vice versa Globals::cube.spin(spin_flag); //Call the update function on cube Globals::cube.update(Globals::updateData); //Call the display routine to draw the cube displayCallback(); }
void DoublePrecisionDemo::clientMoveAndDisplay() { displayCallback(); }
//to be implemented by the demo void LinearConvexCastDemo::clientMoveAndDisplay() { displayCallback(); }
void CollisionInterfaceDemo::clientMoveAndDisplay() { displayCallback(); }
//---------------------------------------------------------------------------- // Callback method called when system is idle. // This is called at the start of every new "frame" (qualitatively) void Window::idleCallback() { //Set up a static time delta for update calls Globals::updateData.dt = 1.0/60.0;// 60 fps if (time1 >= 1.0){ time1 = 0.0; } if (time2 >= 1.0){ time2 = 0.0; } if (time3 >= 1.0){ time3 = 0.0; } camera_pos = Globals::camera_c->move(time1); if (flag == true){ Globals::camera->e = camera_pos; Globals::camera->update(); } Vector3 pos = Globals::explosive_c->move(time1); Matrix4 newpos_matrix; newpos_matrix.makeTranslate(pos[0], pos[1], pos[2]); trans_exp->setMatrix(newpos_matrix); if (!explodeMars) { calcPos(Globals::mars_c->move(time2), trans_m, Globals::mars); } if (!explodeSaturn) { calcPos(Globals::saturn_c->move(time1), trans_sa, Globals::saturn); } if (!explodeSun) { calcPos(Globals::sun_c->move(time3), trans_s, Globals::sun); } if (collision_switch) { calcPos(Globals::mars_ac->move(time2), trans_mr, Globals::asteriod_mars); calcPos(Globals::saturn_ac->move(time1), trans_sar, Globals::asteriod_saturn); calcPos(Globals::sun_ac->move(time3), trans_sr, Globals::asteriod_sun); if (Globals::mars->getBbox().detectCollision(Globals::mars->getBbox(), Globals::asteriod_mars->getBbox())){ explodeMars = true; trans_m->addChild(Globals::marsSystem); trans_m->removeChild(Globals::mars); trans_mr->removeChild(Globals::asteriod_mars); } if (Globals::sun->getBbox().detectCollision(Globals::sun->getBbox(), Globals::asteriod_sun->getBbox())){ explodeSun = true; trans_s->addChild(Globals::sunSystem); trans_s->removeChild(Globals::sun); trans_sr->removeChild(Globals::asteriod_sun); } if (Globals::saturn->getBbox().detectCollision(Globals::saturn->getBbox(), Globals::asteriod_saturn->getBbox())){ explodeSaturn = true; trans_sa->addChild(Globals::saturnSystem); trans_sa->removeChild(Globals::saturn); trans_sar->removeChild(Globals::asteriod_saturn); } } time1 += 0.005; time2 += 0.004; time3 += 0.003; Globals::camera->update(); //Call the display routine to draw the cube displayCallback(); }
void btContinuousConvexCollisionDemo::clientMoveAndDisplay() { displayCallback(); }
void GLFWOSPRayWindow::display() { // clock used to compute frame rate static auto displayStart = std::chrono::high_resolution_clock::now(); if (showUi && uiCallback) { ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize; ImGui::Begin( "Tutorial Controls (press 'g' to hide / show)", nullptr, flags); uiCallback(); ImGui::End(); } // if a display callback has been registered, call it if (displayCallback) { displayCallback(this); } // render OSPRay frame ospRenderFrame(framebuffer, renderer, OSP_FB_COLOR | OSP_FB_ACCUM); // map OSPRay frame buffer, update OpenGL texture with its contents, then // unmap uint32_t *fb = (uint32_t *)ospMapFrameBuffer(framebuffer, OSP_FB_COLOR); glBindTexture(GL_TEXTURE_2D, framebufferTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, windowSize.x, windowSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, fb); ospUnmapFrameBuffer(fb, framebuffer); // clear current OpenGL color buffer glClear(GL_COLOR_BUFFER_BIT); // render textured quad with OSPRay frame buffer contents glBegin(GL_QUADS); glTexCoord2f(0.f, 0.f); glVertex2f(0.f, 0.f); glTexCoord2f(0.f, 1.f); glVertex2f(0.f, windowSize.y); glTexCoord2f(1.f, 1.f); glVertex2f(windowSize.x, windowSize.y); glTexCoord2f(1.f, 0.f); glVertex2f(windowSize.x, 0.f); glEnd(); if (showUi && uiCallback) { ImGui::Render(); } // swap buffers glfwSwapBuffers(glfwWindow); // display frame rate in window title auto displayEnd = std::chrono::high_resolution_clock::now(); auto durationMilliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(displayEnd - displayStart); displayStart = displayEnd; const float frameRate = 1000.f / float(durationMilliseconds.count()); std::stringstream windowTitle; windowTitle << "OSPRay: " << std::setprecision(3) << frameRate << " fps"; glfwSetWindowTitle(glfwWindow, windowTitle.str().c_str()); }
void Raytracer::clientMoveAndDisplay() { displayCallback(); }
void SimplexDemo::clientMoveAndDisplay() { displayCallback(); }
int main(int argc, char* argv[]) { //#ifdef __MINGW32__ // WORD versionWanted = MAKEWORD(1, 1); // WSADATA wsaData; // WSAStartup(versionWanted, &wsaData); //#endif char ncwd[strlen(argv[0]) + 1]; memcpy(ncwd, argv[0], strlen(argv[0]) + 1); char* ecwd = #ifdef __MINGW32__ strrchr(ncwd, '\\'); #else strrchr(ncwd, '/'); #endif if (ecwd != NULL) { ecwd++; ecwd[0] = 0; chdir(ncwd); } printf("Loading... [FROM=%s]\n", ncwd); main_preinit(); width = 800; height = 600; if (!glfwInit()) return -1; glfwWindowHint(GLFW_DOUBLEBUFFER, 1); //glfwWindowHint(GLFW_SAMPLES, 4); // antialiasing glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwSetErrorCallback(__error_callback); window = glfwCreateWindow(800, 600, windowTitle, NULL, NULL); if (!window) { glfwTerminate(); return -1; } glfwMakeContextCurrent (window); glewExperimental = GL_TRUE; GLenum err = glewInit(); if (err != GLEW_OK) { printf("GLEW Init error: %s\n", glewGetErrorString(err)); glfwTerminate(); return -1; } if (!glewIsSupported("GL_VERSION_2_1") || !glewIsSupported("GL_ARB_vertex_program")) { printf("OpenGL version 2.1+ or GL_ARB_vertex_program not satisfied.\n"); glfwTerminate(); return -1; } printf("OpenGL Version: %s\n", glGetString(GL_VERSION)); glfwSetInputMode(window, GLFW_STICKY_KEYS, 1); main_init(); __gui_load(); guistate_set(0); clock_gettime(CLOCK_MONOTONIC, &__main_ts); __main_lt = (double) __main_ts.tv_sec * 1000. + (double) __main_ts.tv_nsec / 1000000.; __main_lf = __main_lt; glfwSetKeyCallback(window, __gui_keyboardCallback); glfwSetCharCallback(window, __gui_textCallback); glfwSetCursorPosCallback(window, __gui_mouseMotionCallback); glfwSetMouseButtonCallback(window, __gui_mouseCallback); glfwSetScrollCallback(window, __gui_scrollCallback); printf("Loaded.\n"); while (!glfwWindowShouldClose(window)) { displayCallback(); glfwSwapBuffers(window); glfwSwapInterval(1); glfwPollEvents(); } glfwTerminate(); return 0; }