GLES2 renderer support on macOS.
This commit is contained in:
parent
4ccc8e57f9
commit
a5a4f3714b
|
@ -161,7 +161,7 @@ void RasterizerGLES2::initialize() {
|
|||
}
|
||||
|
||||
#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..
|
||||
// FIXME glDebugMessageCallbackARB does not seem to work on Mac OS X and opengl 2, this may be an issue with our opengl canvas..
|
||||
#else
|
||||
if (true || OS::get_singleton()->is_stdout_verbose()) {
|
||||
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
|
@ -174,12 +174,16 @@ void RasterizerGLES2::initialize() {
|
|||
|
||||
// For debugging
|
||||
#ifdef GLES_OVER_GL
|
||||
#ifdef __APPLE__
|
||||
// FIXME glDebugMessageCallbackARB does not seem to work on Mac OS X and opengl 2, this may be an issue with our opengl canvas..
|
||||
#else
|
||||
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_ERROR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
|
||||
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
|
||||
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
|
||||
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PORTABILITY_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
|
||||
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PERFORMANCE_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
|
||||
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_OTHER_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
|
||||
#endif
|
||||
#endif
|
||||
/* glDebugMessageInsertARB(
|
||||
GL_DEBUG_SOURCE_API_ARB,
|
||||
|
|
|
@ -50,6 +50,11 @@
|
|||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
*/
|
||||
|
||||
enum VideoDriver {
|
||||
VIDEO_DRIVER_GLES3,
|
||||
VIDEO_DRIVER_GLES2
|
||||
};
|
||||
|
||||
class OS_OSX : public OS_Unix {
|
||||
public:
|
||||
struct KeyEvent {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "os_osx.h"
|
||||
|
||||
#include "dir_access_osx.h"
|
||||
#include "drivers/gles2/rasterizer_gles2.h"
|
||||
#include "drivers/gles3/rasterizer_gles3.h"
|
||||
#include "main/main.h"
|
||||
#include "os/keyboard.h"
|
||||
|
@ -992,12 +993,19 @@ void OS_OSX::set_ime_position(const Point2 &p_pos) {
|
|||
}
|
||||
|
||||
int OS_OSX::get_video_driver_count() const {
|
||||
return 1;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
const char *OS_OSX::get_video_driver_name(int p_driver) const {
|
||||
|
||||
return "GLES3";
|
||||
switch (p_driver) {
|
||||
case VIDEO_DRIVER_GLES2:
|
||||
return "GLES2";
|
||||
case VIDEO_DRIVER_GLES3:
|
||||
default:
|
||||
return "GLES3";
|
||||
}
|
||||
}
|
||||
|
||||
void OS_OSX::initialize_core() {
|
||||
|
@ -1111,8 +1119,12 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
|||
ADD_ATTR(NSOpenGLPFADoubleBuffer);
|
||||
ADD_ATTR(NSOpenGLPFAClosestPolicy);
|
||||
|
||||
//we now need OpenGL 3 or better, maybe even change this to 3_3Core ?
|
||||
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
||||
if (p_video_driver == VIDEO_DRIVER_GLES2) {
|
||||
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy);
|
||||
} else {
|
||||
//we now need OpenGL 3 or better, maybe even change this to 3_3Core ?
|
||||
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
||||
}
|
||||
|
||||
ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);
|
||||
|
||||
|
@ -1174,8 +1186,13 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
|||
AudioDriverManager::add_driver(&audio_driver);
|
||||
|
||||
// only opengl support here...
|
||||
RasterizerGLES3::register_config();
|
||||
RasterizerGLES3::make_current();
|
||||
if (p_video_driver == VIDEO_DRIVER_GLES2) {
|
||||
RasterizerGLES2::register_config();
|
||||
RasterizerGLES2::make_current();
|
||||
} else {
|
||||
RasterizerGLES3::register_config();
|
||||
RasterizerGLES3::make_current();
|
||||
}
|
||||
|
||||
visual_server = memnew(VisualServerRaster);
|
||||
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
/*
|
||||
|
||||
OpenGL loader generated by glad 0.1.16a0 on Thu Nov 30 06:21:28 2017.
|
||||
OpenGL loader generated by glad 0.1.18a0 on Fri Mar 2 11:26:24 2018.
|
||||
|
||||
Language/Generator: C/C++
|
||||
Specification: gl
|
||||
APIs: gl=3.3
|
||||
Profile: compatibility
|
||||
Extensions:
|
||||
GL_ARB_debug_output
|
||||
GL_ARB_debug_output,
|
||||
GL_ARB_framebuffer_object
|
||||
Loader: True
|
||||
Local files: False
|
||||
Omit khrplatform: False
|
||||
|
||||
Commandline:
|
||||
--profile="compatibility" --api="gl=3.3" --generator="c" --spec="gl" --extensions="GL_ARB_debug_output"
|
||||
--profile="compatibility" --api="gl=3.3" --generator="c" --spec="gl" --extensions="GL_ARB_debug_output,GL_ARB_framebuffer_object"
|
||||
Online:
|
||||
http://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D3.3&extensions=GL_ARB_debug_output
|
||||
http://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D3.3&extensions=GL_ARB_debug_output&extensions=GL_ARB_framebuffer_object
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -47,8 +48,8 @@ int open_gl(void) {
|
|||
static
|
||||
void close_gl(void) {
|
||||
if(libGL != NULL) {
|
||||
FreeLibrary(libGL);
|
||||
libGL = NULL;
|
||||
FreeLibrary((HMODULE) libGL);
|
||||
libGL = NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -112,7 +113,7 @@ void* get_proc(const char *namez) {
|
|||
#endif
|
||||
if(result == NULL) {
|
||||
#ifdef _WIN32
|
||||
result = (void*)GetProcAddress(libGL, namez);
|
||||
result = (void*)GetProcAddress((HMODULE) libGL, namez);
|
||||
#else
|
||||
result = dlsym(libGL, namez);
|
||||
#endif
|
||||
|
@ -168,7 +169,7 @@ static int get_exts(void) {
|
|||
const char *gl_str_tmp = (const char*)glGetStringi(GL_EXTENSIONS, index);
|
||||
size_t len = strlen(gl_str_tmp);
|
||||
|
||||
char *local_str = (char*)malloc((len+1) * sizeof(*exts_i));
|
||||
char *local_str = (char*)malloc((len+1) * sizeof(char));
|
||||
if(local_str != NULL) {
|
||||
#if _MSC_VER >= 1400
|
||||
strncpy_s(local_str, len+1, gl_str_tmp, len);
|
||||
|
@ -971,6 +972,7 @@ PFNGLCOLORPOINTERPROC glad_glColorPointer;
|
|||
PFNGLFRONTFACEPROC glad_glFrontFace;
|
||||
PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
|
||||
PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
|
||||
int GLAD_GL_ARB_framebuffer_object;
|
||||
int GLAD_GL_ARB_debug_output;
|
||||
PFNGLDEBUGMESSAGECONTROLARBPROC glad_glDebugMessageControlARB;
|
||||
PFNGLDEBUGMESSAGEINSERTARBPROC glad_glDebugMessageInsertARB;
|
||||
|
@ -1746,9 +1748,33 @@ static void load_GL_ARB_debug_output(GLADloadproc load) {
|
|||
glad_glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)load("glDebugMessageCallbackARB");
|
||||
glad_glGetDebugMessageLogARB = (PFNGLGETDEBUGMESSAGELOGARBPROC)load("glGetDebugMessageLogARB");
|
||||
}
|
||||
static void load_GL_ARB_framebuffer_object(GLADloadproc load) {
|
||||
if(!GLAD_GL_ARB_framebuffer_object) return;
|
||||
glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer");
|
||||
glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer");
|
||||
glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers");
|
||||
glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers");
|
||||
glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage");
|
||||
glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv");
|
||||
glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer");
|
||||
glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer");
|
||||
glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers");
|
||||
glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers");
|
||||
glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus");
|
||||
glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D");
|
||||
glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D");
|
||||
glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D");
|
||||
glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer");
|
||||
glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv");
|
||||
glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap");
|
||||
glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer");
|
||||
glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample");
|
||||
glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer");
|
||||
}
|
||||
static int find_extensionsGL(void) {
|
||||
if (!get_exts()) return 0;
|
||||
GLAD_GL_ARB_debug_output = has_ext("GL_ARB_debug_output");
|
||||
GLAD_GL_ARB_framebuffer_object = has_ext("GL_ARB_framebuffer_object");
|
||||
free_exts();
|
||||
return 1;
|
||||
}
|
||||
|
@ -1828,6 +1854,7 @@ int gladLoadGLLoader(GLADloadproc load) {
|
|||
|
||||
if (!find_extensionsGL()) return 0;
|
||||
load_GL_ARB_debug_output(load);
|
||||
load_GL_ARB_framebuffer_object(load);
|
||||
return GLVersion.major != 0 || GLVersion.minor != 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
/*
|
||||
|
||||
OpenGL loader generated by glad 0.1.16a0 on Thu Nov 30 06:21:28 2017.
|
||||
OpenGL loader generated by glad 0.1.18a0 on Fri Mar 2 11:26:24 2018.
|
||||
|
||||
Language/Generator: C/C++
|
||||
Specification: gl
|
||||
APIs: gl=3.3
|
||||
Profile: compatibility
|
||||
Extensions:
|
||||
GL_ARB_debug_output
|
||||
GL_ARB_debug_output,
|
||||
GL_ARB_framebuffer_object
|
||||
Loader: True
|
||||
Local files: False
|
||||
Omit khrplatform: False
|
||||
|
||||
Commandline:
|
||||
--profile="compatibility" --api="gl=3.3" --generator="c" --spec="gl" --extensions="GL_ARB_debug_output"
|
||||
--profile="compatibility" --api="gl=3.3" --generator="c" --spec="gl" --extensions="GL_ARB_debug_output,GL_ARB_framebuffer_object"
|
||||
Online:
|
||||
http://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D3.3&extensions=GL_ARB_debug_output
|
||||
http://glad.dav1d.de/#profile=compatibility&language=c&specification=gl&loader=on&api=gl%3D3.3&extensions=GL_ARB_debug_output&extensions=GL_ARB_framebuffer_object
|
||||
*/
|
||||
|
||||
|
||||
|
@ -3696,6 +3697,10 @@ typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC)(GLuint count, GLsizei
|
|||
GLAPI PFNGLGETDEBUGMESSAGELOGARBPROC glad_glGetDebugMessageLogARB;
|
||||
#define glGetDebugMessageLogARB glad_glGetDebugMessageLogARB
|
||||
#endif
|
||||
#ifndef GL_ARB_framebuffer_object
|
||||
#define GL_ARB_framebuffer_object 1
|
||||
GLAPI int GLAD_GL_ARB_framebuffer_object;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue