Skip to content

Commit

Permalink
Simplify API for glGetActive{Attrib|Uniform}.
Browse files Browse the repository at this point in the history
This used to only be implemented on LWJGL2+3 & Android, now it's only
implemented on LWJGL2+3 because to do it on Android would require that we
depend on API 17 (4.2) which is the first API for which Google no longer
published the android.jar file via Maven.

Since clearly no one was using this broken, partially implemented API, I'm not
going to go through all the trouble to try to get it working on Android.
  • Loading branch information
samskivert committed Aug 14, 2018
1 parent 003c3b0 commit eaa7915
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 175 deletions.
31 changes: 4 additions & 27 deletions android/src/playn/android/AndroidGL20.java
Original file line number Diff line number Diff line change
Expand Up @@ -436,36 +436,13 @@ public void glGenTextures(int n, IntBuffer textures) {
}

@Override
public void glGetActiveAttrib(int program, int index, int bufsize, int[] length,
int lengthOffset, int[] size, int sizeOffset, int[] type, int typeOffset, byte[] name,
int nameOffset) {
GLES20.glGetActiveAttrib(program, index, bufsize, length, lengthOffset, size, sizeOffset, type,
typeOffset, name, nameOffset);

}

@Override
public void glGetActiveAttrib(int program, int index, int bufsize, IntBuffer length,
IntBuffer size, IntBuffer type, ByteBuffer name) {
int namePos = name.position();
GLES20.glGetActiveAttrib(program, index, bufsize, length, size, type, name.get());
name.position(namePos);
}

@Override
public void glGetActiveUniform(int program, int index, int bufsize, int[] length,
int lengthOffset, int[] size, int sizeOffset, int[] type, int typeOffset, byte[] name,
int nameOffset) {
GLES20.glGetActiveUniform(program, index, bufsize, length, lengthOffset, size, sizeOffset,
type, typeOffset, name, nameOffset);
public String glGetActiveAttrib(int program, int index, IntBuffer size, IntBuffer type) {
throw new RuntimeException("Not implemented");
}

@Override
public void glGetActiveUniform(int program, int index, int bufsize, IntBuffer length,
IntBuffer size, IntBuffer type, ByteBuffer name) {
int namePos = name.position();
GLES20.glGetActiveUniform(program, index, bufsize, length, size, type, name.get());
name.position(namePos);
public String glGetActiveUniform(int program, int index, IntBuffer size, IntBuffer type) {
throw new RuntimeException("Not implemented");
}

@Override
Expand Down
6 changes: 2 additions & 4 deletions core/src/playn/core/GL20.java
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,8 @@ public void glVertexAttrib4fv(int indx, float[] values, int offset) {
public abstract void glGenRenderbuffers (int n, IntBuffer renderbuffers);
public abstract void glGenTextures (int n, IntBuffer textures);

public abstract void glGetActiveAttrib (int program, int index, int bufsize, int[] length, int lengthOffset, int[] size, int sizeOffset, int[] type, int typeOffset, byte[] name, int nameOffset);
public abstract void glGetActiveAttrib (int program, int index, int bufsize, IntBuffer length, IntBuffer size, IntBuffer type, ByteBuffer name);
public abstract void glGetActiveUniform (int program, int index, int bufsize, int[] length, int lengthOffset, int[] size, int sizeOffset, int[] type, int typeOffset, byte[] name, int nameOffset);
public abstract void glGetActiveUniform (int program, int index, int bufsize, IntBuffer length, IntBuffer size, IntBuffer type, ByteBuffer name);
public abstract String glGetActiveAttrib (int program, int index, IntBuffer size, IntBuffer type);
public abstract String glGetActiveUniform (int program, int index, IntBuffer size, IntBuffer type);
public abstract void glGetAttachedShaders (int program, int maxcount, IntBuffer count, IntBuffer shaders);
public abstract int glGetAttribLocation (int program, String name);
public abstract boolean glGetBoolean (int pname);
Expand Down
15 changes: 2 additions & 13 deletions html/src/playn/html/HtmlGL20.java
Original file line number Diff line number Diff line change
Expand Up @@ -798,14 +798,8 @@ public void glGenTextures(int n, int[] textures, int offset) {
}
}


@Override
public void glGetActiveAttrib(int program, int index, int bufsize, IntBuffer length, IntBuffer size, IntBuffer type, ByteBuffer name) {
throw new RuntimeException("NYI glGetActiveAttrib");
}

@Override
public void glGetActiveAttrib(int program, int index, int bufsize, int[] length, int lengthOffset, int[] size, int sizeOffset, int[] type, int typeOffset, byte[] name, int nameOffset) {
public String glGetActiveAttrib(int program, int index, IntBuffer size, IntBuffer type) {
throw new RuntimeException("NYI glGetActiveAttrib");
}

Expand All @@ -820,12 +814,7 @@ public void glGetAttachedShaders(int program, int maxcount, int[] count, int cou
}

@Override
public void glGetActiveUniform(int program, int index, int bufsize, IntBuffer length, IntBuffer size, IntBuffer type, ByteBuffer name) {
throw new RuntimeException("NYI glGetActiveUniform");
}

@Override
public void glGetActiveUniform(int program, int index, int bufsize, int[] length, int lengthOffset, int[] size, int sizeOffset, int[] type, int typeOffset, byte[] name, int nameOffset) {
public String glGetActiveUniform(int program, int index, IntBuffer size, IntBuffer type) {
throw new RuntimeException("NYI glGetActiveUniform");
}

Expand Down
64 changes: 4 additions & 60 deletions java-lwjgl/src/playn/java/LWJGLGL20.java
Original file line number Diff line number Diff line change
Expand Up @@ -1028,69 +1028,13 @@ public void glFramebufferTexture3D(int target, int attachment, int textarget, in
}

@Override
public void glGetActiveAttrib(int program, int index, int bufsize, int[] length, int lengthOffset,
int[] size, int sizeOffset, int[] type, int typeOffset,
byte[] name, int nameOffset) {
// http://www.khronos.org/opengles/sdk/docs/man/xhtml/glGetActiveAttrib.xml
// Returns length, size, type, name
bufs.resizeIntBuffer(2);

// Return name, length
final String nameString = GL20.glGetActiveAttrib(program, index, BufferUtils.createIntBuffer(bufsize), bufs.intBuffer);
try {
final byte[] nameBytes = nameString.getBytes("UTF-8");
final int nameLength = nameBytes.length - nameOffset;
bufs.setByteBuffer(nameBytes, nameOffset, nameLength);
bufs.byteBuffer.get(name, nameOffset, nameLength);
length[lengthOffset] = nameLength;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}

// Return size, type
bufs.intBuffer.get(size, 0, 1);
bufs.intBuffer.get(type, 0, 1);
}

@Override
public void glGetActiveAttrib(int program, int index, int bufsize,
IntBuffer length, IntBuffer size, IntBuffer type, ByteBuffer name) {
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
GL20.glGetActiveAttrib(program, index, BufferUtils.createIntBuffer(256), typeTmp);
type.put(typeTmp.get(0));
type.rewind();
}

@Override
public void glGetActiveUniform(int program, int index, int bufsize,
int[] length, int lengthOffset, int[] size, int sizeOffset,
int[] type, int typeOffset, byte[] name, int nameOffset) {
bufs.resizeIntBuffer(2);

// Return name, length
final String nameString = GL20.glGetActiveUniform(program, index, BufferUtils.createIntBuffer(256), bufs.intBuffer);
try {
final byte[] nameBytes = nameString.getBytes("UTF-8");
final int nameLength = nameBytes.length - nameOffset;
bufs.setByteBuffer(nameBytes, nameOffset, nameLength);
bufs.byteBuffer.get(name, nameOffset, nameLength);
length[lengthOffset] = nameLength;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}

// Return size, type
bufs.intBuffer.get(size, 0, 1);
bufs.intBuffer.get(type, 0, 1);
public String glGetActiveAttrib(int program, int index, IntBuffer size, IntBuffer type) {
return GL20.glGetActiveAttrib(program, index, size, type);
}

@Override
public void glGetActiveUniform(int program, int index, int bufsize, IntBuffer length,
IntBuffer size, IntBuffer type, ByteBuffer name) {
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
GL20.glGetActiveAttrib(program, index, BufferUtils.createIntBuffer(256), typeTmp);
type.put(typeTmp.get(0));
type.rewind();
public String glGetActiveUniform(int program, int index, IntBuffer size, IntBuffer type) {
return GL20.glGetActiveAttrib(program, index, size, type);
}

@Override
Expand Down
86 changes: 23 additions & 63 deletions java-lwjgl2/src/playn/java/LWJGLGL20.java
Original file line number Diff line number Diff line change
Expand Up @@ -1053,69 +1053,29 @@ public void glFramebufferTexture3D(int target, int attachment, int textarget, in
}

@Override
public void glGetActiveAttrib(int program, int index, int bufsize, int[] length, int lengthOffset,
int[] size, int sizeOffset, int[] type, int typeOffset,
byte[] name, int nameOffset) {
// http://www.khronos.org/opengles/sdk/docs/man/xhtml/glGetActiveAttrib.xml
// Returns length, size, type, name
bufs.resizeIntBuffer(2);

// Return name, length
final String nameString = GL20.glGetActiveAttrib(program, index, bufsize, bufs.intBuffer);
try {
final byte[] nameBytes = nameString.getBytes("UTF-8");
final int nameLength = nameBytes.length - nameOffset;
bufs.setByteBuffer(nameBytes, nameOffset, nameLength);
bufs.byteBuffer.get(name, nameOffset, nameLength);
length[lengthOffset] = nameLength;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}

// Return size, type
bufs.intBuffer.get(size, 0, 1);
bufs.intBuffer.get(type, 0, 1);
}

@Override
public void glGetActiveAttrib(int program, int index, int bufsize,
IntBuffer length, IntBuffer size, IntBuffer type, ByteBuffer name) {
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
GL20.glGetActiveAttrib(program, index, 256, typeTmp);
type.put(typeTmp.get(0));
type.rewind();
}

@Override
public void glGetActiveUniform(int program, int index, int bufsize,
int[] length, int lengthOffset, int[] size, int sizeOffset,
int[] type, int typeOffset, byte[] name, int nameOffset) {
bufs.resizeIntBuffer(2);

// Return name, length
final String nameString = GL20.glGetActiveUniform(program, index, 256, bufs.intBuffer);
try {
final byte[] nameBytes = nameString.getBytes("UTF-8");
final int nameLength = nameBytes.length - nameOffset;
bufs.setByteBuffer(nameBytes, nameOffset, nameLength);
bufs.byteBuffer.get(name, nameOffset, nameLength);
length[lengthOffset] = nameLength;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}

// Return size, type
bufs.intBuffer.get(size, 0, 1);
bufs.intBuffer.get(type, 0, 1);
}

@Override
public void glGetActiveUniform(int program, int index, int bufsize, IntBuffer length,
IntBuffer size, IntBuffer type, ByteBuffer name) {
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
GL20.glGetActiveAttrib(program, index, 256, typeTmp);
type.put(typeTmp.get(0));
type.rewind();
public String glGetActiveAttrib(int program, int index, IntBuffer size, IntBuffer type) {
IntBuffer sizeType = BufferUtils.createIntBuffer(2);
String result = GL20.glGetActiveAttrib(program, index, 256, type);
int typePos = type.position();
type.put(sizeType.get(0));
type.position(typePos);
int sizePos = size.position();
size.put(sizeType.get(1));
size.position(sizePos);
return result;
}

@Override
public String glGetActiveUniform(int program, int index, IntBuffer size, IntBuffer type) {
IntBuffer sizeType = BufferUtils.createIntBuffer(2);
String result = GL20.glGetActiveAttrib(program, index, 256, sizeType);
int typePos = type.position();
type.put(sizeType.get(0));
type.position(typePos);
int sizePos = size.position();
size.put(sizeType.get(1));
size.position(sizePos);
return result;
}

@Override
Expand Down
10 changes: 2 additions & 8 deletions robovm/src/playn/robovm/RoboGL20.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,10 @@ public ByteBuffer createByteBuffer(int size) {
@Override public void glGenTextures(int n, IntBuffer textures) {
OpenGLES.glGenTextures(n, textures);
}
@Override public void glGetActiveAttrib(int program, int index, int bufsize, int[] length, int lengthOffset, int[] size, int sizeOffset, int[] type, int typeOffset, byte[] name, int nameOffset) {
@Override public String glGetActiveAttrib(int program, int index, IntBuffer size, IntBuffer type) {
throw new RuntimeException("Not implemented");
}
@Override public void glGetActiveAttrib(int program, int index, int bufsize, IntBuffer length, IntBuffer size, IntBuffer type, ByteBuffer name) {
throw new RuntimeException("Not implemented");
}
@Override public void glGetActiveUniform(int program, int index, int bufsize, int[] length, int lengthOffset, int[] size, int sizeOffset, int[] type, int typeOffset, byte[] name, int nameOffset) {
throw new RuntimeException("Not implemented");
}
@Override public void glGetActiveUniform(int program, int index, int bufsize, IntBuffer length, IntBuffer size, IntBuffer type, ByteBuffer name) {
@Override public String glGetActiveUniform(int program, int index, IntBuffer size, IntBuffer type) {
throw new RuntimeException("Not implemented");
}
@Override public void glGetAttachedShaders(int program, int maxcount, IntBuffer count, IntBuffer shaders) {
Expand Down

0 comments on commit eaa7915

Please sign in to comment.