Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
28f509d
Update GLImageFormats.java
joliver82 May 17, 2018
71fcaa9
Merge remote-tracking branch 'upstream/master'
joliver82 May 23, 2018
4f8a2cc
Merge pull request #3 from jMonkeyEngine/master
joliver82 Nov 14, 2018
05db003
Merge pull request #4 from jMonkeyEngine/master
joliver82 Jun 1, 2019
5a99549
Added basic support for openGL ES 3.0 and GLSL300 for android
joliver82 Jun 1, 2019
2c1835b
Fixed required types of GLES30.glDrawElementsInstanced
joliver82 Jun 1, 2019
5f70be5
Properly check GLES3 version and setting precision for shaders for al…
joliver82 Jun 1, 2019
09e24d6
Added support for Opengl ES 3.1 and 3.2 and their shader versions
joliver82 Jun 1, 2019
d731714
Added depth texture 24bit for OpenGL ES
Jun 3, 2019
22bf94d
Added geometry shaders and tessellation to GLES 3.1 as extension and …
Jun 3, 2019
26bc948
Added FB blit for android GLES30
Jun 3, 2019
2fdea7f
Added GlSL300 or better to all effects not able to run in GLSL100
joliver82 Jun 4, 2019
4bca2d8
Partial multisample support
joliver82 Jun 4, 2019
e7e2605
Temporarily removed texture multisampling (not being able to compile …
Jun 4, 2019
36795c2
Updated android.jar to api28
Jun 4, 2019
1af4dd9
Better checking for GLES3
Jun 6, 2019
65cff92
Removed insert precision for all shaders. This avoided some random pr…
joliver82 Jun 6, 2019
0b63f3d
Merge branch 'android-gl3' of https://github.com/joliver82/jmonkeyeng…
joliver82 Jun 6, 2019
3971d2b
Removed border check for GLES, caused filtered shadows not to render …
Jun 11, 2019
2960a59
Corrected texture comparison function that were incorrectly changed
Jun 11, 2019
62f78c0
Added precision to samplers for GLESSL300 also
Jun 11, 2019
db983e6
Created a subclass of Glsl150ShaderGenerator (Glsl300ShaderGenerator)…
Jun 11, 2019
431bdbd
Cleaned GLSL300 generator
joliver82 Jun 11, 2019
7cd97ba
Fixed usag of textureCubeLod in fragment shader of envMapping which i…
joliver82 Jun 11, 2019
abc5d9c
Added GLSL300 and 310 to PostShadowFilter material definition
Jun 12, 2019
6aefacb
Make post shadow filter use GLSL100 for GLSL300
joliver82 Jun 13, 2019
04338de
Changed water_normalmap.dds to uncompressed RGB8 because DXT1 is most…
Jun 13, 2019
36e8a6e
Fixed GLES30 compilation issues in Water shaders and added GLSL300 to…
Jun 13, 2019
50f52a5
Added RGB8 dds formatted FullskiesSunset to be used in any platform. …
joliver82 Jun 14, 2019
722a814
Set GL_TEXTURE_MAX_LEVEL in GLES30 contexts fixing issue with not ful…
Jun 19, 2019
5ab6c1b
Fixed compilation of jme3-android-examples and upgraded sdk version t…
Jul 1, 2019
f9e1170
Fixed Geometry Shader and Tessellation Shaders in testdata package to…
Jul 1, 2019
9c5757b
Added non-compressed textures to be able to run all examples on android
joliver82 Jul 2, 2019
c32f367
More GLES30 functions included to properly support texture arrays, 3d…
Jul 2, 2019
c9caf48
Fixed 3D texture tests for GLES30
joliver82 Jul 3, 2019
de1c37f
Fixed TestTextureArray for GLES30
joliver82 Jul 3, 2019
00c0206
Some multisample additions and removal of GLES3 multisampling enable …
joliver82 Jul 4, 2019
8cc1a6a
added float and half float formats for gles30
joliver82 Jul 14, 2019
d844f78
Added more image formats for GLES30
joliver82 Jul 14, 2019
e788eca
Enabled RadialBlur for gles30
joliver82 Jul 15, 2019
f8f3ce5
Fixed luminance texture formats for gles
Jul 15, 2019
e21ce86
Added more depth image formats for gles3
Jul 16, 2019
b8635d9
Enabled multisampling in gles3
Jul 18, 2019
1c0fa0d
Merge branch 'master' into android-gl3
joliver82 Jul 18, 2019
beaedb4
Added GLES30 functions to GLDebugES
Jul 19, 2019
ae96f80
Removed all aditional not used compressed dds files
Jul 19, 2019
4af77be
Removed compressed water_normalmap_dxt1.dds
Jul 19, 2019
2479774
Changed GLES_30 and AndroidGL implementing GL2 to avoid duplicated co…
joliver82 Aug 29, 2019
5d3e7c9
Added aditional checking to avoid gles30 calls from gles20 only devices
Aug 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ buildscript {
}
}

