ANDROID: Switch to GLES2

This commit is contained in:
Le Philousophe 2021-08-14 23:17:42 +02:00 committed by Paweł Kołodziejski
parent dd038d72e8
commit 706de81bb0
6 changed files with 29 additions and 15 deletions

View File

@ -79,16 +79,10 @@ GL_FUNC_DEF(void, glEnable, (GLenum cap));
GL_FUNC_DEF(void, glDisable, (GLenum cap));
GL_FUNC_DEF(GLboolean, glIsEnabled, (GLenum cap));
GL_FUNC_DEF(void, glClear, (GLbitfield mask));
GL_FUNC_DEF(void, glColor4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha));
GL_FUNC_DEF(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height));
GL_FUNC_DEF(void, glMatrixMode, (GLenum mode));
GL_FUNC_DEF(void, glLoadIdentity, ());
GL_FUNC_DEF(void, glLoadMatrixf, (const GLfloat *m));
GL_FUNC_DEF(void, glShadeModel, (GLenum mode));
GL_FUNC_DEF(void, glHint, (GLenum target, GLenum mode));
GL_FUNC_DEF(void, glClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha));
GL_FUNC_DEF(void, glBlendFunc, (GLenum sfactor, GLenum dfactor));
GL_FUNC_DEF(void, glEnableClientState, (GLenum array));
GL_FUNC_DEF(void, glPixelStorei, (GLenum pname, GLint param));
GL_FUNC_DEF(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height));
GL_FUNC_DEF(void, glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels));
@ -98,13 +92,22 @@ GL_FUNC_DEF(void, glGenTextures, (GLsizei n, GLuint *textures));
GL_FUNC_DEF(void, glBindTexture, (GLenum target, GLuint texture));
GL_FUNC_DEF(void, glTexParameteri, (GLenum target, GLenum pname, GLint param));
GL_FUNC_DEF(void, glTexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels));
GL_FUNC_DEF(void, glTexCoordPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer));
GL_FUNC_DEF(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer));
GL_FUNC_DEF(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count));
GL_FUNC_DEF(void, glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels));
GL_FUNC_DEF(const GLubyte *, glGetString, (GLenum name));
GL_FUNC_DEF(GLenum, glGetError, ());
#if !USE_FORCED_GLES2
GL_FUNC_DEF(void, glColor4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha));
GL_FUNC_DEF(void, glMatrixMode, (GLenum mode));
GL_FUNC_DEF(void, glLoadIdentity, ());
GL_FUNC_DEF(void, glLoadMatrixf, (const GLfloat *m));
GL_FUNC_DEF(void, glShadeModel, (GLenum mode));
GL_FUNC_DEF(void, glEnableClientState, (GLenum array));
GL_FUNC_DEF(void, glTexCoordPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer));
GL_FUNC_DEF(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer));
#endif
#if !USE_FORCED_GLES
GL_FUNC_2_DEF(void, glEnableVertexAttribArray, glEnableVertexAttribArrayARB, (GLuint index));
GL_FUNC_2_DEF(void, glDisableVertexAttribArray, glDisableVertexAttribArrayARB, (GLuint index));

View File

@ -60,6 +60,10 @@
#ifdef __ANDROID__
#include <GLES/gl.h>
#include <GLES2/gl2.h>
// These types are ScummVM specific
typedef GLuint GLprogram;
typedef GLuint GLshader;
#define USE_BUILTIN_OPENGL
#else
#include "backends/graphics/opengl/opengl-defs.h"

View File

@ -65,8 +65,7 @@ void AndroidGraphicsManager::initSurface() {
JNI::initSurface();
// Notify the OpenGL code about our context.
// FIXME: Support OpenGL ES 2 contexts
setContextType(OpenGL::kContextGLES);
setContextType(OpenGL::kContextGLES2);
// We default to RGB565 and RGBA5551 which is closest to the actual output
// mode we setup.

View File

@ -192,8 +192,11 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
// devices so we have to filter/rank the configs ourselves.
_egl_config = chooseEglConfig(configs);
int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2,
EGL10.EGL_NONE };
_egl_context = _egl.eglCreateContext(_egl_display, _egl_config,
EGL10.EGL_NO_CONTEXT, null);
EGL10.EGL_NO_CONTEXT, attrib_list);
if (_egl_context == EGL10.EGL_NO_CONTEXT)
throw new Exception(String.format(Locale.ROOT, "Failed to create context: 0x%x",

10
configure vendored
View File

@ -5352,8 +5352,9 @@ esac
if test "$_opengl_mode" = auto ; then
case $_backend in
android)
# Android always runs in GLES mode
_opengl_mode=gles
# We require API level 16 while GLES2 APIs have been added in level 8 so we are safe for compilation
_opengl_mode=gles2
_opengl_game_es2=yes
;;
sdl)
case $_sdlversion in
@ -5478,7 +5479,8 @@ echocheck "OpenGL for game"
if test "$_opengl_game" = auto ; then
_opengl_game=no
if (test "$_backend" = "sdl" && test "$_opengl" = yes) || test "$_backend" = "android3d" || test "$_backend" = "switch"; then
if (test "$_backend" = "sdl" && test "$_opengl" = yes) || test "$_backend" = "android" || test "$_backend" = "android3d" \
|| test "$_backend" = "switch"; then
# Try different header filenames
# 1) GL/gl.h This is usually used on POSIX and Windows systems
# 2) OpenGL/gl.h This is used on Mac OS X
@ -6153,7 +6155,7 @@ case $_host_os in
# -lgcc is carefully placed here - we want to catch
# all toolchain symbols in *our* libraries rather
# than pick up anything unhygenic from the Android libs.
LIBS="-Wl,-Bstatic $static_libs -Wl,-Bdynamic -lgcc $system_libs -llog -landroid -lGLESv1_CM"
LIBS="-Wl,-Bstatic $static_libs -Wl,-Bdynamic -lgcc $system_libs -llog -landroid -lGLESv2"
;;
ds)
# Moved -Wl,--gc-sections here to avoid it interfering with the library checks

View File

@ -23,6 +23,9 @@
<uses-feature
android:name="android.software.leanback"
android:required="false" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<supports-screens
android:largeScreens="true"