From 55d425807f6f1784d6ffd84586ae7efd77c1b352 Mon Sep 17 00:00:00 2001 From: BastiaanOlij Date: Wed, 4 Jan 2017 21:56:56 +1100 Subject: [PATCH] First set of changes to fix compilation errors and initialise the gles3 renderer for Mac OS X. Still broken at this point. --- drivers/gl_context/glad/glad.h | 14 ++++++++++++++ drivers/gles3/rasterizer_gles3.cpp | 4 ++++ platform/osx/os_osx.h | 5 +++-- platform/osx/os_osx.mm | 25 +++++++++++++++---------- platform/osx/platform_config.h | 5 +++-- platform/windows/os_windows.cpp | 8 +++++--- servers/visual/shader_language.h | 5 +++++ 7 files changed, 49 insertions(+), 17 deletions(-) diff --git a/drivers/gl_context/glad/glad.h b/drivers/gl_context/glad/glad.h index 7bb465f0ec0..3653abe71ac 100644 --- a/drivers/gl_context/glad/glad.h +++ b/drivers/gl_context/glad/glad.h @@ -150,12 +150,26 @@ typedef unsigned int GLhandleARB; typedef unsigned short GLhalfARB; typedef unsigned short GLhalf; typedef GLint GLfixed; +// Temporary work around for upstream issue: https://github.com/Dav1dde/glad/issues/70 +// Originally fixed by Algorithmus, reapplied in master +#if defined(__APPLE__) +typedef long GLintptr; +typedef long GLsizeiptr; +#else typedef ptrdiff_t GLintptr; typedef ptrdiff_t GLsizeiptr; +#endif typedef int64_t GLint64; typedef uint64_t GLuint64; +// Temporary work around for upstream issue: https://github.com/Dav1dde/glad/issues/70 +// Originally fixed by Algorithmus, reapplied in master +#if defined(__APPLE__) +typedef long GLintptrARB; +typedef long GLsizeiptrARB; +#else typedef ptrdiff_t GLintptrARB; typedef ptrdiff_t GLsizeiptrARB; +#endif typedef int64_t GLint64EXT; typedef uint64_t GLuint64EXT; typedef struct __GLsync *GLsync; diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 0998d9c423c..866091187d0 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -136,9 +136,13 @@ void RasterizerGLES3::initialize() { ERR_PRINT("Error initializing GLAD"); } +#ifdef __APPLE__ + // FIXME glDebugMessageCallbackARB does not seem to work on Mac OS X and opengl 3, this may be an issue with our opengl canvas.. +#else glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB); glDebugMessageCallbackARB(_gl_debug_print, NULL); glEnable(_EXT_DEBUG_OUTPUT); +#endif #endif diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 8c4eb28ff04..a547e318c8d 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -35,7 +35,7 @@ #include "drivers/unix/os_unix.h" #include "main/input_default.h" #include "servers/visual_server.h" -#include "servers/visual/visual_server_wrap_mt.h" +// #include "servers/visual/visual_server_wrap_mt.h" #include "servers/visual/rasterizer.h" #include "servers/physics_server.h" #include "servers/audio/audio_server_sw.h" @@ -58,7 +58,8 @@ class OS_OSX : public OS_Unix { public: bool force_quit; - Rasterizer *rasterizer; +// rasterizer seems to no longer be given to visual server, its using GLES3 directly? +// Rasterizer *rasterizer; VisualServer *visual_server; List args; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index d5b870bc7da..a57a877fb80 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -38,13 +38,14 @@ #include "servers/visual/visual_server_raster.h" //#include "drivers/opengl/rasterizer_gl.h" //#include "drivers/gles2/rasterizer_gles2.h" +#include "drivers/gles3/rasterizer_gles3.h" #include "os_osx.h" #include #include #include "print_string.h" #include "servers/physics/physics_server_sw.h" -#include "drivers/gles2/rasterizer_instance_gles2.h" -#include "servers/visual/visual_server_wrap_mt.h" +// #include "drivers/gles2/rasterizer_instance_gles2.h" +// #include "servers/visual/visual_server_wrap_mt.h" #include "main/main.h" #include "os/keyboard.h" #include "dir_access_osx.h" @@ -1084,15 +1085,19 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi AudioDriverManagerSW::add_driver(&audio_driver_osx); + // only opengl support here... + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); - rasterizer = instance_RasterizerGLES2(); +// rasterizer = instance_RasterizerGLES2(); +// visual_server = memnew( VisualServerRaster(rasterizer) ); - visual_server = memnew( VisualServerRaster(rasterizer) ); - - if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) { - - visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD)); - } + visual_server = memnew( VisualServerRaster ); + // FIXME: Reimplement threaded rendering? Or remove? +// if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) { +// +// visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD)); +// } visual_server->init(); visual_server->cursor_set_visible(false, 0); @@ -1176,7 +1181,7 @@ void OS_OSX::finalize() { visual_server->finish(); memdelete(visual_server); - memdelete(rasterizer); +// memdelete(rasterizer); physics_server->finish(); memdelete(physics_server); diff --git a/platform/osx/platform_config.h b/platform/osx/platform_config.h index e3c1ee031cd..e661b3da73d 100644 --- a/platform/osx/platform_config.h +++ b/platform/osx/platform_config.h @@ -28,6 +28,7 @@ /*************************************************************************/ #include -#define GLES2_INCLUDE_H "GL/glew.h" -#define GLES3_INCLUDE_H "GL/glew.h" +//#define GLES2_INCLUDE_H "GL/glew.h" +//#define GLES3_INCLUDE_H "GL/glew.h" +#define GLES3_INCLUDE_H "gl_context/glad/glad.h" #define PTHREAD_RENAME_SELF diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 445f4fc3282..cfa73b5e0e7 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1087,13 +1087,15 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_ RasterizerGLES3::make_current(); #else - #ifdef DX9_ENABLED + // FIXME: Does DX support still work now that rasterizer is no longer used? +#ifdef DX9_ENABLED rasterizer = memnew( RasterizerDX9(hWnd) ); - #endif +#endif #endif visual_server = memnew( VisualServerRaster ); - //if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) { + // FIXME: Reimplement threaded rendering? Or remove? +// if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) { // // visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD)); // } diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h index 6326b5089ef..b5f843c114c 100644 --- a/servers/visual/shader_language.h +++ b/servers/visual/shader_language.h @@ -151,6 +151,11 @@ public: /* COMPILER */ + // lame work around to Apple defining this as a macro in 10.12 SDK + #ifdef TYPE_BOOL + #undef TYPE_BOOL + #endif + enum DataType { TYPE_VOID, TYPE_BOOL,