mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 07:20:04 +00:00 
			
		
		
		
	Display an informational dialog when OpenGL cannot properly be initialized
This commit is contained in:
		
							parent
							
								
									a6f8547455
								
							
						
					
					
						commit
						8e9db6a2fe
					
				
					 3 changed files with 69 additions and 22 deletions
				
			
		|  | @ -3,12 +3,9 @@ | ||||||
| #include <scwx/util/logger.hpp> | #include <scwx/util/logger.hpp> | ||||||
| 
 | 
 | ||||||
| #include <boost/container_hash/hash.hpp> | #include <boost/container_hash/hash.hpp> | ||||||
|  | #include <QMessageBox> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx::qt::gl | ||||||
| { |  | ||||||
| namespace qt |  | ||||||
| { |  | ||||||
| namespace gl |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::gl::gl_context"; | static const std::string logPrefix_ = "scwx::qt::gl::gl_context"; | ||||||
|  | @ -63,16 +60,49 @@ void GlContext::Impl::InitializeGL() | ||||||
|    const GLenum error = glewInit(); |    const GLenum error = glewInit(); | ||||||
|    if (error != GLEW_OK) |    if (error != GLEW_OK) | ||||||
|    { |    { | ||||||
|       logger_->error("glewInit failed: {}", |       auto glewErrorString = | ||||||
|                      reinterpret_cast<const char*>(glewGetErrorString(error))); |          reinterpret_cast<const char*>(glewGetErrorString(error)); | ||||||
|  |       logger_->error("glewInit failed: {}", glewErrorString); | ||||||
|  | 
 | ||||||
|  |       QMessageBox::critical( | ||||||
|  |          nullptr, | ||||||
|  |          "Supercell Wx", | ||||||
|  |          QString("Unable to initialize OpenGL: %1").arg(glewErrorString)); | ||||||
|  | 
 | ||||||
|  |       throw std::runtime_error("Unable to initialize OpenGL"); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    logger_->info("OpenGL Version: {}", |    auto glVersion  = reinterpret_cast<const char*>(glGetString(GL_VERSION)); | ||||||
|                  reinterpret_cast<const char*>(glGetString(GL_VERSION))); |    auto glVendor   = reinterpret_cast<const char*>(glGetString(GL_VENDOR)); | ||||||
|    logger_->info("OpenGL Vendor: {}", |    auto glRenderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER)); | ||||||
|                  reinterpret_cast<const char*>(glGetString(GL_VENDOR))); | 
 | ||||||
|    logger_->info("OpenGL Renderer: {}", |    logger_->info("OpenGL Version: {}", glVersion); | ||||||
|                  reinterpret_cast<const char*>(glGetString(GL_RENDERER))); |    logger_->info("OpenGL Vendor: {}", glVendor); | ||||||
|  |    logger_->info("OpenGL Renderer: {}", glRenderer); | ||||||
|  | 
 | ||||||
|  |    // Get OpenGL version
 | ||||||
|  |    GLint major = 0; | ||||||
|  |    GLint minor = 0; | ||||||
|  |    glGetIntegerv(GL_MAJOR_VERSION, &major); | ||||||
|  |    glGetIntegerv(GL_MINOR_VERSION, &minor); | ||||||
|  | 
 | ||||||
|  |    if (major < 3 || (major == 3 && minor < 3)) | ||||||
|  |    { | ||||||
|  |       logger_->error( | ||||||
|  |          "OpenGL 3.3 or greater is required, found {}.{}", major, minor); | ||||||
|  | 
 | ||||||
|  |       QMessageBox::critical( | ||||||
|  |          nullptr, | ||||||
|  |          "Supercell Wx", | ||||||
|  |          QString("OpenGL 3.3 or greater is required, found %1.%2\n\n%3\n%4\n%5") | ||||||
|  |             .arg(major) | ||||||
|  |             .arg(minor) | ||||||
|  |             .arg(glVersion) | ||||||
|  |             .arg(glVendor) | ||||||
|  |             .arg(glRenderer)); | ||||||
|  | 
 | ||||||
|  |       throw std::runtime_error("OpenGL version too low"); | ||||||
|  |    } | ||||||
| 
 | 
 | ||||||
|    glGenTextures(1, &textureAtlas_); |    glGenTextures(1, &textureAtlas_); | ||||||
| 
 | 
 | ||||||
|  | @ -151,6 +181,4 @@ std::size_t GlContext::Impl::GetShaderKey( | ||||||
|    return seed; |    return seed; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace gl
 | } // namespace scwx::qt::gl
 | ||||||
| } // namespace qt
 |  | ||||||
| } // namespace scwx
 |  | ||||||
|  |  | ||||||
|  | @ -151,8 +151,23 @@ int main(int argc, char* argv[]) | ||||||
|       // Run Qt main loop
 |       // Run Qt main loop
 | ||||||
|       { |       { | ||||||
|          scwx::qt::main::MainWindow w; |          scwx::qt::main::MainWindow w; | ||||||
|          w.show(); | 
 | ||||||
|          result = a.exec(); |          bool initialized = false; | ||||||
|  | 
 | ||||||
|  |          try | ||||||
|  |          { | ||||||
|  |             w.show(); | ||||||
|  |             initialized = true; | ||||||
|  |          } | ||||||
|  |          catch (const std::exception& ex) | ||||||
|  |          { | ||||||
|  |             logger_->critical(ex.what()); | ||||||
|  |          } | ||||||
|  | 
 | ||||||
|  |          if (initialized) | ||||||
|  |          { | ||||||
|  |             result = a.exec(); | ||||||
|  |          } | ||||||
|       } |       } | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -2011,10 +2011,14 @@ void MapWidgetImpl::RadarProductViewConnect() | ||||||
|             std::shared_ptr<config::RadarSite> radarSite = |             std::shared_ptr<config::RadarSite> radarSite = | ||||||
|                radarProductManager_->radar_site(); |                radarProductManager_->radar_site(); | ||||||
| 
 | 
 | ||||||
|             RadarRangeLayer::Update( |             if (map_ != nullptr) | ||||||
|                map_, |             { | ||||||
|                radarProductView->range(), |                RadarRangeLayer::Update( | ||||||
|                {radarSite->latitude(), radarSite->longitude()}); |                   map_, | ||||||
|  |                   radarProductView->range(), | ||||||
|  |                   {radarSite->latitude(), radarSite->longitude()}); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|             widget_->update(); |             widget_->update(); | ||||||
|             Q_EMIT widget_->RadarSweepUpdated(); |             Q_EMIT widget_->RadarSweepUpdated(); | ||||||
|          }, |          }, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat