1
0
Fork 0

Renderer2D: reverse the relationship between Renderer2D and Renderable.

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.
This commit is contained in:
Henrik Hautakoski 2016-06-18 13:25:58 +02:00
parent b2dbee33fb
commit 84ffd0189e
8 changed files with 32 additions and 2 deletions

View file

@ -1,4 +1,5 @@
#include <Spectre/Graphics/Renderer2D.h>
#include <Spectre/Graphics/Texture.h>
#include <Spectre/Graphics/Sprite.h>
@ -108,4 +109,9 @@ const std::vector<unsigned short>& Sprite::getIndices() const
void Sprite::updateGeometry()
{
}
void Sprite::render(Renderer2D& renderer) const
{
renderer.draw(this);
}