void GraspTest::displayCallback(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (m_dynamicsWorld) m_dynamicsWorld->debugDrawWorld(); // drawLimit(); renderme(); glFlush(); swapBuffers(); }
void StelAppGraphicsWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { // Don't even try to draw if we don't have a core yet (fix a bug during splash screen) if (!stelApp || !stelApp->getCore() || !doPaint) return; StelPainter::setQPainter(painter); if (useBuffers) { StelPainter::makeMainGLContextCurrent(); initBuffers(); backgroundBuffer->bind(); QPainter* pa = new QPainter(backgroundBuffer); StelPainter::setQPainter(pa); // If we are using the gui, then we try to have the best reactivity, even if we need to lower the fps for that. int minFps = StelApp::getInstance().getGui()->isCurrentlyUsed() ? 16 : 2; while (true) { bool keep = paintPartial(); if (!keep) // The paint is done { delete pa; backgroundBuffer->release(); swapBuffers(); break; } double spentTime = StelApp::getTotalRunTime() - previousPaintFrameTime; if (1. / spentTime <= minFps) // we spent too much time { // We stop the painting operation for now delete pa; backgroundBuffer->release(); break; } } Q_ASSERT(!backgroundBuffer->isBound()); Q_ASSERT(!foregroundBuffer->isBound()); // Paint the last completed painted buffer StelPainter::setQPainter(painter); viewportEffect->paintViewportBuffer(foregroundBuffer); } else { while (paintPartial()) {;} } StelPainter::setQPainter(NULL); previousPaintFrameTime = StelApp::getTotalRunTime(); }
void createWindow(char* windowName, int boardSize, MouseListener l) { int windowSize = 2*BOARD_PADDING + boardSize * TILE_SIZE; initwindow(windowSize, windowSize, windowName); setbkcolor(LIGHTGRAY); clearScreen(); swapBuffers(); mouseClickListener.l = l; // register mouse listeners registermousehandler(WM_LBUTTONDOWN, mouseDown); registermousehandler(WM_LBUTTONUP, mouseUp); registermousehandler(WM_MOUSEMOVE, mouseMove); }
//----------------------------------------------------------------------- void RenderTarget::update(bool swap) { OgreProfileBeginGPUEvent("RenderTarget: " + getName()); // call implementation updateImpl(); if (swap) { // Swap buffers swapBuffers(); } OgreProfileEndGPUEvent("RenderTarget: " + getName()); }
void BulletOpenGLViewer::displayCallback() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (m_dynamicsWorld) { m_dynamicsWorld->debugDrawWorld(); } renderme(); glFlush(); swapBuffers(); }
void SceneDisplayerWidget::paintGL() { if(sceneDisplayer!=nullptr) { sceneDisplayer->paint(); }else { glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.1f, 0.05f, 0.1f, 1.0f); } swapBuffers(); update(); }
void GLWidget::Draw() { setRotate(); GLfloat length = 2.0; int i,j,k; glPushMatrix(); for( i = -1; i <= 1; i++) for( j = -1; j <= 1; j++) for( k = -1; k <= 1; k++) { glPushMatrix(); glTranslatef(length*i*1.05,length*j*1.05,length*k*1.05); cube(length); glPopMatrix(); } glPopMatrix(); swapBuffers(); ///////////////////////////////// /* glPushMatrix(); glBegin( GL_QUADS ); glColor3f( 0.0, 1.0, 0.0 ); glVertex3f( 1.0, 1.0, -1.0 ); glVertex3f( -1.0, 1.0, -1.0 ); glVertex3f( -1.0, 1.0, 1.0 ); glVertex3f( 1.0, 1.0, 1.0 );glColor3f( 1.0, 0.5, 0.0 ); glVertex3f( 1.0, -1.0, 1.0 ); glVertex3f( -1.0, -1.0, 1.0 ); glVertex3f( -1.0, -1.0, -1.0 ); glVertex3f( 1.0, -1.0, -1.0 );glColor3f( 1.0, 0.0, 0.0 ); glVertex3f( 1.0, 1.0, 1.0 ); glVertex3f( -1.0, 1.0, 1.0 ); glVertex3f( -1.0, -1.0, 1.0 ); glVertex3f( 1.0, -1.0, 1.0 );glColor3f( 1.0, 1.0, 0.0 ); glVertex3f( 1.0, -1.0, -1.0 ); glVertex3f( -1.0, -1.0, -1.0 ); glVertex3f( -1.0, 1.0, -1.0 ); glVertex3f( 1.0, 1.0, -1.0 );glColor3f( 0.0, 0.0, 1.0 ); glVertex3f( -1.0, 1.0, 1.0 ); glVertex3f( -1.0, 1.0, -1.0 ); glVertex3f( -1.0, -1.0, -1.0 ); glVertex3f( -1.0, -1.0, 1.0 );glColor3f( 1.0, 0.0, 1.0 ); glVertex3f( 1.0, 1.0, -1.0 ); glVertex3f( 1.0, 1.0, 1.0 ); glVertex3f( 1.0, -1.0, 1.0 ); glVertex3f( 1.0, -1.0, -1.0 ); glEnd(); glPopMatrix(); */ }
void ConvexDecompositionDemo::displayCallback(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (m_dynamicsWorld) m_dynamicsWorld->debugDrawWorld(); renderme(); glFlush(); swapBuffers(); }
bool Window::_cmdSwap( co::Command& command ) { const WindowSwapPacket* packet = command.get< WindowSwapPacket >(); LBLOG( LOG_TASKS ) << "TASK swap buffers " << getName() << " " << packet << std::endl; if( getDrawableConfig().doublebuffered ) { // swap WindowStatistics stat( Statistic::WINDOW_SWAP, this ); makeCurrent(); swapBuffers(); } return true; }
//----------------------------------------------------------------------------- void MainWindow::paintGL() { gr->Clf(); gr->SubPlot(1,1,0); gr->Rotate(40,60); gr->Light(true); gr->AddLight(0,mglPoint(0,0,10),mglPoint(0,0,-1)); gr->Axis(); gr->Box(); gr->FPlot("sin(pi*x)","i2"); gr->FPlot("cos(pi*x)","|"); gr->FSurf("cos(2*pi*(x^2+y^2))"); gr->Finish(); swapBuffers(); }
void QGLBlitter::SubWidget::paintGL() { clear = 2; if (reinterpret_cast<const QGLBlitter*>(parentWidget())->isPaused()) { // if (swapInterval) // blitFront(); // else { if (!blitted) blit(); swapBuffers(); blitted = false; // } } }
void Context::startLoop() { Info() << "Context initializing renderloop."; m_loop->initialize(*this); Info() << "Starting render loop."; do { m_loop->render(); swapBuffers(); pollEvents(); } while (!windowShouldClose()); Info() << "Renderloop exited."; }
void GLWidgetRenderer::paintGL() { DPTR_D(GLWidgetRenderer); /* we can mix gl and qpainter. * QPainter painter(this); * painter.beginNativePainting(); * gl functions... * painter.endNativePainting(); * swapBuffers(); */ handlePaintEvent(); swapBuffers(); if (d.painter && d.painter->isActive()) d.painter->end(); }
void GemWindow::render(void){ if(!makeCurrent()) { error("unable to switch to current window (do you have one?), cannot render!"); return; } if(!pushContext()) { error("unable to switch to current context, cannot render!"); return; } bang(); if(m_buffer==2) swapBuffers(); popContext(); }
void tgSimViewGraphics::displayCallback() { if (isInitialzed()) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderme(); // optional but useful: debug drawing to detect problems if (m_dynamicsWorld) { m_dynamicsWorld->debugDrawWorld(); } glFlush(); swapBuffers(); } }
void BasicDemo::displayCallback(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderme(); renderSurfacePoints(); //optional but useful: debug drawing to detect problems if (m_dynamicsWorld) m_dynamicsWorld->debugDrawWorld(); glFlush(); swapBuffers(); }
void MyWindow::displayFunc() { glClearColor(1.0f, 1.0f, 1.0f, 0.1f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); my_cam->update(); glDepthFunc(GL_LESS); drawBackground(); glDepthRange(0,1000); drawAxis(); drawCurs(); swapBuffers(); glFlush(); }
void View::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glDisable(GL_LIGHTING); renderScene(); swapBuffers(); glEnable(GL_LIGHTING); }
void MyWindow::display() { WindowInertiaCamera::display(); glClearColor(0.4f,0.0f,0.0f,0.0f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // // timing for frames // //ViewerStates::realtime.update(true); ViewerStates::fTime += (float)m_realtime.frameDT; // // SCENE-LEVEL TEST // nvFX::PassInfo pr; memset(&pr, 0, sizeof(pr)); if(fx_TechScene) { int np = fx_TechScene->getNumPasses(); for(int i=0; i<np; i++) { nvFX::IPass* scenePass = fx_TechScene->getPass(i, &pr); if(!pr.bActive) continue; if(!scenePass->isValidated()) { continue; } pr.renderingGroup = 0; // set back to 0 before each pass. So no persistent value across passes scenePass->execute(&pr); iResolution->updateValue3f((float)m_W, (float)m_H, 0, scenePass); iGlobalTime->updateValue1f(ViewerStates::fTime, scenePass); iMouse->updateValue4fv(m_mouse, scenePass); //iDate = fx_EffectScene->findUniform("iDate"); //iSampleRate = fx_EffectScene->findUniform("iSampleRate"); switch(pr.renderingMode) { default: break; } glUseProgram(0); } } // Draw tweak bars #ifdef USEANTTWEAKBAR //TwDraw(); #endif swapBuffers(); }
void CanvasContext::draw() { LOG_ALWAYS_FATAL_IF(!mCanvas || mEglSurface == EGL_NO_SURFACE, "drawRenderNode called on a context with no canvas or surface!"); profiler().markPlaybackStart(); SkRect dirty; mDamageAccumulator.finish(&dirty); EGLint width, height; mEglManager.beginFrame(mEglSurface, &width, &height); if (width != mCanvas->getViewportWidth() || height != mCanvas->getViewportHeight()) { mCanvas->setViewport(width, height); dirty.setEmpty(); } else if (!mDirtyRegionsEnabled || mHaveNewSurface) { dirty.setEmpty(); } else { if (!dirty.isEmpty() && !dirty.intersect(0, 0, width, height)) { ALOGW("Dirty " RECT_STRING " doesn't intersect with 0 0 %d %d ?", SK_RECT_ARGS(dirty), width, height); dirty.setEmpty(); } profiler().unionDirty(&dirty); } status_t status; if (!dirty.isEmpty()) { status = mCanvas->prepareDirty(dirty.fLeft, dirty.fTop, dirty.fRight, dirty.fBottom, mOpaque); } else { status = mCanvas->prepare(mOpaque); } Rect outBounds; status |= mCanvas->drawRenderNode(mRootRenderNode.get(), outBounds); profiler().draw(mCanvas); mCanvas->finish(); profiler().markPlaybackEnd(); if (status & DrawGlInfo::kStatusDrew) { swapBuffers(); } profiler().finishFrame(); }
void BenchmarkDemo::displayCallback(void) { #ifdef USE_GRAPHICAL_BENCHMARK glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderme(); //optional but useful: debug drawing to detect problems if (m_dynamicsWorld) m_dynamicsWorld->debugDrawWorld(); glFlush(); swapBuffers(); #endif //USE_GRAPHICAL_BENCHMARK }
bool Window::_cmdSwap( co::ICommand& cmd ) { co::ObjectICommand command( cmd ); LBLOG( LOG_TASKS ) << "TASK swap buffers " << getName() << " " << command << std::endl; if( getDrawableConfig().doublebuffered ) { // swap WindowStatistics stat( Statistic::WINDOW_SWAP, this ); makeCurrent(); swapBuffers(); } return true; }
void PostComposer::passDistortion() { writeBuffer->bind(); glClear(GL_COLOR_BUFFER_BIT); shaderDistortion->bind(); shaderFXAA->transmitUniform("resolution", 1 / widthf, 1 / heightf); readBuffer->bindAndTransmitTextures(shaderDistortion); quad->draw(shaderDistortion->attribute("position")); writeBuffer->unbind(); swapBuffers(); }
bool SDLwindow::oneStep() { if (!initialized){ // init() must be executed in the thread where draw() is called init(); } double startT = SDL_GetTicks(); if (!processEvents()) return false; draw(); swapBuffers(); double dt = SDL_GetTicks() - startT; if (dt < 1000.0/30){ SDL_Delay(1000.0/30 - dt); } return true; }
int main(int argc, char* argv[]) { auto device = RenderDevice::getInstance(); device->init(); device->setQuitOnStart(true); Text text(30.0f); text.setString("Random color"); // Create a thread that changes the text color every second Thread thread([&](void*) { while(device->isRunning()) { text.setColor(Color::Random()); Thread::sleep(Time::seconds(1)); } }); // Start the thread thread.start(); while(device->isRunning()) { device->setTargetScreen(Screen::Top); device->clear(Color::Black); device->startFrame(); text.draw(); device->endFrame(); device->setTargetScreen(Screen::Bottom); device->clear(Color::Black); device->startFrame(); device->endFrame(); device->swapBuffers(); } // Wait the thread end thread.join(); // DON'T FORGET TO CALL THIS OR THE 3DS WILL CRASH AT EXIT device->destroy(); return 0; }
int main(int argc, char* argv[]) { // Get device singleton instance. auto device = RenderDevice::getInstance(); device->init(); device->setQuitOnStart(true); // Create a rectangle shape RectangleShape rect(100, 60, 100, 100); // And we set it's color to blue rect.setColor(Color::Blue); rect.setOutlineColor(Color::Red); rect.setOutlineThickness(2); // Create a line LineShape line(0, 0, BOTTOM_SCREEN_WIDTH, BOTTOM_SCREEN_HEIGHT); // And set its color to yellow line.setColor(Color::Yellow); // Main loop while(device->isRunning()) { device->setTargetScreen(Screen::Top); device->clear(Color::Black); device->startFrame(); // Draw the rectangle to top screen rect.draw(); device->endFrame(); device->setTargetScreen(Screen::Bottom); device->clear(Color::Black); device->startFrame(); // Draw a diagonal line on bottom screen line.draw(); device->endFrame(); device->swapBuffers(); } // DON'T FORGET TO CALL THIS OR THE 3DS WILL CRASH AT EXIT device->destroy(); return 0; }
void SerializeDemo::clientMoveAndDisplay() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //simple dynamics world doesn't handle fixed-time-stepping float ms = getDeltaTimeMicroseconds(); ///step the simulation if (m_dynamicsWorld) { m_dynamicsWorld->stepSimulation(ms / 1000000.f); #ifdef DESERIALIZE_SOFT_BODIES if (fSoftBodySolver) fSoftBodySolver->copyBackToSoftBodies(); #endif m_dynamicsWorld->debugDrawWorld(); #ifdef DESERIALIZE_SOFT_BODIES if (m_dynamicsWorld->getWorldType()==BT_SOFT_RIGID_DYNAMICS_WORLD) { //optional but useful: debug drawing btSoftRigidDynamicsWorld* softWorld = (btSoftRigidDynamicsWorld*)m_dynamicsWorld; for ( int i=0;i<softWorld->getSoftBodyArray().size();i++) { btSoftBody* psb=(btSoftBody*)softWorld->getSoftBodyArray()[i]; if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe))) { btSoftBodyHelpers::DrawFrame(psb,softWorld->getDebugDrawer()); btSoftBodyHelpers::Draw(psb,softWorld->getDebugDrawer(),softWorld->getDrawFlags()); } } } #endif //DESERIALIZE_SOFT_BODIES } renderme(); glFlush(); swapBuffers(); }
void PendulumApplication::clientMoveAndDisplay() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //simple dynamics world doesn't handle fixed-time-stepping float dt = getDeltaTimeMicroseconds()/1000000.f; ///step the simulation if (m_dynamicsWorld) { m_dynamicsWorld->stepSimulation(dt); //optional but useful: debug drawing m_dynamicsWorld->debugDrawWorld(); } renderme(); swapBuffers(); }
void Render::paintGL() { glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-getFrustWidth(), getFrustWidth(), -getFrustHeight(), getFrustHeight(), mFrustNear, mFrustFar); glTranslatef(-mCamPoint.x(),-mCamPoint.y(),-mCamPoint.z()); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); float conv[16]; rotToFloatArray(conv); glMultMatrixf(conv); /*float xt = -3; float xf = 3; float yf = -3; float yt = 3; float z = 0;*/ glColor4f(1, 1, 1, 1); glLineWidth(10); glBegin(GL_LINES); glVertex3f(mCamOldPoint.x(),mCamOldPoint.y(),mCamOldPoint.z()); glVertex3f(mCamOldPoint.x() + mSelectionDir.x(), mCamOldPoint.y() + mSelectionDir.y(), mCamOldPoint.z() + mSelectionDir.z()); glEnd(); glColor4f(1, 0, 0, 1); glLineWidth(10); glBegin(GL_LINES); glVertex3f(mCamOldPoint.x() + mSelectionDir.x(), mCamOldPoint.y() + mSelectionDir.y(), mCamOldPoint.z() + mSelectionDir.z()); glVertex3f(mCamOldPoint.x() + mSelectionDir.x()*2, mCamOldPoint.y() + mSelectionDir.y()*2, mCamOldPoint.z() + mSelectionDir.z()*2); glEnd(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor3f(1,1,1); mMesh.draw(0,0,0, false, true); /* glBegin(GL_QUADS); glVertex3f(xf,yt,z); glVertex3f(xf,yf,z); glVertex3f(xt,yf,z); glVertex3f(xt,yt,z); glEnd();*/ glFlush(); glFinish(); swapBuffers(); }
void ConvexDecompositionDemo::clientMoveAndDisplay() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); float dt = getDeltaTimeMicroseconds() * 0.000001f; m_dynamicsWorld->stepSimulation(dt); //optional but useful: debug drawing m_dynamicsWorld->debugDrawWorld(); renderme(); glFlush(); swapBuffers(); }