Skip to content

Commit

Permalink
- bugfix for g3d viewer and updated wxwidgets
Browse files Browse the repository at this point in the history
  • Loading branch information
softcoder committed Nov 29, 2014
1 parent 126ed18 commit ad0b652
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
27 changes: 17 additions & 10 deletions source/g3d_viewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,15 @@ void MainWindow::setupTimer() {
}

void MainWindow::setupStartupSettings() {
GLuint err = glewInit();
if (GLEW_OK != err) {

glCanvas->setCurrentGLContext();

GLuint err = glewInit();
if (GLEW_OK != err) {
fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
//return 1;
throw std::runtime_error((char *)glewGetErrorString(err));
}
}

renderer= Renderer::getInstance();

Expand Down Expand Up @@ -567,12 +570,12 @@ MainWindow::~MainWindow(){
void MainWindow::init() {

#if wxCHECK_VERSION(2, 9, 3)
glCanvas->setCurrentGLContext();
//glCanvas->setCurrentGLContext();
//printf("setcurrent #1\n");
#elif wxCHECK_VERSION(2, 9, 1)

#else
glCanvas->SetCurrent();
//glCanvas->SetCurrent();
//printf("setcurrent #2\n");
#endif

Expand All @@ -585,10 +588,12 @@ void MainWindow::init() {
void MainWindow::onPaint(wxPaintEvent &event) {
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)
glCanvas->setCurrentGLContext();
//glCanvas->setCurrentGLContext();
#endif

if(startupSettingsInited == false) {
Expand Down Expand Up @@ -756,8 +761,8 @@ void MainWindow::onClose(wxCloseEvent &event){
delete timer;
timer = NULL;

delete model;
model = NULL;
//delete model;
//model = NULL;

delete renderer;
renderer = NULL;
Expand Down Expand Up @@ -2029,7 +2034,7 @@ GlCanvas::GlCanvas(MainWindow * mainWindow, int *args)
}

GlCanvas::~GlCanvas() {
delete this->context;
if(this->context) delete this->context;
this->context = NULL;
}

Expand All @@ -2039,11 +2044,13 @@ void GlCanvas::setCurrentGLContext() {
#if wxCHECK_VERSION(2, 9, 1)
if(this->context == NULL) {
this->context = new wxGLContext(this);
//printf("Set ctx [%p]\n",this->context);
}
#endif
//printf("Set ctx [%p]\n",this->context);
if(this->context) {
wxGLCanvas::SetCurrent(*this->context);
//printf("Set ctx2 [%p]\n",this->context);
}
#else
this->SetCurrent();
Expand Down
1 change: 1 addition & 0 deletions source/g3d_viewer/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ class GlCanvas: public wxGLCanvas {
void onKeyDown(wxKeyEvent &event);
void setCurrentGLContext();

wxGLContext * getCtx() { return context; }
private:
MainWindow *mainWindow;
wxGLContext *context;
Expand Down
2 changes: 1 addition & 1 deletion source/shared_lib/sources/graphics/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ Model::Model() {
}

Model::~Model() {
delete [] meshes;
if(meshes) delete [] meshes;
meshes = NULL;
}

Expand Down

0 comments on commit ad0b652

Please sign in to comment.