Replace GLEW with a glLoadGen loader.
This should fix the GL loading errors that occur in some drivers due to the use of deprecated functions by GLEW. Side benefits are more accurate auto-completion (deprecated function and symbols don't exist) and faster pointer loading (less entrypoints to load). In addition it removes an external library depency, simplifying the build system a bit and eliminating one set of binary libraries for Windows.
This commit is contained in:
		| @@ -10,9 +10,9 @@ endif() | ||||
| add_executable(citra ${SRCS} ${HEADERS}) | ||||
|  | ||||
| if (APPLE) | ||||
|     target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES}) | ||||
|     target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES}) | ||||
| else() | ||||
|     target_link_libraries(citra core common video_core GLEW pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB} ${PNG_LIBRARIES}) | ||||
|     target_link_libraries(citra core common video_core pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB} ${PNG_LIBRARIES}) | ||||
| endif() | ||||
|  | ||||
| #install(TARGETS citra RUNTIME DESTINATION ${bindir}) | ||||
|   | ||||
| @@ -4,7 +4,6 @@ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <GL/glew.h> | ||||
| #include <GLFW/glfw3.h> | ||||
|  | ||||
| #include "common/emu_window.h" | ||||
|   | ||||
| @@ -47,7 +47,7 @@ else() | ||||
| 	set(RT_LIBRARY rt) | ||||
| endif() | ||||
|  | ||||
| target_link_libraries(citra-qt core common video_core qhexedit ${ICONV_LIBRARY} ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${RT_LIBRARY} ${GLEW_LIBRARY} ${PNG_LIBRARIES}) | ||||
| target_link_libraries(citra-qt core common video_core qhexedit ${ICONV_LIBRARY} ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${RT_LIBRARY} ${PNG_LIBRARIES}) | ||||
| if(USE_QT5) | ||||
|     target_link_libraries(citra-qt Qt5::Gui Qt5::Widgets Qt5::OpenGL) | ||||
| endif() | ||||
|   | ||||
| @@ -5,6 +5,7 @@ set(SRCS    clipper.cpp | ||||
|             utils.cpp | ||||
|             vertex_shader.cpp | ||||
|             video_core.cpp | ||||
|             renderer_opengl/generated/gl_3_2_core.c | ||||
|             renderer_opengl/renderer_opengl.cpp | ||||
|             renderer_opengl/gl_shader_util.cpp | ||||
|             debug_utils/debug_utils.cpp) | ||||
| @@ -19,6 +20,7 @@ set(HEADERS clipper.h | ||||
|             renderer_base.h | ||||
|             vertex_shader.h | ||||
|             video_core.h | ||||
|             renderer_opengl/generated/gl_3_2_core.h | ||||
|             renderer_opengl/renderer_opengl.h | ||||
|             renderer_opengl/gl_shader_util.h | ||||
|             renderer_opengl/gl_shaders.h | ||||
|   | ||||
							
								
								
									
										5
									
								
								src/video_core/renderer_opengl/generated/Readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/video_core/renderer_opengl/generated/Readme.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| These file were generated by the [glLoadGen](https://bitbucket.org/alfonse/glloadgen/wiki/Home) OpenGL loader generator and have been checked in as-is. You can re-generate them using version 2.0.2 of glLoadGen and executing the following command: | ||||
|  | ||||
| ``` | ||||
| lua LoadGen.lua -version 3.2 -profile core -indent space 3_2_core | ||||
| ``` | ||||
							
								
								
									
										1186
									
								
								src/video_core/renderer_opengl/generated/gl_3_2_core.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1186
									
								
								src/video_core/renderer_opengl/generated/gl_3_2_core.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1609
									
								
								src/video_core/renderer_opengl/generated/gl_3_2_core.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1609
									
								
								src/video_core/renderer_opengl/generated/gl_3_2_core.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -4,7 +4,7 @@ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <GL/glew.h> | ||||
| #include "generated/gl_3_2_core.h" | ||||
|  | ||||
| namespace ShaderUtil { | ||||
|  | ||||
|   | ||||
| @@ -247,10 +247,9 @@ void RendererOpenGL::SetWindow(EmuWindow* window) { | ||||
| void RendererOpenGL::Init() { | ||||
|     render_window->MakeCurrent(); | ||||
|  | ||||
|     GLenum err = glewInit(); | ||||
|     if (GLEW_OK != err) { | ||||
|         ERROR_LOG(RENDER, "Failed to initialize GLEW! Error message: \"%s\". Exiting...", | ||||
|                   glewGetErrorString(err)); | ||||
|     int err = ogl_LoadFunctions(); | ||||
|     if (ogl_LOAD_SUCCEEDED != err) { | ||||
|         ERROR_LOG(RENDER, "Failed to initialize GL functions! Exiting..."); | ||||
|         exit(-1); | ||||
|     } | ||||
|  | ||||
| @@ -265,7 +264,6 @@ void RendererOpenGL::Init() { | ||||
|  | ||||
|     // Initialize everything else | ||||
|     // -------------------------- | ||||
|  | ||||
|     InitFramebuffer(); | ||||
|  | ||||
|     NOTICE_LOG(RENDER, "GL_VERSION: %s\n", glGetString(GL_VERSION)); | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <GL/glew.h> | ||||
| #include "generated/gl_3_2_core.h" | ||||
|  | ||||
| #include "common/common.h" | ||||
| #include "common/emu_window.h" | ||||
|   | ||||
| @@ -30,11 +30,6 @@ void Start() { | ||||
|  | ||||
| /// Initialize the video core | ||||
| void Init(EmuWindow* emu_window) { | ||||
|  | ||||
|     // Required in order for GLFW to work on Linux,  | ||||
|     // or for GL contexts above 2.x on OS X | ||||
|     glewExperimental = GL_TRUE; | ||||
|  | ||||
|     g_emu_window = emu_window; | ||||
|     g_renderer = new RendererOpenGL(); | ||||
|     g_renderer->SetWindow(g_emu_window); | ||||
|   | ||||
| @@ -20,6 +20,7 @@ | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="debug_utils\debug_utils.cpp" /> | ||||
|     <ClCompile Include="renderer_opengl\generated\gl_3_2_core.c" /> | ||||
|     <ClCompile Include="renderer_opengl\renderer_opengl.cpp" /> | ||||
|     <ClCompile Include="renderer_opengl\gl_shader_util.cpp" /> | ||||
|     <ClCompile Include="clipper.cpp" /> | ||||
| @@ -39,6 +40,7 @@ | ||||
|     <ClInclude Include="primitive_assembly.h" /> | ||||
|     <ClInclude Include="rasterizer.h" /> | ||||
|     <ClInclude Include="renderer_base.h" /> | ||||
|     <ClInclude Include="renderer_opengl\generated\gl_3_2_core.h" /> | ||||
|     <ClInclude Include="utils.h" /> | ||||
|     <ClInclude Include="vertex_shader.h" /> | ||||
|     <ClInclude Include="video_core.h" /> | ||||
|   | ||||
| @@ -7,6 +7,9 @@ | ||||
|     <Filter Include="debug_utils"> | ||||
|       <UniqueIdentifier>{0ac498e6-bbd8-46e3-9d5f-e816546ab90e}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|     <Filter Include="renderer_opengl\generated"> | ||||
|       <UniqueIdentifier>{00301d57-24b3-4717-86a4-0073d131eb78}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="renderer_opengl\renderer_opengl.cpp"> | ||||
| @@ -25,6 +28,9 @@ | ||||
|     <ClCompile Include="debug_utils\debug_utils.cpp"> | ||||
|       <Filter>debug_utils</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="renderer_opengl\generated\gl_3_2_core.c"> | ||||
|       <Filter>renderer_opengl\generated</Filter> | ||||
|     </ClCompile> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="clipper.h" /> | ||||
| @@ -50,8 +56,11 @@ | ||||
|     <ClInclude Include="debug_utils\debug_utils.h"> | ||||
|       <Filter>debug_utils</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="renderer_opengl\generated\gl_3_2_core.h"> | ||||
|       <Filter>renderer_opengl\generated</Filter> | ||||
|     </ClInclude> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Text Include="CMakeLists.txt" /> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
| </Project> | ||||
		Reference in New Issue
	
	Block a user