Support GLES2 for iOS
This commit is contained in:
parent
244cc11edd
commit
20de0679fc
2 changed files with 57 additions and 9 deletions
|
@ -47,6 +47,7 @@
|
||||||
@end
|
@end
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
bool gles3_available = true;
|
||||||
int gl_view_base_fb;
|
int gl_view_base_fb;
|
||||||
static String keyboard_text;
|
static String keyboard_text;
|
||||||
static GLView *_instance = NULL;
|
static GLView *_instance = NULL;
|
||||||
|
@ -287,10 +288,14 @@ static void clear_touches() {
|
||||||
// Create our EAGLContext, and if successful make it current and create our framebuffer.
|
// Create our EAGLContext, and if successful make it current and create our framebuffer.
|
||||||
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
|
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
|
||||||
|
|
||||||
|
if (!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
|
||||||
|
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||||
|
gles3_available = false;
|
||||||
if (!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
|
if (!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
|
||||||
[self release];
|
[self release];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Default the animation interval to 1/60th of a second.
|
// Default the animation interval to 1/60th of a second.
|
||||||
animationInterval = 1.0 / 60.0;
|
animationInterval = 1.0 / 60.0;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include "os_iphone.h"
|
#include "os_iphone.h"
|
||||||
|
|
||||||
|
#include "drivers/gles2/rasterizer_gles2.h"
|
||||||
#include "drivers/gles3/rasterizer_gles3.h"
|
#include "drivers/gles3/rasterizer_gles3.h"
|
||||||
#include "servers/visual/visual_server_raster.h"
|
#include "servers/visual/visual_server_raster.h"
|
||||||
#include "servers/visual/visual_server_wrap_mt.h"
|
#include "servers/visual/visual_server_wrap_mt.h"
|
||||||
|
@ -51,12 +52,19 @@
|
||||||
|
|
||||||
int OSIPhone::get_video_driver_count() const {
|
int OSIPhone::get_video_driver_count() const {
|
||||||
|
|
||||||
return 1;
|
return 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *OSIPhone::get_video_driver_name(int p_driver) const {
|
const char *OSIPhone::get_video_driver_name(int p_driver) const {
|
||||||
|
|
||||||
|
switch (p_driver) {
|
||||||
|
case VIDEO_DRIVER_GLES3:
|
||||||
return "GLES3";
|
return "GLES3";
|
||||||
|
case VIDEO_DRIVER_GLES2:
|
||||||
|
return "GLES2";
|
||||||
|
}
|
||||||
|
ERR_EXPLAIN("Invalid video driver index " + itos(p_driver));
|
||||||
|
ERR_FAIL_V(NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
OSIPhone *OSIPhone::get_singleton() {
|
OSIPhone *OSIPhone::get_singleton() {
|
||||||
|
@ -97,16 +105,48 @@ int OSIPhone::get_current_video_driver() const {
|
||||||
return video_driver_index;
|
return video_driver_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern bool gles3_available; // from gl_view.mm
|
||||||
|
|
||||||
Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||||
|
|
||||||
video_driver_index = VIDEO_DRIVER_GLES3;
|
bool use_gl3 = GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3";
|
||||||
|
bool gl_initialization_error = false;
|
||||||
|
|
||||||
if (RasterizerGLES3::is_viable() != OK) {
|
while (true) {
|
||||||
return ERR_UNAVAILABLE;
|
if (use_gl3) {
|
||||||
}
|
if (RasterizerGLES3::is_viable() == OK && gles3_available) {
|
||||||
RasterizerGLES3::register_config();
|
RasterizerGLES3::register_config();
|
||||||
RasterizerGLES3::make_current();
|
RasterizerGLES3::make_current();
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
|
||||||
|
p_video_driver = VIDEO_DRIVER_GLES2;
|
||||||
|
use_gl3 = false;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
gl_initialization_error = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (RasterizerGLES2::is_viable() == OK) {
|
||||||
|
RasterizerGLES2::register_config();
|
||||||
|
RasterizerGLES2::make_current();
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
gl_initialization_error = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gl_initialization_error) {
|
||||||
|
OS::get_singleton()->alert("Your device does not support any of the supported OpenGL versions.",
|
||||||
|
"Unable to initialize Video driver");
|
||||||
|
return ERR_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
video_driver_index = p_video_driver;
|
||||||
visual_server = memnew(VisualServerRaster);
|
visual_server = memnew(VisualServerRaster);
|
||||||
// FIXME: Reimplement threaded rendering
|
// FIXME: Reimplement threaded rendering
|
||||||
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
||||||
|
@ -117,7 +157,10 @@ Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p
|
||||||
//visual_server->cursor_set_visible(false, 0);
|
//visual_server->cursor_set_visible(false, 0);
|
||||||
|
|
||||||
// reset this to what it should be, it will have been set to 0 after visual_server->init() is called
|
// reset this to what it should be, it will have been set to 0 after visual_server->init() is called
|
||||||
|
if (use_gl3)
|
||||||
RasterizerStorageGLES3::system_fbo = gl_view_base_fb;
|
RasterizerStorageGLES3::system_fbo = gl_view_base_fb;
|
||||||
|
else
|
||||||
|
RasterizerStorageGLES2::system_fbo = gl_view_base_fb;
|
||||||
|
|
||||||
AudioDriverManager::initialize(p_audio_driver);
|
AudioDriverManager::initialize(p_audio_driver);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue