Improves OpenGL-ES support (especially for Raspberry Pi), contribution of Erkki Nokso-Koivisto

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10269 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
jul..om 12 years ago
parent 7534d90dde
commit 0acece86e0
  1. 44
      engine/src/jogl/com/jme3/renderer/jogl/JoglRenderer.java

@ -2277,7 +2277,7 @@ public class JoglRenderer implements Renderer {
assert bufId != -1; assert bufId != -1;
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
if (gl.isGL2GL3()) {
if (context.boundElementArrayVBO != bufId) { if (context.boundElementArrayVBO != bufId) {
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, bufId); gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, bufId);
context.boundElementArrayVBO = bufId; context.boundElementArrayVBO = bufId;
@ -2309,7 +2309,7 @@ public class JoglRenderer implements Renderer {
int elementLength = elementLengths[i]; int elementLength = elementLengths[i];
if (useInstancing) { if (useInstancing) {
if (gl.isGL2GL3()) {
indexBuf.getData().position(curOffset); indexBuf.getData().position(curOffset);
indexBuf.getData().limit(curOffset + elementLength); indexBuf.getData().limit(curOffset + elementLength);
@ -2318,43 +2318,63 @@ public class JoglRenderer implements Renderer {
fmt, fmt,
indexBuf.getData(), indexBuf.getData(),
count); count);
} else { } else {
throw new IllegalArgumentException(
"instancing is not supported.");
}
} else {
if (gl.isGL2GL3()) {
gl.getGL2GL3().glDrawRangeElements(elMode, gl.getGL2GL3().glDrawRangeElements(elMode,
0, 0,
vertCount, vertCount,
elementLength, elementLength,
fmt, fmt,
curOffset); curOffset);
} else {
indexBuf.getData().position(curOffset);
gl.glDrawElements(elMode, elementLength, fmt,
indexBuf.getData());
}
} }
//FIXME check whether elSize is required //FIXME check whether elSize is required
curOffset += elementLength/* * elSize*/; curOffset += elementLength * elSize;
} }
} else { } else {
if (useInstancing) { if (useInstancing) {
if (gl.isGL2GL3()) {
gl.getGL2GL3().glDrawElementsInstanced(convertElementMode(mesh.getMode()), gl.getGL2GL3().glDrawElementsInstanced(convertElementMode(mesh.getMode()),
indexBuf.getData().limit(), indexBuf.getData().limit(),
convertFormat(indexBuf.getFormat()), convertFormat(indexBuf.getFormat()),
indexBuf.getData(), indexBuf.getData(),
count); count);
} else { } else {
throw new IllegalArgumentException(
"instancing is not supported.");
}
} else {
if (gl.isGL2GL3()) {
gl.getGL2GL3().glDrawRangeElements(convertElementMode(mesh.getMode()), gl.getGL2GL3().glDrawRangeElements(convertElementMode(mesh.getMode()),
0, 0,
vertCount, vertCount,
indexBuf.getData().limit(), indexBuf.getData().limit(),
convertFormat(indexBuf.getFormat()), convertFormat(indexBuf.getFormat()),
0); 0);
} else {
indexBuf.getData().rewind();
gl.glDrawElements(convertElementMode(mesh.getMode()),
indexBuf.getData().limit(),
convertFormat(indexBuf.getFormat()), 0);
} }
} }
} else {
//FIXME: ES impl
} }
} }
/*********************************************************************\ /**
|* Render Calls *| * *******************************************************************\ |*
\*********************************************************************/ * Render Calls *|
\********************************************************************
*/
private int convertElementMode(Mesh.Mode mode) { private int convertElementMode(Mesh.Mode mode) {
switch (mode) { switch (mode) {
case Points: case Points:
@ -2379,10 +2399,7 @@ public class JoglRenderer implements Renderer {
public void updateVertexArray(Mesh mesh) { public void updateVertexArray(Mesh mesh) {
int id = mesh.getId(); int id = mesh.getId();
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
//FIXME rather use GLCaps and do it once for all
boolean isVaoSupported = gl.isFunctionAvailable("glGenVertexArrays") &&
gl.isFunctionAvailable("glBindVertexArray");
if (isVaoSupported) {
if (id == -1) { if (id == -1) {
IntBuffer temp = intBuf1; IntBuffer temp = intBuf1;
if (gl.isGL2GL3()) { if (gl.isGL2GL3()) {
@ -2398,7 +2415,6 @@ public class JoglRenderer implements Renderer {
} }
context.boundVertexArray = id; context.boundVertexArray = id;
} }
}
VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData); VertexBuffer interleavedData = mesh.getBuffer(Type.InterleavedData);
if (interleavedData != null && interleavedData.isUpdateNeeded()) { if (interleavedData != null && interleavedData.isUpdateNeeded()) {

Loading…
Cancel
Save