Skip to content

Commit

Permalink
Added fix for data overflows
Browse files Browse the repository at this point in the history
  • Loading branch information
L4ZZA committed Apr 17, 2020
1 parent fe119a8 commit 2bafad0
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pyro/src/pyro/renderer/renderer_2d.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "pyro_pch.h"
#include "pyro_pch.h"
#include "renderer_2d.h"
#include "vertex_array.h"
#include "shader.h"
Expand Down Expand Up @@ -114,9 +114,7 @@ void pyro::renderer_2d::begin_scene(camera &camera)
s_data.texture_shader->bind();
s_data.texture_shader->set_mat4("u_view_projection", camera.view_projection_matrix());

s_data.texture_slot_index = 1;
s_data.quad_index_count = 0;
s_data.quad_vertex_buffer_ptr = s_data.quad_vertex_buffer_base;
reset_render_data();
}

void pyro::renderer_2d::end_scene()
Expand All @@ -142,7 +140,13 @@ void pyro::renderer_2d::draw_quad(quad_properties const& props)
{
PYRO_PROFILE_FUNCTION();

//constexpr glm::vec4 color = { 1.0f, 1.0f, 1.0f, 1.0f };
if (s_data.quad_index_count >= max_indices)
{
end_scene();
reset_render_data();
}

//constexpr glm::vec4 color = { 1.0f, 1.0f, 1.0f, 1.0f };

// if texture is passed as parameter

Expand Down Expand Up @@ -209,5 +213,11 @@ void pyro::renderer_2d::draw_quad(quad_properties const& props)
s_data.quad_vertex_buffer_ptr++;

s_data.quad_index_count += s_quad_indices; // 6 indices per quad
}

void pyro::renderer_2d::reset_render_data()
{
s_data.texture_slot_index = 1;
s_data.quad_index_count = 0;
s_data.quad_vertex_buffer_ptr = s_data.quad_vertex_buffer_base;
}

0 comments on commit 2bafad0

Please sign in to comment.