diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 766129f..28777ae 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -58,6 +58,7 @@ void Engine::Render(float elapsedTime) gameTime += elapsedTime; Transformation all; + Transformation skybox; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -67,7 +68,8 @@ void Engine::Render(float elapsedTime) m_player.Move(m_keyW, m_keyS, m_keyA, m_keyD, elapsedTime); m_player.ApplyTransformation(all); - all.Use(); + m_player.ApplyTransformation(skybox, false); + skybox.Use(); // Skybox m_textureSkybox.Bind(); @@ -75,44 +77,53 @@ void Engine::Render(float elapsedTime) glBegin(GL_QUADS); glTexCoord2f(1, 0); - glVertex3f(100.f, 100.f, 100.f); + glVertex3f(10.f, 10.f, 10.f); glTexCoord2f(0, 0); - glVertex3f(-100.f, 100.f, 100.f); + glVertex3f(-10.f, 10.f, 10.f); glTexCoord2f(0, 1); - glVertex3f(-100.f, -3.f, 100.f); + glVertex3f(-10.f, -10.f, 10.f); glTexCoord2f(1, 1); - glVertex3f(100.f, -3.f, 100.f); + glVertex3f(10.f, -10.f, 10.f); glTexCoord2f(1, 0); - glVertex3f(100.f, -3.f, -100.f); + glVertex3f(10.f, -10.f, -10.f); glTexCoord2f(0, 0); - glVertex3f(-100.f, -3.f, -100.f); + glVertex3f(-10.f, -10.f, -10.f); glTexCoord2f(0, 1); - glVertex3f(-100.f, 100.f, -100.f); + glVertex3f(-10.f, 10.f, -10.f); glTexCoord2f(1, 1); - glVertex3f(100.f, 100.f, -100.f); + glVertex3f(10.f, 10.f, -10.f); glTexCoord2f(1, 0); - glVertex3f(-100.f, 100.f, 100.f); + glVertex3f(-10.f, 10.f, 10.f); glTexCoord2f(0, 0); - glVertex3f(-100.f, 100.f, -100.f); + glVertex3f(-10.f, 10.f, -10.f); glTexCoord2f(0, 1); - glVertex3f(-100.f, -3.f, -100.f); + glVertex3f(-10.f, -10.f, -10.f); glTexCoord2f(1, 1); - glVertex3f(-100.f, -3.f, 100.f); + glVertex3f(-10.f, -10.f, 10.f); glTexCoord2f(1, 0); - glVertex3f(100.f, 100.f, -100.f); + glVertex3f(10.f, 10.f, -10.f); glTexCoord2f(0, 0); - glVertex3f(100.f, 100.f, 100.f); + glVertex3f(10.f, 10.f, 10.f); glTexCoord2f(0, 1); - glVertex3f(100.f, -3.f, 100.f); + glVertex3f(10.f, -10.f, 10.f); glTexCoord2f(1, 1); - glVertex3f(100.f, -3.f, -100.f); + glVertex3f(10.f, -10.f, -10.f); + + glTexCoord2f(0, 0); // Les coordos de textures sont intentionnellement laissées à 0 pour que l'engine sample 1 pixel et ainsi me fait une couleur unie. + glVertex3f(10.f, 10.f, -10.f); + glTexCoord2f(0, 0); + glVertex3f(10.f, 10.f, 10.f); + glTexCoord2f(0, 0); + glVertex3f(-10.f, 10.f, 10.f); + glTexCoord2f(0, 0); + glVertex3f(-10.f, 10.f, -10.f); glEnd(); glEnable(GL_DEPTH_TEST); - + all.Use(); // Plancher // Les vertex doivent etre affiches dans le sens anti-horaire (CCW) m_textureFloor.Bind(); diff --git a/SQCSim2021/openglcontext.cpp b/SQCSim2021/openglcontext.cpp index 356d22e..b89d5d5 100644 --- a/SQCSim2021/openglcontext.cpp +++ b/SQCSim2021/openglcontext.cpp @@ -152,7 +152,7 @@ void OpenglContext::ShowCrossCursor() const void OpenglContext::InitWindow(int width, int height) { - m_app.create(sf::VideoMode(width, height, 32), m_title.c_str(), m_fullscreen ? sf::Style::Fullscreen : (sf::Style::Resize|sf::Style::Close), sf::ContextSettings(32, 8, 0)); + m_app.create(sf::VideoMode(width, height, 32), m_title.c_str(), m_fullscreen ? sf::Style::Fullscreen : (sf::Style::Resize|sf::Style::Close), sf::ContextSettings(32, 8, 4)); } OpenglContext::MOUSE_BUTTON OpenglContext::ConvertMouseButton(sf::Mouse::Button button) const diff --git a/SQCSim2021/player.cpp b/SQCSim2021/player.cpp index fc8efd9..95a3321 100644 --- a/SQCSim2021/player.cpp +++ b/SQCSim2021/player.cpp @@ -40,8 +40,8 @@ void Player::Move(bool front, bool back, bool left, bool right, float elapsedTim } } -void Player::ApplyTransformation(Transformation& transformation) const { +void Player::ApplyTransformation(Transformation& transformation, bool rel) const { transformation.ApplyRotation(-m_rotX, 1.f, 0, 0); transformation.ApplyRotation(-m_rotY, 0, 1.f, 0); - transformation.ApplyTranslation(-m_position); + if (rel) transformation.ApplyTranslation(-m_position); } diff --git a/SQCSim2021/player.h b/SQCSim2021/player.h index ea37472..a359daa 100644 --- a/SQCSim2021/player.h +++ b/SQCSim2021/player.h @@ -9,7 +9,7 @@ public: void TurnLeftRight(float value); void TurnTopBottom(float value); void Move(bool front, bool back, bool left, bool right, float elapsedTime); - void ApplyTransformation(Transformation& transformation) const; + void ApplyTransformation(Transformation& transformation, bool rel = true) const; private: Vector3f m_position;