void resizeGL(unsigned int width, unsigned int height) { glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); setPerspective(45, (float)width/height, 0.1, 100.0); }
// Creates a default camera resembling Maya Persp CameraPersp::CameraPersp() : Camera(), mLensShift( Vec2f::zero() ) { lookAt( Vec3f( 28.0f, 21.0f, 28.0f ), Vec3f::zero(), Vec3f::yAxis() ); setCenterOfInterest( 44.822f ); setPerspective( 35.0f, 1.0f, 0.1f, 1000.0f ); }
Camera::Camera() : _pitch(0), _yaw(0), _position(0,0,0), _moveSpeed(1.0f), _movementFlags(0) { updateViewMatrix(); setPerspective(60.0f, 16.0f/9.0f, 0.01f, 100.0f); }
// Creates a default camera resembling Maya Persp CameraPersp::CameraPersp() : Camera() { lookAt( vec3( 28, 21, 28 ), vec3(), vec3( 0, 1, 0 ) ); setCenterOfInterest( 44.822f ); setPerspective( 35, 1, 0.1f, 1000 ); }
void AbstractContent::slotSetPerspective(const QPointF & sceneRelPoint, Qt::KeyboardModifiers modifiers) { if (modifiers & Qt::ControlModifier) return slotClearPerspective(); qreal k = modifiers == Qt::NoModifier ? 0.2 : 0.5; setPerspective(QPointF(qBound((qreal)-70.0, (qreal)sceneRelPoint.x()*k, (qreal)70.0), qBound((qreal)-70.0, (qreal)sceneRelPoint.y()*k, (qreal)70.0))); }
void ElevatorSimRenderWindow::setViewport() { glViewport(0, 0, w(), h()); float ratio = (float)w() / (float)h(); setPerspective(45.0, 1.0*ratio, 1.0, 200.0); }
Camera::Camera(float fovY, float aspectRatio, float near, float far) : m_speed(10), m_up(0,1,0), m_transform(1), m_view(1) { setPerspective(fovY, aspectRatio, near, far); }
void Camera::setViewport(float x0, float y0, float xn, float yn) { m_viewport[0] = x0; m_viewport[1] = y0; m_viewport[2] = xn; m_viewport[3] = yn; setPerspective(m_near, m_far, m_fov, xn/yn); }
void GlWindow::resizeGL( int w, int h ) { glViewport( 0, 0, w, h ); float a = w / static_cast<GLfloat>(h); // printf( "Size: (%d,%d) - AspectRatio: %f\n", w, h, a ); setPerspective( 45.0f, a, 0.1f, 100.0f ); }
void OGLViewer::resetCamera() { Transform cam2w = lookAt(Point3D(30, 10, 30), Point3D(0.0, 0.0, 0.0), Point3D(0, 1, 0)); Transform pers = Transform(setPerspective(67, width() / static_cast<double>(height()), 0.1, 500)); view_cam = new perspCamera(cam2w, pers); view_cam->exportVBO(view_mat, proj_mat, nullptr); //update(); }
Camera::Camera(void) { p_position = D3DXVECTOR3(0.0f,0.0f,10.0f); p_updir = D3DXVECTOR3(0.0f,1.0f,0.0f); //hard coded to 1.3333 by default float ratio = 640 / 480; setPerspective(3.14159f / 4, ratio, 1.0f, 2000.0f); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->action,SIGNAL(changed()),ui->SceneWidget,SLOT(setOrthogonal())); connect(ui->action_2,SIGNAL(changed()),ui->SceneWidget,SLOT(setPerspective())); connect(ui->SceneWidget,SIGNAL(setPerspectiveInfo(QString)),ui->label,SLOT(setText(QString))); connect(ui->SceneWidget,SIGNAL(setFiguresInfo(QString)),ui->label_2,SLOT(setText(QString))); }
static void myReshape(int w, int h) { /* Callback function to handle window dimensions and size changes */ glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); /* specifies the current matrix */ glLoadIdentity(); /* Sets the currant matrix to identity */ // gluPerspective(30,1.0,0.1,20.0); //ankle, aspect ratio x/y, near, far // gluLookAt(0,0,10,0.5,0.5,0.5,0,1,0); //Eye:XYZ, Center XYZ, Up XYZ setPerspective(); }
void Camera::centerOn(float center[4], float halfDists[4]) { vec4fCopy(m_o, center); m_radius = vec3fNorm(halfDists) * 2.f; if (m_far < m_radius) { m_far = 1.5 * m_radius; setPerspective(m_near, m_far, m_fov, m_ratio); } }
///// resizeGL //////////////////////////////////////////////////////////////// void GLView::resizeGL(int w, int h) /// Overridden from QGlWidget::resizeGL(). /// Resizes the OpenGL viewport according to the size of the widget. { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); //aspectRatio = static_cast<float>(w) / static_cast<float>(h); setPerspective(); // calls gluPerspective or glOrtho depending on the prespective setting glMatrixMode(GL_MODELVIEW); }
void GLWidget::resizeGL(int width, int height) { glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); setPerspective(); glMatrixMode(GL_MODELVIEW); updateGL(); }
Camera::Camera() { rotX = 0.0f; rotY = 0.0f; rotZ = 0.0f; setPos(0.0f, 0.0f, 70.0f); setPerspective(45.0f, 1.0f, 0.1f, 200.0f); recalcRotateView(); Model = glm::scale(glm::mat4(1.0f), glm::vec3(1.0f)); MVP = Projection * View * Model; }
void GLES2Lesson::render() { clearBuffers(); prepareShaderProgram(); setPerspective(); resetTransformMatrices(); drawGeometry(vboCubeVertexDataIndex, vboCubeVertexIndicesIndex, 36, cubeTransformMatrix ); }
void CCCameraBase::setupViewport(float x, float y, float width, float height, const int frameBufferID) { this->frameBufferID = frameBufferID; viewportX = x; viewportY = y; viewportX2 = x+width; viewportY2 = y+height; viewportWidth = width; viewportHeight = height; invViewportWidth = 1.0f / viewportWidth; invViewportHeight = 1.0f / viewportHeight; if( frameBufferID == -1 ) { const CCTarget<float> &orientation = CCAppManager::GetOrientation(); if( orientation.target == 270.0f ) { CCSwapFloat( x, y ); CCSwapFloat( width, height ); x = 1.0f - width - x; } else if( orientation.target == 90.0f ) { CCSwapFloat( x, y ); CCSwapFloat( width, height ); y = 1.0f - height - y; } else if( orientation.target == 180.0f ) { x = 1.0f - width - x; y = 1.0f - height - y; } else { } } const float invY = ( 1.0f-height ) - y; const float frameBufferWidth = gEngine->renderer->frameBufferManager.getWidth( frameBufferID ); const float frameBufferHeight = gEngine->renderer->frameBufferManager.getHeight( frameBufferID ); const float definedWidth = width * frameBufferWidth; const float definedHeight = height * frameBufferHeight; viewport[0] = x * frameBufferWidth; viewport[1] = invY * frameBufferHeight; viewport[2] = definedWidth; viewport[3] = definedHeight; aspectRatio = definedWidth / definedHeight; setPerspective( perspective ); }
void zoom_in(){ if(!ortho){ if(view_angle>20)view_angle-=1; else if(view_angle>1)view_angle-=.1; else return; } else{ if(view_angle>-8) view_angle-=1; } setPerspective(GL_RENDER,0,0); }
void zoom_out(){ if(!ortho){ if(view_angle<150)view_angle+=1; else if(view_angle<170)view_angle+=.1; else return; } else { view_angle+=1; } setPerspective(GL_RENDER,0,0); }
void MyWorld::Update() { // Adjust perspective based on dimensions of screen to keep board in view int max = IwGxGetScreenHeight() > IwGxGetScreenWidth() ? IwGxGetScreenHeight() : IwGxGetScreenWidth(); setPerspective(480.0f - (1024 - max) / 2); // Update camera swing if (CamSwing) { float d = CamSwingTime / CAM_SWING_TIME; LookFrom.x = StartCamSwingPos.x + (FinalCamSwingPos.x - StartCamSwingPos.x) * d; LookFrom.y = StartCamSwingPos.y + (FinalCamSwingPos.y - StartCamSwingPos.y) * d; LookFrom.z = StartCamSwingPos.z + (FinalCamSwingPos.z - StartCamSwingPos.z) * d; TransformDirty = true; CamSwingTime++; if (CamSwingTime > CAM_SWING_TIME) { CamSwing = false; CamSwingTime = 0; } } // TODO: Add world logic here World::Update(); switch (GameState) { case eGameState_GameOver: if (GameOverTimer.HasTimedOut()) { RestartGame(); } break; case eGameState_Running: if (TurnsLeftChanged) { char str[64]; snprintf(str, 64, "%u", TurnsLeft); TurnsLeftLabel->setText(str); TurnsLeftChanged = false; } if (RoundChanged) { char str[64]; snprintf(str, 64, "%u", Round); RoundLabel->setText(str); RoundChanged = false; } break; } }
void Camera::reset( GLfloat width, GLfloat height ) { setPos(m_InitialPos); setDir(m_InitialDir); setUp(m_InitialUp); setPerspective(m_InitialFOV, width, height, m_InitialNear, m_InitialFar); m_Pitch = 0.0f; m_Yaw = 0.0f; m_Speed = m_InitialSpeed; m_PosDelta = vec3(0.0f); }
//-------------------------------------------------------------------------- Camera::Camera() : mAnimationComponent(mTransformComponent), mCurrentTranslationAnimation(nullptr), mCurrentSlerpAnimation(nullptr) { mView = glm::lookAt(glm::vec3(0.0f, 0.0, 7.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)); mZoom = 1.0f; //Perspective values mBaseFov = DEFAULT_FOVY; setPerspective(mBaseFov, DEFAULT_ASPECT_RATIO, DEFAULT_NEAR_PLANE, DEFAULT_FAR_PLANE); }
void onReshape (int width, int height) /* pre: glut window has been resized post: resets cameras location and aspect to match window */ { glViewport(0, 0, width, height); if (! isFullScreen) { theWindowWidth = width; theWindowHeight = height; } /* set camera to view resized area */ setPerspective(GL_RENDER,0,0); }
static void RenderScene(void) { /* Creating the Scene */ // Clear screen and Z-buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(0,0,0.5); /* Farbe festlegen */ glMatrixMode( GL_MODELVIEW ); // Modell-Matrixstack wählen glLoadIdentity(); // Die Matrix zurücksetzen glCallList(CUBE); glMatrixMode( GL_PROJECTION ); // World-Matrixstack wählen glLoadIdentity(); // Die Matrix zurücksetzen setPerspective(); glutSwapBuffers(); }
CameraPersp::CameraPersp( int pixelWidth, int pixelHeight, float fovDegrees, float nearPlane, float farPlane ) : Camera(), mLensShift( Vec2f::zero() ) { float halfFov, theTan, aspect; float eyeX = pixelWidth / 2.0f; float eyeY = pixelHeight / 2.0f; halfFov = 3.14159f * fovDegrees / 360.0f; theTan = cinder::math<float>::tan( halfFov ); float dist = eyeY / theTan; aspect = pixelWidth / (float)pixelHeight; setPerspective( fovDegrees, aspect, nearPlane, farPlane ); lookAt( Vec3f( eyeX, eyeY, dist ), Vec3f( eyeX, eyeY, 0.0f ) ); }
CameraPersp::CameraPersp( int pixelWidth, int pixelHeight, float fovDegrees ) : Camera() { float eyeX = pixelWidth / 2.0f; float eyeY = pixelHeight / 2.0f; float halfFov = 3.14159f * fovDegrees / 360.0f; float theTan = cinder::math<float>::tan( halfFov ); float dist = eyeY / theTan; float nearDist = dist / 10.0f; // near / far clip plane float farDist = dist * 10.0f; float aspect = pixelWidth / (float)pixelHeight; setPerspective( fovDegrees, aspect, nearDist, farDist ); lookAt( vec3( eyeX, eyeY, dist ), vec3( eyeX, eyeY, 0.0f ) ); }
void renderFn() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); g_program.use(); setPerspective(); glActiveTexture(GL_TEXTURE9); glBindTexture(GL_TEXTURE_2D, omap2); g_program.setUniform("MaxTessLevel", max_tess); g_program.setUniform("ModelView", g_modelview); g_program.setUniform("Projection", g_projection); g_program.setUniform("MVP", g_projection * g_modelview); g_program.setUniform("NormalMatrix", glm::inverseTranspose(mat3(g_modelview))); g_program.setUniform("MousePosition", mouse); g_program.setUniform("Time", elapsed); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); renderLand(); d_program.use(); glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &plv); glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, 1, &plf); glActiveTexture(GL_TEXTURE9); glBindTexture(GL_TEXTURE_2D, plane); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); renderPlane(scene->mRootNode); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); d_program.setUniform("FrameTime", clockdiff); d_program.setUniform("Elapsed", elapsed); glUniformSubroutinesuiv(GL_VERTEX_SHADER, 1, &pav); glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, 1, &paf); renderParticles(); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); }
void GLES2Lesson::render() { clearBuffers(); prepareShaderProgram(); setPerspective(); resetTransformMatrices(); for (auto &star : mStars) { glUniform4fv(fragmentTintPosition, 1, &star->mColor[0]); drawGeometry(vboCubeVertexDataIndex, vboCubeVertexIndicesIndex, 4, star->mTransform ); } }