Skip to content

Commit 2af6e39

Browse files
committed
Add some GL3ES3 functions to PGL
1 parent 771f8a2 commit 2af6e39

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

core/src/processing/opengl/PGL.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,12 +2666,14 @@ protected interface FontOutline {
26662666

26672667
public static int ARRAY_BUFFER;
26682668
public static int ELEMENT_ARRAY_BUFFER;
2669+
public static int PIXEL_PACK_BUFFER;
26692670

26702671
public static int MAX_VERTEX_ATTRIBS;
26712672

26722673
public static int STATIC_DRAW;
26732674
public static int DYNAMIC_DRAW;
26742675
public static int STREAM_DRAW;
2676+
public static int STREAM_READ;
26752677

26762678
public static int BUFFER_SIZE;
26772679
public static int BUFFER_USAGE;
@@ -2886,6 +2888,10 @@ protected interface FontOutline {
28862888
public static int LINE_SMOOTH;
28872889
public static int POLYGON_SMOOTH;
28882890

2891+
public static int SYNC_GPU_COMMANDS_COMPLETE;
2892+
public static int ALREADY_SIGNALED;
2893+
public static int CONDITION_SATISFIED;
2894+
28892895
///////////////////////////////////////////////////////////
28902896

28912897
// Special Functions
@@ -2930,6 +2936,14 @@ protected interface FontOutline {
29302936

29312937
//////////////////////////////////////////////////////////////////////////////
29322938

2939+
// Synchronization
2940+
2941+
public abstract long fenceSync(int condition, int flags);
2942+
public abstract void deleteSync(long sync);
2943+
public abstract int clientWaitSync(long sync, int flags, long timeout);
2944+
2945+
//////////////////////////////////////////////////////////////////////////////
2946+
29332947
// Viewport and Clipping
29342948

29352949
public abstract void depthRangef(float n, float f);
@@ -2959,7 +2973,23 @@ public void readPixels(int x, int y, int width, int height, int format, int type
29592973
graphics.endReadPixels();
29602974
}
29612975

2976+
public void readPixels(int x, int y, int width, int height, int format, int type, long offset){
2977+
boolean multisampled = isMultisampled() || graphics.offscreenMultisample;
2978+
boolean depthReadingEnabled = graphics.getHint(PConstants.ENABLE_BUFFER_READING);
2979+
boolean depthRequested = format == STENCIL_INDEX || format == DEPTH_COMPONENT || format == DEPTH_STENCIL;
2980+
2981+
if (multisampled && depthRequested && !depthReadingEnabled) {
2982+
PGraphics.showWarning(DEPTH_READING_NOT_ENABLED_ERROR);
2983+
return;
2984+
}
2985+
2986+
graphics.beginReadPixels();
2987+
readPixelsImpl(x, y, width, height, format, type, offset);
2988+
graphics.endReadPixels();
2989+
}
2990+
29622991
protected abstract void readPixelsImpl(int x, int y, int width, int height, int format, int type, Buffer buffer);
2992+
protected abstract void readPixelsImpl(int x, int y, int width, int height, int format, int type, long offset);
29632993

29642994
//////////////////////////////////////////////////////////////////////////////
29652995

core/src/processing/opengl/PJOGL.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.jogamp.opengl.GL2ES2;
4545
import com.jogamp.opengl.GL2ES3;
4646
import com.jogamp.opengl.GL2GL3;
47+
import com.jogamp.opengl.GL3ES3;
4748
import com.jogamp.opengl.GLAutoDrawable;
4849
import com.jogamp.opengl.GLCapabilities;
4950
import com.jogamp.opengl.GLCapabilitiesImmutable;
@@ -109,6 +110,9 @@ public class PJOGL extends PGL {
109110
* multisampled renderbuffers) */
110111
protected GL2 gl2x;
111112

113+
/** GL3ES3 interface */
114+
protected GL3ES3 gl3es3;
115+
112116
/** Stores exceptions that ocurred during drawing */
113117
protected Exception drawException;
114118

@@ -233,6 +237,7 @@ protected void getGL(PGL pgl) {
233237
this.gl2 = pjogl.gl2;
234238
this.gl2x = pjogl.gl2x;
235239
this.gl3 = pjogl.gl3;
240+
this.gl3es3 = pjogl.gl3es3;
236241
}
237242

238243

@@ -253,6 +258,11 @@ public void getGL(GLAutoDrawable glDrawable) {
253258
} catch (com.jogamp.opengl.GLException e) {
254259
gl3 = null;
255260
}
261+
try {
262+
gl3es3 = gl.getGL3ES3();
263+
} catch (com.jogamp.opengl.GLException e) {
264+
gl3es3 = null;
265+
}
256266
}
257267

258268

@@ -736,12 +746,14 @@ public void next() {
736746

737747
ARRAY_BUFFER = GL.GL_ARRAY_BUFFER;
738748
ELEMENT_ARRAY_BUFFER = GL.GL_ELEMENT_ARRAY_BUFFER;
749+
PIXEL_PACK_BUFFER = GL3ES3.GL_PIXEL_PACK_BUFFER;
739750

740751
MAX_VERTEX_ATTRIBS = GL2ES2.GL_MAX_VERTEX_ATTRIBS;
741752

742753
STATIC_DRAW = GL.GL_STATIC_DRAW;
743754
DYNAMIC_DRAW = GL.GL_DYNAMIC_DRAW;
744755
STREAM_DRAW = GL2ES2.GL_STREAM_DRAW;
756+
STREAM_READ = GL3ES3.GL_STREAM_READ;
745757

746758
BUFFER_SIZE = GL.GL_BUFFER_SIZE;
747759
BUFFER_USAGE = GL.GL_BUFFER_USAGE;
@@ -956,6 +968,10 @@ public void next() {
956968
MULTISAMPLE = GL.GL_MULTISAMPLE;
957969
LINE_SMOOTH = GL.GL_LINE_SMOOTH;
958970
POLYGON_SMOOTH = GL2GL3.GL_POLYGON_SMOOTH;
971+
972+
SYNC_GPU_COMMANDS_COMPLETE = GL3ES3.GL_SYNC_GPU_COMMANDS_COMPLETE;
973+
ALREADY_SIGNALED = GL3ES3.GL_ALREADY_SIGNALED;
974+
CONDITION_SATISFIED = GL3ES3.GL_CONDITION_SATISFIED;
959975
}
960976

961977
///////////////////////////////////////////////////////////
@@ -1114,6 +1130,37 @@ public void unmapBuffer(int target) {
11141130

11151131
//////////////////////////////////////////////////////////////////////////////
11161132

1133+
// Synchronization
1134+
1135+
@Override
1136+
public long fenceSync(int condition, int flags) {
1137+
if (gl3es3 != null) {
1138+
return gl3es3.glFenceSync(condition, flags);
1139+
} else {
1140+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "fenceSync()"));
1141+
}
1142+
}
1143+
1144+
@Override
1145+
public void deleteSync(long sync) {
1146+
if (gl3es3 != null) {
1147+
gl3es3.glDeleteSync(sync);
1148+
} else {
1149+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "deleteSync()"));
1150+
}
1151+
}
1152+
1153+
@Override
1154+
public int clientWaitSync(long sync, int flags, long timeout) {
1155+
if (gl3es3 != null) {
1156+
return gl3es3.glClientWaitSync(sync, flags, timeout);
1157+
} else {
1158+
throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "clientWaitSync()"));
1159+
}
1160+
}
1161+
1162+
//////////////////////////////////////////////////////////////////////////////
1163+
11171164
// Viewport and Clipping
11181165

11191166
@Override
@@ -1141,6 +1188,11 @@ protected void readPixelsImpl(int x, int y, int width, int height, int format, i
11411188
gl.glReadPixels(x, y, width, height, format, type, buffer);
11421189
}
11431190

1191+
@Override
1192+
protected void readPixelsImpl(int x, int y, int width, int height, int format, int type, long offset) {
1193+
gl.glReadPixels(x, y, width, height, format, type, 0);
1194+
}
1195+
11441196
//////////////////////////////////////////////////////////////////////////////
11451197

11461198
// Vertices

0 commit comments

Comments
 (0)