summaryrefslogtreecommitdiffstats
path: root/Project/wxGLString.cpp
diff options
context:
space:
mode:
authorThales1330 <thaleslima.ufu@gmail.com>2017-01-05 19:31:28 -0200
committerThales1330 <thaleslima.ufu@gmail.com>2017-01-05 19:31:28 -0200
commitb6f96ca48bc156898df79deba63d270b393fb150 (patch)
tree9c6e2fa2a45d6c6c4c14d8711b2b89066bfb37d7 /Project/wxGLString.cpp
parenta1932eec23589ed67d824873b37de3e83a09cd24 (diff)
downloadPSP.git-b6f96ca48bc156898df79deba63d270b393fb150.tar.gz
PSP.git-b6f96ca48bc156898df79deba63d270b393fb150.tar.xz
PSP.git-b6f96ca48bc156898df79deba63d270b393fb150.zip
Text bugs fixed
Diffstat (limited to 'Project/wxGLString.cpp')
-rw-r--r--Project/wxGLString.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/Project/wxGLString.cpp b/Project/wxGLString.cpp
index 23286bc..07c8c48 100644
--- a/Project/wxGLString.cpp
+++ b/Project/wxGLString.cpp
@@ -25,7 +25,7 @@ GLuint* loadImage(wxImage* img)
// convert it to an alpha channel by the way (not all platforms support transparency in wxDCs
// so it's the easiest way to go)
GLubyte* bitmapData = img->GetData();
- GLubyte* imageData;
+ GLubyte* imageData = NULL;
int bytesPerPixel = 4;
@@ -43,7 +43,7 @@ GLuint* loadImage(wxImage* img)
// alpha
imageData[(x + y * w) * bytesPerPixel + 3] = 255 - bitmapData[(x + (rev_val - y) * w) * 3];
} // next
- } // next
+ } // next
glTexImage2D(GL_TEXTURE_2D, 0, bytesPerPixel, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
@@ -67,7 +67,7 @@ class TextTexture
friend class wxGLStringNumber;
private:
- GLuint* ID;
+ GLuint* ID = NULL;
protected:
GLuint* getID();
@@ -97,7 +97,7 @@ TextGLDrawable::TextGLDrawable(TextTexture* image_arg)
xflip = false;
yflip = false;
- if(image_arg != NULL)
+ if(image_arg)
setImage(image_arg);
else
image = NULL;
@@ -138,7 +138,7 @@ void TextGLDrawable::rotate(int angle) { TextGLDrawable::angle = angle; }
void TextGLDrawable::render() const
{
- assert(image != NULL);
+ assert(image);
glPushMatrix();
glTranslatef(x - w / 2, y - h / 2, 0);
@@ -182,7 +182,7 @@ GLuint* TextTexture::getID() { return ID; }
TextTexture::~TextTexture()
{
glDeleteTextures(1, ID);
- delete ID;
+ if(ID) delete ID; // Memory leak?
}
#if 0
@@ -203,7 +203,10 @@ wxGLString::wxGLString(wxString message)
img = NULL;
}
void wxGLString::operator=(wxString& string) { (*((wxString*)this)) = string; }
-void wxGLString::bind() const { glBindTexture(GL_TEXTURE_2D, img->getID()[0]); }
+void wxGLString::bind() const
+{
+ if(img->getID()[0]) glBindTexture(GL_TEXTURE_2D, img->getID()[0]);
+}
void wxGLString::calculateSize(wxDC* dc, const bool ignore_font /* when from array */)
{
if(!ignore_font) {
@@ -239,7 +242,7 @@ void wxGLString::consolidate(wxDC* dc)
temp_dc.DrawText(*this, 0, 0);
}
- if(img != NULL) delete img;
+ if(img) delete img;
img = new TextTexture(bmp);
TextGLDrawable::texw = power_of_2_w;
@@ -262,7 +265,7 @@ void wxGLString::render(const double x, const double y)
}
wxGLString::~wxGLString()
{
- if(img != NULL) delete img;
+ if(img) delete img;
}
#if 0
@@ -397,11 +400,14 @@ wxGLStringArray::wxGLStringArray(const wxString strings_arg[], int amount)
}
wxGLStringArray::~wxGLStringArray()
{
- if(img != NULL) delete img;
+ if(img) delete img;
}
wxGLString& wxGLStringArray::get(const int id) { return strings[id]; }
-void wxGLStringArray::bind() { glBindTexture(GL_TEXTURE_2D, img->getID()[0]); }
+void wxGLStringArray::bind()
+{
+ if(img->getID()[0]) glBindTexture(GL_TEXTURE_2D, img->getID()[0]);
+}
void wxGLStringArray::addString(wxString string) { strings.push_back(wxGLString(string)); }
void wxGLStringArray::setFont(wxFont font) { wxGLStringArray::font = font; }
@@ -469,7 +475,7 @@ void wxGLStringArray::consolidate(wxDC* dc)
}
}
}
- if(img != NULL) delete img;
+ if(img) delete img;
img = new TextTexture(bmp);
for(int n = 0; n < amount; n++) strings[n].setImage(img);