diff --git a/Example/MyBuiltinCubeScene.cpp b/Example/MyBuiltinCubeScene.cpp index e73628a..55b2a24 100644 --- a/Example/MyBuiltinCubeScene.cpp +++ b/Example/MyBuiltinCubeScene.cpp @@ -10,7 +10,7 @@ MyBuiltinCubeScene::MyBuiltinCubeScene(Application& application) : Scene(application), m_shape(meshgenerator::gen_cube_p(DRAW_TRIANGLES, 2.0f, 2.0f, 2.0f), DrawMode::DRAW_TRIANGLES), m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f)), - m_batch(&m_shape, 2) + m_batch(&m_shape) { m_pipeline.add_batch(&m_batch); m_pipeline.set_camera(&m_camera); diff --git a/Example/MyBuiltinLitScene.cpp b/Example/MyBuiltinLitScene.cpp index b656bbb..3fcf29c 100644 --- a/Example/MyBuiltinLitScene.cpp +++ b/Example/MyBuiltinLitScene.cpp @@ -18,7 +18,7 @@ MyBuiltinLitScene::MyBuiltinLitScene(Application& application) ), DrawMode::DRAW_TRIANGLES ), m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f)), - m_batch(&m_shape, 2), + m_batch(&m_shape), m_light( Position(0.0f, 2.0f, 2.0f), PhongLight::Power(0.2f, 1.0f, 1.0f), diff --git a/Example/MyBuiltinTexturedScene.cpp b/Example/MyBuiltinTexturedScene.cpp index 19950d0..b481733 100644 --- a/Example/MyBuiltinTexturedScene.cpp +++ b/Example/MyBuiltinTexturedScene.cpp @@ -23,8 +23,8 @@ MyBuiltinTexturedScene::MyBuiltinTexturedScene(Application& application) texturegenerator::gen_quick_sampler() ), m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f), vec3(0.0f, 0.0f, -1.0f)), - m_cube_batch(&m_cube, 2), - m_sprite_batch(&m_sprite, 1) + m_cube_batch(&m_cube), + m_sprite_batch(&m_sprite) { m_pipeline.add_batch(&m_cube_batch); m_pipeline.add_batch(&m_sprite_batch); diff --git a/Example/MyPongScene.cpp b/Example/MyPongScene.cpp index 47c6bdc..bdbb7e1 100644 --- a/Example/MyPongScene.cpp +++ b/Example/MyPongScene.cpp @@ -49,11 +49,11 @@ MyPongScene::MyPongScene(Application& application) m_life(meshgenerator::gen_rect_p(DRAW_TRIANGLES, LIFE_THICKNESS, LIFE_THICKNESS), DRAW_TRIANGLES), m_paddle(meshgenerator::gen_rect_p(DRAW_TRIANGLES, PADDLE_THICKNESS, PADDLE_HEIGHT), DRAW_TRIANGLES), - m_outline_column_batch(&m_outline_column, 2), - m_outline_row_batch(&m_outline_row, 2), - m_ball_batch(&m_ball, 1), - m_life_batch(&m_life, STARTING_LIVES * 2), - m_paddle_batch(&m_paddle, 2), + m_outline_column_batch(&m_outline_column), + m_outline_row_batch(&m_outline_row), + m_ball_batch(&m_ball), + m_life_batch(&m_life), + m_paddle_batch(&m_paddle), m_outline_top_pose(glm::vec3(0.0f, (m_screen_size.y - OUTLINE_THICKNESS) / 2.0f - OUTLINE_OFFSET, 0.0f)), m_outline_bottom_pose(glm::vec3(0.0f, -((m_screen_size.y - OUTLINE_THICKNESS) / 2.0f - OUTLINE_OFFSET), 0.0f)), diff --git a/Example/MyTestTextScene.cpp b/Example/MyTestTextScene.cpp index 60f8ff1..7ac2011 100644 --- a/Example/MyTestTextScene.cpp +++ b/Example/MyTestTextScene.cpp @@ -31,7 +31,7 @@ MyTextTestScene::MyTextTestScene(Application& application) texturegenerator::gen_quick_sampler() ), m_camera(m_screen_size), - m_text_batch(&m_text, 1) + m_text_batch(&m_text) { m_pipeline.set_camera(&m_camera); m_pipeline.add_batch(&m_text_batch); diff --git a/charcoal-builtin/PoseableBatch.h b/charcoal-builtin/PoseableBatch.h index e78143f..ce9aaaa 100644 --- a/charcoal-builtin/PoseableBatch.h +++ b/charcoal-builtin/PoseableBatch.h @@ -14,39 +14,35 @@ namespace charcoal class PoseableBatch : public builtin::Batch { public: - PoseableBatch( - RenderableType* renderable, - int element_count - ) : PoseableBatch(renderable, element_count, element_count) - {} - - PoseableBatch( - RenderableType* renderable, - int element_count, - int element_render_count - ) : builtin::Batch(renderable, element_render_count), m_orientation_elements(element_count) + PoseableBatch(RenderableType* renderable) + : builtin::Batch(renderable, 0) {} virtual ~PoseableBatch() {} void reset_rendered() { - // Also clear the matrix array? + m_orientation_elements.clear(); charcoal::InstancedBatch::set_render_count(0); + // Just thinking, maybe want to not make want set_render_count to be public... The end-developer + // could screw up things by using that function. Then again, it could allow for preventing of + // needing to resize the element buffers once that optimization is made. } void add_rendered(const Poseable& poseable) { - // Maybe just push back and then increment the render count? - m_orientation_elements[charcoal::InstancedBatch::m_render_count++] = poseable.get_orientation_matrix(); + m_orientation_elements.emplace_back(poseable.get_orientation_matrix()); + charcoal::InstancedBatch::m_render_count++; } protected: void setup_element_buffers() override { - // This feels worthless because it is also done in update_element_buffers. - glBindBuffer(GL_ARRAY_BUFFER, charcoal::ElementBatch<1>::m_element_buffers[0]); - glBufferData(GL_ARRAY_BUFFER, m_orientation_elements.size() * sizeof(mat4), NULL, GL_STREAM_DRAW); + // This is (was) worthless because it is also done in update_element_buffers. + //glBindBuffer(GL_ARRAY_BUFFER, charcoal::ElementBatch<1>::m_element_buffers[0]); + //glBufferData(GL_ARRAY_BUFFER, m_orientation_elements.size() * sizeof(mat4), NULL, GL_STREAM_DRAW); + // TODO: Find a way to not have to do a re-allocation every frame. + // While we're like this, I guess the adding and resetting of rendered can be changed though! } void resize_element_buffers() override