I have a class (to render Text):
class TextRenderer {
public:
TextRenderer();
void RenderText(GLFWwindow *window, std::string text);
private:
FT_Library ft;
FT_Face face;
};
where I initialize the members ft
and face
in the constructor
TextRenderer::TextRenderer() {
FT_Library ft;
FT_Face face;
FT_Init_FreeType(&ft));
FT_New_Face(ft, "Assets/monospace.ttf", 0, &face);
FT_Load_Char(face, 3, FT_LOAD_RENDER);
}
void TextRenderer::RenderText(GLFWwindow *window, std::string text) {
FT_GlyphSlot slot = face->glyph; //Shortcut
...
}
but when I want to use it like this:
TextRenderer tr;
while (cond) {
tr.RenderText(consoleEngine.window, prefix + inp);
}
I get an error stating
Exception thrown: read access violation.
this->face was nullptr.
for the first line of the TextRenderer::RenterText
function.
I don't understand this. Isn't the variable face a member of the class TextRenderer and should thus have access to it?