aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-07-15 14:35:02 +0200
committerSven Gothel <[email protected]>2023-07-15 14:35:02 +0200
commitbe9c3e42e618148584689a1ccf30c8c3f4e6227a (patch)
tree6daa57deb2ba89640c44da0a75bcada528c04570 /src/jogl/classes/com/jogamp/opengl
parentddbffc38f001e3297d560ab1f6b3e7575771bdc5 (diff)
Add {GL, GLContext}.getDefaultDrawBuffer() to complement getDefaultReadBuffer()
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/FBObject.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLBase.java76
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLContext.java28
3 files changed, 80 insertions, 28 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java
index a559445c7..8f62c9952 100644
--- a/src/jogl/classes/com/jogamp/opengl/FBObject.java
+++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java
@@ -2772,7 +2772,11 @@ public class FBObject {
public final int getReadFramebuffer() {
return 0 < samples ? ( null != samplingSink ? samplingSink.getReadFramebuffer() : 0 ) : fbName;
}
+
+ public final int getDefaultDrawBuffer() { return GL.GL_COLOR_ATTACHMENT0; }
+
public final int getDefaultReadBuffer() { return GL.GL_COLOR_ATTACHMENT0; }
+
/** Return the number of attached {@link Colorbuffer}s */
public final int getColorbufferCount() { return colorbufferCount; }
/** Return the number of attached {@link TextureAttachment}s */
diff --git a/src/jogl/classes/com/jogamp/opengl/GLBase.java b/src/jogl/classes/com/jogamp/opengl/GLBase.java
index 0cbcbe40f..a2f22a4d4 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLBase.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLBase.java
@@ -648,31 +648,55 @@ public interface GLBase {
*/
public int getDefaultReadFramebuffer();
- /**
- * Returns the default color buffer within the current bound
- * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER,
- * which will be used as the source for pixel reading commands,
- * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels} etc.
- * <p>
- * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
- * otherwise this is {@link GL#GL_FRONT} for single buffer configurations
- * and {@link GL#GL_BACK} for double buffer configurations.
- * </p>
- * <p>
- * Note-1: Neither ES1 nor ES2 supports selecting the read buffer via glReadBuffer
- * and {@link GL#GL_BACK} is the default.
- * </p>
- * <p>
- * Note-2: ES3 only supports {@link GL#GL_BACK}, {@link GL#GL_NONE} or {@link GL#GL_COLOR_ATTACHMENT0}+i
- * </p>
- * <p>
- * Note-3: See {@link com.jogamp.opengl.util.GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable) swapBuffersBeforeRead}
- * for read-pixels and swap-buffers implications.
- * </p>
- * <p>
- * Calls {@link GLContext#getDefaultReadBuffer()}.
- * </p>
- */
- public int getDefaultReadBuffer();
+ /**
+ * Returns the default color buffer within the current bound
+ * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​,
+ * which will be used as the target (output) for (fragment shader) draw commands,
+ * settable via {@link GL2ES2#glDrawBuffers(int, int[], int)} or {@link GL2#glDrawBuffer(int)}.
+ * <p>
+ * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
+ * otherwise this is {@link GL#GL_FRONT} for non-ES profile and single buffer configurations
+ * and {@link GL#GL_BACK} for double buffer configurations or ES profiles.
+ * </p>
+ * <p>
+ * Note-1: Neither ES1 nor ES2 supports selecting the draw buffer at all
+ * and {@link GL#GL_BACK} is the default.
+ * </p>
+ * <p>
+ * Note-2: ES3 only supports {@link GL#GL_BACK}, {@link GL#GL_NONE} or {@link GL#GL_COLOR_ATTACHMENT0}+i
+ * via {@link GL2ES2#glDrawBuffers(int, int[], int)}.
+ * </p>
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
+ */
+ public int getDefaultDrawBuffer();
+
+ /**
+ * Returns the default color buffer within the current bound
+ * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​,
+ * which will be used as the source for pixel reading commands,
+ * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels} etc.
+ * <p>
+ * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
+ * otherwise this is {@link GL#GL_FRONT} for non-ES profile and single buffer configurations
+ * and {@link GL#GL_BACK} for double buffer configurations or ES profiles.
+ * </p>
+ * <p>
+ * Note-1: Neither ES1 nor ES2 supports selecting the read buffer via glReadBuffer
+ * and {@link GL#GL_BACK} is the default.
+ * </p>
+ * <p>
+ * Note-2: ES3 only supports {@link GL#GL_BACK}, {@link GL#GL_NONE} or {@link GL#GL_COLOR_ATTACHMENT0}+i
+ * </p>
+ * <p>
+ * Note-3: See {@link com.jogamp.opengl.util.GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable) swapBuffersBeforeRead}
+ * for read-pixels and swap-buffers implications.
+ * </p>
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
+ */
+ public int getDefaultReadBuffer();
}
diff --git a/src/jogl/classes/com/jogamp/opengl/GLContext.java b/src/jogl/classes/com/jogamp/opengl/GLContext.java
index 4455633a1..470635a98 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLContext.java
@@ -1367,12 +1367,36 @@ public abstract class GLContext {
/**
* Returns the default color buffer within the current bound
* {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​,
+ * which will be used as the target (output) for (fragment shader) draw commands,
+ * settable via {@link GL2ES2#glDrawBuffers(int, int[], int)} or {@link GL2#glDrawBuffer(int)}.
+ * <p>
+ * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
+ * otherwise this is {@link GL#GL_FRONT} for non-ES profile and single buffer configurations
+ * and {@link GL#GL_BACK} for double buffer configurations or ES profiles.
+ * </p>
+ * <p>
+ * Note-1: Neither ES1 nor ES2 supports selecting the draw buffer at all
+ * and {@link GL#GL_BACK} is the default.
+ * </p>
+ * <p>
+ * Note-2: ES3 only supports {@link GL#GL_BACK}, {@link GL#GL_NONE} or {@link GL#GL_COLOR_ATTACHMENT0}+i
+ * via {@link GL2ES2#glDrawBuffers(int, int[], int)}.
+ * </p>
+ * <p>
+ * Method is only thread-safe while context is {@link #makeCurrent() made current}.
+ * </p>
+ */
+ public abstract int getDefaultDrawBuffer();
+
+ /**
+ * Returns the default color buffer within the current bound
+ * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​,
* which will be used as the source for pixel reading commands,
* like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels} etc.
* <p>
* For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0},
- * otherwise this is {@link GL#GL_FRONT} for single buffer configurations
- * and {@link GL#GL_BACK} for double buffer configurations.
+ * otherwise this is {@link GL#GL_FRONT} for non-ES profile and single buffer configurations
+ * and {@link GL#GL_BACK} for double buffer configurations or ES profiles.
* </p>
* <p>
* Note-1: Neither ES1 nor ES2 supports selecting the read buffer via glReadBuffer