Skip to content

Commit fad086f

Browse files
Added missing glGetVertexAttrib method to WebGL20 class
1 parent c2c58ca commit fad086f

File tree

1 file changed

+96
-4
lines changed

1 file changed

+96
-4
lines changed

webgl4j/src/main/java/com/shc/webgl4j/client/WebGL20.java

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
import java.util.List;
4040

41+
import static com.shc.webgl4j.client.WebGL10.*;
42+
4143
/**
4244
* @author Sri Harsha Chilakapati
4345
*/
@@ -719,6 +721,19 @@ public static Uint32Array glGetUniformIndices(int program, String... uniformName
719721
return glGetUniformIndices(program, arrayString);
720722
}
721723

724+
@SuppressWarnings("unchecked")
725+
public static <T> T glGetVertexAttrib(int index, int pname)
726+
{
727+
checkContextCompatibility();
728+
729+
Object value = nglGetVertexAttrib(index, pname);
730+
731+
if (pname == GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING)
732+
return (T) (Integer) WebGLObjectMap.get().createBuffer((JavaScriptObject) value);
733+
734+
return nglGetVertexAttrib(index, pname);
735+
}
736+
722737
public static void glInvalidateFramebuffer(int target, ArrayBufferView attachments)
723738
{
724739
checkContextCompatibility();
@@ -1181,7 +1196,21 @@ private static native String nglGetActiveUniformBlockName(JavaScriptObject progr
11811196
}-*/;
11821197

11831198
private static native <T> T nglGetActiveUniformBlockParameter(JavaScriptObject program, int uniformBlockIndex, int pname) /*-{
1184-
return $wnd.gl.getActiveUniformBlockParameter(program, uniformBlockIndex, pname);
1199+
var value = $wnd.gl.getActiveUniformBlockParameter(program, uniformBlockIndex, pname);
1200+
1201+
switch (pname)
1202+
{
1203+
case @com.shc.webgl4j.client.WebGL20::GL_UNIFORM_BLOCK_BINDING:
1204+
case @com.shc.webgl4j.client.WebGL20::GL_UNIFORM_BLOCK_DATA_SIZE:
1205+
case @com.shc.webgl4j.client.WebGL20::GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
1206+
return @java.lang.Integer::valueOf(I)(value);
1207+
1208+
case @com.shc.webgl4j.client.WebGL20::GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
1209+
case @com.shc.webgl4j.client.WebGL20::GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
1210+
return @java.lang.Boolean::valueOf(Z)(value);
1211+
}
1212+
1213+
return value;
11851214
}-*/;
11861215

11871216
private static native Int32Array nglGetActiveUniforms(JavaScriptObject program, Uint32Array uniformIndices, int pname) /*-{
@@ -1197,7 +1226,18 @@ private static native int nglGetFragDataLocation(JavaScriptObject program, Strin
11971226
}-*/;
11981227

11991228
private static native <T> T nglGetIndexedParameter(int target, int index) /*-{
1200-
return $wnd.gl.getIndexedParameter(target, index);
1229+
var value = $wnd.gl.getIndexedParameter(target, index);
1230+
1231+
switch (value)
1232+
{
1233+
case @com.shc.webgl4j.client.WebGL20::GL_UNIFORM_BUFFER_SIZE:
1234+
case @com.shc.webgl4j.client.WebGL20::GL_UNIFORM_BUFFER_START:
1235+
case @com.shc.webgl4j.client.WebGL20::GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
1236+
case @com.shc.webgl4j.client.WebGL20::GL_TRANSFORM_FEEDBACK_BUFFER_START:
1237+
return @java.lang.Integer::valueOf(I)(value);
1238+
}
1239+
1240+
return value;
12011241
}-*/;
12021242

12031243
private static native Int32Array nglGetInternalformatParameter(int target, int internalFormat, int pName) /*-{
@@ -1209,11 +1249,43 @@ private static native JavaScriptObject nglGetQuery(int target, int pname) /*-{
12091249
}-*/;
12101250

12111251
private static native <T> T nglGetQueryParameter(JavaScriptObject query, int pname) /*-{
1212-
return $wnd.gl.getQueryParameter(query, pname);
1252+
var value = $wnd.gl.getQueryParameter(query, pname);
1253+
1254+
if (value != null)
1255+
{
1256+
switch (pname)
1257+
{
1258+
case @com.shc.webgl4j.client.WebGL20::GL_QUERY_RESULT:
1259+
return @java.lang.Integer::valueOf(I)(value);
1260+
1261+
case @com.shc.webgl4j.client.WebGL20::GL_QUERY_RESULT_AVAILABLE:
1262+
return @java.lang.Boolean::valueOf(Z)(value);
1263+
}
1264+
}
1265+
1266+
return value;
12131267
}-*/;
12141268

12151269
private static native <T> T nglGetSamplerParameter(JavaScriptObject sampler, int pname) /*-{
1216-
return $wnd.gl.getSamplerParameter(sampler, pname);
1270+
var value = $wnd.gl.getSamplerParameter(sampler, pname);
1271+
1272+
switch (value)
1273+
{
1274+
case @com.shc.webgl4j.client.WebGL20::GL_TEXTURE_COMPARE_FUNC:
1275+
case @com.shc.webgl4j.client.WebGL20::GL_TEXTURE_COMPARE_MODE:
1276+
case @com.shc.webgl4j.client.WebGL10::GL_TEXTURE_MAG_FILTER:
1277+
case @com.shc.webgl4j.client.WebGL10::GL_TEXTURE_MIN_FILTER:
1278+
case @com.shc.webgl4j.client.WebGL20::GL_TEXTURE_WRAP_R:
1279+
case @com.shc.webgl4j.client.WebGL10::GL_TEXTURE_WRAP_S:
1280+
case @com.shc.webgl4j.client.WebGL10::GL_TEXTURE_WRAP_T:
1281+
return @java.lang.Integer::valueOf(I)(value);
1282+
1283+
case @com.shc.webgl4j.client.WebGL20::GL_TEXTURE_MAX_LOD:
1284+
case @com.shc.webgl4j.client.WebGL20::GL_TEXTURE_MIN_LOD:
1285+
return @java.lang.Float::valueOf(F)(value);
1286+
}
1287+
1288+
return value;
12171289
}-*/;
12181290

12191291
private static native int nglGetSyncParameter(JavaScriptObject sync, int pname) /*-{
@@ -1232,6 +1304,26 @@ private static native Uint32Array nglGetUniformIndices(JavaScriptObject program,
12321304
return $wnd.gl.getUniformIndices(program, uniformNames);
12331305
}-*/;
12341306

1307+
private static native <T> T nglGetVertexAttrib(int index, int pname) /*-{
1308+
var value = $wnd.gl.getVertexAttrib(index, pname);
1309+
1310+
switch (value)
1311+
{
1312+
case @com.shc.webgl4j.client.WebGL10::GL_VERTEX_ATTRIB_ARRAY_SIZE:
1313+
case @com.shc.webgl4j.client.WebGL10::GL_VERTEX_ATTRIB_ARRAY_TYPE:
1314+
case @com.shc.webgl4j.client.WebGL10::GL_VERTEX_ATTRIB_ARRAY_STRIDE:
1315+
case @com.shc.webgl4j.client.WebGL20::GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
1316+
return @java.lang.Integer::valueOf(I)(value);
1317+
1318+
case @com.shc.webgl4j.client.WebGL10::GL_VERTEX_ATTRIB_ARRAY_ENABLED:
1319+
case @com.shc.webgl4j.client.WebGL10::GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
1320+
case @com.shc.webgl4j.client.WebGL20::GL_VERTEX_ATTRIB_ARRAY_INTEGER:
1321+
return @java.lang.Boolean::valueOf(Z)(value);
1322+
}
1323+
1324+
return value;
1325+
}-*/;
1326+
12351327
private static native void nglInvalidateFramebuffer(int target, ArrayBufferView attachments) /*-{
12361328
$wnd.gl.invalidateFramebuffer(target, attachments);
12371329
}-*/;

0 commit comments

Comments
 (0)