From e7064ece049705e013d80985eae698ce0ee3c4e3 Mon Sep 17 00:00:00 2001
From: Sven Gothel
+ * 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. + *
+ */ + public int getDefaultReadBuffer(); + } diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index de10a2815..235003c38 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -970,6 +970,32 @@ public abstract class GLContext { */ public abstract 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)} etc. + *+ * 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. + *
+ */ + public abstract int getDefaultReadBuffer(); + + /** On some platforms the mismatch between OpenGL's coordinate + system (origin at bottom left) and the window system's + coordinate system (origin at top left) necessitates a vertical + flip of pixels read from offscreen contexts. +
+ Default impl. is true
.
+
+ * If {@link GLCapabilities#getDoubleBuffered() double buffering} is not chosen, this is a NOP. + *
+ *+ * Must be called before {@link #isInitialized() initialization}, otherwise an exception is thrown. + *
+ * @return the new number of buffers (FBO) used, maybe different than the requestedbufferCount
(see above)
+ * @throws GLException if already initialized, see {@link #isInitialized()}.
+ */
+ int setNumBuffers(int bufferCount) throws GLException;
+
+ /**
+ * @return the number of buffers (FBO) being used. 1 if not using {@link GLCapabilities#getDoubleBuffered() double buffering},
+ * otherwise ≥ 2, depending on {@link #setNumBuffers(int)}.
+ */
+ int getNumBuffers();
/**
* @return the used {@link DoubleBufferMode}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index dcfc1f0dd..a9d4989dc 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -618,12 +618,18 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
public NativeSurface getNativeSurface() {
- throw new GLException("FIXME");
+ if(null != backend) {
+ return backend.getDrawable().getNativeSurface();
+ }
+ return null;
}
@Override
public long getHandle() {
- throw new GLException("FIXME");
+ if(null != backend) {
+ return backend.getDrawable().getNativeSurface().getSurfaceHandle();
+ }
+ return 0;
}
@Override
@@ -657,6 +663,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
if (oglPipelineEnabled) {
backend = new J2DOGLBackend();
} else {
+ backend = new SoftwareBackend();
+ /**
if (!hardwareAccelerationDisabled &&
factory.canCreateGLPbuffer(null)) {
backend = new PbufferBackend();
@@ -665,7 +673,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
throw new GLException("Fallback to software rendering disabled by user");
}
backend = new SoftwareBackend();
- }
+ } */
}
}
@@ -996,7 +1004,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
gl.glPixelStorei(GL2.GL_PACK_ALIGNMENT, 1);
// Actually read the pixels.
- gl.glReadBuffer(GL2.GL_FRONT);
+ gl.glReadBuffer(gl.getDefaultReadBuffer());
if (readBackBytes != null) {
gl.glReadPixels(0, 0, readBackWidthInPixels, readBackHeightInPixels, glFormat, glType, readBackBytes);
} else if (readBackInts != null) {
@@ -1173,12 +1181,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
protected int getGLPixelType() {
- return offscreenContext.getOffscreenContextPixelDataType();
+ return offscreenContext.getDefaultPixelDataType();
}
@Override
protected boolean flipVertically() {
- return offscreenContext.offscreenImageNeedsVerticalFlip();
+ return offscreenContext.isGLOrientationFlippedVertical();
}
}
--
cgit v1.2.3