//-------------------------------------------------------------- void testApp::draw() { /// Scene Manager draw // ------------------ setDrawFloorAuto(true); int main_screen_width = 1920; int main_screen_height = 1200; main_screen_width = min(main_screen_width, ofGetWidth()); main_screen_height = min(main_screen_height, ofGetHeight()); ramCameraManager::instance().setActiveCamera(0); ofPushView(); ofViewport(0, 0, 1920, 1200); ramBeginCamera(); drawFloor(); ramEndCamera(); sceneManager.draw(); ofPopView(); int screen_w = 1280, screen_h = 720; int inv_screen_height = ofGetHeight() - screen_h; for (int i = 0; i < 5; i++) { ofPushView(); ofCamera *screen_camera = ramCameraManager::instance().getCamera(i + 1); ofViewport(ofRectangle(main_screen_width + i * screen_w, inv_screen_height, screen_w, screen_w)); ramCameraManager::instance().setActiveCamera(i + 1); screen_camera->begin(); drawFloor(); screen_camera->end(); sceneManager.draw(); ofPopView(); } ramCameraManager::instance().setActiveCamera(0); setDrawFloorAuto(false); }
void BufferCont::drawSolution(){ float size = m_view[camBot].width<m_view[camBot].height ? m_view[camBot].width : m_view[camBot].height; if (g_showPop) drawPoint(m_view[viewBot], m_cam[camBot], m_solPoint.front()); m_cam[camBot].begin(m_view[viewBot]); ofSetColor(255, 0, 0); ofVec3f start, end; start.x = -size / 2; start.y = -size / 2; start.z = 0; end.x = size / 2; end.y = -size / 2; end.z = 0; ofDrawArrow(start, end, 5.0); m_font.drawString("x1", end.x, end.y); end.x = -size / 2; end.y = size / 2; end.z = 0; ofDrawArrow(start, end, 5.0); m_font.drawString("x2", end.x, end.y); m_cam[camBot].end(); ofPushView(); ofViewport(m_view[viewBot]); ofSetupScreen(); stringstream ss; ss << "evals: " << Global::msp_global->mp_problem->getEvaluations(); ofSetColor(0, 0, 0); m_font.drawString(ss.str(), 5, 25); ofPopView(); }
// if begin(); pushes first, then we need an end to pop //---------------------------------------- void ofCamera::end() { if (isActive) { ofPopView(); isActive = false; } }
//-------------------------------------------------------------- void testApp::render_texture(ofEventArgs &args) { // ofClear(127, 0, 0, 1); // // float w = cml->tex_width(); // float h = cml->tex_height(); // // ofPushView(); // ofViewport(ofRectangle(0,0,w,h)); // ofSetupScreenOrtho(w, h, -1, 1); // ofSetColor(255); // // glClearColor(0.5, 0, 0, 1); // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ofClear(255 * 0.5, 0, 0, 1); float w = cml->tex_width(); float h = cml->tex_height(); ofPushView(); ofViewport(0,0,w,h,true); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w, 0, h, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //kinect.drawDepth(0, 0, w, h); colorMap.draw(0, 0, w, h); //cml->get_hue_tex_ref( kinect.getRawDepthPixels() ).draw( 0, 0, w, h ); ofPopView(); }
void ofxComposer::draw(){ ofPushView(); ofPushStyle(); ofPushMatrix(); ofEnableAlphaBlending(); for(int i = 0; i < patches.size(); i++){ patches[i]->draw(); } if ( bGLEditor && (selected >= 0)){ if (patches[selected]->getType() == "ofShader"){ editorFbo.begin(); ofClear(0, 150); ofRotate(180, 0, 1, 0); editor.draw(); editorFbo.end(); } else { editorFbo.begin(); ofClear(0, 50); editorFbo.end(); } } if (selectedDot >= 0){ ofLine(patches[selectedDot]->getOutPutPosition(), ofPoint(ofGetMouseX(),ofGetMouseY())); } ofDisableBlendMode(); ofEnableAlphaBlending(); ofPopMatrix(); ofPopStyle(); ofPopView(); }
//-------------------------------------------------------------- void testApp::draw() { simpleCam.begin(); // ofRectangle(ofGetWidth(), ofGetHeight(), 10000, -10000) if(bdrawdebug){ ofDrawAxis(100); } ofPushView(); ofTranslate(-(colsmesh*distsmesh)*0.5, -(rowsmesh*distsmesh)*0.5, 0); blackmesh.draw(); myhand.draw(true); ofPopView(); simpleCam.end(); // finally, a report: //ofSetHexColor(0xff0000); ofSetColor(255,0,0); char reportStr[1024]; sprintf(reportStr, "deformable mesh\nKEY 'o' to select ID particles --\nKEY 'p' to select ID particles ++\nKEY 'm' for move particles\nKEY 'f' for apply vector forces to strings\nfps: %f", ofGetFrameRate()); if(bdrawdebug){ ofDrawBitmapString(reportStr, 20, 600); } }
// --------------------------------------------------------------------------------------------------------------------------------------------------- // void ofxOculusRift::endRender( ofFbo* _fbo ) { ofPopMatrix(); _fbo->end(); ofPopView(); }
//-------------------------------------------------------------- void ofxGLEditor::draw() { ofPushView(); ofPushMatrix(); ofPushStyle(); ofEnableAlphaBlending(); if(!bHideEditor) { if(m_fileDialog->isActive()) { m_fileDialog->draw(); } else { m_editors[m_currentEditor]->draw(); } } else { // make sure to update animation timing even if not drawn m_editors[m_currentEditor]->updateTimestamps(); } ofDisableAlphaBlending(); ofPopStyle(); ofPopMatrix(); ofPopView(); // glDisable(GL_LIGHTING); // glDisable(GL_DEPTH_TEST); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); }
//-------------------------------------------------------------- void myAmeManager::draw() { ofSetColor(255,255,255,255); cam.begin(); ofPushMatrix(); // save the old coordinate system ofScale(1.0f, -1.0f); // flip the y axis vertically, so that it points upward myVolume.drawVolume(0,0,0, ofGetHeight(), 0); // draw Volume mesh_tracker_interaction.draw(cam, myData); // draw mesh ofPushView(); myData.draw(); // draw tracker ofSetupScreenPerspective(ofGetWidth(), ofGetHeight(),OF_ORIENTATION_DEFAULT,true,50,0,1000); ofPopView(); ofPopMatrix(); // restore the previous coordinate system cam.end(); if(bStadisticsVisible) { myTracker.draw(); //logTracker::getInstance()->draw(1000, 30); } }
void ofFbo::end() { unbind(); if(ofGetGLRenderer()){ ofGetGLRenderer()->setCurrentFBO(NULL); } ofPopView(); }
//-------------------------------------------------------------- void testApp::draw(){ ofRectangle viewLeft = ofGetCurrentViewport(); viewLeft.width /= 2.0f; ofRectangle viewRight = viewLeft; viewRight.x += viewLeft.width; ofPushStyle(); ofNoFill(); ofSetColor(255); ofRect(viewLeft); ofRect(viewRight); ofPopStyle(); if (!(indexLeft == cameraIndices.end() || indexRight == cameraIndices.end())) { CorrespondenceSetd::iterator it; ofMesh pointsLeft, pointsRight; for (it = dataSet.begin(); it != dataSet.end(); it++) { if (it->cameraID1 == *indexLeft && it->cameraID2 == *indexRight) { pointsLeft.addVertex(it->getXY1()); pointsLeft.addColor(ofFloatColor((it->xy2[0] + 1.0f) / 2.0f, (1.0f - it->xy2[1]) / 2.0f, 0)); pointsRight.addVertex(it->getXY2()); pointsRight.addColor(ofFloatColor((it->xy1[0] + 1.0f) / 2.0f, (1.0f - it->xy1[1]) / 2.0f, 0)); } } ofPushView(); glPointSize(5.0f); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); ofViewport(viewLeft); pointsLeft.drawVertices(); ofViewport(viewRight); pointsRight.drawVertices(); ofPopView(); } if (indexLeft != cameraIndices.end()) ofDrawBitmapString(ofToString(*indexLeft), viewLeft.x + 10, viewLeft.height - 10); if (indexRight != cameraIndices.end()) ofDrawBitmapString(ofToString(*indexRight), viewRight.x + 10, viewRight.height - 10); stringstream message; message << "Cameras {"; set<int>::iterator it; for (it = cameraIndices.begin(); it != cameraIndices.end(); it++) { if (it != cameraIndices.begin()) message << ", "; message << *it; } message << "}" << endl; ofDrawBitmapString(message.str(), 20, 30); }
void ofFbo::end() { if(!bIsAllocated) return; unbind(); if(ofGetGLRenderer()){ ofGetGLRenderer()->setCurrentFBO(NULL); } ofPopView(); }
//-------------------------------------------------------------- void ofxCubeMap::endDrawingInto3D() { ofPopView(); ofPopMatrix(); fbo.end(); }
void ftParticleFlow::draw(int _x, int _y, int _width, int _height) { ofPushView(); ofTranslate(_x, _y); ofScale(_width / numParticlesX, _height / numParticlesY); drawParticleShader.update(particleMesh, numParticles, particlePositionSwapBuffer.getBackTexture(), particleAgeLifespanMassSizeSwapBuffer.getBackTexture(), twinkleSpeed.get()); ofPopView(); }
// --------------------------------------------------------------------------------------------------------------------------------------------------- // void ofxOculusRift::draw( ofVec2f pos, ofVec2f size ) { // Todo: rewrite this ofPushView(); // draw into the new fbo we have made ofSetColor( 255 ); glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); ofClear(0,0,0); eyeFboLeft.draw( 0.0f, 0.0f ); eyeFboRight.draw( eyeFboLeft.getWidth(), 0.0f ); // is this being drawn correctly? glBindFramebuffer(GL_FRAMEBUFFER, 0); ofSetMatrixMode(OF_MATRIX_PROJECTION); ofLoadIdentityMatrix(); ofSetMatrixMode(OF_MATRIX_MODELVIEW); ofLoadIdentityMatrix(); ofSetColor( 255 ); if( doWarping ) { glEnable( GL_TEXTURE_2D ); glBindTexture(GL_TEXTURE_2D, colorTextureID); renderDistortedEyeNew( true, 0.0f, 0.0f, 0.5f, 1.0f); renderDistortedEyeNew( false, 0.5f, 0.0f, 0.5f, 1.0f); glDisable( GL_TEXTURE_2D ); } ofPopView(); /* glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(pos.x, pos.y ); glVertex2f(-1.0f, -1.0f); glTexCoord2f(pos.x+size.x, pos.y ); glVertex2f(0.0f, -1.0f); glTexCoord2f(pos.x, pos.y+size.y); glVertex2f(-1.0f, 1.0f); glTexCoord2f(pos.x+size.x, pos.y+size.y); glVertex2f(0.0f, 1.0f); glEnd(); */ if( !doWarping ) { ofSetColor(255); eyeFboLeft.draw( 0.0f, 0.0f ); eyeFboRight.draw( eyeFboLeft.getWidth(), 0.0f ); } needSensorReadingThisFrame = true; }
void MissingControl::drawPlan(float x, float y, float side) { ofPushView(); ofViewport(x, y, side, side); ofSetupScreenOrtho(side, side, OF_ORIENTATION_DEFAULT, false, -stageHeight, stageHeight); ofTranslate(side / 2, side / 2); float scale = side / stageSize; ofScale(scale, scale, scale); drawScene(false); ofPopView(); }
//--------- void ThreadSet::drawProjectionSpace() { ofPushView(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); for(auto thread : *this) { thread.drawProjectionSpace(); } ofPopView(); }
void ftParticleFlow::draw(int _x, int _y, int _width, int _height, ofTexture& _velocity) { ofPushView(); ofTranslate(_x, _y); ofScale(_width / numParticlesX, _height / numParticlesY); if (!bStretch) { drawParticleShader.update(particleMesh, numParticles, particlePositionSwapBuffer.getBackTexture(), particleAgeLifespanMassSizeSwapBuffer.getBackTexture(), twinkleSpeed.get(), hueToRgb); } else { drawParticleStretchedShader.update(particleMesh, numParticles, particlePositionSwapBuffer.getBackTexture(), particleAgeLifespanMassSizeSwapBuffer.getBackTexture(), twinkleSpeed.get(), hueToRgb, _velocity, particleTexture, stretchFactor.get()); } ofPopView(); }
//-------------------------------------------------------------- void ofApp::draw(){ depthImage.draw(0, 0); ofPushView(); tracker.getOverlayCamera().begin(ofRectangle(0, 0, 640, 480)); tracker.draw(); tracker.getOverlayCamera().end(); ofPopView(); ofDrawBitmapStringHighlight(ofToString((int) ofGetFrameRate()) + " FPS", 20, 30); }
void ofxGLEditor::draw() { ofPushView(); ofPushMatrix(); ofPushStyle(); glEditor[currentEditor]->Render(); ofPopStyle(); ofPopMatrix(); ofPopView(); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); }
void Informer::draw( float x, float y, float w, float h ) { ofPushView(); ofViewport(x,y,w,h); for(auto &info:I) { if(info.second.delay<=0) { info.second.iNode->draw(); } } ofPopView(); }
//-------------------------------------------------------------- void ofApp::draw() { //-- // 2d view drawViewportOutline(viewport2D); // keep a copy of your viewport and transform matrices for later ofPushView(); // tell OpenGL to change your viewport. note that your transform matrices will now need setting up ofViewport(viewport2D); // setup transform matrices for normal oF-style usage, i.e. // 0,0=left,top // ofGetViewportWidth(),ofGetViewportHeight()=right,bottom ofSetupScreen(); ofFill(); ofSetColor(220); for(int x = 0; x < 1000; x += 20) { for(int y = 0; y < 1000; y += 20) { ofCircle(x, y, sin((x + y) / 100.0f + ofGetElapsedTimef()) * 5.0f); } } // restore the old viewport (now full view and oF coords) ofPopView(); //-- //-- // 3d view drawViewportOutline(viewport3D); // note the camera accepts the viewport as an argument // this is so that the camera can be aware of which viewport // it is acting on // // ofPushView() / ofPopView() are automatic camera.begin(viewport3D); ofDrawGrid(100); camera.end(); //-- ofDrawBitmapString("Press [space] to randomize viewports", 20, 20); }
//-------------------------------------------------------------- void ofxFileDialog::draw() { if(!m_active) {return;} // default size if not set if(m_width == 0 || m_height == 0) { resize(ofGetWidth(), ofGetHeight()); } ofPushStyle(); ofPushView(); ofEnableAlphaBlending(); // for fontstash ofViewport(0, 0, m_width, m_height); ofFill(); // font color s_font->setColor(m_settings->getTextColor(), m_settings->getAlpha()); s_font->setShadowColor(m_settings->getTextShadowColor(), m_settings->getAlpha()); // draw current path int pathWidth = s_font->stringWidth(m_path); if(pathWidth > m_visibleWidth) { // make sure right side is visible s_font->drawString(m_path, m_visibleWidth-pathWidth, s_charHeight); } else { s_font->drawString(m_path, 0, s_charHeight); } // indent and draw dialogs ofTranslate(s_charWidth*4, 0); switch(m_mode) { case SAVEAS: drawSaveAs(); break; case OPEN: drawOpen(); break; case NEWFOLDER: drawNewFolder(); break; } ofPopView(); ofPopStyle(); // update animation timestamps updateTimestamps(); }
//-------------------------------------------------------------- void ofApp::draw(){ ofBackgroundGradient(100, 50); camera.begin(); this->lineSet.updateIndexBuffer(this->shift); this->drawScene(); this->cameraCursorCached = this->camera.getCursorWorld(); this->drawCursor(); camera.end(); //-- //draw zoomed // if (this->shift) { zoomed.begin(); ofClear(0,0,0,255); ofPushView(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glScalef(10.0f, 10.0f, 1.0f); ofVec3f offset = this->camera.worldToCamera(this->camera.getCursorWorld()); offset.z = 0.0f; ofTranslate(-offset); glMultMatrixf(camera.getProjectionMatrix().getPtr()); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(camera.getModelViewMatrix().getPtr()); this->drawScene(); this->drawCursor(); ofPopView(); zoomed.end(); zoomed.draw(0, ofGetHeight(), zoomed.getWidth(), - zoomed.getHeight()); } // //-- this->drawInstructions(); }
void View::draw() { ofPushView(); ofViewport(getBounds()); ofSetupScreenPerspective(getWidth(), getHeight()); ofNoFill(); ofSetColor(getColor()); ofPushMatrix(); ofTranslate(getWidth()*.5, getHeight()*.5, 0); ofTranslate(offset); ofRotateX(ofNoise(rotX)*360); ofRotateY(ofNoise(rotY)*360); float s = (ofNoise(scale)-.5)*30; ofScale(s, s, s); ofBox(200); ofPopMatrix(); ofPopView(); }
//-------------------------------------------------------------- void testApp::draw(){ ofPushView(); glMatrixMode(GL_PROJECTION); glLoadMatrixf(projector.getProjectionMatrix().getPtr()); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(projector.getViewMatrix().getPtr()); points.drawVertices(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); ofVec3f projected; ofNoFill(); for (int i=0; i<points.getNumVertices(); i++) { projected = projector.projectPoint(points.getVertex(i)); ofCircle(projected.x, projected.y, 0.01); } ofPopView(); }
//-------------------------------------------------------------- static void ramPopAll() { ofPopStyle(); GLint matrixMode; glGetIntegerv(GL_MATRIX_MODE, &matrixMode); glMatrixMode(GL_COLOR); glPopMatrix(); glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(matrixMode); glPopAttrib(); ofPopView(); }
//-------------------------------------------------------------- void visionScene1::update(){ //begin Fbo myFbo.begin(); //begin Pushview ofPushView(); //update and draw the videoGrabber in Fbo myVideoGrabber.update(); myVideoGrabber.draw(0,0); //end the pushView ofPopView(); //end the Fbo myFbo.end(); }
//-------------------------------------------------------------- void testApp::update(){ float fade = abs(sin( ofGetElapsedTimef()*0.099 )); ofPushView(); ofPushStyle(); blur.begin(); ofPushMatrix(); ofEnableBlendMode(OF_BLENDMODE_ALPHA); ofClear(0, 255); ofSetColor( ofMap( fade , 0.0f, 0.5f, 0.0f, 1.0f, true) * 255,255); font.drawString(message, width*0.5f - font.getStringBoundingBox(message,0,0).width*0.5f, height*0.5f); ofDisableBlendMode(); ofPopMatrix(); blur.end(); blur.setRadius( 1.0f + ( 1.0f - fade ) * 5.0f ); blur.setPasses( 1.0f + ( 1.0f - fade ) * 3.0f ); blur.update(); tint.setFade( 0.2 + (1.0-fade )*0.8 ); if ( fade < 0.01 ){ tint.clear(); } tint << blur; tint.update(); ofPopView(); ofPopStyle(); ofSetWindowTitle(ofToString(ofGetFrameRate())); }
bool ofxRGBDRenderer::setup(string calibrationDirectory){ if(!ofDirectory(calibrationDirectory).exists()){ ofLogError("ofxRGBDRenderer --- Calibration directory doesn't exist: " + calibrationDirectory); return false; } depthCalibration.load(calibrationDirectory+"/depthCalib.yml"); rgbCalibration.load(calibrationDirectory+"/rgbCalib.yml"); loadMat(rotationDepthToRGB, calibrationDirectory+"/rotationDepthToRGB.yml"); loadMat(translationDepthToRGB, calibrationDirectory+"/translationDepthToRGB.yml"); depthToRGBView = ofxCv::makeMatrix(rotationDepthToRGB, translationDepthToRGB); ofPushView(); rgbCalibration.getDistortedIntrinsics().loadProjectionMatrix(); glGetFloatv(GL_PROJECTION_MATRIX, rgbProjection.getPtr()); ofPopView(); calibrationSetup = true; return true; }