-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
iOS gl3 and some improvements #1473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
28f509d
71fcaa9
4f8a2cc
05db003
18b431f
38e330b
f9282c1
9d8cbfa
2a6ca82
0569a0a
8a90e91
1092b80
066ba48
70a63d1
ce68960
732016e
077e854
44c9430
f59ddf3
d92c48c
ad5dcc1
2a7c2d9
b076c56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,8 +33,11 @@ | |
|
|
||
| import com.jme3.renderer.RendererException; | ||
| import com.jme3.renderer.opengl.GL; | ||
| import com.jme3.renderer.opengl.GL2; | ||
| import com.jme3.renderer.opengl.GLES_30; | ||
| import com.jme3.renderer.opengl.GLExt; | ||
| import com.jme3.renderer.opengl.GLFbo; | ||
| import com.jme3.util.BufferUtils; | ||
| import java.nio.Buffer; | ||
| import java.nio.BufferOverflowException; | ||
| import java.nio.ByteBuffer; | ||
|
|
@@ -43,13 +46,14 @@ | |
| import java.nio.ShortBuffer; | ||
|
|
||
| /** | ||
| * Implements OpenGL ES 2.0 for iOS. | ||
| * Implements OpenGL ES 2.0 and 3.0 for iOS. | ||
| * | ||
| * @author Kirill Vainer | ||
| * @author Kirill Vainer, Jesus Oliver | ||
| */ | ||
| public class IosGL implements GL, GLExt, GLFbo { | ||
| public class IosGL implements GL, GL2, GLES_30, GLExt, GLFbo { | ||
|
|
||
| private final int[] temp_array = new int[16]; | ||
| private final IntBuffer tmpBuff = BufferUtils.createIntBuffer(1); | ||
|
|
||
| @Override | ||
| public void resetStats() { | ||
|
|
@@ -129,7 +133,7 @@ public void glAttachShader(int program, int shader) { | |
|
|
||
| @Override | ||
| public void glBeginQuery(int target, int query) { | ||
| throw new UnsupportedOperationException("Today is not a good day for this"); | ||
| JmeIosGLES.glBeginQuery(target, query); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -314,7 +318,7 @@ public void glEnableVertexAttribArray(int index) { | |
|
|
||
| @Override | ||
| public void glEndQuery(int target) { | ||
| throw new UnsupportedOperationException("Today is not a good day for this"); | ||
| JmeIosGLES.glEndQuery(target); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -333,7 +337,7 @@ public void glGenTextures(IntBuffer textures) { | |
|
|
||
| @Override | ||
| public void glGenQueries(int num, IntBuffer buff) { | ||
| throw new UnsupportedOperationException("Today is not a good day for this"); | ||
| JmeIosGLES.glGenQueries(num, buff); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -343,9 +347,7 @@ public int glGetAttribLocation(int program, String name) { | |
|
|
||
| @Override | ||
| public void glGetBoolean(int pname, ByteBuffer params) { | ||
| // TODO: fix me!!! | ||
| // JmeIosGLES.glGetBoolean(pname, params); | ||
| throw new UnsupportedOperationException("Today is not a good day for this"); | ||
| JmeIosGLES.glGetBoolean(pname, params); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -374,12 +376,14 @@ public String glGetProgramInfoLog(int program, int maxLength) { | |
|
|
||
| @Override | ||
| public long glGetQueryObjectui64(int query, int pname) { | ||
| throw new UnsupportedOperationException("Today is not a good day for this"); | ||
| JmeIosGLES.glGetQueryObjectuiv(query, pname, temp_array); | ||
| return temp_array[0]; | ||
| } | ||
|
|
||
| @Override | ||
| public int glGetQueryObjectiv(int query, int pname) { | ||
| throw new UnsupportedOperationException("Today is not a good day for this"); | ||
| JmeIosGLES.glGetQueryiv(query, pname, temp_array); | ||
| return temp_array[0]; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -406,11 +410,11 @@ public int glGetUniformLocation(int program, String name) { | |
|
|
||
| @Override | ||
| public boolean glIsEnabled(int cap) { | ||
| // TODO: fix me!!! | ||
| // kept this always returning true for compatibility | ||
| if (cap == GLExt.GL_MULTISAMPLE_ARB) { | ||
| return true; | ||
| } else { | ||
| throw new UnsupportedOperationException(); | ||
| return JmeIosGLES.glIsEnabled(cap); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -454,25 +458,22 @@ public void glShaderSource(int shader, String[] string, IntBuffer length) { | |
|
|
||
| @Override | ||
| public void glStencilFuncSeparate(int face, int func, int ref, int mask) { | ||
| // TODO: fix me!!! | ||
| // JmeIosGLES.glStencilFuncSeparate(face, func, ref, mask); | ||
| JmeIosGLES.glStencilFuncSeparate(face, func, ref, mask); | ||
| } | ||
|
|
||
| @Override | ||
| public void glStencilOpSeparate(int face, int sfail, int dpfail, int dppass) { | ||
| // TODO: fix me!!! | ||
| // JmeIosGLES.glStencilOpSeparate(face, sfail, dpfail, dppass); | ||
| JmeIosGLES.glStencilOpSeparate(face, sfail, dpfail, dppass); | ||
| } | ||
|
|
||
| @Override | ||
| public void glTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, ByteBuffer data) { | ||
| JmeIosGLES.glTexImage2D(target, level, format, width, height, 0, format, type, data); | ||
| JmeIosGLES.glTexImage2D(target, level, internalFormat, width, height, 0, format, type, data); | ||
| } | ||
|
|
||
| @Override | ||
| public void glTexParameterf(int target, int pname, float param) { | ||
| // TODO: fix me!!! | ||
| // JmeIosGLES.glTexParameterf(target, pname, param); | ||
| JmeIosGLES.glTexParameterf(target, pname, param); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -583,7 +584,7 @@ public void glViewport(int x, int y, int width, int height) { | |
|
|
||
| @Override | ||
| 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 iOS"); | ||
| JmeIosGLES.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -598,17 +599,17 @@ public void glBufferSubData(int target, long offset, IntBuffer data) { | |
|
|
||
| @Override | ||
| public void glDrawArraysInstancedARB(int mode, int first, int count, int primcount) { | ||
| throw new UnsupportedOperationException("Instancing not available on iOS"); | ||
| JmeIosGLES.glDrawArraysInstanced(mode, first, count, primcount); | ||
| } | ||
|
|
||
| @Override | ||
| public void glDrawBuffers(IntBuffer bufs) { | ||
| throw new UnsupportedOperationException("MRT not available on iOS"); | ||
| JmeIosGLES.glDrawBuffers(getLimitBytes(bufs), bufs); | ||
| } | ||
|
|
||
| @Override | ||
| public void glDrawElementsInstancedARB(int mode, int indices_count, int type, long indices_buffer_offset, int primcount) { | ||
| throw new UnsupportedOperationException("Instancing not available on iOS"); | ||
| JmeIosGLES.glDrawElementsInstanced(mode, indices_count, type, indices_buffer_offset, primcount); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -628,7 +629,7 @@ public void glTexImage2DMultisample(int target, int samples, int internalformat, | |
|
|
||
| @Override | ||
| public void glVertexAttribDivisorARB(int index, int divisor) { | ||
| throw new UnsupportedOperationException("Instancing not available on iOS"); | ||
| JmeIosGLES.glVertexAttribDivisor(index, divisor); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -717,6 +718,59 @@ public Object glFenceSync(int condition, int flags) { | |
|
|
||
| @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"); | ||
| JmeIosGLES.glFramebufferTextureLayer(target, attachment, texture, level, layer); | ||
| } | ||
|
|
||
| // New methods from GL2 interface which are supported in GLES30 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Supported or unsupported? given that they are stubs atm
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment is not too clear... Methods below are those defined in GL2 which we need to implement because gles30 supports some of them like GL{Read|Write}Buffer and also 3D textures. The reason to create the stubs is that glAlphaFunc, glPointSize and glPolygonMode have no gles equivalent but are defined in GL2 interface. |
||
| @Override | ||
| public void glAlphaFunc(int func, float ref) { | ||
| } | ||
|
|
||
| @Override | ||
| public void glPointSize(float size) { | ||
| } | ||
|
|
||
| @Override | ||
| public void glPolygonMode(int face, int mode) { | ||
| } | ||
|
|
||
| // Wrapper to DrawBuffers as there's no DrawBuffer method in GLES | ||
| @Override | ||
| public void glDrawBuffer(int mode) { | ||
| ((Buffer)tmpBuff).clear(); | ||
| tmpBuff.put(0, mode); | ||
| tmpBuff.rewind(); | ||
| glDrawBuffers(tmpBuff); | ||
| } | ||
|
|
||
| @Override | ||
| public void glReadBuffer(int mode) { | ||
| JmeIosGLES.glReadBuffer(mode); | ||
| } | ||
|
|
||
| @Override | ||
| public void glCompressedTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, | ||
| int border, ByteBuffer data) { | ||
| JmeIosGLES.glCompressedTexImage3D(target, level, internalFormat, width, height, depth, border, getLimitBytes(data), data); | ||
| } | ||
|
|
||
| @Override | ||
| public void glCompressedTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, | ||
| int height, int depth, int format, ByteBuffer data) { | ||
| JmeIosGLES.glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, getLimitBytes(data), data); | ||
| } | ||
|
|
||
| @Override | ||
| public void glTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border, | ||
| int format, int type, ByteBuffer data) { | ||
| JmeIosGLES.glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, data); | ||
| } | ||
|
|
||
| @Override | ||
| 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) { | ||
| JmeIosGLES.glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data); | ||
| } | ||
|
|
||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.