Merge pull request #110 from devZoGok/bf-109-mem-leaks

Bf 109 mem leaks
This commit is contained in:
devZoGok
2026-04-24 19:10:48 +03:00
committed by GitHub
5 changed files with 25 additions and 18 deletions
+1
View File
@@ -21,6 +21,7 @@ namespace vb01{
Model(std::string);
~Model();
inline Material* getMaterial(){return material;}
inline bool isWireframe(){return wireframe;}
void update();
void setMaterial(Material*);
void setCastShadow(bool);
+4
View File
@@ -33,6 +33,10 @@ namespace vb01{
loadShaders();
}
Shader::~Shader(){
glDeleteProgram(id);
}
string Shader::getName(){
int dirId = vString->path.find_last_of('/');
string name = (dirId != -1 ? vString->path.substr(dirId + 1) : vString->path);
+1 -1
View File
@@ -18,7 +18,7 @@ namespace vb01{
Shader(std::string, bool = false);
Shader(std::string, std::string);
Shader(std::string, std::string, std::string);
~Shader(){}
~Shader();
std::string getName();
void use();
void loadShaders();
+17 -16
View File
@@ -16,9 +16,9 @@
using namespace std;
namespace vb01{
Text::Text(string fontPath, wstring entry, u16 firstChar, u16 lastChar){
Text::Text(string fontPath, wstring e, u16 firstChar, u16 lastChar) : entry(e){
init();
applyFont(fontPath, firstChar, lastChar);
setText(entry);
}
Text::~Text(){
@@ -26,6 +26,21 @@ namespace vb01{
glDeleteBuffers(1, &VBO);
}
void Text::init(){
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 6 * 4, NULL, GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
//TODO ensure destruction of textures when unloading the asset
void Text::applyFont(string fontPath, u16 firstChar, u16 lastChar){
characters.clear();
@@ -120,20 +135,6 @@ namespace vb01{
glDrawArrays(GL_TRIANGLES, 0, 6);
}
void Text::setText(wstring text){
this->entry = text;
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 6 * 4, NULL, GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
Text::Glyph* Text::getGlyph(u16 ch){
Glyph *glyph = nullptr;
+2 -1
View File
@@ -26,7 +26,7 @@ namespace vb01{
Text(std::string, std::wstring, u16 = 0, u16 = 256);
~Text();
void update();
void setText(std::wstring);
void setText(std::wstring e){this->entry = e;}
inline void setScale(float s){this->scale = s;}
inline float getScale(){return scale;}
inline int getLength(){return entry.length();}
@@ -39,6 +39,7 @@ namespace vb01{
inline void setMaterial(Material *mat){this->material = mat;}
Glyph* getGlyph(u16);
private:
void init();
void applyFont(std::string, u16, u16 = 256);
void clearFont();
void prepareGlyphs(Glyph, int, Vector2);