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);
}
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);

View File

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

View File

@ -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();

View File

@ -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;

View File

@ -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();