Commit 45dffaf5 authored by Justine Martin's avatar Justine Martin 💖
Browse files

feat : Implémentation basique du Split-Screen

parent 16a49518
Loading
Loading
Loading
Loading
+4 −0
Changes for include/GlApplication.hpp: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ class GlApplication : public Application {
        void setCallbacks() override;
        static void usage(std::string & shortDescritpion, std::string & synopsis, std::string & description);

        void setFramebufferSize(int framebufferWidth, int framebufferHeight);

    public:
        static bool displayNormals; ///< Toggles normal display

@@ -43,4 +45,6 @@ class GlApplication : public Application {
        float m_eyeTheta;                                     ///< Camera position latitude angle
        float m_currentTime;                                  ///< elapsed time since first frame
        float m_deltaTime;                                    ///< elapsed time since last frame
        int m_framebufferWidth;                               ///< Window's width
        int m_framebufferHeight;                              ///< Window's height
};
+18 −2
Changes for src/GlApplication.cpp: 18 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

bool GlApplication::displayNormals;

GlApplication::GlApplication(int windowWidth, int windowHeight) : Application(windowWidth, windowHeight), m_currentTime(0), m_deltaTime(0)
GlApplication::GlApplication(int windowWidth, int windowHeight) : Application(windowWidth, windowHeight), m_currentTime(0), m_deltaTime(0), m_framebufferHeight(windowHeight), m_framebufferWidth(windowWidth)
{
    GLFWwindow * window = glfwGetCurrentContext();
    glfwGetFramebufferSize(window, &windowWidth, &windowHeight);
@@ -32,6 +32,7 @@ GlApplication::GlApplication(int windowWidth, int windowHeight) : Application(wi
    
    mw = glm::mat4(1);
    mw = glm::scale(mw, {0.2, 0.2, 0.2});
    mw = glm::translate(mw, {0, 0, 4});
    m_objects.push_back(RenderObject::createWavefrontInstance("meshes/fighter/fighter_blue.obj", mw));
}

@@ -58,6 +59,14 @@ void GlApplication::renderFrame()
    glClearColor(0, 0, 0, 1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glViewport(0, 0, m_framebufferWidth, m_framebufferHeight / 2);

    for (auto & object : m_objects) {
        object->draw();
    }

    glViewport(0, m_framebufferHeight / 2, m_framebufferWidth, m_framebufferHeight / 2);

    for (auto & object : m_objects) {
        object->draw();
    }
@@ -117,8 +126,10 @@ void GlApplication::resize(GLFWwindow * window, int framebufferWidth, int frameb
{
    GlApplication & app = *static_cast<GlApplication *>(glfwGetWindowUserPointer(window));
    float aspect = framebufferWidth / float(framebufferHeight);
    app.m_proj = glm::perspective(120.f, aspect, 0.1f, 100.f);
    app.m_proj = glm::perspective(90.f, aspect, 0.1f, 100.f);
    glViewport(0, 0, framebufferWidth, framebufferHeight);
    
    app.setFramebufferSize(framebufferWidth, framebufferHeight);
}

void GlApplication::keyCallback(GLFWwindow * window, int key, int /*scancode*/, int action, int /*mods*/)
@@ -135,3 +146,8 @@ void GlApplication::keyCallback(GLFWwindow * window, int key, int /*scancode*/,
            break;
    }
}

void GlApplication::setFramebufferSize(int framebufferWidth, int framebufferHeight) {
    m_framebufferWidth = framebufferWidth;
    m_framebufferHeight = framebufferHeight;
}
 No newline at end of file