- attempt to fix segfault on ubuntu 10.04
This commit is contained in:
parent
37d6bb4b6b
commit
da222ddefd
File diff suppressed because it is too large
Load Diff
|
@ -3,9 +3,9 @@
|
||||||
<Workspace title="Workspace">
|
<Workspace title="Workspace">
|
||||||
<Project filename="libstreflop.cbp" />
|
<Project filename="libstreflop.cbp" />
|
||||||
<Project filename="shared_lib.cbp" />
|
<Project filename="shared_lib.cbp" />
|
||||||
<Project filename="glest_game.cbp" active="1" />
|
<Project filename="glest_game.cbp" />
|
||||||
<Project filename="glest_editor.cbp" />
|
<Project filename="glest_editor.cbp" />
|
||||||
<Project filename="g3d_viewer.cbp" />
|
<Project filename="g3d_viewer.cbp" active="1" />
|
||||||
<Project filename="glest_configurator.cbp" />
|
<Project filename="glest_configurator.cbp" />
|
||||||
</Workspace>
|
</Workspace>
|
||||||
</CodeBlocks_workspace_file>
|
</CodeBlocks_workspace_file>
|
||||||
|
|
|
@ -189,19 +189,12 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
|
||||||
float defaultZoom,float defaultXRot, float defaultYRot)
|
float defaultZoom,float defaultXRot, float defaultYRot)
|
||||||
: wxFrame(NULL, -1, ToUnicode(winHeader),
|
: wxFrame(NULL, -1, ToUnicode(winHeader),
|
||||||
wxPoint(Renderer::windowX, Renderer::windowY),
|
wxPoint(Renderer::windowX, Renderer::windowY),
|
||||||
wxSize(Renderer::windowW, Renderer::windowH)), model(NULL), glCanvas(NULL), renderer(NULL), initTextureManager(true)
|
wxSize(Renderer::windowW, Renderer::windowH)), model(NULL), glCanvas(NULL), renderer(NULL), initTextureManager(true), timer(NULL)
|
||||||
{
|
{
|
||||||
//getGlPlatformExtensions();
|
//getGlPlatformExtensions();
|
||||||
int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; // to prevent flicker
|
int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; // to prevent flicker
|
||||||
glCanvas = new GlCanvas(this, args);
|
glCanvas = new GlCanvas(this, args);
|
||||||
glCanvas->SetCurrent();
|
glCanvas->SetCurrent();
|
||||||
//assertGl();
|
|
||||||
GLenum error= glGetError();
|
|
||||||
|
|
||||||
if(error != GL_NO_ERROR){
|
|
||||||
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
|
|
||||||
throw runtime_error("OpenGL error: "+string(errorString));
|
|
||||||
}
|
|
||||||
|
|
||||||
renderer= Renderer::getInstance();
|
renderer= Renderer::getInstance();
|
||||||
|
|
||||||
|
@ -363,15 +356,16 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
|
||||||
#endif
|
#endif
|
||||||
SetIcon(icon);
|
SetIcon(icon);
|
||||||
|
|
||||||
timer = new wxTimer(this);
|
|
||||||
timer->Start(100);
|
|
||||||
|
|
||||||
glCanvas->SetFocus();
|
|
||||||
|
|
||||||
fileDialog = new wxFileDialog(this);
|
fileDialog = new wxFileDialog(this);
|
||||||
if(modelPath != "") {
|
if(modelPath != "") {
|
||||||
fileDialog->SetPath(ToUnicode(modelPath));
|
fileDialog->SetPath(ToUnicode(modelPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glCanvas->SetCurrent();
|
||||||
|
glCanvas->SetFocus();
|
||||||
|
|
||||||
|
timer = new wxTimer(this);
|
||||||
|
timer->Start(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow(){
|
MainWindow::~MainWindow(){
|
||||||
|
@ -390,6 +384,14 @@ void MainWindow::init() {
|
||||||
glCanvas->SetCurrent();
|
glCanvas->SetCurrent();
|
||||||
renderer->init();
|
renderer->init();
|
||||||
|
|
||||||
|
//assertGl();
|
||||||
|
GLenum error= glGetError();
|
||||||
|
|
||||||
|
if(error != GL_NO_ERROR){
|
||||||
|
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
|
||||||
|
throw runtime_error("OpenGL error: "+string(errorString));
|
||||||
|
}
|
||||||
|
|
||||||
wxCommandEvent event;
|
wxCommandEvent event;
|
||||||
onMenuRestart(event);
|
onMenuRestart(event);
|
||||||
}
|
}
|
||||||
|
@ -480,8 +482,8 @@ void MainWindow::onClose(wxCloseEvent &event){
|
||||||
particleProjectilePathList.clear();
|
particleProjectilePathList.clear();
|
||||||
particleSplashPathList.clear(); // as above
|
particleSplashPathList.clear(); // as above
|
||||||
|
|
||||||
timer->Stop();
|
if(timer) timer->Stop();
|
||||||
renderer->end();
|
if(renderer) renderer->end();
|
||||||
|
|
||||||
unitParticleSystems.clear();
|
unitParticleSystems.clear();
|
||||||
unitParticleSystemTypes.clear();
|
unitParticleSystemTypes.clear();
|
||||||
|
@ -760,8 +762,8 @@ void MainWindow::onMenuFileClearAll(wxCommandEvent &event) {
|
||||||
particleProjectilePathList.clear();
|
particleProjectilePathList.clear();
|
||||||
particleSplashPathList.clear(); // as above
|
particleSplashPathList.clear(); // as above
|
||||||
|
|
||||||
timer->Stop();
|
if(timer) timer->Stop();
|
||||||
renderer->end();
|
if(renderer) renderer->end();
|
||||||
|
|
||||||
unitParticleSystems.clear();
|
unitParticleSystems.clear();
|
||||||
unitParticleSystemTypes.clear();
|
unitParticleSystemTypes.clear();
|
||||||
|
@ -786,7 +788,7 @@ void MainWindow::onMenuFileClearAll(wxCommandEvent &event) {
|
||||||
printf("END onMenuFileClearAll\n");
|
printf("END onMenuFileClearAll\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
timer->Start(100);
|
if(timer) timer->Start(100);
|
||||||
}
|
}
|
||||||
catch(std::runtime_error e) {
|
catch(std::runtime_error e) {
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
|
@ -807,8 +809,8 @@ void MainWindow::loadUnit(string path, string skillName) {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if(this->unitPath.first != "") {
|
if(this->unitPath.first != "") {
|
||||||
timer->Stop();
|
if(timer) timer->Stop();
|
||||||
renderer->end();
|
if(renderer) renderer->end();
|
||||||
|
|
||||||
string titlestring = winHeader;
|
string titlestring = winHeader;
|
||||||
|
|
||||||
|
@ -941,16 +943,16 @@ void MainWindow::loadModel(string path) {
|
||||||
|
|
||||||
printf("Loading model [%s] %u of %lu\n",modelPath.c_str(),idx, this->modelPathList.size());
|
printf("Loading model [%s] %u of %lu\n",modelPath.c_str(),idx, this->modelPathList.size());
|
||||||
|
|
||||||
timer->Stop();
|
if(timer) timer->Stop();
|
||||||
delete model;
|
delete model;
|
||||||
Model *tmpModel= new ModelGl();
|
Model *tmpModel= new ModelGl();
|
||||||
renderer->loadTheModel(tmpModel, modelPath);
|
if(renderer) renderer->loadTheModel(tmpModel, modelPath);
|
||||||
model= tmpModel;
|
model= tmpModel;
|
||||||
|
|
||||||
statusbarText = getModelInfo();
|
statusbarText = getModelInfo();
|
||||||
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY);
|
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY);
|
||||||
GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str()));
|
GetStatusBar()->SetStatusText(ToUnicode(statusTextValue.c_str()));
|
||||||
timer->Start(100);
|
if(timer) timer->Start(100);
|
||||||
titlestring = extractFileFromDirectoryPath(modelPath) + " - "+ titlestring;
|
titlestring = extractFileFromDirectoryPath(modelPath) + " - "+ titlestring;
|
||||||
}
|
}
|
||||||
SetTitle(ToUnicode(titlestring));
|
SetTitle(ToUnicode(titlestring));
|
||||||
|
@ -962,7 +964,7 @@ void MainWindow::loadModel(string path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadParticle(string path) {
|
void MainWindow::loadParticle(string path) {
|
||||||
timer->Stop();
|
if(timer) timer->Stop();
|
||||||
if(path != "" && fileExists(path) == true) {
|
if(path != "" && fileExists(path) == true) {
|
||||||
renderer->end();
|
renderer->end();
|
||||||
unitParticleSystems.clear();
|
unitParticleSystems.clear();
|
||||||
|
@ -1047,11 +1049,11 @@ void MainWindow::loadParticle(string path) {
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
timer->Start(100);
|
if(timer) timer->Start(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadProjectileParticle(string path) {
|
void MainWindow::loadProjectileParticle(string path) {
|
||||||
timer->Stop();
|
if(timer) timer->Stop();
|
||||||
if(path != "" && fileExists(path) == true) {
|
if(path != "" && fileExists(path) == true) {
|
||||||
renderer->end();
|
renderer->end();
|
||||||
projectileParticleSystems.clear();
|
projectileParticleSystems.clear();
|
||||||
|
@ -1147,11 +1149,11 @@ void MainWindow::loadProjectileParticle(string path) {
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
timer->Start(100);
|
if(timer) timer->Start(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSplash::load (and own list...)
|
void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSplash::load (and own list...)
|
||||||
timer->Stop();
|
if(timer) timer->Stop();
|
||||||
if(path != "" && fileExists(path) == true) {
|
if(path != "" && fileExists(path) == true) {
|
||||||
renderer->end();
|
renderer->end();
|
||||||
splashParticleSystems.clear();
|
splashParticleSystems.clear();
|
||||||
|
@ -1248,7 +1250,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
|
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
|
||||||
}
|
}
|
||||||
timer->Start(100);
|
if(timer) timer->Start(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMenuModeNormals(wxCommandEvent &event){
|
void MainWindow::onMenuModeNormals(wxCommandEvent &event){
|
||||||
|
@ -1564,8 +1566,8 @@ void MainWindow::onKeyDown(wxKeyEvent &e) {
|
||||||
void MainWindow::onMenuRestart(wxCommandEvent &event) {
|
void MainWindow::onMenuRestart(wxCommandEvent &event) {
|
||||||
try {
|
try {
|
||||||
// std::cout << "pressed R (restart particle animation)" << std::endl;
|
// std::cout << "pressed R (restart particle animation)" << std::endl;
|
||||||
timer->Stop();
|
if(timer) timer->Stop();
|
||||||
renderer->end();
|
if(renderer) renderer->end();
|
||||||
|
|
||||||
unitParticleSystems.clear();
|
unitParticleSystems.clear();
|
||||||
unitParticleSystemTypes.clear();
|
unitParticleSystemTypes.clear();
|
||||||
|
@ -1584,7 +1586,7 @@ void MainWindow::onMenuRestart(wxCommandEvent &event) {
|
||||||
if(initTextureManager) {
|
if(initTextureManager) {
|
||||||
renderer->initTextureManager();
|
renderer->initTextureManager();
|
||||||
}
|
}
|
||||||
timer->Start(100);
|
if(timer) timer->Start(100);
|
||||||
}
|
}
|
||||||
catch(std::runtime_error e) {
|
catch(std::runtime_error e) {
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
|
@ -1637,12 +1639,6 @@ void translateCoords(wxWindow *wnd, int &x, int &y) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GlCanvas::GlCanvas(MainWindow * mainWindow):
|
|
||||||
wxGLCanvas(mainWindow, -1, wxDefaultPosition)
|
|
||||||
{
|
|
||||||
this->mainWindow = mainWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
// to prevent flicker
|
// to prevent flicker
|
||||||
GlCanvas::GlCanvas(MainWindow * mainWindow, int *args)
|
GlCanvas::GlCanvas(MainWindow * mainWindow, int *args)
|
||||||
: wxGLCanvas(mainWindow, -1, wxDefaultPosition, wxDefaultSize, 0, wxT("GLCanvas"), args) {
|
: wxGLCanvas(mainWindow, -1, wxDefaultPosition, wxDefaultSize, 0, wxT("GLCanvas"), args) {
|
||||||
|
|
|
@ -167,7 +167,6 @@ private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GlCanvas(MainWindow *mainWindow);
|
|
||||||
GlCanvas(MainWindow *mainWindow, int *args);
|
GlCanvas(MainWindow *mainWindow, int *args);
|
||||||
|
|
||||||
void onMouseWheel(wxMouseEvent &event);
|
void onMouseWheel(wxMouseEvent &event);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user