- editor and g3d viewer work in wxwidgets 3.0.2
This commit is contained in:
parent
88c536a8c6
commit
952e0a6315
|
@ -469,7 +469,7 @@ IF(NOT DEFINED CPACK_GENERATOR)
|
|||
libsdl1.2-dev,
|
||||
libvlc-dev,
|
||||
libvorbis-dev,
|
||||
libwxgtk2.8-dev,
|
||||
libwxgtk2.9-dev,
|
||||
libxerces-c2-dev,
|
||||
libxml2-dev,
|
||||
libz-dev,
|
||||
|
|
|
@ -423,6 +423,7 @@ IF(wxWidgets_FIND_STYLE STREQUAL "win32")
|
|||
D:/
|
||||
$ENV{ProgramFiles}
|
||||
PATH_SUFFIXES
|
||||
wxWidgets-3.0.2
|
||||
wxWidgets-2.9.4
|
||||
wxWidgets-2.9.3
|
||||
wxWidgets-2.9.2
|
||||
|
@ -704,7 +705,7 @@ ELSE(wxWidgets_FIND_STYLE STREQUAL "win32")
|
|||
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
MESSAGE(STATUS "Searching for wx on FreeBSD")
|
||||
FIND_PROGRAM(wxWidgets_CONFIG_EXECUTABLE NAMES $ENV{WX_CONFIG} wxgtk2u-2.8-config wxgtk2u-2.6-config wxgtk2-2.6-config
|
||||
FIND_PROGRAM(wxWidgets_CONFIG_EXECUTABLE NAMES $ENV{WX_CONFIG} wxgtk2u-3.0-config wxgtk2u-2.9-config wxgtk2u-2.8-config wxgtk2u-2.6-config wxgtk2-2.6-config
|
||||
ONLY_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
|
@ -737,7 +738,15 @@ ELSE(wxWidgets_FIND_STYLE STREQUAL "win32")
|
|||
ERROR_QUIET
|
||||
)
|
||||
MESSAGE(STATUS "${wxWidgets_CONFIG_EXECUTABLE} ${wxWidgets_SELECT_OPTIONS} --cxxflags")
|
||||
|
||||
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
|
||||
--version
|
||||
OUTPUT_VARIABLE wxWidgets_VERSION
|
||||
ERROR_QUIET
|
||||
)
|
||||
MESSAGE(STATUS "${wxWidgets_CONFIG_EXECUTABLE} --version returned: ${wxWidgets_VERSION}")
|
||||
|
||||
IF(RET EQUAL 0)
|
||||
STRING(STRIP "${wxWidgets_CXX_FLAGS}" wxWidgets_CXX_FLAGS)
|
||||
SEPARATE_ARGUMENTS(wxWidgets_CXX_FLAGS)
|
||||
|
|
|
@ -303,12 +303,8 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
|
|||
model= NULL;
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
//getGlPlatformExtensions();
|
||||
|
||||
isControlKeyPressed = false;
|
||||
int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; // to prevent flicker
|
||||
//int args[] = { WX_GL_RGBA, WX_GL_MIN_ALPHA, 0 }; // to prevent flicker
|
||||
glCanvas = new GlCanvas(this, args);
|
||||
|
||||
#if wxCHECK_VERSION(2, 9, 1)
|
||||
|
||||
|
@ -438,10 +434,9 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
|
|||
fileDialog->SetDirectory(ToUnicode(defaultPath.c_str()));
|
||||
|
||||
|
||||
glCanvas->SetFocus();
|
||||
|
||||
//timer = new wxTimer(this);
|
||||
//timer->Start(100);
|
||||
if(glCanvas != NULL) {
|
||||
glCanvas->SetFocus();
|
||||
}
|
||||
|
||||
// For windows register g3d file extension to launch this app
|
||||
#if defined(WIN32) && !defined(__MINGW32__)
|
||||
|
@ -482,7 +477,13 @@ void MainWindow::setupTimer() {
|
|||
|
||||
void MainWindow::setupStartupSettings() {
|
||||
|
||||
//printf("In setupStartupSettings #1\n");
|
||||
if(glCanvas == NULL) {
|
||||
int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; // to prevent flicker
|
||||
glCanvas = new GlCanvas(this, args);
|
||||
}
|
||||
glCanvas->setCurrentGLContext();
|
||||
//printf("In setupStartupSettings #2\n");
|
||||
|
||||
GLuint err = glewInit();
|
||||
if (GLEW_OK != err) {
|
||||
|
@ -563,8 +564,9 @@ MainWindow::~MainWindow(){
|
|||
delete renderer;
|
||||
renderer = NULL;
|
||||
|
||||
//delete glCanvas;
|
||||
if(glCanvas) glCanvas->Destroy();
|
||||
if(glCanvas) {
|
||||
glCanvas->Destroy();
|
||||
}
|
||||
glCanvas = NULL;
|
||||
|
||||
}
|
||||
|
@ -572,45 +574,27 @@ MainWindow::~MainWindow(){
|
|||
void MainWindow::init() {
|
||||
|
||||
#if wxCHECK_VERSION(2, 9, 3)
|
||||
//glCanvas->setCurrentGLContext();
|
||||
//printf("setcurrent #1\n");
|
||||
|
||||
#elif wxCHECK_VERSION(2, 9, 1)
|
||||
|
||||
#else
|
||||
glCanvas->SetCurrent();
|
||||
//printf("setcurrent #2\n");
|
||||
#endif
|
||||
|
||||
//renderer->init();
|
||||
|
||||
//wxCommandEvent event;
|
||||
//onMenuRestart(event);
|
||||
}
|
||||
|
||||
void MainWindow::onPaint(wxPaintEvent &event) {
|
||||
if(!IsShown()) return;
|
||||
if(!IsShown()) {
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
#if wxCHECK_VERSION(2, 9, 4)
|
||||
//glCanvas->setCurrentGLContext();
|
||||
#elif wxCHECK_VERSION(2, 9, 3)
|
||||
|
||||
#elif wxCHECK_VERSION(2, 9, 1)
|
||||
glCanvas->setCurrentGLContext();
|
||||
#endif
|
||||
|
||||
bool isFirstWindowShownEvent = !startupSettingsInited ;
|
||||
if(startupSettingsInited == false) {
|
||||
startupSettingsInited = true;
|
||||
setupStartupSettings();
|
||||
}
|
||||
|
||||
//wxClientDC &dc = event.GetDC();
|
||||
// wxPaintDC dc(this);
|
||||
// if(overrideSize.first > 0 && overrideSize.second > 0) {
|
||||
// wxRect r(0,0,100,100);
|
||||
// dc.SetDeviceClippingRegion(r);
|
||||
// // Then I destroy the clipping region
|
||||
// dc.DestroyClippingRegion();
|
||||
// }
|
||||
glCanvas->setCurrentGLContext();
|
||||
|
||||
static float autoScreenshotRender = -1;
|
||||
if(autoScreenShotAndExit == true && autoScreenshotRender >= 0) {
|
||||
|
@ -667,6 +651,12 @@ void MainWindow::onPaint(wxPaintEvent &event) {
|
|||
|
||||
renderer->renderParticleManager();
|
||||
|
||||
if(isFirstWindowShownEvent) {
|
||||
this->Refresh();
|
||||
glCanvas->Refresh();
|
||||
glCanvas->SetFocus();
|
||||
}
|
||||
|
||||
bool haveLoadedParticles = (particleProjectilePathList.empty() == false || particleSplashPathList.empty() == false);
|
||||
|
||||
if(autoScreenShotAndExit == true && viewportW > 0 && viewportH > 0) {
|
||||
|
@ -770,7 +760,9 @@ void MainWindow::onClose(wxCloseEvent &event){
|
|||
renderer = NULL;
|
||||
|
||||
//delete glCanvas;
|
||||
if(glCanvas) glCanvas->Destroy();
|
||||
if(glCanvas) {
|
||||
glCanvas->Destroy();
|
||||
}
|
||||
glCanvas = NULL;
|
||||
|
||||
this->Destroy();
|
||||
|
@ -1257,12 +1249,6 @@ void MainWindow::loadUnit(string path, string skillName) {
|
|||
this->particleSplashPathList.push_back(skillParticleSplashFile);
|
||||
printf("Added skill splash particle [%s]\n",skillParticleSplashFile.c_str());
|
||||
}
|
||||
|
||||
//glCanvas->SetCurrent();
|
||||
//renderer->init();
|
||||
|
||||
//wxCommandEvent event;
|
||||
//onMenuRestart(event);
|
||||
}
|
||||
SetTitle(ToUnicode(titlestring));
|
||||
}
|
||||
|
@ -1271,7 +1257,6 @@ void MainWindow::loadUnit(string path, string skillName) {
|
|||
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();
|
||||
}
|
||||
//timer->Start(100);
|
||||
}
|
||||
|
||||
void MainWindow::loadModel(string path) {
|
||||
|
@ -2030,8 +2015,8 @@ void translateCoords(wxWindow *wnd, int &x, int &y) {
|
|||
// to prevent flicker
|
||||
GlCanvas::GlCanvas(MainWindow * mainWindow, int *args)
|
||||
#if wxCHECK_VERSION(2, 9, 1)
|
||||
: wxGLCanvas(mainWindow, -1, args, wxDefaultPosition, wxDefaultSize, 0, wxT("GLCanvas")) {
|
||||
this->context = NULL;
|
||||
: wxGLCanvas(mainWindow, wxID_ANY, args, wxDefaultPosition, mainWindow->GetClientSize(), wxFULL_REPAINT_ON_RESIZE, wxT("GLCanvas")) {
|
||||
this->context = new wxGLContext(this);
|
||||
#else
|
||||
: wxGLCanvas(mainWindow, -1, wxDefaultPosition, wxDefaultSize, 0, wxT("GLCanvas"), args) {
|
||||
this->context = NULL;
|
||||
|
@ -2040,14 +2025,28 @@ GlCanvas::GlCanvas(MainWindow * mainWindow, int *args)
|
|||
}
|
||||
|
||||
GlCanvas::~GlCanvas() {
|
||||
if(this->context) delete this->context;
|
||||
if(this->context) {
|
||||
delete this->context;
|
||||
}
|
||||
this->context = NULL;
|
||||
}
|
||||
|
||||
void GlCanvas::setCurrentGLContext() {
|
||||
#ifndef __APPLE__
|
||||
|
||||
#if wxCHECK_VERSION(2, 9, 1)
|
||||
#if wxCHECK_VERSION(3, 0, 0)
|
||||
//printf("Setting glcontext 3x!\n");
|
||||
|
||||
//if(!IsShown()) {}
|
||||
if(this->context == NULL) {
|
||||
//printf("Make new ctx!\n");
|
||||
this->context = new wxGLContext(this);
|
||||
//printf("Set ctx [%p]\n",this->context);
|
||||
}
|
||||
#elif wxCHECK_VERSION(2, 9, 1)
|
||||
//printf("Setting glcontext 29x!\n");
|
||||
|
||||
//if(!IsShown()) {}
|
||||
if(this->context == NULL) {
|
||||
this->context = new wxGLContext(this);
|
||||
//printf("Set ctx [%p]\n",this->context);
|
||||
|
@ -2080,6 +2079,12 @@ void GlCanvas::onKeyDown(wxKeyEvent &event) {
|
|||
mainWindow->onKeyDown(event);
|
||||
}
|
||||
|
||||
void GlCanvas::OnSize(wxSizeEvent&event) {
|
||||
|
||||
//printf("OnSize %dx%d\n",event.m_size.GetWidth(),event.m_size.GetHeight());
|
||||
Update();
|
||||
}
|
||||
|
||||
// EVT_SPIN_DOWN(GlCanvas::onMouseDown)
|
||||
// EVT_SPIN_UP(GlCanvas::onMouseDown)
|
||||
// EVT_MIDDLE_DOWN(GlCanvas::onMouseWheel)
|
||||
|
@ -2089,6 +2094,7 @@ BEGIN_EVENT_TABLE(GlCanvas, wxGLCanvas)
|
|||
EVT_MOUSEWHEEL(GlCanvas::onMouseWheel)
|
||||
EVT_MOTION(GlCanvas::onMouseMove)
|
||||
EVT_KEY_DOWN(GlCanvas::onKeyDown)
|
||||
EVT_SIZE(GlCanvas::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ===============================================
|
||||
|
|
|
@ -199,6 +199,7 @@ public:
|
|||
void onMouseMove(wxMouseEvent &event);
|
||||
void onPaint(wxPaintEvent &event);
|
||||
void onKeyDown(wxKeyEvent &event);
|
||||
void OnSize(wxSizeEvent&);
|
||||
void setCurrentGLContext();
|
||||
|
||||
wxGLContext * getCtx() { return context; }
|
||||
|
|
|
@ -312,9 +312,6 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST
|
|||
streflop/softfloat)
|
||||
ENDIF()
|
||||
|
||||
#IF(NOT WANT_STATIC_LIBS)
|
||||
#MESSAGE(STATUS "*** Searching for miniupnpc since WANT_STATIC_LIBS is off ...")
|
||||
#MESSAGE(STATUS "*** Searching for miniupnpc ...")
|
||||
IF(NOT FORCE_EMBEDDED_LIBS)
|
||||
FIND_PACKAGE(Miniupnpc)
|
||||
ENDIF()
|
||||
|
|
Loading…
Reference in New Issue