When writing the X11 (linux) implementation there was a problem with X11 defining a "Display" type and we also have a Display class in the engine. So to fix that problem and minimize the risk for running into other name conflicts. We move everything from global namespace.
76 lines
No EOL
1.2 KiB
C++
76 lines
No EOL
1.2 KiB
C++
|
|
#ifndef SPECTRE_BATCH_RENDERER2D_H
|
|
#define SPECTRE_BATCH_RENDERER2D_H
|
|
|
|
#include "Renderer2D.h"
|
|
#include <Spectre/Scene/Camera2D.h>
|
|
|
|
#include <Spectre/Graphics/RenderState.h>
|
|
#include <Spectre/Graphics/Vertex2D.h>
|
|
#include <Spectre/Math/Matrix4.h>
|
|
#include <vector>
|
|
|
|
namespace sp {
|
|
|
|
class ShaderProgram;
|
|
class Texture;
|
|
|
|
class BatchRenderer2D : public Renderer2D
|
|
{
|
|
public :
|
|
|
|
BatchRenderer2D();
|
|
~BatchRenderer2D();
|
|
|
|
void setBatchSize(unsigned short value);
|
|
|
|
void begin();
|
|
|
|
void end();
|
|
|
|
void submit(const Renderable2D& renderable);
|
|
|
|
// Drawing
|
|
virtual void draw(const Renderable2D* renderable);
|
|
|
|
void render();
|
|
|
|
protected :
|
|
|
|
struct Batch
|
|
{
|
|
RenderType type;
|
|
const Texture* texture;
|
|
unsigned int count;
|
|
unsigned int offset;
|
|
};
|
|
|
|
typedef std::vector<Batch> BatchQueue;
|
|
|
|
void prepareQueue();
|
|
|
|
unsigned int addRenderable(Vertex2D* buffer, const Renderable2D* renderable);
|
|
|
|
void uploadBatch(const Batch& batch);
|
|
|
|
void drawBatch(Batch& batch);
|
|
|
|
protected :
|
|
|
|
std::vector<const Renderable2D*> m_queue;
|
|
|
|
unsigned int m_VAO;
|
|
unsigned int m_IBO;
|
|
unsigned int m_VBO;
|
|
|
|
RenderState m_state;
|
|
|
|
unsigned short m_size;
|
|
|
|
ShaderProgram m_textShader;
|
|
ShaderProgram m_spriteShader;
|
|
};
|
|
|
|
} // namespace
|
|
|
|
#endif /* SPECTRE_BATCH_RENDERER2D_H */ |