#ifndef ASCIIENTITY_H #define ASCIIENTITY_H #include #include #include #include #include "material.h" #include "resourcebase.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 = ResourceBase::getShader("ascii"); } virtual void bindAttributes(); }; class ASCIIEntity : public Entity { GLuint rows; GLuint columns; char* textBuffer; glm::vec2 position; glm::vec2 size; glm::mat4 modelView; ASCIIMaterial* mat; 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