From: Timo Lotterbach Date: Mon, 12 Dec 2011 13:19:44 +0000 (+0100) Subject: EGLX11MockNavigation: Camera aspect ratio was hard coded, now using viewport width... X-Git-Tag: ivi-layer-management_version_0_9_5_rc~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abfb1480a3d69e402057acced86d8f82d363d956;p=profile%2Fivi%2Flayer-management.git EGLX11MockNavigation: Camera aspect ratio was hard coded, now using viewport width and height to calculate aspect ratio --- diff --git a/LayerManagerExamples/EGLX11MockNavigation/include/Camera.h b/LayerManagerExamples/EGLX11MockNavigation/include/Camera.h index c070025..5ec44cf 100644 --- a/LayerManagerExamples/EGLX11MockNavigation/include/Camera.h +++ b/LayerManagerExamples/EGLX11MockNavigation/include/Camera.h @@ -26,7 +26,7 @@ class Camera : public IUpdateable { public: - Camera(vec3f position, vec3f target); + Camera(vec3f position, vec3f target, float viewportWidth, float viewportHeight); virtual ~Camera(); IlmMatrix* getViewProjectionMatrix(); diff --git a/LayerManagerExamples/EGLX11MockNavigation/src/Camera.cpp b/LayerManagerExamples/EGLX11MockNavigation/src/Camera.cpp index 55a590d..3ba753c 100644 --- a/LayerManagerExamples/EGLX11MockNavigation/src/Camera.cpp +++ b/LayerManagerExamples/EGLX11MockNavigation/src/Camera.cpp @@ -24,18 +24,18 @@ #include #include -Camera::Camera(vec3f position, vec3f target) +Camera::Camera(vec3f position, vec3f target, float viewportWidth, float viewportHeight) : m_position(position) , m_target(target) { - IlmMatrixIdentity(m_identityMatrix); - IlmMatrixTranslation(m_translationMatrix, m_position.x, m_position.y, m_position.z); - IlmMatrixRotateX(m_rotationMatrix, 45.0); - IlmMatrixProjection(m_projectionMatrix, - 45.0, // field of view - 0.1f, // near - 1000.0f, // far - 800.0/480.0); // aspect ration + IlmMatrixIdentity(m_identityMatrix); + IlmMatrixTranslation(m_translationMatrix, m_position.x, m_position.y, m_position.z); + IlmMatrixRotateX(m_rotationMatrix, 45.0); + IlmMatrixProjection(m_projectionMatrix, + 45.0, // field of view + 0.1f, // near + 1000.0f, // far + viewportWidth/viewportHeight); // aspect ratio } Camera::~Camera() @@ -44,19 +44,19 @@ Camera::~Camera() IlmMatrix* Camera::getViewProjectionMatrix() { - return &m_viewProjectionMatrix; + return &m_viewProjectionMatrix; } void Camera::update(int currentTimeInMs, int lastFrameTime) { - (void)currentTimeInMs; // prevent warning - (void)lastFrameTime; // prevent warning + (void)currentTimeInMs; // prevent warning + (void)lastFrameTime; // prevent warning - IlmMatrixTranslation(m_translationMatrix, m_position.x, m_position.y, m_position.z); + IlmMatrixTranslation(m_translationMatrix, m_position.x, m_position.y, m_position.z); - m_viewProjectionMatrix = m_identityMatrix; - //IlmMatrixMultiply(m_viewProjectionMatrix, m_viewProjectionMatrix, m_rotationMatrix); - IlmMatrixMultiply(m_viewProjectionMatrix, m_viewProjectionMatrix, m_translationMatrix); - IlmMatrixMultiply(m_viewProjectionMatrix, m_viewProjectionMatrix, m_projectionMatrix); + m_viewProjectionMatrix = m_identityMatrix; + //IlmMatrixMultiply(m_viewProjectionMatrix, m_viewProjectionMatrix, m_rotationMatrix); + IlmMatrixMultiply(m_viewProjectionMatrix, m_viewProjectionMatrix, m_translationMatrix); + IlmMatrixMultiply(m_viewProjectionMatrix, m_viewProjectionMatrix, m_projectionMatrix); } diff --git a/LayerManagerExamples/EGLX11MockNavigation/src/MockNavi.cpp b/LayerManagerExamples/EGLX11MockNavigation/src/MockNavi.cpp index ee5f141..5e155e0 100644 --- a/LayerManagerExamples/EGLX11MockNavigation/src/MockNavi.cpp +++ b/LayerManagerExamples/EGLX11MockNavigation/src/MockNavi.cpp @@ -31,7 +31,7 @@ MockNavi::MockNavi(float fps, float animationSpeed, SurfaceConfiguration* config) : OpenGLES2App(fps, animationSpeed, config) -, m_camera(vec3f(-1.5 * CITY_GRID_SIZE, -0.1, 0.0), vec3f(0.0, 0.0, 0.0)) +, m_camera(vec3f(-1.5 * CITY_GRID_SIZE, -0.1, 0.0), vec3f(0.0, 0.0, 0.0), config->surfaceWidth, config->surfaceHeight) , m_houseCount(15) { generateCity();