//-------------------------------------------------------------- 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 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 ofxFenster::draw() { if(isDestroyed) return; setActive(); ofPoint size=getWindowSize(); if ( bClearAuto == true) { ofClear(bgColor.r, bgColor.g, bgColor.b, bgColor.a); } ofViewport(0, 0, size.x, size.y); ofSetupScreenPerspective(size.x, size.y, OF_ORIENTATION_DEFAULT); ofGetWidth(); ofNotifyEvent(events.draw, voidEventArgs); ofxFensterListenerList::iterator it=listeners.begin(); while(it!=listeners.end()) { (*it)->draw(this); (*it)->isUpdated=false; ++it; } win->swapBuffers(); return; }
void update() { if( goFullscreen == 2 ){ ofSetFullscreen(false); ofSetWindowPosition(1920, 0); } if( goFullscreen == 4 ){ ofSetFullscreen(true); ofViewport(ofGetNativeViewport()); } goFullscreen++; if(goFullscreen > 4 && ofGetWindowPositionX() < 1440) { goFullscreen = 0; } renderTimer.tick(); while(osc.hasWaitingMessages()) { ofxOscMessage msg; osc.getNextMessage(&msg); if(msg.getAddress() == "/lookAngle/set") { targetLookAngle = msg.getArgAsFloat(0); } if(msg.getAddress() == "/lookAngle/add") { targetLookAngle += msg.getArgAsFloat(0); ofLog() << "targetLookAngle: " << targetLookAngle; } if(msg.getAddress() == "/screenshot") { saveScreen("button/"); } } lookAngle = ofLerp(lookAngle, targetLookAngle, .1); if(screenshotTimer.tick()) { // saveScreen("automatic/"); // uncomment to enable automatic screenshot } }
//---------------------------------------- void ofCamera::begin(ofRectangle viewport) { if(!isActive) ofPushView(); isActive = true; ofSetCoordHandedness(OF_RIGHT_HANDED); // autocalculate near/far clip planes if not set by user calcClipPlanes(viewport); glMatrixMode(GL_PROJECTION); ofLoadIdentityMatrix(); if(isOrtho) { // if(vFlip) glOrtho(0, width, height, 0, nearDist, farDist); // else #ifndef TARGET_OPENGLES glOrtho(0, viewport.width, 0, viewport.height, nearClip, farClip); #else ofMatrix4x4 ortho; ortho.makeOrthoMatrix(0, viewport.width, 0, viewport.height, nearClip, farClip); ofLoadMatrix( ortho ); #endif } else { ofMatrix4x4 persp; persp.makePerspectiveMatrix( fov, viewport.width/viewport.height, nearClip, farClip ); ofLoadMatrix( persp ); //gluPerspective(fov, viewport.width/viewport.height, nearClip, farClip); } glMatrixMode(GL_MODELVIEW); ofLoadMatrix( ofMatrix4x4::getInverseOf(getGlobalTransformMatrix()) ); ofViewport(viewport); }
void Intrinsics::loadProjectionMatrix(float nearDist, float farDist, cv::Point2d viewportOffset) const { ofViewport(viewportOffset.x, viewportOffset.y, imageSize.width, imageSize.height); ofSetMatrixMode(OF_MATRIX_PROJECTION); ofLoadIdentityMatrix(); float w = imageSize.width; float h = imageSize.height; float fx = cameraMatrix.at<double>(0, 0); float fy = cameraMatrix.at<double>(1, 1); float cx = principalPoint.x; float cy = principalPoint.y * aspectRatio; ofMatrix4x4 frustum; frustum.makeFrustumMatrix( nearDist * (-cx) / fx, nearDist * (w - cx) / fx, nearDist * (cy) / fy, nearDist * (cy - h) / fy, nearDist, farDist); ofMultMatrix(frustum); ofSetMatrixMode(OF_MATRIX_MODELVIEW); ofLoadIdentityMatrix(); ofMatrix4x4 lookAt; lookAt.makeLookAtViewMatrix(ofVec3f(0, 0, 0), ofVec3f(0, 0, 1), ofVec3f(0, -1, 0)); ofMultMatrix(lookAt); }
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(); }
//-------------------------------------------------------------- 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(); }
/* Call to render the next GL frame */ void Java_cc_openframeworks_OFAndroid_render( JNIEnv* env, jclass thiz ) { int beginFrameMillis = ofGetElapsedTimeMillis(); if(paused) return; //LOGI("update"); ofNotifyUpdate(); int width, height; width = sWindowWidth; height = sWindowHeight; height = height > 0 ? height : 1; // set viewport, clear the screen //glViewport( 0, 0, width, height ); ofViewport(0, 0, width, height, false); // used to be glViewport( 0, 0, width, height ); float * bgPtr = ofBgColorPtr(); bool bClearAuto = ofbClearBg(); if ( bClearAuto == true || nFrameCount < 3){ ofClear(bgPtr[0]*255,bgPtr[1]*255,bgPtr[2]*255, bgPtr[3]*255); } if(bSetupScreen) ofSetupScreen(); ofNotifyDraw(); /*timeNow = ofGetElapsedTimef(); double diff = timeNow-timeThen; if( diff > 0.00001 ){ fps = 1.0 / diff; frameRate *= 0.9f; frameRate += 0.1f*fps; } lastFrameTime = diff; timeThen = timeNow;*/ // -------------- int currTime = ofGetElapsedTimeMillis(); if(currTime - onesec>=1000){ frameRate = frames; frames = 0; onesec = currTime; } frames++; int frameMillis = currTime - beginFrameMillis; lastFrameTime = double(frameMillis)/1000.; previousFrameMillis = currTime; nFrameCount++; // increase the overall frame count*/ if(bFrameRateSet && frameMillis<oneFrameTime) ofSleepMillis(oneFrameTime-frameMillis); }
void ofFbo::begin() { bind(); ofPushView(); if(ofGetGLRenderer()){ ofGetGLRenderer()->setCurrentFBO(this); } ofViewport(0, 0, getWidth(), getHeight(), false); ofSetupScreenPerspective(getWidth(), getHeight(), ofGetOrientation(), false); }
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 SecondCamera::begin(ofRectangle viewport) { ofPushView(); ofViewport(viewport); glMatrixMode(GL_PROJECTION); glLoadMatrixf(matProjection.getPtr()); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(matModelView.getPtr()); }
static int lua_graphics_set_viewport(lua_State *L) { float x = luaL_checknumber(L, 1); float y = luaL_checknumber(L, 2); float w = luaL_checknumber(L, 3); float h = luaL_checknumber(L, 4); bool invert_y = lua_toboolean(L, 5); ofViewport(x, y, w, h, invert_y); return 0; }
void ofFbo::begin(bool setupScreen) { if(!bIsAllocated) return; ofPushView(); if(ofGetGLRenderer()){ ofGetGLRenderer()->setCurrentFBO(this); } ofViewport(); if(setupScreen){ ofSetupScreenPerspective(); } bind(); }
//---------------------------------------------------------- void ofGLRenderer::popView() { if( viewportHistory.size() ){ ofRectangle viewRect = viewportHistory.front(); ofViewport(viewRect.x, viewRect.y, viewRect.width, viewRect.height); viewportHistory.pop_front(); } glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); }
//---------------------------------------- void ofx2DCam::begin(ofRectangle _viewport){ viewport = _viewport; ofPushView(); ofViewport(viewport); ofSetupScreenOrtho(viewport.width, viewport.height, nearClip, farClip); ofPushMatrix(); ofRotateX(orientation.x); ofRotateY(orientation.y); ofTranslate(translation*orientationMatrix); ofScale(scale,scale,scale); }
//---------------------------------------- void ofCamera::begin(ofRectangle viewport) { if(!isActive) ofPushView(); isActive = true; ofViewport(viewport.x,viewport.y,viewport.width,viewport.height); ofSetOrientation(ofGetOrientation(),vFlip); ofSetMatrixMode(OF_MATRIX_PROJECTION); ofLoadMatrix( getProjectionMatrix(viewport) ); ofSetMatrixMode(OF_MATRIX_MODELVIEW); ofLoadViewMatrix( getModelViewMatrix() ); }
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 ofFbo::begin(bool setupScreen) { ofPushView(); if(ofGetGLRenderer()){ ofGetGLRenderer()->setCurrentFBO(this); } ofViewport(0, 0, getWidth(), getHeight(), false); if(setupScreen){ ofOrientation orient = ofGetOrientation(); #ifdef TARGET_OF_IPHONE orient = OF_ORIENTATION_DEFAULT; #endif ofSetupScreenPerspective(getWidth(), getHeight(), orient, false); } bind(); }
void ofxMapamok::begin() { if (!calibrationReady) { return; } ofPushMatrix(); ofSetMatrixMode(OF_MATRIX_PROJECTION); ofPushMatrix(); ofSetMatrixMode(OF_MATRIX_MODELVIEW); intrinsics.loadProjectionMatrix(nearDist, farDist); ofMultMatrix(modelMatrix); if (!useDistortionShader) { ofViewport(viewport); } else { if (distortionBuffer.getWidth() != viewport.width || distortionBuffer.getHeight() != viewport.height) { distortionBuffer.allocate(viewport.width, viewport.height, GL_RGBA); } distortionBuffer.begin(false); ofViewport(ofRectangle(0, 0, viewport.width, viewport.height)); ofClear(0, 0); } }
//-------------------------------------------------------------- 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 PostProcessing::begin() { raw.begin(ofFboBeginMode::NoDefaults); ofMatrixMode(OF_MATRIX_PROJECTION); ofPushMatrix(); ofMatrixMode(OF_MATRIX_MODELVIEW); ofPushMatrix(); ofViewport(0, 0, raw.getWidth(), raw.getHeight()); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); ofPushStyle(); glPushAttrib(GL_ENABLE_BIT); }
//---------------------------------------- void ofCamera::begin(ofRectangle viewport) { if(!isActive) ofPushView(); isActive = true; ofSetCoordHandedness(OF_RIGHT_HANDED); // autocalculate near/far clip planes if not set by user calcClipPlanes(viewport); ofSetMatrixMode(OF_MATRIX_PROJECTION); ofLoadIdentityMatrix(); ofLoadMatrix( this->getProjectionMatrix(viewport) ); ofSetMatrixMode(OF_MATRIX_MODELVIEW); ofLoadMatrix( ofMatrix4x4::getInverseOf(getGlobalTransformMatrix()) ); ofViewport(viewport); }
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 ofxMapamok::end() { if (!calibrationReady) { return; } if (useDistortionShader) { distortionBuffer.end(); } // restore default viewport ofViewport(0, 0, ofGetWidth(), ofGetHeight()); ofPopMatrix(); ofSetMatrixMode(OF_MATRIX_PROJECTION); ofPopMatrix(); ofSetMatrixMode(OF_MATRIX_MODELVIEW); if (useDistortionShader) { distortionShader.begin(); distortionBuffer.draw(viewport.getLeft(), viewport.getBottom(), viewport.width, -viewport.height); // draw FBO upside-down distortionShader.end(); } }
void PostProcessing::begin(ofCamera& cam) { // update camera matrices cam.begin(); cam.end(); raw.begin(ofFboBeginMode::NoDefaults); ofMatrixMode(OF_MATRIX_PROJECTION); ofPushMatrix(); ofLoadMatrix(cam.getProjectionMatrix(ofRectangle(0, 0, width, height))); ofMatrixMode(OF_MATRIX_MODELVIEW); ofPushMatrix(); ofLoadMatrix(cam.getModelViewMatrix()); ofViewport(0, 0, raw.getWidth(), raw.getHeight()); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); ofPushStyle(); glPushAttrib(GL_ENABLE_BIT); }
void PostProcessing::end(bool autoDraw) { glPopAttrib(); ofPopStyle(); ofViewport(0, 0, ofGetWidth(), ofGetHeight()); ofMatrixMode(OF_MATRIX_PROJECTION); ofPopMatrix(); ofMatrixMode(OF_MATRIX_MODELVIEW); ofPopMatrix(); raw.end(); ofPushStyle(); glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); ofSetColor(255, 255, 255); process(); if (autoDraw) draw(); glPopAttrib(); ofPopStyle(); }
void GamingScene6::Steup() { w_ = ofGetWindowWidth(); h_ = ofGetWindowHeight(); x_ = ofGetWindowPositionX(); y_ = ofGetWindowPositionY(); hand_pos_.set(200,200,0); hand_vel_.set(0,0,0); hand_radius_ = 50; max_hand_radius_ = 70; hand_mass_ = 1; moving_time_ = 0; moving_ = false; track_moving_ = false; interval_ = false; interval_time_ = 0; butterfly_pos_.set(350, 350,0); butterfly_vel_.set(0, 0, 0); butterfly_radius_ = 50; butterfly_mass_ = 1; ofEnableLighting(); main_camera_.setPosition(0,12,51); main_camera_.lookAt(ofVec3f(0,0,0)); ofBackground(0); ofSetFrameRate(60); ofSetVerticalSync(true); ofViewport(x_, y_, w_, h_, false); }
void ofFbo::begin() { bind(); ofPushView(); ofViewport(0, 0, getWidth(), getHeight(), false); ofSetupScreenPerspective(getWidth(), getHeight(), ofGetOrientation(), false); }