diff --git a/src/Pudding.cpp b/src/Pudding.cpp index 75eb50d..66fe6ba 100644 --- a/src/Pudding.cpp +++ b/src/Pudding.cpp @@ -175,8 +175,8 @@ void Pudding::load_gl_context() flat_program = glCreateProgram(); glAttachShader(flat_program, vertex_shader); glAttachShader(flat_program, fragment_shader); - plane.attributes("position")->bind(0, flat_program, "in_position"); - plane.attributes("uv")->bind(1, flat_program, "vertex_uv"); + Plane::position->bind(0, flat_program, "in_position"); + Plane::uv->bind(1, flat_program, "vertex_uv"); /* load, configure and link the 3D world program */ vertex_shader = load_shader("src/mvp.vert", GL_VERTEX_SHADER); fragment_shader = load_shader("src/mvp.frag", GL_FRAGMENT_SHADER); @@ -188,9 +188,9 @@ void Pudding::load_gl_context() pudding_model.attributes("color")->bind(4, mvp_program, "vertex_color"); sb::Log::gl_errors("after loading shaders"); /* Fill VBO with attribute data */ - vbo.allocate(plane.size() + pudding_model.size(), GL_STATIC_DRAW); - vbo.add(*plane.attributes("position")); - vbo.add(*plane.attributes("uv")); + vbo.allocate(background.size() + pudding_model.size(), GL_STATIC_DRAW); + vbo.add(*Plane::position); + vbo.add(*Plane::uv); vbo.add(*pudding_model.attributes("uv")); vbo.add(*pudding_model.attributes("position")); vbo.add(*pudding_model.attributes("color")); @@ -737,9 +737,9 @@ void Pudding::update() /* switch to flat shader for background */ glUseProgram(flat_program); glUniform1f(uniform["flat"]["time"], time_seconds); - /* disable pudding attributes and enable rectangle attributes */ + /* disable pudding attributes and enable background attributes */ pudding_model.disable(); - plane.enable(); + background.enable(); glUniform1i(uniform["flat"]["texture"], 0); glActiveTexture(GL_TEXTURE0); background.current().bind(); @@ -747,7 +747,7 @@ void Pudding::update() glUniform3f(uniform["flat"]["blend"], 0.0f, 0.0f, 1.0f); glUniform1i(uniform["flat"]["scroll"], true); /* draws rectangle vertices and rectangle texture using UV coords */ - glDrawArrays(GL_TRIANGLES, 0, plane.attributes("position")->count()); + glDrawArrays(GL_TRIANGLES, 0, background.attributes("position")->count()); glUniform1i(uniform["flat"]["scroll"], false); /* draw pudding model using MVP shader */ glUseProgram(mvp_program); @@ -759,8 +759,8 @@ void Pudding::update() mvp = projection * VIEW_MATRIX * model; /* pass the mvp matrix to the shader */ glUniformMatrix4fv(uniform["mvp"]["mvp"], 1, GL_FALSE, &mvp[0][0]); - /* disable rectangle attributes and enable pudding attributes */ - plane.disable(); + /* disable bg attributes and enable pudding attributes */ + background.disable(); pudding_model.attributes("position")->enable(); if (items.size() == 0) { @@ -795,9 +795,7 @@ void Pudding::update() { /* switch to flat shader for item and camera */ glUseProgram(flat_program); - /* disable pudding attributes and enable rectangle attributes */ pudding_model.disable(); - plane.enable(); glDisable(GL_DEPTH_TEST); /* just need to set these once since we're drawing one texture per viewport */ glUniform1i(uniform["flat"]["texture"], 0); @@ -817,6 +815,7 @@ void Pudding::update() } glViewport(viewport_box.left(), viewport_box.bottom(), viewport_box.width(), viewport_box.height()); current_item().get_active_image_texture().bind(); + plane.enable(); /* draws rectangle vertices and rectangle texture using UV coords */ glDrawArrays(GL_TRIANGLES, 0, plane.attributes("position")->count()); } @@ -827,8 +826,9 @@ void Pudding::update() glViewport(viewport_box.left(), viewport_box.bottom(), viewport_box.width(), viewport_box.height()); /* bind texture for drawing */ camera_view.current().bind(); + camera_view.enable(); /* draws rectangle vertices and rectangle texture using UV coords */ - glDrawArrays(GL_TRIANGLES, 0, plane.attributes("position")->count()); + glDrawArrays(GL_TRIANGLES, 0, camera_view.attributes("position")->count()); } } SDL_GL_SwapWindow(get_window());