- bugfix for g3d viewer and updated wxwidgets

This commit is contained in:
SoftCoder
2014-11-28 23:35:35 -08:00
parent 126ed18589
commit ad0b652727
3 changed files with 19 additions and 11 deletions

View File

@@ -480,6 +480,9 @@ void MainWindow::setupTimer() {
} }
void MainWindow::setupStartupSettings() { void MainWindow::setupStartupSettings() {
glCanvas->setCurrentGLContext();
GLuint err = glewInit(); GLuint err = glewInit();
if (GLEW_OK != err) { if (GLEW_OK != err) {
fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err)); fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
@@ -567,12 +570,12 @@ MainWindow::~MainWindow(){
void MainWindow::init() { void MainWindow::init() {
#if wxCHECK_VERSION(2, 9, 3) #if wxCHECK_VERSION(2, 9, 3)
glCanvas->setCurrentGLContext(); //glCanvas->setCurrentGLContext();
//printf("setcurrent #1\n"); //printf("setcurrent #1\n");
#elif wxCHECK_VERSION(2, 9, 1) #elif wxCHECK_VERSION(2, 9, 1)
#else #else
glCanvas->SetCurrent(); //glCanvas->SetCurrent();
//printf("setcurrent #2\n"); //printf("setcurrent #2\n");
#endif #endif
@@ -585,10 +588,12 @@ void MainWindow::init() {
void MainWindow::onPaint(wxPaintEvent &event) { void MainWindow::onPaint(wxPaintEvent &event) {
if(!IsShown()) return; if(!IsShown()) return;
#if wxCHECK_VERSION(2, 9, 3) #if wxCHECK_VERSION(2, 9, 4)
//glCanvas->setCurrentGLContext();
#elif wxCHECK_VERSION(2, 9, 3)
#elif wxCHECK_VERSION(2, 9, 1) #elif wxCHECK_VERSION(2, 9, 1)
glCanvas->setCurrentGLContext(); //glCanvas->setCurrentGLContext();
#endif #endif
if(startupSettingsInited == false) { if(startupSettingsInited == false) {
@@ -756,8 +761,8 @@ void MainWindow::onClose(wxCloseEvent &event){
delete timer; delete timer;
timer = NULL; timer = NULL;
delete model; //delete model;
model = NULL; //model = NULL;
delete renderer; delete renderer;
renderer = NULL; renderer = NULL;
@@ -2029,7 +2034,7 @@ GlCanvas::GlCanvas(MainWindow * mainWindow, int *args)
} }
GlCanvas::~GlCanvas() { GlCanvas::~GlCanvas() {
delete this->context; if(this->context) delete this->context;
this->context = NULL; this->context = NULL;
} }
@@ -2039,11 +2044,13 @@ void GlCanvas::setCurrentGLContext() {
#if wxCHECK_VERSION(2, 9, 1) #if wxCHECK_VERSION(2, 9, 1)
if(this->context == NULL) { if(this->context == NULL) {
this->context = new wxGLContext(this); this->context = new wxGLContext(this);
//printf("Set ctx [%p]\n",this->context);
} }
#endif #endif
//printf("Set ctx [%p]\n",this->context); //printf("Set ctx [%p]\n",this->context);
if(this->context) { if(this->context) {
wxGLCanvas::SetCurrent(*this->context); wxGLCanvas::SetCurrent(*this->context);
//printf("Set ctx2 [%p]\n",this->context);
} }
#else #else
this->SetCurrent(); this->SetCurrent();

View File

@@ -201,6 +201,7 @@ public:
void onKeyDown(wxKeyEvent &event); void onKeyDown(wxKeyEvent &event);
void setCurrentGLContext(); void setCurrentGLContext();
wxGLContext * getCtx() { return context; }
private: private:
MainWindow *mainWindow; MainWindow *mainWindow;
wxGLContext *context; wxGLContext *context;

View File

@@ -1099,7 +1099,7 @@ Model::Model() {
} }
Model::~Model() { Model::~Model() {
delete [] meshes; if(meshes) delete [] meshes;
meshes = NULL; meshes = NULL;
} }