aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/YAGE/spritebatch.hpp8
-rw-r--r--src/spritebatch.cpp6
2 files changed, 8 insertions, 6 deletions
diff --git a/include/YAGE/spritebatch.hpp b/include/YAGE/spritebatch.hpp
index 3f40a009..c5a55b17 100644
--- a/include/YAGE/spritebatch.hpp
+++ b/include/YAGE/spritebatch.hpp
@@ -11,6 +11,8 @@
namespace yage
{
+class SpriteBatch;
+
class Glyph
{
// member variables
@@ -36,11 +38,11 @@ public:
class RenderBatch
{
+ friend SpriteBatch;
// member variables
-public:
- GLint offset_;
private:
- GLsizei num_vertices_;
+ GLsizei num_vertices_;
+ GLint offset_;
GLuint texture_;
// member functions
diff --git a/src/spritebatch.cpp b/src/spritebatch.cpp
index 8a08ea86..d09b663b 100644
--- a/src/spritebatch.cpp
+++ b/src/spritebatch.cpp
@@ -18,8 +18,8 @@ Glyph::Glyph(GLuint texture, float depth, const Vertex &top_left, const Vertex &
{}
RenderBatch::RenderBatch(GLint offset, GLsizei num_vertices, GLuint texture) :
- offset_(offset),
num_vertices_(num_vertices),
+ offset_(offset),
texture_(texture)
{}
@@ -129,7 +129,7 @@ void SpriteBatch::createRenderBatches()
std::vector<Vertex> vertices;
if(glyph_ptrs_.empty())
return;
-
+
render_batches_.reserve(glyph_ptrs_.size()*NUM_VERTICES);
for(int i=0; i<(int)glyph_ptrs_.size(); ++i)
@@ -137,7 +137,7 @@ void SpriteBatch::createRenderBatches()
if(i==0 || (i>0 && (glyph_ptrs_[i]->texture()!=glyph_ptrs_[i-1]->texture())))
render_batches_.emplace_back(i*NUM_VERTICES, NUM_VERTICES, glyph_ptrs_[i]->texture());
else
- render_batches_.back().offset_+=NUM_VERTICES;
+ render_batches_.back().num_vertices_+=NUM_VERTICES;
vertices.push_back(glyph_ptrs_[i]->bottom_left());
vertices.push_back(glyph_ptrs_[i]->top_left());