From f949692714e72a0e2d45ebb6a5d698424ab71dee Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Mon, 25 Dec 2017 13:54:09 +0000 Subject: [Broken] Reorganising and fixing. --- yage/core/spritebatch.h | 110 ------------------------------------------------ 1 file changed, 110 deletions(-) delete mode 100644 yage/core/spritebatch.h (limited to 'yage/core/spritebatch.h') diff --git a/yage/core/spritebatch.h b/yage/core/spritebatch.h deleted file mode 100644 index c16b44f6..00000000 --- a/yage/core/spritebatch.h +++ /dev/null @@ -1,110 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: spritebatch.h - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -/** @file - */ - -#ifndef YAGE_SPRITE_BATCH_H -#define YAGE_SPRITE_BATCH_H - -#include "vertex.h" - -#include -#include -#include - -#include - -namespace yage -{ - -class SpriteBatch; - -/** Glyph with information of the texture. - */ -class Glyph -{ -private: - GLuint texture_; - float depth_; - Vertex top_left_; - Vertex top_right_; - Vertex bottom_right_; - Vertex bottom_left_; - -public: - Glyph(GLuint texture, float depth, const Vertex &top_left, - const Vertex &top_right, const Vertex &bottom_right, - const Vertex &bottom_left); - - GLuint texture() const { return texture_; } - float depth() const { return depth_; } - Vertex top_left() const { return top_left_; } - Vertex top_right() const { return top_right_; } - Vertex bottom_right() const { return bottom_right_; } - Vertex bottom_left() const { return bottom_left_; } -}; - -class RenderBatch -{ - friend SpriteBatch; - -private: - GLsizei num_vertices_; - GLint offset_; - GLuint texture_; - -public: - RenderBatch(GLint offset, GLsizei num_vertices, GLuint texture); - - GLint offset() const { return offset_; } - GLsizei num_vertices() const { return num_vertices_; } - GLuint texture() const { return texture_; } -}; - -class SpriteBatch -{ -public: - static const int NUM_VERTICES = 6; - -private: - GLuint vbo_ = 0; - GLuint vao_ = 0; - std::vector glyphs_; - std::vector glyph_ptrs_; - std::vector render_batches_; - -public: - SpriteBatch(); - SpriteBatch(const SpriteBatch &) = delete; - SpriteBatch(SpriteBatch &&) = delete; - ~SpriteBatch(); - - SpriteBatch &operator=(const SpriteBatch &) = delete; - SpriteBatch &operator=(SpriteBatch &&) = delete; - - // initialize vaos and vbos - void begin(); - void end(); - - // adds a sprite to the sprite batch to be rendered later - void draw(const yage::Vector4f &destination_rect, - const yage::Vector4f &uv_rect, GLuint texture, - const Colour &colour, float depth); - // render the batch - void render(); - -private: - void createVertexArray(); - void createRenderBatches(); - void sortGlyphs(); -}; - -} // namespace yage - -#endif -- cgit