void RigidBody::draw(Interface* interface) { ResourceManager* rm = interface->getResourceManager(); if(!rm || !isVisible()) { return; } Visual& model = getVisual(); if(!&model) { return; } if(!body_) { Object::draw(interface); return; } glPushMatrix(); btScalar m[16]; btTransform &transform = body_->getWorldTransform(); transform.getOpenGLMatrix(m); glMultMatrixf(m); /*glDisable(GL_LIGHTING); drawCube(); glEnable(GL_LIGHTING);*/ preDraw(interface); model.draw(interface); postDraw(interface); glPopMatrix(); }
void GlutApp::drawFunc() { update(); preDraw(); draw(); postDraw(); }
void KnotsViewer::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter painter; painter.begin(this); painter.setRenderHint(QPainter::Antialiasing); // Save current OpenGL state glPushAttrib(GL_ALL_ATTRIB_BITS); glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); // Classical 3D drawing, usually performed by paintGL(). preDraw(); draw(); postDraw(); // Restore OpenGL state glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glPopAttrib(); if(bcurvature_show) draw_curvature_colorbar(&painter); if (berrordomainview) draw_curvature_error_colorbar(&painter); if (berror_show) draw_fitting_error_colorbar(&painter); painter.end(); swapBuffers( ); }
void B2Thread::run() { init(); float32 timeStep = 1.0f / 60.0f; int32 velocityIterations = 8; int32 positionIterations = 3; QElapsedTimer timer; timer.start(); for(int step = 0; m_playing; ++step){ { QMutexLocker locker(&m_mutex); m_b2world.Step(timeStep, velocityIterations, positionIterations); } emit preDraw(); { QMutexLocker locker(&m_mutex); m_b2world.DrawDebugData(); } qint64 remain = static_cast<qint64>(step * timeStep * 1000.0f - timer.elapsed()); if(remain > 0){ msleep(remain); } emit postDraw(); } }
void PocketViewer::mousePressEvent(QMouseEvent *e){ if(m_processor->powerDiagram == NULL){ QGLViewer::mousePressEvent(e); return; } PowerDiagram * pd = m_processor->powerDiagram; if(e->button()== Qt::MidButton || e->button()== Qt::RightButton){ preDraw(); pd->drawNodesForPicking(); int select = pd->processPick(e->x(), e->y(), camera()); if(select>=0){ if(e->button()== Qt::MidButton){ pd->setStartVertex(select); m_processor->proteinRenderer->makeDisplayList(); startLabel->setText(QString::number(select)); } if(e->button()== Qt::RightButton){ pd->setTargetVertex(select); m_processor->proteinRenderer->makeDisplayList(); targetLabel->setText(QString::number(select)); } } init(); } QGLViewer::mousePressEvent(e); }
//-------------------------------------------------------------- void Page::draw() { preDraw(); fillDraw(); meshDraw(); postDraw(); }
void Environment::step(btScalar dt, int maxSubSteps, btScalar fixedTimeStep) { ObjectList::iterator i; for (i = objects.begin(); i != objects.end(); ++i) (*i)->prePhysics(); if (dt > 0) { bullet->dynamicsWorld->stepSimulation(dt, maxSubSteps, fixedTimeStep); bullet->softBodyWorldInfo->m_sparsesdf.GarbageCollect(); } preDraw(); }
void WorldObjectEffect::drawInternal(DrawInfo &di) { int frameIndex = xapp().getCurrentBackBufferIndex(); if (inThreadOperation) { //mutex_Object.lock(); threadLocal.commandList->RSSetViewports(1, &threadLocal.vr_eyesm[di.eyeNum].viewports[di.eyeNum]); threadLocal.commandList->RSSetScissorRects(1, &threadLocal.vr_eyesm[di.eyeNum].scissorRects[di.eyeNum]); //threadLocal.commandList->RSSetViewports(1, xapp().vr.getViewportByIndex(di.eyeNum)); //threadLocal.commandList->RSSetScissorRects(1, xapp().vr.getScissorRectByIndex(di.eyeNum)); threadLocal.commandList->SetGraphicsRootConstantBufferView(0, getCBVVirtualAddress(frameIndex, di.threadNum, di.objectNum, di.eyeNum)); threadLocal.commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); // update buffers for this text line: //XMStoreFloat4x4(&cbv.wvp, wvp); //cbv.rot = lines[0].rot; //memcpy(cbvGPUDest, &cbv, sizeof(cbv)); threadLocal.commandList->IASetVertexBuffers(0, 1, &di.mesh->vertexBufferView); threadLocal.commandList->IASetIndexBuffer(&di.mesh->indexBufferView); //auto *tex = xapp().textureStore.getTexture(elvec.first); // Set SRV ID3D12DescriptorHeap* ppHeaps[] = { di.tex->m_srvHeap.Get() }; threadLocal.commandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps); threadLocal.commandList->SetGraphicsRootDescriptorTable(2, di.tex->m_srvHeap->GetGPUDescriptorHandleForHeapStart()); threadLocal.commandList->DrawIndexedInstanced(di.numIndexes, 1, 0, 0, 0); //Log("draw frame/thread/obj/eye " << frameIndex << " " << di.threadNum << " " << di.objectNum << " " << di.eyeNum << endl); //this_thread::sleep_for(20ms); //mutex_Object.unlock(); return; } mutex_Object.lock(); preDraw(di); commandLists[frameIndex]->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); // update buffers for this text line: //XMStoreFloat4x4(&cbv.wvp, wvp); //cbv.rot = lines[0].rot; //memcpy(cbvGPUDest, &cbv, sizeof(cbv)); if (inBulkOperation) { commandLists[frameIndex]->RSSetViewports(1, &vr_eyes.viewports[di.eyeNum]); commandLists[frameIndex]->RSSetScissorRects(1, &vr_eyes.scissorRects[di.eyeNum]); //commandLists[frameIndex]->RSSetViewports(1, xapp().vr.getViewport()); //commandLists[frameIndex]->RSSetScissorRects(1, xapp().vr.getScissorRect()); commandLists[frameIndex]->SetGraphicsRootConstantBufferView(0, getCBVVirtualAddress(frameIndex, di.threadNum, di.objectNum, di.eyeNum)); } commandLists[frameIndex]->IASetVertexBuffers(0, 1, &di.mesh->vertexBufferView); commandLists[frameIndex]->IASetIndexBuffer(&di.mesh->indexBufferView); //auto *tex = xapp().textureStore.getTexture(elvec.first); // Set SRV ID3D12DescriptorHeap* ppHeaps[] = { di.tex->m_srvHeap.Get() }; commandLists[frameIndex]->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps); commandLists[frameIndex]->SetGraphicsRootDescriptorTable(2, di.tex->m_srvHeap->GetGPUDescriptorHandleForHeapStart()); commandLists[frameIndex]->DrawIndexedInstanced(di.numIndexes, 1, 0, 0, 0); postDraw(); mutex_Object.unlock(); //Sleep(50); }
void GLWidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0,0,-1000); glRotatef(rotx,1,0,0); glRotatef(roty,0,1,0); preDraw(); draw(); postDraw(); }
// Draws all the windows. Called in a idle callback void sgGlutApp::idleDraw() { for(int i=0; i<256; i++) { if(win[i] != NULL) { glutSetWindow(i); preDraw(); // Do any special pre-Draw win[i]->draw(); postDraw(); // Same for post draw glutSwapBuffers(); // Done drawing. Swap em } } }
/** * Retrieves the model data from the resource manager and rraws the * Model to screen using RCBC. * @param rm The ResourceManager to use to load the model */ void VModel::draw(Interface* interface) { if(!interface) { return; } if(!isVisible() && interface->getEditMode() == MODE_NONE) { return; } ResourceManager* rm = interface->getResourceManager(); if(!rm) { return; } Model* model = rm->loadModel(filename_); bool selected; Object* object = interface->getSelectedObject(); if(object) { Visual* visual = &object->getVisual(); selected = (this == visual); glEnable(GL_COLOR_MATERIAL); glColor3f(1.0f, 0.2f, 0.2f); //DEBUG_H("Drawing selected. %s", object->getTag().c_str()); //glEnable } if(!selected) { //DEBUG_H("Drawing selected. %s", object->getTag().c_str()); glColor3f(1.0f, 1.0f, 1.0f); // If we are editing, draw visible objects if(!isVisible() && interface->getEditMode() != MODE_NONE) { glColor4f(0.5f, 0.5f, 1.0f, 0.5f); } else glDisable(GL_COLOR_MATERIAL); } preDraw(interface); RCBC_Render(model); postDraw(interface); }
void Game::loop() { int delta = (int)mDeltaClock.restart().asMilliseconds(); //if(delta > 50) //delta = 50; sf::Event evt; // Loop runs through all new events mGameData.world.Step(delta/1000.f, 8, 3 ); while(mWindow.pollEvent(evt)) { switch(evt.type) { case sf::Event::Closed: close(); return; break; case sf::Event::KeyPressed: if(evt.key.code == sf::Keyboard::Escape) { close(); return; break; } default: mGameData.input.add(evt); break; } } mGameData.mPos = (sf::Vector2f)sf::Mouse::getPosition(mWindow) * (mView.getSize()/(sf::Vector2f)mWindow.getSize()); mWindow.clear(sf::Color::White); mGameData.controlList.update(mGameData); update(delta); preDraw(); draw(); cleanUp(); mGameData.input.clear(); }
void Canvas::Draw() { if (_StyleModules.empty()) return; preDraw(); TimeStamp *timestamp = TimeStamp::instance(); for (unsigned int i = 0; i < _StyleModules.size(); ++i) { _current_sm = _StyleModules[i]; if (i < _Layers.size() && _Layers[i]) delete _Layers[i]; _Layers[i] = _StyleModules[i]->execute(); if (!_Layers[i]) continue; stroke_count += _Layers[i]->strokes_size(); timestamp->increment(); } postDraw(); }
/************************************************************************** * Name: draw(float32 _dt) * Description: Method used to draw the particle system. It first activate the * transmits the shader, then it transmits the different * uniform variables, gets the different attributes and * draws all the particles thanks to the STRIDE of the * 'Particle' structure defining the number of floats to skip * between the different Particles to draw. * Inputs: * -_dt : float32, time difference when the last rendering occured. * Returns: none **************************************************************************/ void ParticleSystem::draw(float32 _dt) { /* Activates the shader and transmits the uniform variables. */ m_shader->activate(); m_shader->transmitUniformMat4("W", m_world, GL_FALSE); m_shader->transmitUniformMat4("V", m_view, GL_FALSE); m_shader->transmitUniformMat4("P", m_projection, GL_FALSE); m_shader->transmitUniformFloat("t", m_globalTime); /* Do pre-draw computing. */ preDraw(_dt); /* Casts the Particle array into a GLfloat. */ GLfloat* particles_to_float = (float*)m_particles; /* Send GLfloat arrays to Shader in order to give values to 'in' shader variables. */ glVertexAttribPointer(m_shader->getAttrLocation("position"), 3, GL_FLOAT, GL_FALSE, sizeof(Particle), particles_to_float + 0); glVertexAttribPointer(m_shader->getAttrLocation("speed"), 3, GL_FLOAT, GL_FALSE, sizeof(Particle), particles_to_float + 3); glVertexAttribPointer(m_shader->getAttrLocation("acceleration"), 3, GL_FLOAT, GL_FALSE, sizeof(Particle), particles_to_float + 6); glVertexAttribPointer(m_shader->getAttrLocation("color"), 3, GL_FLOAT, GL_FALSE, sizeof(Particle), particles_to_float + 9); glVertexAttribPointer(m_shader->getAttrLocation("ttl"), 1, GL_FLOAT, GL_FALSE, sizeof(Particle), particles_to_float + 12); glVertexAttribPointer(m_shader->getAttrLocation("spawnTime"), 1, GL_FLOAT, GL_FALSE, sizeof(Particle), particles_to_float + 13); /* Enables all attributes */ m_shader->enableAllAttrib(); /* Sets the point size to the ParticleSize. */ glPointSize(m_particleSize); /* Calls the shader to draw the Particles. */ glDrawArrays(GL_POINTS, 0, m_particleCount); /* Disables all shader attributes. */ m_shader->disableAllAttrib(); }
void Scene::handleScenePreDraw(EventDataRef event) { auto e = std::dynamic_pointer_cast<ScenePreDrawEvent>(event); preDraw(); }