From 04c31686ecf4588e661c0dc9cda267eb67bb86ca Mon Sep 17 00:00:00 2001 From: elipzer Date: Mon, 15 Oct 2018 11:42:12 -0400 Subject: [PATCH] Fixed reverse-texture rendering by flipping the camera "handedness" --- Example/MyBuiltinCubeScene.cpp | 2 +- Example/MyBuiltinTexturedScene.cpp | 2 +- Example/MySimple3DScene.cpp | 2 +- Example/MySimpleCubeScene.cpp | 2 +- OpenGLEngine/Camera3D.h | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Example/MyBuiltinCubeScene.cpp b/Example/MyBuiltinCubeScene.cpp index 6b2c258..e73628a 100644 --- a/Example/MyBuiltinCubeScene.cpp +++ b/Example/MyBuiltinCubeScene.cpp @@ -9,7 +9,7 @@ MyBuiltinCubeScene::MyBuiltinCubeScene(Application& application) : Scene(application), m_shape(meshgenerator::gen_cube_p(DRAW_TRIANGLES, 2.0f, 2.0f, 2.0f), DrawMode::DRAW_TRIANGLES), - m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f)), + m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f)), m_batch(&m_shape, 2) { m_pipeline.add_batch(&m_batch); diff --git a/Example/MyBuiltinTexturedScene.cpp b/Example/MyBuiltinTexturedScene.cpp index e06ce1c..19950d0 100644 --- a/Example/MyBuiltinTexturedScene.cpp +++ b/Example/MyBuiltinTexturedScene.cpp @@ -22,7 +22,7 @@ MyBuiltinTexturedScene::MyBuiltinTexturedScene(Application& application) TextureFactory::gen_image_texture(m_sprite_image), texturegenerator::gen_quick_sampler() ), - m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f)), + m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f), vec3(0.0f, 0.0f, -1.0f)), m_cube_batch(&m_cube, 2), m_sprite_batch(&m_sprite, 1) { diff --git a/Example/MySimple3DScene.cpp b/Example/MySimple3DScene.cpp index 1ce0234..e386064 100644 --- a/Example/MySimple3DScene.cpp +++ b/Example/MySimple3DScene.cpp @@ -18,7 +18,7 @@ MySimple3DScene::MySimple3DScene(Application& application) MySimpleShaderProgram::Vertex(2.0f, -1.0f, 0.0f) ), DrawMode::DRAW_TRIANGLES), m_batch(&m_shape, 2), - m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f)) + m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f)) {} MySimple3DScene::~MySimple3DScene() diff --git a/Example/MySimpleCubeScene.cpp b/Example/MySimpleCubeScene.cpp index 9bb1203..59eaa32 100644 --- a/Example/MySimpleCubeScene.cpp +++ b/Example/MySimpleCubeScene.cpp @@ -18,7 +18,7 @@ MySimpleCubeScene::MySimpleCubeScene(Application& application) MySimpleShaderProgram::Vertex( 1.0f, -1.0f, 1.0f) ), DrawMode::DRAW_TRIANGLES), m_batch(&m_shape, 1), - m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f)) + m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f)) {} MySimpleCubeScene::~MySimpleCubeScene() diff --git a/OpenGLEngine/Camera3D.h b/OpenGLEngine/Camera3D.h index ac63ebc..c5f568f 100644 --- a/OpenGLEngine/Camera3D.h +++ b/OpenGLEngine/Camera3D.h @@ -17,7 +17,7 @@ namespace charcoal float znear, float zfar, const vec3& position, - const vec3& forward = vec3(0.0f, 0.0f, 1.0f), + const vec3& forward = vec3(0.0f, 0.0f, -1.0f), const vec3& up = vec3(0.0f, 1.0f, 0.0f), const vec3& right = vec3(0.0f) // Zero for auto-calculated ); @@ -27,7 +27,7 @@ namespace charcoal // Updates the orientation based on three vectors. // If right is equal to zero it is calculated with glm::cross(forward, up). // Then the true up is calculated with glm::cross(right, forward) - void update_orientation(const vec3& forward = vec3(0.0f, 0.0f, 1.0f), const vec3& up = vec3(0.0f, 1.0f, 0.0f), const vec3& right = vec3(0.0f)); + void update_orientation(const vec3& forward = vec3(0.0f, 0.0f, -1.0f), const vec3& up = vec3(0.0f, 1.0f, 0.0f), const vec3& right = vec3(0.0f)); // Directly sets the forward, up, and right values. void direct_update_orientation(const vec3& forward, const vec3& up, const vec3& right);