You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB

#ifndef TEXTCOMPONENT_H
#define TEXTCOMPONENT_H
#include <GL/glew.h>
#include "../text/TextRasterizerCache.h"
#include "Component.h"
#include <array>
#include <memory>
#include <vector>
#include <iostream>
class TextComponent : public Component {
private:
unsigned int fontSize;
6 years ago
bool bold;
unsigned int color;
const unsigned int indices[6] = {
0, 1, 2,
0, 2, 3
};
std::unique_ptr<Glyph[]> glyphs;
std::vector<std::unique_ptr<float[]>> glyphVertices;
std::vector<GLuint> vertexArrayObjects;
std::vector<GLuint> vertexBufferObjects;
GLuint elementBufferObject;
std::vector<GLuint> textures;
public:
std::string text;
TextComponent(const std::string &rawText, const int rawX, const int rawY, const unsigned int size, const bool bolded, const unsigned int hexColor, const int passedWindowWidth, const int passedWindowHeight);
~TextComponent();
void rasterize(const int rawX, const int rawY, const int passedWindowWidth, const int passedWindowHeight);
void render();
void resize();
void pointToViewport(float &rawX, float &rawY, const int passedWindowWidth, const int passedWindowHeight) const;
void sanitize(std::string &str);
// backgroundColor
rgba backgroundColor;
};
#endif