diff options
author | Sven Gothel <[email protected]> | 2013-09-07 16:57:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-09-07 16:57:47 +0200 |
commit | 6fe3e99dab9721294a3bf72eaea77af33afc9481 (patch) | |
tree | 4b78f33d646f7081e5d1076f1626654b9847227c /src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java | |
parent | 42500210d8a8626ee6c3c1b169eaa9e5fbf85a21 (diff) |
Fix TileRenderer*: Allow general usage w/ any GL profile, only image-buffer requires >= GL2ES3; Always set pack-alignment, Set glReadBuffer(..) >= GL2ES3
- Allow general usage w/ any GL profile, only image-buffer requires >= GL2ES3
Due to GL2ES3.GL_PACK_ROW_LENGTH and image-width != tile-width
- Always set pack-alignment
Forgot for tile-buffer
- Set glReadBuffer(..) >= GL2ES3
Required if using FBO offscreen, i.e. MSAA mode.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java index 695e2d93d..46a1e2452 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java @@ -37,7 +37,9 @@ package com.jogamp.opengl.util; import javax.media.nativewindow.util.Dimension; +import javax.media.opengl.GL; import javax.media.opengl.GL2ES3; +import javax.media.opengl.GLException; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; @@ -248,10 +250,11 @@ public class TileRenderer extends TileRendererBase { } @Override - public final void beginTile( GL2ES3 gl ) throws IllegalStateException { + public final void beginTile( GL gl ) throws IllegalStateException, GLException { if( 0 >= imageSize.getWidth() || 0 >= imageSize.getHeight() ) { throw new IllegalStateException("Image size has not been set"); } + validateGL(gl); if (currentTile <= 0) { setup(); } @@ -311,19 +314,28 @@ public class TileRenderer extends TileRendererBase { } @Override - public void endTile( GL2ES3 gl ) throws IllegalStateException { + public void endTile( GL gl ) throws IllegalStateException, GLException { if( !beginCalled ) { throw new IllegalStateException("beginTile(..) has not been called"); } + validateGL(gl); // be sure OpenGL rendering is finished gl.glFlush(); // save current glPixelStore values psm.save(gl); - + psm.setPackAlignment(gl, 1); + final GL2ES3 gl2es3; + if( gl.isGL2ES3() ) { + gl2es3 = gl.getGL2ES3(); + gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer()); + } else { + gl2es3 = null; + } + final int tmp[] = new int[1]; - + if( tileBuffer != null ) { final GLPixelAttributes pixelAttribs = tileBuffer.pixelAttributes; final int srcX = tileBorder; @@ -351,8 +363,7 @@ public class TileRenderer extends TileRendererBase { /* setup pixel store for glReadPixels */ final int rowLength = imageSize.getWidth(); - psm.setPackRowLength(gl, rowLength); - psm.setPackAlignment(gl, 1); + psm.setPackRowLength(gl2es3, rowLength); /* read the tile into the final image */ final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.bytesPerPixel, srcWidth, srcHeight, 1, true); |