No more disabling buffers, just enable the next one.

This commit is contained in:
Dane Johnson 2021-03-08 14:02:18 -06:00
parent 2fa2082098
commit ccd69afc2e
5 changed files with 19 additions and 17 deletions

View File

@ -69,13 +69,6 @@ void Screen::Enable() {
glEnable(GL_DEPTH_TEST); 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() { void Screen::Draw() {
glBindVertexArray(quad); glBindVertexArray(quad);
glDrawArrays(GL_TRIANGLES, 0, 6); glDrawArrays(GL_TRIANGLES, 0, 6);

View File

@ -14,7 +14,6 @@ class Screen {
public: public:
Screen(); Screen();
void Enable(); void Enable();
void Disable();
void Draw(); void Draw();
const int width = 640; const int width = 640;
const int height = 480; const int height = 480;

View File

@ -32,6 +32,14 @@ bool Window::ShouldClose() {
return glfwWindowShouldClose(glfwWindow); 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() { void Window::Update() {
glfwSwapBuffers(glfwWindow); glfwSwapBuffers(glfwWindow);
glfwPollEvents(); glfwPollEvents();

View File

@ -31,19 +31,23 @@ class Window {
public: public:
/** /**
Initializes the window. Initializes the window.
*/ */
void Init(); void Init();
/** /**
@returns whether or not the user tried to close the window @returns whether or not the user tried to close the window
*/ */
bool ShouldClose(); bool ShouldClose();
/** /**
Close the window. Begin rendering to the window
*/ */
void Enable();
/** /**
Swap the buffers and poll for events Swap the buffers and poll for events
*/ */
void Update(); void Update();
/**
Close the window.
*/
void Close(); void Close();
private: private:
friend class Input; friend class Input;

View File

@ -133,13 +133,11 @@ int main() {
glDepthFunc(GL_LESS); glDepthFunc(GL_LESS);
} }
// Stop rendering to texture // Render to the window
screen.Disable(); window.Enable();
// // Render the screen
screenShader->Use(); screenShader->Use();
screenShader->UpdateTex(screen.tex); screenShader->UpdateTex(screen.tex);
// Ummm?
// glViewport(0, 0, width, height);
screen.Draw(); screen.Draw();
window.Update(); window.Update();