mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:10:05 +00:00 
			
		
		
		
	Use glad instead of GLEW to load OpenGL
This commit is contained in:
		
							parent
							
								
									6cb668f546
								
							
						
					
					
						commit
						d5cda9b353
					
				
					 5 changed files with 26 additions and 12 deletions
				
			
		
							
								
								
									
										2
									
								
								external/CMakeLists.txt
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								external/CMakeLists.txt
									
										
									
									
										vendored
									
									
								
							|  | @ -6,6 +6,7 @@ set_property(DIRECTORY | ||||||
|              PROPERTY CMAKE_CONFIGURE_DEPENDS |              PROPERTY CMAKE_CONFIGURE_DEPENDS | ||||||
|              aws-sdk-cpp.cmake |              aws-sdk-cpp.cmake | ||||||
|              date.cmake |              date.cmake | ||||||
|  |              glad.cmake | ||||||
|              hsluv-c.cmake |              hsluv-c.cmake | ||||||
|              imgui.cmake |              imgui.cmake | ||||||
|              maplibre-native-qt.cmake |              maplibre-native-qt.cmake | ||||||
|  | @ -16,6 +17,7 @@ set_property(DIRECTORY | ||||||
| 
 | 
 | ||||||
| include(aws-sdk-cpp.cmake) | include(aws-sdk-cpp.cmake) | ||||||
| include(date.cmake) | include(date.cmake) | ||||||
|  | include(glad.cmake) | ||||||
| include(hsluv-c.cmake) | include(hsluv-c.cmake) | ||||||
| include(imgui.cmake) | include(imgui.cmake) | ||||||
| include(maplibre-native-qt.cmake) | include(maplibre-native-qt.cmake) | ||||||
|  |  | ||||||
							
								
								
									
										11
									
								
								external/glad.cmake
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								external/glad.cmake
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | ||||||
|  | cmake_minimum_required(VERSION 3.24) | ||||||
|  | set(PROJECT_NAME scwx-glad) | ||||||
|  | 
 | ||||||
|  | # Path to glad directory | ||||||
|  | set(GLAD_SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/glad/") | ||||||
|  | 
 | ||||||
|  | # Path to glad CMake files | ||||||
|  | add_subdirectory("${GLAD_SOURCES_DIR}/cmake" glad_cmake) | ||||||
|  | 
 | ||||||
|  | # Specify glad settings | ||||||
|  | glad_add_library(glad_gl_core_33 LOADER REPRODUCIBLE API gl:core=3.3) | ||||||
|  | @ -745,7 +745,7 @@ target_link_libraries(scwx-qt PUBLIC Qt${QT_VERSION_MAJOR}::Widgets | ||||||
|                                      GeographicLib::GeographicLib |                                      GeographicLib::GeographicLib | ||||||
|                                      GEOS::geos |                                      GEOS::geos | ||||||
|                                      GEOS::geos_cxx_flags |                                      GEOS::geos_cxx_flags | ||||||
|                                      GLEW::GLEW |                                      glad_gl_core_33 | ||||||
|                                      glm::glm |                                      glm::glm | ||||||
|                                      imgui |                                      imgui | ||||||
|                                      qt6ct-common |                                      qt6ct-common | ||||||
|  | @ -753,7 +753,8 @@ target_link_libraries(scwx-qt PUBLIC Qt${QT_VERSION_MAJOR}::Widgets | ||||||
|                                      SQLite::SQLite3 |                                      SQLite::SQLite3 | ||||||
|                                      wxdata) |                                      wxdata) | ||||||
| 
 | 
 | ||||||
| target_link_libraries(supercell-wx PRIVATE scwx-qt | target_link_libraries(supercell-wx PRIVATE GLEW::GLEW | ||||||
|  |                                            scwx-qt | ||||||
|                                            wxdata) |                                            wxdata) | ||||||
| 
 | 
 | ||||||
| if (LINUX) | if (LINUX) | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <GL/glew.h> | #include <glad/gl.h> | ||||||
| 
 | 
 | ||||||
| #define SCWX_GL_CHECK_ERROR()                                                  \ | #define SCWX_GL_CHECK_ERROR()                                                  \ | ||||||
|    {                                                                           \ |    {                                                                           \ | ||||||
|  |  | ||||||
|  | @ -57,21 +57,21 @@ void GlContext::Impl::InitializeGL() | ||||||
|       return; |       return; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    const GLenum error = glewInit(); |    const int gladVersion = gladLoaderLoadGL(); | ||||||
|    if (error != GLEW_OK) |    if (!gladVersion) | ||||||
|    { |    { | ||||||
|       auto glewErrorString = |       logger_->error("gladLoaderLoadGL failed"); | ||||||
|          reinterpret_cast<const char*>(glewGetErrorString(error)); |  | ||||||
|       logger_->error("glewInit failed: {}", glewErrorString); |  | ||||||
| 
 | 
 | ||||||
|       QMessageBox::critical( |       QMessageBox::critical( | ||||||
|          nullptr, |          nullptr, "Supercell Wx", "Unable to initialize OpenGL"); | ||||||
|          "Supercell Wx", |  | ||||||
|          QString("Unable to initialize OpenGL: %1").arg(glewErrorString)); |  | ||||||
| 
 | 
 | ||||||
|       throw std::runtime_error("Unable to initialize OpenGL"); |       throw std::runtime_error("Unable to initialize OpenGL"); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |    logger_->info("GLAD initialization complete: OpenGL {}.{}", | ||||||
|  |                  GLAD_VERSION_MAJOR(gladVersion), | ||||||
|  |                  GLAD_VERSION_MINOR(gladVersion)); | ||||||
|  | 
 | ||||||
|    auto glVersion  = reinterpret_cast<const char*>(glGetString(GL_VERSION)); |    auto glVersion  = reinterpret_cast<const char*>(glGetString(GL_VERSION)); | ||||||
|    auto glVendor   = reinterpret_cast<const char*>(glGetString(GL_VENDOR)); |    auto glVendor   = reinterpret_cast<const char*>(glGetString(GL_VENDOR)); | ||||||
|    auto glRenderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER)); |    auto glRenderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER)); | ||||||
|  | @ -86,7 +86,7 @@ void GlContext::Impl::InitializeGL() | ||||||
|    glGetIntegerv(GL_MAJOR_VERSION, &major); |    glGetIntegerv(GL_MAJOR_VERSION, &major); | ||||||
|    glGetIntegerv(GL_MINOR_VERSION, &minor); |    glGetIntegerv(GL_MINOR_VERSION, &minor); | ||||||
| 
 | 
 | ||||||
|    if (major < 3 || (major == 3 && minor < 3)) |    if (major < 3 || (major == 3 && minor < 3) || !GLAD_GL_VERSION_3_3) | ||||||
|    { |    { | ||||||
|       logger_->error( |       logger_->error( | ||||||
|          "OpenGL 3.3 or greater is required, found {}.{}", major, minor); |          "OpenGL 3.3 or greater is required, found {}.{}", major, minor); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat