GLES2 renderer support on macOS.
This commit is contained in:
parent
4ccc8e57f9
commit
a5a4f3714b
|
@ -161,7 +161,7 @@ void RasterizerGLES2::initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#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
|
#else
|
||||||
if (true || OS::get_singleton()->is_stdout_verbose()) {
|
if (true || OS::get_singleton()->is_stdout_verbose()) {
|
||||||
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||||
|
@ -174,12 +174,16 @@ void RasterizerGLES2::initialize() {
|
||||||
|
|
||||||
// For debugging
|
// For debugging
|
||||||
#ifdef GLES_OVER_GL
|
#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_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_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_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_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_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);
|
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_OTHER_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/* glDebugMessageInsertARB(
|
/* glDebugMessageInsertARB(
|
||||||
GL_DEBUG_SOURCE_API_ARB,
|
GL_DEBUG_SOURCE_API_ARB,
|
||||||
|
|
|
@ -50,6 +50,11 @@
|
||||||
@author Juan Linietsky <reduzio@gmail.com>
|
@author Juan Linietsky <reduzio@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
enum VideoDriver {
|
||||||
|
VIDEO_DRIVER_GLES3,
|
||||||
|
VIDEO_DRIVER_GLES2
|
||||||
|
};
|
||||||
|
|
||||||
class OS_OSX : public OS_Unix {
|
class OS_OSX : public OS_Unix {
|
||||||
public:
|
public:
|
||||||
struct KeyEvent {
|
struct KeyEvent {
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "os_osx.h"
|
#include "os_osx.h"
|
||||||
|
|
||||||
#include "dir_access_osx.h"
|
#include "dir_access_osx.h"
|
||||||
|
#include "drivers/gles2/rasterizer_gles2.h"
|
||||||
#include "drivers/gles3/rasterizer_gles3.h"
|
#include "drivers/gles3/rasterizer_gles3.h"
|
||||||
#include "main/main.h"
|
#include "main/main.h"
|
||||||
#include "os/keyboard.h"
|
#include "os/keyboard.h"
|
||||||
|
@ -992,13 +993,20 @@ void OS_OSX::set_ime_position(const Point2 &p_pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int OS_OSX::get_video_driver_count() const {
|
int OS_OSX::get_video_driver_count() const {
|
||||||
return 1;
|
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *OS_OSX::get_video_driver_name(int p_driver) const {
|
const char *OS_OSX::get_video_driver_name(int p_driver) const {
|
||||||
|
|
||||||
|
switch (p_driver) {
|
||||||
|
case VIDEO_DRIVER_GLES2:
|
||||||
|
return "GLES2";
|
||||||
|
case VIDEO_DRIVER_GLES3:
|
||||||
|
default:
|
||||||
return "GLES3";
|
return "GLES3";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OS_OSX::initialize_core() {
|
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(NSOpenGLPFADoubleBuffer);
|
||||||
ADD_ATTR(NSOpenGLPFAClosestPolicy);
|
ADD_ATTR(NSOpenGLPFAClosestPolicy);
|
||||||
|
|
||||||
|
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 ?
|
//we now need OpenGL 3 or better, maybe even change this to 3_3Core ?
|
||||||
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
||||||
|
}
|
||||||
|
|
||||||
ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);
|
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);
|
AudioDriverManager::add_driver(&audio_driver);
|
||||||
|
|
||||||
// only opengl support here...
|
// only opengl support here...
|
||||||
|
if (p_video_driver == VIDEO_DRIVER_GLES2) {
|
||||||
|
RasterizerGLES2::register_config();
|
||||||
|
RasterizerGLES2::make_current();
|
||||||
|
} else {
|
||||||
RasterizerGLES3::register_config();
|
RasterizerGLES3::register_config();
|
||||||
RasterizerGLES3::make_current();
|
RasterizerGLES3::make_current();
|
||||||
|
}
|
||||||
|
|
||||||
visual_server = memnew(VisualServerRaster);
|
visual_server = memnew(VisualServerRaster);
|
||||||
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
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++
|
Language/Generator: C/C++
|
||||||
Specification: gl
|
Specification: gl
|
||||||
APIs: gl=3.3
|
APIs: gl=3.3
|
||||||
Profile: compatibility
|
Profile: compatibility
|
||||||
Extensions:
|
Extensions:
|
||||||
GL_ARB_debug_output
|
GL_ARB_debug_output,
|
||||||
|
GL_ARB_framebuffer_object
|
||||||
Loader: True
|
Loader: True
|
||||||
Local files: False
|
Local files: False
|
||||||
Omit khrplatform: False
|
Omit khrplatform: False
|
||||||
|
|
||||||
Commandline:
|
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:
|
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>
|
#include <stdio.h>
|
||||||
|
@ -47,7 +48,7 @@ int open_gl(void) {
|
||||||
static
|
static
|
||||||
void close_gl(void) {
|
void close_gl(void) {
|
||||||
if(libGL != NULL) {
|
if(libGL != NULL) {
|
||||||
FreeLibrary(libGL);
|
FreeLibrary((HMODULE) libGL);
|
||||||
libGL = NULL;
|
libGL = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +113,7 @@ void* get_proc(const char *namez) {
|
||||||
#endif
|
#endif
|
||||||
if(result == NULL) {
|
if(result == NULL) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
result = (void*)GetProcAddress(libGL, namez);
|
result = (void*)GetProcAddress((HMODULE) libGL, namez);
|
||||||
#else
|
#else
|
||||||
result = dlsym(libGL, namez);
|
result = dlsym(libGL, namez);
|
||||||
#endif
|
#endif
|
||||||
|
@ -168,7 +169,7 @@ static int get_exts(void) {
|
||||||
const char *gl_str_tmp = (const char*)glGetStringi(GL_EXTENSIONS, index);
|
const char *gl_str_tmp = (const char*)glGetStringi(GL_EXTENSIONS, index);
|
||||||
size_t len = strlen(gl_str_tmp);
|
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(local_str != NULL) {
|
||||||
#if _MSC_VER >= 1400
|
#if _MSC_VER >= 1400
|
||||||
strncpy_s(local_str, len+1, gl_str_tmp, len);
|
strncpy_s(local_str, len+1, gl_str_tmp, len);
|
||||||
|
@ -971,6 +972,7 @@ PFNGLCOLORPOINTERPROC glad_glColorPointer;
|
||||||
PFNGLFRONTFACEPROC glad_glFrontFace;
|
PFNGLFRONTFACEPROC glad_glFrontFace;
|
||||||
PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
|
PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
|
||||||
PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
|
PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
|
||||||
|
int GLAD_GL_ARB_framebuffer_object;
|
||||||
int GLAD_GL_ARB_debug_output;
|
int GLAD_GL_ARB_debug_output;
|
||||||
PFNGLDEBUGMESSAGECONTROLARBPROC glad_glDebugMessageControlARB;
|
PFNGLDEBUGMESSAGECONTROLARBPROC glad_glDebugMessageControlARB;
|
||||||
PFNGLDEBUGMESSAGEINSERTARBPROC glad_glDebugMessageInsertARB;
|
PFNGLDEBUGMESSAGEINSERTARBPROC glad_glDebugMessageInsertARB;
|
||||||
|
@ -1746,9 +1748,33 @@ static void load_GL_ARB_debug_output(GLADloadproc load) {
|
||||||
glad_glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)load("glDebugMessageCallbackARB");
|
glad_glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)load("glDebugMessageCallbackARB");
|
||||||
glad_glGetDebugMessageLogARB = (PFNGLGETDEBUGMESSAGELOGARBPROC)load("glGetDebugMessageLogARB");
|
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) {
|
static int find_extensionsGL(void) {
|
||||||
if (!get_exts()) return 0;
|
if (!get_exts()) return 0;
|
||||||
GLAD_GL_ARB_debug_output = has_ext("GL_ARB_debug_output");
|
GLAD_GL_ARB_debug_output = has_ext("GL_ARB_debug_output");
|
||||||
|
GLAD_GL_ARB_framebuffer_object = has_ext("GL_ARB_framebuffer_object");
|
||||||
free_exts();
|
free_exts();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1828,6 +1854,7 @@ int gladLoadGLLoader(GLADloadproc load) {
|
||||||
|
|
||||||
if (!find_extensionsGL()) return 0;
|
if (!find_extensionsGL()) return 0;
|
||||||
load_GL_ARB_debug_output(load);
|
load_GL_ARB_debug_output(load);
|
||||||
|
load_GL_ARB_framebuffer_object(load);
|
||||||
return GLVersion.major != 0 || GLVersion.minor != 0;
|
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++
|
Language/Generator: C/C++
|
||||||
Specification: gl
|
Specification: gl
|
||||||
APIs: gl=3.3
|
APIs: gl=3.3
|
||||||
Profile: compatibility
|
Profile: compatibility
|
||||||
Extensions:
|
Extensions:
|
||||||
GL_ARB_debug_output
|
GL_ARB_debug_output,
|
||||||
|
GL_ARB_framebuffer_object
|
||||||
Loader: True
|
Loader: True
|
||||||
Local files: False
|
Local files: False
|
||||||
Omit khrplatform: False
|
Omit khrplatform: False
|
||||||
|
|
||||||
Commandline:
|
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:
|
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;
|
GLAPI PFNGLGETDEBUGMESSAGELOGARBPROC glad_glGetDebugMessageLogARB;
|
||||||
#define glGetDebugMessageLogARB glad_glGetDebugMessageLogARB
|
#define glGetDebugMessageLogARB glad_glGetDebugMessageLogARB
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef GL_ARB_framebuffer_object
|
||||||
|
#define GL_ARB_framebuffer_object 1
|
||||||
|
GLAPI int GLAD_GL_ARB_framebuffer_object;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue