SparrowRenderer/asciientity.h

67 lines
1.4 KiB
C++

#ifndef ASCIIENTITY_H
#define ASCIIENTITY_H
#include <glew/glew.h>
#include <glm/vec2.hpp>
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>
#include "material.h"
#include "asciimodule.h"
class Texture;
#include "entity.h"
class ASCIIMaterial : public Material
{
Texture* glyphMap;
glm::vec4 backColor;
glm::vec4 fontColor;
public:
ASCIIMaterial(Texture* myGlyphMap = NULL,
glm::vec4 myBackColor = glm::vec4(1, 1, 1, 0),
glm::vec4 myFontColor = glm::vec4(0)) :
glyphMap(myGlyphMap),
backColor(myBackColor),
fontColor(myFontColor)
{
shader = ASCIIModule::getShader();
}
virtual void bindAttributes();
};
class ASCIIEntity : public Entity
{
glm::vec2 position;
glm::vec2 size;
glm::mat4 modelView;
ASCIIMaterial* mat;
GLuint rows;
GLuint columns;
char* textBuffer;
void updateModelView();
public:
ASCIIEntity(int nbRows = 10, int nbColumns = 40, ASCIIMaterial* myMat = NULL) :
position(glm::vec2(0)),
size(glm::vec2(1)),
mat(myMat),
rows(nbRows),
columns(nbColumns)
{
textBuffer = new char[rows*columns];
// TODO set all chars to ' '
updateModelView();
}
virtual void draw(const glm::mat4 viewMatrix, const glm::mat4 projectionMatrix);
};
#endif // ASCIIENTITY_H