From ccd69afc2eb5145f9ab0ad9608116dc4d9654339 Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Mon, 8 Mar 2021 14:02:18 -0600 Subject: [PATCH] No more disabling buffers, just enable the next one. --- core/Screen.cpp | 7 ------- core/Screen.h | 1 - core/Window.cpp | 8 ++++++++ core/Window.h | 12 ++++++++---- core/couch.cpp | 8 +++----- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/core/Screen.cpp b/core/Screen.cpp index 8ba1ee4..5be3959 100644 --- a/core/Screen.cpp +++ b/core/Screen.cpp @@ -69,13 +69,6 @@ void Screen::Enable() { glEnable(GL_DEPTH_TEST); } -void Screen::Disable() { - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - glDisable(GL_DEPTH_TEST); -} - void Screen::Draw() { glBindVertexArray(quad); glDrawArrays(GL_TRIANGLES, 0, 6); diff --git a/core/Screen.h b/core/Screen.h index eeb95af..cf797e2 100644 --- a/core/Screen.h +++ b/core/Screen.h @@ -14,7 +14,6 @@ class Screen { public: Screen(); void Enable(); - void Disable(); void Draw(); const int width = 640; const int height = 480; diff --git a/core/Window.cpp b/core/Window.cpp index 743dafa..a870572 100644 --- a/core/Window.cpp +++ b/core/Window.cpp @@ -32,6 +32,14 @@ bool Window::ShouldClose() { return glfwWindowShouldClose(glfwWindow); } +void Window::Enable() { + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + glDisable(GL_DEPTH_TEST); + glViewport(0, 0, width, height); +} + void Window::Update() { glfwSwapBuffers(glfwWindow); glfwPollEvents(); diff --git a/core/Window.h b/core/Window.h index 7c390f8..e9cd0ae 100644 --- a/core/Window.h +++ b/core/Window.h @@ -31,19 +31,23 @@ class Window { public: /** Initializes the window. - */ + */ void Init(); /** @returns whether or not the user tried to close the window - */ + */ bool ShouldClose(); /** - Close the window. + Begin rendering to the window */ + void Enable(); /** Swap the buffers and poll for events - */ + */ void Update(); + /** + Close the window. + */ void Close(); private: friend class Input; diff --git a/core/couch.cpp b/core/couch.cpp index c452996..9bb45ae 100644 --- a/core/couch.cpp +++ b/core/couch.cpp @@ -133,13 +133,11 @@ int main() { glDepthFunc(GL_LESS); } - // Stop rendering to texture - screen.Disable(); - // // Render the screen + // Render to the window + window.Enable(); + screenShader->Use(); screenShader->UpdateTex(screen.tex); - // Ummm? - // glViewport(0, 0, width, height); screen.Draw(); window.Update();