Upgrade OpenGL backend to ES 3.0 (#995)
Co-authored-by: Tadej Novak <tadej@tano.si>
This commit is contained in:
@@ -43,20 +43,12 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser {
|
||||
private static final String TAG = "Mbgl-EGLConfigChooser";
|
||||
|
||||
/**
|
||||
* Requires API level 17
|
||||
* Requires API level 18
|
||||
*
|
||||
* @see android.opengl.EGL14.EGL_CONFORMANT;
|
||||
* @see android.opengl.EGL15.EGL_OPENGL_ES3_BIT;
|
||||
*/
|
||||
@SuppressWarnings("JavadocReference")
|
||||
private static final int EGL_CONFORMANT = 0x3042;
|
||||
|
||||
/**
|
||||
* Requires API level 17
|
||||
*
|
||||
* @see android.opengl.EGL14.EGL_OPENGL_ES2_BIT;
|
||||
*/
|
||||
@SuppressWarnings("JavadocReference")
|
||||
private static final int EGL_OPENGL_ES2_BIT = 0x0004;
|
||||
private static final int EGL_OPENGL_ES3_BIT = 0x0040;
|
||||
|
||||
private boolean translucentSurface;
|
||||
|
||||
@@ -144,16 +136,14 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser {
|
||||
class Config implements Comparable<Config> {
|
||||
private final BufferFormat bufferFormat;
|
||||
private final DepthStencilFormat depthStencilFormat;
|
||||
private final boolean isNotConformant;
|
||||
private final boolean isCaveat;
|
||||
private final int index;
|
||||
private final EGLConfig config;
|
||||
|
||||
public Config(BufferFormat bufferFormat, DepthStencilFormat depthStencilFormat,
|
||||
boolean isNotConformant, boolean isCaveat, int index, EGLConfig config) {
|
||||
boolean isCaveat, int index, EGLConfig config) {
|
||||
this.bufferFormat = bufferFormat;
|
||||
this.depthStencilFormat = depthStencilFormat;
|
||||
this.isNotConformant = isNotConformant;
|
||||
this.isCaveat = isCaveat;
|
||||
this.index = index;
|
||||
this.config = config;
|
||||
@@ -172,11 +162,6 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser {
|
||||
return i;
|
||||
}
|
||||
|
||||
i = compare(isNotConformant, other.isNotConformant);
|
||||
if (i != 0) {
|
||||
return i;
|
||||
}
|
||||
|
||||
i = compare(isCaveat, other.isCaveat);
|
||||
if (i != 0) {
|
||||
return i;
|
||||
@@ -202,7 +187,6 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser {
|
||||
i++;
|
||||
|
||||
int caveat = getConfigAttr(egl, display, config, EGL_CONFIG_CAVEAT);
|
||||
int conformant = getConfigAttr(egl, display, config, EGL_CONFORMANT);
|
||||
int bits = getConfigAttr(egl, display, config, EGL_BUFFER_SIZE);
|
||||
int red = getConfigAttr(egl, display, config, EGL_RED_SIZE);
|
||||
int green = getConfigAttr(egl, display, config, EGL_GREEN_SIZE);
|
||||
@@ -243,12 +227,11 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser {
|
||||
depthStencilFormat = DepthStencilFormat.Format24Depth8Stencil;
|
||||
}
|
||||
|
||||
boolean isNotConformant = (conformant & EGL_OPENGL_ES2_BIT) != EGL_OPENGL_ES2_BIT;
|
||||
boolean isCaveat = caveat != EGL_NONE;
|
||||
|
||||
// Ignore formats we don't recognise
|
||||
if (bufferFormat != BufferFormat.Unknown) {
|
||||
matches.add(new Config(bufferFormat, depthStencilFormat, isNotConformant, isCaveat, i, config));
|
||||
matches.add(new Config(bufferFormat, depthStencilFormat, isCaveat, i, config));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,10 +251,6 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser {
|
||||
Logger.w(TAG, "Chosen config has a caveat.");
|
||||
}
|
||||
|
||||
if (bestMatch.isNotConformant) {
|
||||
Logger.w(TAG, "Chosen config is not conformant.");
|
||||
}
|
||||
|
||||
return bestMatch.config;
|
||||
}
|
||||
|
||||
@@ -300,9 +279,8 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser {
|
||||
EGL_ALPHA_SIZE, translucentSurface ? 8 : 0,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_STENCIL_SIZE, 8,
|
||||
(emulator ? EGL_NONE : EGL_CONFORMANT), EGL_OPENGL_ES2_BIT,
|
||||
(emulator ? EGL_NONE : EGL_COLOR_BUFFER_TYPE), EGL_RGB_BUFFER,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ endif()
|
||||
|
||||
target_compile_definitions(
|
||||
mbgl-core
|
||||
PUBLIC MBGL_USE_GLES2
|
||||
PUBLIC
|
||||
)
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/vendor/icu.cmake)
|
||||
@@ -83,7 +83,7 @@ target_link_libraries(
|
||||
mbgl-core
|
||||
PRIVATE
|
||||
EGL
|
||||
GLESv2
|
||||
GLESv3
|
||||
Mapbox::Base::jni.hpp
|
||||
android
|
||||
atomic
|
||||
@@ -107,7 +107,7 @@ target_include_directories(
|
||||
target_link_libraries(
|
||||
example-custom-layer
|
||||
PRIVATE
|
||||
GLESv2
|
||||
GLESv3
|
||||
Mapbox::Base
|
||||
Mapbox::Base::optional
|
||||
log
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES3/gl3.h>
|
||||
#include <android/log.h>
|
||||
#include <jni.h>
|
||||
#include <mbgl/gl/custom_layer.hpp>
|
||||
@@ -109,8 +109,8 @@ void checkCompileStatus(GLuint shader) {
|
||||
|
||||
// /DEBUGGING
|
||||
|
||||
static const GLchar * vertexShaderSource = "attribute vec2 a_pos; void main() { gl_Position = vec4(a_pos, 0, 1); }";
|
||||
static const GLchar * fragmentShaderSource = "uniform highp vec4 fill_color; void main() { gl_FragColor = fill_color; }";
|
||||
static const GLchar * vertexShaderSource = "#version 300 es\nlayout (location = 0) in vec2 a_pos; void main() { gl_Position = vec4(a_pos, 0, 1); }";
|
||||
static const GLchar * fragmentShaderSource = "#version 300 es\nuniform highp vec4 fill_color; out highp vec4 fragColor; void main() { fragColor = fill_color; }";
|
||||
|
||||
class ExampleCustomLayer: mbgl::style::CustomLayerHost {
|
||||
public:
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include <mbgl/platform/gl_functions.hpp>
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <GLES3/gl3.h>
|
||||
|
||||
namespace mbgl {
|
||||
namespace platform {
|
||||
|
||||
Reference in New Issue
Block a user