From 4b586bc7b36470edd01ad60c2f2fcb8fcee18273 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 10 Aug 2012 06:19:35 +0000 Subject: [PATCH] - added more opengl checking to see if the user has enough support to run megaglest. - for windows users, bring error message dialog in front of everything else --- source/glest_game/graphics/renderer.cpp | 107 +++++++++++++++++- source/glest_game/main/main.cpp | 30 +++-- .../sources/platform/sdl/gl_wrap.cpp | 24 +++- .../sources/platform/sdl/window.cpp | 71 +++++++++++- .../sources/platform/win32/platform_util.cpp | 6 +- 5 files changed, 216 insertions(+), 22 deletions(-) diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 3c31740f..97556d1d 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -350,43 +350,84 @@ void Renderer::reinitAll() { // ==================== init ==================== void Renderer::init() { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + Config &config= Config::getInstance(); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + loadConfig(); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { return; } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(config.getBool("CheckGlCaps")){ + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + checkGlCaps(); } - if(config.getBool("FirstTime")){ - config.setBool("FirstTime", false); - autoConfig(); - config.save(); + if(glActiveTexture == NULL) { + char szBuf[8096]=""; + sprintf(szBuf,"Error: glActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + throw megaglest_runtime_error(szBuf); } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + + if(config.getBool("FirstTime")){ + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + + config.setBool("FirstTime", false); + autoConfig(); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + + config.save(); + } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + modelManager[rsGlobal]->init(); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + textureManager[rsGlobal]->init(); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + fontManager[rsGlobal]->init(); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + init2dList(); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + glHint(GL_FOG_HINT, GL_FASTEST); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST); glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); //glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST); //glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } void Renderer::initGame(const Game *game, GameCamera *gameCamera) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); this->gameCamera = gameCamera; VisibleQuadContainerCache::enableFrustumCalcs = Config::getInstance().getBool("EnableFrustrumCalcs","true"); quadCache = VisibleQuadContainerCache(); @@ -401,6 +442,7 @@ void Renderer::initGame(const Game *game, GameCamera *gameCamera) { shadowMapFrame= 0; waterAnim= 0; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { @@ -408,6 +450,7 @@ void Renderer::initGame(const Game *game, GameCamera *gameCamera) { } //check gl caps + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); checkGlOptionalCaps(); //shadows @@ -7246,6 +7289,17 @@ void Renderer::checkGlCaps() { return; } + if(glActiveTexture == NULL) { + string message; + + message += "Your system supports OpenGL version \""; + message += getGlVersion() + string("\"\n"); + message += "MegaGlest needs a version that supports\n"; + message += "glActiveTexture (OpenGL 1.3) or the ARB_multitexture extension."; + + throw megaglest_runtime_error(message.c_str()); + } + //opengl 1.3 //if(!isGlVersionSupported(1, 3, 0)) { if(glewIsSupported("GL_VERSION_1_3") == false) { @@ -7271,6 +7325,7 @@ void Renderer::checkGlOptionalCaps() { return; } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //shadows if(shadows == sProjected || shadows == sShadowMapping) { if(getGlMaxTextureUnits() < 3) { @@ -7278,12 +7333,15 @@ void Renderer::checkGlOptionalCaps() { } } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //shadow mapping if(shadows == sShadowMapping) { checkExtension("GL_ARB_shadow", "Shadow Mapping"); //checkExtension("GL_ARB_shadow_ambient", "Shadow Mapping"); //checkExtension("GL_ARB_depth_texture", "Shadow Mapping"); } + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } void Renderer::checkExtension(const string &extension, const string &msg) { @@ -7291,10 +7349,12 @@ void Renderer::checkExtension(const string &extension, const string &msg) { return; } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(!isGlExtensionSupported(extension.c_str())) { string str= "OpenGL extension not supported: " + extension + ", required for " + msg; throw megaglest_runtime_error(str); } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } // ==================== init 3d lists ==================== @@ -7304,9 +7364,13 @@ void Renderer::init3dList() { return; } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); render3dSetup(); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + //const Metrics &metrics= Metrics::getInstance(); //assertGl(); @@ -7331,6 +7395,7 @@ void Renderer::init3dList() { } void Renderer::render3dSetup() { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); const Metrics &metrics= Metrics::getInstance(); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); @@ -7343,6 +7408,8 @@ void Renderer::render3dSetup() { //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + //texture state glActiveTexture(shadowTexUnit); glDisable(GL_TEXTURE_2D); @@ -7358,6 +7425,8 @@ void Renderer::render3dSetup() { //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + //material state glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defSpecularColor.ptr()); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, defAmbientColor.ptr()); @@ -7369,6 +7438,8 @@ void Renderer::render3dSetup() { glDisable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + //alpha test state glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.f); @@ -7391,6 +7462,7 @@ void Renderer::render3dSetup() { glDisable(GL_STENCIL_TEST); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //fog const Tileset *tileset= NULL; @@ -7437,6 +7509,8 @@ void Renderer::init2dList() { } void Renderer::render2dMenuSetup() { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + const Metrics &metrics= Metrics::getInstance(); //projection glViewport(0, 0, metrics.getScreenW(), metrics.getScreenH()); @@ -7444,10 +7518,14 @@ void Renderer::render2dMenuSetup() { glLoadIdentity(); glOrtho(0, metrics.getVirtualW(), 0, metrics.getVirtualH(), 0, 1); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + //modelview glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + //disable everything glDisable(GL_BLEND); glDisable(GL_LIGHTING); @@ -7457,15 +7535,32 @@ void Renderer::render2dMenuSetup() { glDisable(GL_FOG); glDisable(GL_CULL_FACE); glFrontFace(GL_CCW); - glActiveTexture(baseTexUnit); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + + if(glActiveTexture != NULL) { + glActiveTexture(baseTexUnit); + } + else { + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s] Line: %d\nglActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + throw megaglest_runtime_error(szBuf); + } + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glDisable(GL_TEXTURE_2D); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + //blend func glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //color glColor4f(1.f, 1.f, 1.f, 1.f); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } void Renderer::init3dListMenu(const MainMenu *mm) { @@ -7575,6 +7670,8 @@ void Renderer::init3dListMenu(const MainMenu *mm) { } void Renderer::render3dMenuSetup(const MainMenu *mm) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + const Metrics &metrics= Metrics::getInstance(); const MenuBackground *mb = NULL; if(mm != NULL) { diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index e3df8de5..7c4d0c5a 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -401,25 +401,31 @@ public: if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); mainProgram->showMessage(errMsg.c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) { - //program->getState()->render(); - Window::handleEvent(); - mainProgram->loop(); - //printf("\nhandle error #1\n"); - } + if(glActiveTexture != NULL) { + for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) { + //program->getState()->render(); + Window::handleEvent(); + mainProgram->loop(); + + //printf("\nhandle error #1\n"); + } + } } else { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); mainProgram->showMessage(errMsg.c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) { - //program->renderProgramMsgBox(); - Window::handleEvent(); - mainProgram->loop(); - //printf("\nhandle error #2\n"); - } + if(glActiveTexture != NULL) { + for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) { + //program->renderProgramMsgBox(); + Window::handleEvent(); + mainProgram->loop(); + + //printf("\nhandle error #2\n"); + } + } } if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index 4bf67f62..8a878e3c 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -54,10 +54,12 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits, bool hardware_acceleration, bool fullscreen_anti_aliasing, float gammaValue) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); Window::setupGraphicsScreen(depthBits, stencilBits, hardware_acceleration, fullscreen_anti_aliasing); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); int flags = SDL_OPENGL; @@ -149,6 +151,7 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits, } #endif + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to set resolution: %d x %d, colorBits = %d.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,resW,resH,colorBits); if(screen != NULL) { @@ -156,8 +159,12 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits, screen = NULL; } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + screen = SDL_SetVideoMode(resW, resH, colorBits, flags); if(screen == 0) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + std::ostringstream msg; msg << "Couldn't set video mode " << resW << "x" << resH << " (" << colorBits @@ -203,22 +210,37 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits, } } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); SDL_WM_GrabInput(SDL_GRAB_OFF); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d] BEFORE glewInit call\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + GLuint err = glewInit(); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d] AFTER glewInit call err = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,err); + if (GLEW_OK != err) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err)); //return 1; throw std::runtime_error((char *)glewGetErrorString(err)); } //fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + int bufferSize = (resW * resH * BaseColorPickEntity::COLOR_COMPONENTS); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + BaseColorPickEntity::init(bufferSize); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(gammaValue != 0.0) { //printf("Attempting to call SDL_SetGamma using value %f\n", gammaValue); - + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if (SDL_SetGamma(gammaValue, gammaValue, gammaValue) < 0) { printf("WARNING, SDL_SetGamma failed using value %f [%s]\n", gammaValue,SDL_GetError()); } diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 9d5ccece..2285bdba 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -89,7 +89,11 @@ Window::Window() { lastMouseY[idx] = 0; } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); assert(global_window == 0); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + global_window = this; Window::isActive = true; @@ -103,12 +107,16 @@ Window::Window() { } Window::~Window() { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); #ifdef WIN32 + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); done_win32(); #endif + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); assert(global_window == this); global_window = 0; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } bool Window::handleEvent() { @@ -364,7 +372,9 @@ float Window::getAspect() { } void Window::setText(string text) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); SDL_WM_SetCaption(text.c_str(), 0); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } void Window::setSize(int w, int h) { @@ -401,18 +411,26 @@ void Window::setStyle(WindowStyle windowStyle) { void Window::create() { // nothing here + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); #ifdef WIN32 ontop_win32(this->w,this->h); #endif + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } void Window::destroy() { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + SDL_Event event; event.type = SDL_QUIT; SDL_PushEvent(&event); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_acceleration, bool fullscreen_anti_aliasing) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + static int newDepthBits = depthBits; static int newStencilBits = stencilBits; if(depthBits >= 0) @@ -420,7 +438,11 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a if(stencilBits >= 0) newStencilBits = stencilBits; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(fullscreen_anti_aliasing == true) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2); @@ -428,6 +450,9 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a if(hardware_acceleration == true) { SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); } + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 1); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 1); @@ -435,6 +460,8 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, newStencilBits); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, newDepthBits); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + //const SDL_VideoInfo *info = SDL_GetVideoInfo(); #ifdef SDL_GL_SWAP_CONTROL if(Window::tryVSynch == true) { @@ -443,6 +470,8 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a } #endif + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + // setup LOD bias factor //const float lodBias = std::max(std::min( configHandler->Get("TextureLODBias", 0.0f) , 4.0f), -4.0f); const float lodBias = max(min(0.0f,4.0f),-4.0f); @@ -454,11 +483,13 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a #endif glTexEnvf(GL_TEXTURE_FILTER_CONTROL,GL_TEXTURE_LOD_BIAS, lodBias ); } - } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + } } void Window::toggleFullscreen() { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); Window::isFullScreen = !Window::isFullScreen; #ifdef WIN32 @@ -467,15 +498,30 @@ void Window::toggleFullscreen() { width and height of the current video mode (or the desktop mode, if no mode has been set). Use 0 for Height, Width, and Color Depth to keep the current values. */ + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(Window::allowAltEnterFullscreenToggle == true) { + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) { + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + SDL_Surface *cur_surface = SDL_GetVideoSurface(); if(cur_surface != NULL) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); Window::isFullScreen = !((cur_surface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN); } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); SDL_Surface *sf = SDL_GetVideoSurface(); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); SDL_Surface **surface = &sf; + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + uint32 *flags = NULL; //void *pixels = NULL; //SDL_Color *palette = NULL; @@ -486,9 +532,11 @@ void Window::toggleFullscreen() { int h = 0; int bpp = 0; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if ( (!surface) || (!(*surface)) ) // don't bother if there's no surface. return; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); tmpflags = (*surface)->flags; @@ -496,11 +544,14 @@ void Window::toggleFullscreen() { h = (*surface)->h; bpp = (*surface)->format->BitsPerPixel; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n w = %d, h = %d, bpp = %d",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,w,h,bpp); if (flags == NULL) // use the surface's flags. flags = &tmpflags; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + // if ( *flags & SDL_FULLSCREEN ) *flags &= ~SDL_FULLSCREEN; @@ -508,25 +559,37 @@ void Window::toggleFullscreen() { else *flags |= SDL_FULLSCREEN; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + SDL_GetClipRect(*surface, &clip); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); *surface = SDL_SetVideoMode(w, h, bpp, (*flags)); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if (*surface == NULL) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); *surface = SDL_SetVideoMode(w, h, bpp, tmpflags); } // if + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); SDL_SetClipRect(*surface, &clip); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } } else { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + HWND handle = GetSDLWindow(); if(Window::isFullScreen == true) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == true [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,handle); ShowWindow(handle, SW_MAXIMIZE); //if(Window::getUseDefaultCursorOnly() == false) { @@ -534,12 +597,17 @@ void Window::toggleFullscreen() { //} } else { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == false [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,handle); ShowWindow(handle, SW_RESTORE); //showCursor(true); } + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + #else if(Window::allowAltEnterFullscreenToggle == true) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); @@ -555,6 +623,7 @@ void Window::toggleFullscreen() { } #endif + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } diff --git a/source/shared_lib/sources/platform/win32/platform_util.cpp b/source/shared_lib/sources/platform/win32/platform_util.cpp index b0b96471..632bc105 100644 --- a/source/shared_lib/sources/platform/win32/platform_util.cpp +++ b/source/shared_lib/sources/platform/win32/platform_util.cpp @@ -349,13 +349,13 @@ void message(string message){ std::cerr << "******************************************************\n"; LPWSTR wstr = Ansi2WideString(message.c_str()); - MessageBox(NULL, wstr, L"Message", MB_OK); + MessageBox(NULL, wstr, L"Message", MB_OK | MB_SYSTEMMODAL); delete [] wstr; } bool ask(string message){ LPWSTR wstr = Ansi2WideString(message.c_str()); - bool result = MessageBox(NULL, wstr, L"Confirmation", MB_YESNO)==IDYES; + bool result = MessageBox(NULL, wstr, L"Confirmation", MB_YESNO | MB_SYSTEMMODAL) == IDYES; delete [] wstr; return result; } @@ -372,7 +372,7 @@ void exceptionMessage(const exception &excp){ LPWSTR wstr = Ansi2WideString(message.c_str()); LPWSTR wstr1 = Ansi2WideString(title.c_str()); - MessageBox(NULL, wstr, wstr1, MB_ICONSTOP | MB_OK | MB_TASKMODAL); + MessageBox(NULL, wstr, wstr1, MB_ICONSTOP | MB_OK | MB_SYSTEMMODAL); delete [] wstr; delete [] wstr1; }