aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java101
1 files changed, 62 insertions, 39 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index aeb8501ec..cac39fb21 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -30,7 +30,6 @@ package jogamp.graph.curve.opengl;
import java.nio.FloatBuffer;
import javax.media.opengl.GL2ES2;
-// FIXME: Subsume GL2GL3.GL_DRAW_FRAMEBUFFER -> GL2ES2.GL_DRAW_FRAMEBUFFER !
import javax.media.opengl.GL;
import javax.media.opengl.GLUniformData;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
@@ -68,7 +67,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
private int fboWidth = 0;
private int fboHeight = 0;
GLUniformData mgl_ActiveTexture;
- GLUniformData mgl_TextureSize; // if GLSL < 1.30
+ GLUniformData mgl_TextureSize;
final int[] maxTexSize = new int[] { -1 } ;
@@ -124,10 +123,10 @@ public class VBORegion2PVBAAES2 extends GLRegion {
texCoordFboAttr = GLArrayDataServer.createGLSL(AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT,
false, 4, GL.GL_STATIC_DRAW);
st.ownAttribute(texCoordFboAttr, true);
- texCoordFboAttr.putf(5); texCoordFboAttr.putf(5);
- texCoordFboAttr.putf(5); texCoordFboAttr.putf(6);
- texCoordFboAttr.putf(6); texCoordFboAttr.putf(6);
- texCoordFboAttr.putf(6); texCoordFboAttr.putf(5);
+ texCoordFboAttr.putf(0); texCoordFboAttr.putf(0);
+ texCoordFboAttr.putf(0); texCoordFboAttr.putf(1);
+ texCoordFboAttr.putf(1); texCoordFboAttr.putf(1);
+ texCoordFboAttr.putf(1); texCoordFboAttr.putf(0);
texCoordFboAttr.seal(true);
verticeFboAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT,
@@ -152,16 +151,16 @@ public class VBORegion2PVBAAES2 extends GLRegion {
// update all bbox related data
verticeFboAttr.seal(gl, false);
verticeFboAttr.rewind();
- verticeFboAttr.putf(box.getLow()[0]); verticeFboAttr.putf(box.getLow()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getLow()[0]); verticeFboAttr.putf(box.getHigh()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getHigh()[0]); verticeFboAttr.putf(box.getHigh()[1]); verticeFboAttr.putf(box.getLow()[2]);
- verticeFboAttr.putf(box.getHigh()[0]); verticeFboAttr.putf(box.getLow()[1]); verticeFboAttr.putf(box.getLow()[2]);
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMaxY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()); verticeFboAttr.putf(box.getMaxY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
verticeFboAttr.seal(gl, true);
verticeFboAttr.enableBuffer(gl, false);
fboPMVMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
fboPMVMatrix.glLoadIdentity();
- fboPMVMatrix.glOrthof(box.getLow()[0], box.getHigh()[0], box.getLow()[1], box.getHigh()[1], -1, 1);
+ fboPMVMatrix.glOrthof(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY(), -1, 1);
// push data 2 GPU ..
indicesFbo.seal(gl, true);
@@ -186,6 +185,8 @@ public class VBORegion2PVBAAES2 extends GLRegion {
final RenderState rs = renderer.getRenderState();
final float winWidth, winHeight;
int targetFboWidth, targetFboHeight;
+ float renderFboWidth, renderFboHeight;
+ float diffWidth, diffHeight;
{
// Calculate perspective pixel width/height for FBO,
// considering the sampleCount.
@@ -199,15 +200,21 @@ public class VBORegion2PVBAAES2 extends GLRegion {
pmv.gluProject(box.getMaxX(), box.getMaxY(), objZ, view, 0, winPosSzMax, 0);
winWidth = Math.abs(winPosSzMax[0] - winPosSzMin[0]);
winHeight = Math.abs(winPosSzMax[1] - winPosSzMin[1]);
- targetFboWidth = Math.round(winWidth*sampleCount[0]);
- targetFboHeight= Math.round(winHeight*sampleCount[0]);
+ diffWidth = (float)Math.ceil(winWidth)-winWidth;
+ diffHeight = (float)Math.ceil(winHeight)-winHeight;
+ renderFboWidth = winWidth*sampleCount[0];
+ renderFboHeight = winHeight*sampleCount[0];
+ targetFboWidth = (int)Math.ceil(renderFboWidth);
+ targetFboHeight = (int)Math.ceil(renderFboHeight);
if( DEBUG_FBO_2 ) {
System.err.printf("XXX.MinMax1 min [%.1f, %.1f -> %.3f, %.3f, %.3f]"+
- ", max [%.1f, %.1f -> %.3f, %.3f, %.3f], view[%d, %d] -> [%f x %f]%n",
+ ", max [%.1f, %.1f -> %.3f, %.3f, %.3f], view[%d, %d] -> win[%.3f, %.3f]: FBO f[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], msaa %d%n",
box.getMinX(), box.getMinY(), winPosSzMin[0], winPosSzMin[1], winPosSzMin[2],
box.getMaxX(), box.getMaxY(), winPosSzMax[0], winPosSzMax[1], winPosSzMax[2],
- view[2], view[3], winWidth, winHeight);
- System.err.printf("XXX.MinMax1 [%f x %f] * %d = %d x %d%n", winWidth, winHeight, sampleCount[0], targetFboWidth, targetFboHeight);
+ view[2], view[3],
+ winWidth, winHeight,
+ renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight,
+ diffWidth, diffHeight, sampleCount[0]);
}
}
final int deltaFboWidth = Math.abs(targetFboWidth-fboWidth);
@@ -237,11 +244,14 @@ public class VBORegion2PVBAAES2 extends GLRegion {
} else {
sampleCount[0] = (int)Math.floor(maxTexSize[0] / winHeight);
}
- targetFboWidth = Math.round(winWidth*sampleCount[0]);
- targetFboHeight= Math.round(winHeight*sampleCount[0]);
+ renderFboWidth = winWidth*sampleCount[0];
+ renderFboHeight = winHeight*sampleCount[0];
+ targetFboWidth = (int)Math.ceil(renderFboWidth);
+ targetFboHeight = (int)Math.ceil(renderFboHeight);
if( DEBUG_FBO_1 ) {
- System.err.printf("XXX.Rescale (MAX): %d * [%f x %f]: %d x %d%n",
- sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight);
+ System.err.printf("XXX.Rescale (MAX): win[%.3f, %.3f]: FBO f[%.3f, %.3f], i[%d x %d], msaa %d%n",
+ winWidth, winHeight,
+ renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight, sampleCount[0]);
}
if( sampleCount[0] <= 0 ) {
// Last way out!
@@ -249,20 +259,44 @@ public class VBORegion2PVBAAES2 extends GLRegion {
return;
}
}
- renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight);
+ verticeFboAttr.seal(false);
+ verticeFboAttr.rewind();
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMinX()); verticeFboAttr.putf(box.getMaxY()+diffHeight); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()+diffWidth); verticeFboAttr.putf(box.getMaxY()+diffHeight); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.putf(box.getMaxX()+diffWidth); verticeFboAttr.putf(box.getMinY()); verticeFboAttr.putf(box.getMinZ());
+ verticeFboAttr.seal(true);
+ fboPMVMatrix.glLoadIdentity();
+ fboPMVMatrix.glOrthof(box.getMinX(), box.getMaxX()+diffWidth,
+ box.getMinY(), box.getMaxY()+diffHeight, -1, 1);
+ renderRegion2FBO(gl, rs, targetFboWidth, targetFboHeight, sampleCount[0]);
}
// System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3));
- renderFBO(gl, rs, width, height);
+ renderFBO(gl, rs, width, height, sampleCount[0]);
}
}
+ private void setTexSize(final GL2ES2 gl, final ShaderState st, boolean firstPass, int sampleCount) {
+ if(null == mgl_TextureSize) {
+ mgl_TextureSize = new GLUniformData(UniformNames.gcu_TextureSize, 3, Buffers.newDirectFloatBuffer(3));
+ }
+ final FloatBuffer texSize = (FloatBuffer) mgl_TextureSize.getBuffer();
+ if( firstPass ) {
+ texSize.put(2, 0f);
+ } else {
+ texSize.put(0, fboWidth);
+ texSize.put(1, fboHeight);
+ texSize.put(2, sampleCount);
+ }
+ st.uniform(gl, mgl_TextureSize);
+ }
- private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int hight) {
+ private void renderFBO(final GL2ES2 gl, final RenderState rs, final int width, final int height, int sampleCount) {
final ShaderState st = rs.getShaderState();
- gl.glViewport(0, 0, width, hight);
+ gl.glViewport(0, 0, width, height);
st.uniform(gl, mgl_ActiveTexture);
gl.glActiveTexture(GL.GL_TEXTURE0 + mgl_ActiveTexture.intValue());
- setTexSize(gl, st);
+ setTexSize(gl, st, false, sampleCount);
fbo.use(gl, texA);
verticeFboAttr.enableBuffer(gl, true);
@@ -279,7 +313,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
// setback: gl.glActiveTexture(currentActiveTextureEngine[0]);
}
- private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int targetFboWidth, final int targetFboHeight) {
+ private void renderRegion2FBO(final GL2ES2 gl, final RenderState rs, final int targetFboWidth, final int targetFboHeight, int sampleCount) {
final ShaderState st = rs.getShaderState();
if( 0 >= targetFboWidth || 0 >= targetFboHeight ) {
@@ -291,7 +325,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
fboHeight = targetFboHeight;
fbo = new FBObject();
fbo.reset(gl, fboWidth, fboHeight);
- // FIXME: shall not use bilinear (GL_LINEAR), due to own VBAA. Seems result is smooth w/o it now!
+ // Shall not use bilinear (GL_LINEAR), due to own VBAA. Result is smooth w/o it now!
// texA = fbo.attachTexture2D(gl, 0, true, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
texA = fbo.attachTexture2D(gl, 0, true, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE);
fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24);
@@ -309,6 +343,7 @@ public class VBORegion2PVBAAES2 extends GLRegion {
} else {
fbo.bind(gl);
}
+ setTexSize(gl, st, true, sampleCount);
//render texture
gl.glViewport(0, 0, fboWidth, fboHeight);
@@ -321,18 +356,6 @@ public class VBORegion2PVBAAES2 extends GLRegion {
st.uniform(gl, rs.getPMVMatrix()); // switch back to real PMV matrix
}
- private void setTexSize(final GL2ES2 gl, final ShaderState st) {
- // if( !gl.isGL3() ) {
- // GLSL < 1.30
- if(null == mgl_TextureSize) {
- mgl_TextureSize = new GLUniformData(UniformNames.gcu_TextureSize, 2, Buffers.newDirectFloatBuffer(2));
- }
- final FloatBuffer texSize = (FloatBuffer) mgl_TextureSize.getBuffer();
- texSize.put(0, fboWidth);
- texSize.put(1, fboHeight);
- st.uniform(gl, mgl_TextureSize);
- //}
- }
private void renderRegion(final GL2ES2 gl) {
verticeTxtAttr.enableBuffer(gl, true);