allprojects {
repositories {
google()
jcenter()
}
}

apply plugin: 'base'
apply from: file('version.gradle')

Expand Down
13 changes: 9 additions & 4 deletions jme3-android-examples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 28
buildToolsVersion "28.0.3"

lintOptions {
// Fix nifty gui referencing "java.awt" package.
Expand All @@ -13,7 +13,7 @@ android {
defaultConfig {
applicationId "org.jmonkeyengine.jme3androidexamples"
minSdkVersion 15 // Android 4.0.3 ICE CREAM SANDWICH
targetSdkVersion 22 // Android 5.1 LOLLIPOP
targetSdkVersion 28 // Android 9 PIE
versionCode 1
versionName "1.0" // TODO: from settings.gradle
}
Expand All @@ -25,6 +25,11 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
java {
Expand All @@ -42,7 +47,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:appcompat-v7:28.0.0'

compile project(':jme3-core')
compile project(':jme3-android')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ public JmeFragment() {
public void onCreate(Bundle savedInstanceState) {
Bundle bundle=getArguments();

appClass = bundle.getString(SELECTED_APP_CLASS);
appClass = bundle.getString(MainActivity.SELECTED_APP_CLASS);
// Log.d(this.getClass().getSimpleName(), "AppClass: " + appClass);
joystickEventsEnabled = bundle.getBoolean(ENABLE_JOYSTICK_EVENTS);
joystickEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_JOYSTICK_EVENTS);
// Log.d(this.getClass().getSimpleName(), "JoystickEventsEnabled: " + joystickEventsEnabled);
keyEventsEnabled = bundle.getBoolean(ENABLE_KEY_EVENTS);
keyEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_KEY_EVENTS);
// Log.d(this.getClass().getSimpleName(), "KeyEventsEnabled: " + keyEventsEnabled);
mouseEventsEnabled = bundle.getBoolean(ENABLE_MOUSE_EVENTS);
mouseEventsEnabled = bundle.getBoolean(MainActivity.ENABLE_MOUSE_EVENTS);
// Log.d(this.getClass().getSimpleName(), "MouseEventsEnabled: " + mouseEventsEnabled);
boolean verboseLogging = bundle.getBoolean(VERBOSE_LOGGING);
boolean verboseLogging = bundle.getBoolean(MainActivity.VERBOSE_LOGGING);
// Log.d(this.getClass().getSimpleName(), "VerboseLogging: " + verboseLogging);
if (verboseLogging) {
// Set the default logging level (default=Level.INFO, Level.ALL=All Debug Info)
Expand Down
68 changes: 57 additions & 11 deletions jme3-android/src/main/java/com/jme3/renderer/android/AndroidGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@
import android.opengl.*;
import com.jme3.renderer.RendererException;
import com.jme3.renderer.opengl.*;
import com.jme3.util.BufferUtils;

import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

public class AndroidGL implements GL, GLExt, GLFbo {
public class AndroidGL implements GL, GL2, GLES_30, GLExt, GLFbo {

IntBuffer tmpBuff = BufferUtils.createIntBuffer(1);

public void resetStats() {
}
Expand Down Expand Up @@ -361,7 +364,7 @@ public void glStencilOpSeparate(int face, int sfail, int dpfail, int dppass) {
}

public void glTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, ByteBuffer data) {
GLES20.glTexImage2D(target, level, format, width, height, 0, format, type, data);
GLES20.glTexImage2D(target, level, internalFormat, width, height, 0, format, type, data);
}

public void glTexParameterf(int target, int pname, float param) {
Expand Down Expand Up @@ -449,7 +452,7 @@ public void glViewport(int x, int y, int width, int height) {
}

public void glBlitFramebufferEXT(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) {
throw new UnsupportedOperationException("FBO blit not available on Android");
GLES30.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
}

public void glBufferData(int target, IntBuffer data, int usage) {
Expand All @@ -461,31 +464,31 @@ public void glBufferSubData(int target, long offset, IntBuffer data) {
}

public void glDrawArraysInstancedARB(int mode, int first, int count, int primcount) {
throw new UnsupportedOperationException("Instancing not available on Android");
GLES30.glDrawArraysInstanced(mode, first, count, primcount);
}

public void glDrawBuffers(IntBuffer bufs) {
throw new UnsupportedOperationException("MRT not available on Android");
GLES30.glDrawBuffers(bufs.limit(), bufs);
}

public void glDrawElementsInstancedARB(int mode, int indices_count, int type, long indices_buffer_offset, int primcount) {
throw new UnsupportedOperationException("Instancing not available on Android");
GLES30.glDrawElementsInstanced(mode, indices_count, type, (int)indices_buffer_offset, primcount);
}

public void glGetMultisample(int pname, int index, FloatBuffer val) {
throw new UnsupportedOperationException("Multisample renderbuffers not available on Android");
GLES31.glGetMultisamplefv(pname, index, val);
}

public void glRenderbufferStorageMultisampleEXT(int target, int samples, int internalformat, int width, int height) {
throw new UnsupportedOperationException("Multisample renderbuffers not available on Android");
GLES30.glRenderbufferStorageMultisample(target, samples, internalformat, width, height);
}

public void glTexImage2DMultisample(int target, int samples, int internalformat, int width, int height, boolean fixedsamplelocations) {
throw new UnsupportedOperationException("Multisample textures not available on Android");
GLES31.glTexStorage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations);
}

public void glVertexAttribDivisorARB(int index, int divisor) {
throw new UnsupportedOperationException("Instancing not available on Android");
GLES30.glVertexAttribDivisor(index, divisor);
}

public void glBindFramebufferEXT(int param1, int param2) {
Expand Down Expand Up @@ -564,6 +567,49 @@ public void glBlendEquationSeparate(int colorMode, int alphaMode) {

@Override
public void glFramebufferTextureLayerEXT(int target, int attachment, int texture, int level, int layer) {
throw new UnsupportedOperationException("OpenGL ES 2 does not support texture arrays");
GLES30.glFramebufferTextureLayer(target, attachment, texture, level, layer);
}

public void glAlphaFunc(int func, float ref) {
}

public void glPointSize(float size) {
}

public void glPolygonMode(int face, int mode) {
}

// Wrapper to DrawBuffers as there's no DrawBuffer method in GLES
public void glDrawBuffer(int mode) {
tmpBuff.clear();
tmpBuff.put(0, mode);
tmpBuff.rewind();
glDrawBuffers(tmpBuff);
}

public void glReadBuffer(int mode) {
GLES30.glReadBuffer(mode);
}

public void glCompressedTexImage3D(int target, int level, int internalFormat, int width, int height, int depth,
int border, ByteBuffer data) {
GLES30.glCompressedTexImage3D(target, level, internalFormat, width, height, depth, border, getLimitBytes(data), data);
}

public void glCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width,
int height, int depth, int format, ByteBuffer data) {
GLES30.glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, getLimitBytes(data), data);
}

public void glTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border,
int format, int type, ByteBuffer data) {
GLES30.glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, data);
}

public void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height,
int depth, int format, int type, ByteBuffer data) {
GLES30.glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class AndroidConfigChooser implements EGLConfigChooser {
private static final Logger logger = Logger.getLogger(AndroidConfigChooser.class.getName());
protected AppSettings settings;
private final static int EGL_OPENGL_ES2_BIT = 4;
private final static int EGL_OPENGL_ES3_BIT = 0x40;

public AndroidConfigChooser(AppSettings settings) {
this.settings = settings;
Expand Down Expand Up @@ -140,12 +141,29 @@ private EGLConfig[] getConfigs(EGL10 egl, EGLDisplay display) {

int[] num_config = new int[1];
int[] configSpec = new int[]{
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
EGL10.EGL_NONE};
boolean gles3=true;

if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
RendererUtil.checkEGLError(egl);
throw new AssertionError();
// Try openGL ES 3
try {
if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
RendererUtil.checkEGLError(egl);
gles3=false;
}
} catch (com.jme3.renderer.RendererException re) {
// it's just the device not supporting GLES3. Fallback to GLES2
gles3=false;
}

if(!gles3)
{
// Get back to openGL ES 2
configSpec[1]=EGL_OPENGL_ES2_BIT;
if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
RendererUtil.checkEGLError(egl);
throw new AssertionError();
}
}

int numConfigs = num_config[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import com.jme3.input.dummy.DummyMouseInput;
import com.jme3.renderer.android.AndroidGL;
import com.jme3.renderer.opengl.GL;
import com.jme3.renderer.opengl.GLES_30;
import com.jme3.renderer.opengl.GLDebugES;
import com.jme3.renderer.opengl.GLExt;
import com.jme3.renderer.opengl.GLFbo;
Expand Down Expand Up @@ -99,13 +100,13 @@ public Type getType() {
* @return GLSurfaceView The newly created view
*/
public GLSurfaceView createView(Context context) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
ConfigurationInfo info = am.getDeviceConfigurationInfo();
// NOTE: We assume all ICS devices have OpenGL ES 2.0.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
// below 4.0, check OpenGL ES 2.0 support.
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
ConfigurationInfo info = am.getDeviceConfigurationInfo();
if (info.reqGlEsVersion < 0x20000) {
throw new UnsupportedOperationException("OpenGL ES 2.0 is not supported on this device");
throw new UnsupportedOperationException("OpenGL ES 2.0 or better is not supported on this device");
}
} else if (Build.VERSION.SDK_INT < 9){
throw new UnsupportedOperationException("jME3 requires Android 2.3 or later");
Expand All @@ -126,7 +127,8 @@ public GLSurfaceView createView(Context context) {

// setEGLContextClientVersion must be set before calling setRenderer
// this means it cannot be set in AndroidConfigChooser (too late)
view.setEGLContextClientVersion(2);
// use proper openGL ES version
view.setEGLContextClientVersion(info.reqGlEsVersion>>16);

view.setFocusableInTouchMode(true);
view.setFocusable(true);
Expand Down Expand Up @@ -201,7 +203,7 @@ public void uncaughtException(Thread thread, Throwable thrown) {
gl = new GLDebugES((GL) gl, (GLExt) gl, (GLFbo) gl);
}
if (settings.getBoolean("GraphicsTrace")) {
gl = GLTracer.createGlesTracer(gl, GL.class, GLFbo.class, GLExt.class);
gl = GLTracer.createGlesTracer(gl, GL.class, GLES_30.class, GLFbo.class, GLExt.class);
}
renderer = new GLRenderer((GL)gl, (GLExt)gl, (GLFbo)gl);
renderer.initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.jme3.scene.Spatial;
import com.jme3.shader.Glsl100ShaderGenerator;
import com.jme3.shader.Glsl150ShaderGenerator;
import com.jme3.shader.Glsl300ShaderGenerator;
import com.jme3.shader.ShaderGenerator;
import com.jme3.system.JmeSystem;
import com.jme3.texture.Texture;
Expand Down Expand Up @@ -434,7 +435,9 @@ public FilterPostProcessor loadFilter(String name){
@Override
public ShaderGenerator getShaderGenerator(EnumSet<Caps> caps) {
if (shaderGenerator == null) {
if(caps.contains(Caps.GLSL150)){
if(caps.contains(Caps.OpenGLES30) && caps.contains(Caps.GLSL300)){
shaderGenerator = new Glsl300ShaderGenerator(this);
}else if(caps.contains(Caps.GLSL150)) {
shaderGenerator = new Glsl150ShaderGenerator(this);
}else{
shaderGenerator = new Glsl100ShaderGenerator(this);
Expand Down
40 changes: 39 additions & 1 deletion jme3-core/src/main/java/com/jme3/renderer/Caps.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,45 @@ public enum Caps {
/**
* Supporting working with ShaderStorageBufferObjects.
*/
ShaderStorageBufferObject;
ShaderStorageBufferObject,

/**
* Supports OpenGL ES 3.0
*/
OpenGLES30,

/**
* Supports GLSL 3.0
*/
GLSL300,

/**
* Supports OpenGL ES 3.1
*/
OpenGLES31,

/**
* Supports GLSL 3.1
*/
GLSL310,

/**
* Supports OpenGL ES 3.2
*/
OpenGLES32,

/**
* Supports GLSL 3.2
*/
GLSL320,

/**
* Explicit support of depth 24 textures
*/
Depth24;




/**
* Returns true if given the renderer capabilities, the texture
Expand Down
Loading