瀏覽代碼

Fixed debug GL functions on windows (amend)

 - Removed the dependency on windows.h for windows.  I feel it's an
   unnecessarily large dependency to have to add to all source files
   when the only thing that's needed to make the windows version compile
   the debug functions is just the __stdcall call convention keyword.

   On top of increasing compile time due to the large number of headers
   it includes from all the windows API headers, it also adds a lot of
   potential name conflicts, as I was getting a number of name conflicts
   for lots of names like near/far, which were used in old legacy 16bit
   windows code.
jp9000 11 年之前
父節點
當前提交
156009cc0c
共有 2 個文件被更改,包括 17 次插入11 次删除
  1. 17 7
      libobs-opengl/gl-subsystem.c
  2. 0 4
      libobs-opengl/gl-subsystem.h

+ 17 - 7
libobs-opengl/gl-subsystem.c

@@ -44,13 +44,19 @@ static const char* debug_severity_table[] = {
 	"Low"
 	"Low"
 };
 };
 
 
-/* ARB and core values are the same. They'll always be linear so no hardcoding. */
-/* The values subtracted are the lowest value in the list of valid values. */
+/* ARB and core values are the same. They'll always be linear so no hardcoding.
+ * The values subtracted are the lowest value in the list of valid values. */
 #define GL_DEBUG_SOURCE_OFFSET(x) (x - GL_DEBUG_SOURCE_API_ARB)
 #define GL_DEBUG_SOURCE_OFFSET(x) (x - GL_DEBUG_SOURCE_API_ARB)
 #define GL_DEBUG_TYPE_OFFSET(x) (x - GL_DEBUG_TYPE_ERROR_ARB)
 #define GL_DEBUG_TYPE_OFFSET(x) (x - GL_DEBUG_TYPE_ERROR_ARB)
 #define GL_DEBUG_SEVERITY_OFFSET(x) (x - GL_DEBUG_SEVERITY_HIGH_ARB)
 #define GL_DEBUG_SEVERITY_OFFSET(x) (x - GL_DEBUG_SEVERITY_HIGH_ARB)
 
 
-static APIENTRY void gl_debug_proc(
+#ifdef _WIN32
+#define GLEW_TEMP_API __stdcall
+#else
+#define GLEW_TEMP_API
+#endif
+
+static void GLEW_TEMP_API gl_debug_proc(
 	GLenum source, GLenum type, GLuint id, GLenum severity, 
 	GLenum source, GLenum type, GLuint id, GLenum severity, 
 	GLsizei length, const GLchar *message, GLvoid *data )
 	GLsizei length, const GLchar *message, GLvoid *data )
 {
 {
@@ -72,7 +78,8 @@ static void gl_enable_debug()
 	else if (GLEW_ARB_debug_output) 
 	else if (GLEW_ARB_debug_output) 
 		glDebugMessageCallbackARB(gl_debug_proc, NULL);
 		glDebugMessageCallbackARB(gl_debug_proc, NULL);
 	else {
 	else {
-		blog(LOG_DEBUG, "Failed to set GL debug callback as it is not supported.");
+		blog(LOG_DEBUG, "Failed to set GL debug callback as it is "
+		                "not supported.");
 		return;
 		return;
 	}
 	}
 
 
@@ -89,14 +96,16 @@ static inline void required_extension_error(const char *extension)
 static bool gl_init_extensions(struct gs_device* device) 
 static bool gl_init_extensions(struct gs_device* device) 
 {
 {
 	if (!GLEW_VERSION_2_1) {
 	if (!GLEW_VERSION_2_1) {
-		blog(LOG_ERROR, "obs-studio requires OpenGL version 2.1 or higher.");
+		blog(LOG_ERROR, "obs-studio requires OpenGL version 2.1 or "
+		                "higher.");
 		return false;
 		return false;
 	}
 	}
 
 
 	gl_enable_debug();
 	gl_enable_debug();
 
 
 	if (!GLEW_VERSION_3_0 && !GLEW_ARB_framebuffer_object) {
 	if (!GLEW_VERSION_3_0 && !GLEW_ARB_framebuffer_object) {
-		blog(LOG_ERROR, "OpenGL extension ARB_framebuffer_object is required.");
+		blog(LOG_ERROR, "OpenGL extension ARB_framebuffer_object "
+		                "is required.");
 		return false;
 		return false;
 	}
 	}
 
 
@@ -105,7 +114,8 @@ static bool gl_init_extensions(struct gs_device* device)
 	}
 	}
 
 
 	if (!GLEW_VERSION_4_1 && !GLEW_ARB_separate_shader_objects) {
 	if (!GLEW_VERSION_4_1 && !GLEW_ARB_separate_shader_objects) {
-		blog(LOG_ERROR, "OpenGL extension ARB_separate_shader_objects is required.");
+		blog(LOG_ERROR, "OpenGL extension ARB_separate_shader_objects "
+		                "is required.");
 		return false;
 		return false;
 	}
 	}
 
 

+ 0 - 4
libobs-opengl/gl-subsystem.h

@@ -27,10 +27,6 @@
 #include <GL/glew.h>
 #include <GL/glew.h>
 #endif
 #endif
 
 
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
 #include "gl-helpers.h"
 #include "gl-helpers.h"
 #include "gl-exports.h"
 #include "gl-exports.h"