Pass Renderer2D to Renderable and have each subclass of Renderable decide what the Renderer should do (like drawText(), drawRect() etc). This makes the Renderable more flexible. right now, each renderable has a texture, vertices and indices. but what if some renderables does not use textures? or more than one? What if some renderables are just a group of other renderables? (Scene Graph's). If we instead just make Renderables implement render(Renderer2D& r) interface. we can make each renderable pass the data it holds to the renderer without a hard defined interface.
39 lines
822 B
C++
39 lines
822 B
C++
|
|
#ifndef SPECTRE_GRAPHICS_RENDERABLE_H
|
|
#define SPECTRE_GRAPHICS_RENDERABLE_H
|
|
|
|
#include "Vertex2D.h"
|
|
#include "Transformable.h"
|
|
#include <Spectre/Math/Matrix4.h>
|
|
#include <Spectre/Math/Vector2.h>
|
|
#include <vector>
|
|
|
|
class Renderer2D;
|
|
class ShaderProgram;
|
|
class Texture;
|
|
|
|
enum RenderType
|
|
{
|
|
RenderType_Scene = 0,
|
|
RenderType_UI = 1
|
|
};
|
|
|
|
class Renderable2D : public Transformable
|
|
{
|
|
public :
|
|
Renderable2D();
|
|
Renderable2D(const Vector2f& position);
|
|
virtual ~Renderable2D();
|
|
|
|
virtual const std::vector<Vertex2D>& getVertices() const = 0;
|
|
|
|
virtual const std::vector<unsigned short>& getIndices() const = 0;
|
|
|
|
virtual const Texture* getTexture() const { return NULL; };
|
|
|
|
virtual const RenderType getRenderType() const = 0;
|
|
|
|
virtual void render(Renderer2D& renderer) const = 0;
|
|
};
|
|
|
|
#endif /* SPECTRE_GRAPHCIS_RENDERABLE_H */
|