summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-05 03:46:59 -0700
committerSven Gothel <[email protected]>2009-10-05 03:46:59 -0700
commitb737b3b5efa42136f5b5348e09e2e592b4fc9863 (patch)
tree3fbdd37688e1852c88456a7f79c77c8d189c6470
parent7997824464198164a74f4d20620d2f432578024c (diff)
Fix ReadBuffer ..
-rwxr-xr-xsrc/demos/readbuffer/Main.java1
-rwxr-xr-xsrc/demos/readbuffer/ReadBuffer2Screen.java25
-rwxr-xr-xsrc/demos/readbuffer/ReadBufferUtil.java3
3 files changed, 24 insertions, 5 deletions
diff --git a/src/demos/readbuffer/Main.java b/src/demos/readbuffer/Main.java
index cf281b6..cbe9cfd 100755
--- a/src/demos/readbuffer/Main.java
+++ b/src/demos/readbuffer/Main.java
@@ -58,6 +58,7 @@ public class Main implements WindowListener, MouseListener, SurfaceUpdatedListen
GLCapabilities capsOffscreen = (GLCapabilities) caps.clone();
capsOffscreen.setOnscreen(false);
capsOffscreen.setPBuffer(true);
+ capsOffscreen.setDoubleBuffered(false);
GLWindow windowOffscreen = GLWindow.create(capsOffscreen);
windowOffscreen.enablePerfLog(true);
windowOffscreen.setSize(w, h);
diff --git a/src/demos/readbuffer/ReadBuffer2Screen.java b/src/demos/readbuffer/ReadBuffer2Screen.java
index 48db635..4d10fcc 100755
--- a/src/demos/readbuffer/ReadBuffer2Screen.java
+++ b/src/demos/readbuffer/ReadBuffer2Screen.java
@@ -44,13 +44,16 @@ import javax.media.opengl.fixedfunc.GLPointerFunc;
import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureData;
import com.sun.opengl.util.texture.TextureCoords;
+import com.sun.opengl.util.GLArrayDataClient;
import com.sun.opengl.util.GLArrayDataServer;
import com.sun.opengl.util.BufferUtil;
public class ReadBuffer2Screen extends ReadBufferBase {
PMVMatrix pmvMatrix;
- GLArrayDataServer readTextureVertices = null;
- GLArrayDataServer readTextureCoords = null;
+ GLArrayDataClient readTextureVertices = null;
+ GLArrayDataClient readTextureCoords = null;
+ boolean enableBufferAlways = false; // FIXME
+ boolean enableBufferVBO = true; // FIXME
public ReadBuffer2Screen (GLDrawable externalRead) {
super(externalRead);
@@ -65,8 +68,12 @@ public class ReadBuffer2Screen extends ReadBufferBase {
float f_edge = 1f;
if(null==readTextureVertices) {
+ //readTextureVertices = GLArrayDataClient.createFixed(gl, GLPointerFunc.GL_VERTEX_ARRAY, "mgl_Vertex",
+ // 2, GL.GL_FLOAT, true, 4);
readTextureVertices = GLArrayDataServer.createFixed(gl, GLPointerFunc.GL_VERTEX_ARRAY, "mgl_Vertex",
2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW);
+ readTextureVertices.setEnableAlways(enableBufferAlways);
+ readTextureVertices.setVBOUsage(enableBufferVBO);
{
FloatBuffer vb = (FloatBuffer)readTextureVertices.getBuffer();
vb.put(-f_edge); vb.put(-f_edge);
@@ -75,6 +82,7 @@ public class ReadBuffer2Screen extends ReadBufferBase {
vb.put( f_edge); vb.put( f_edge);
}
readTextureVertices.seal(gl, true);
+ System.out.println(readTextureVertices);
}
// Clear background to gray
@@ -125,21 +133,27 @@ public class ReadBuffer2Screen extends ReadBufferBase {
void renderOffscreenTexture(GL gl) {
if(!readBufferUtil.isValid()) return;
- updateTextureCoords(gl, false);
-
// Now draw one quad with the texture
readBufferUtil.getTexture().enable();
readBufferUtil.getTexture().bind();
+
if(gl.isGL2ES1()) {
// gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, GL2ES1.GL_REPLACE);
gl.getGL2ES1().glTexEnvi(GL2ES1.GL_TEXTURE_ENV, GL2ES1.GL_TEXTURE_ENV_MODE, GL2ES1.GL_MODULATE);
}
+ updateTextureCoords(gl, false);
+
readTextureVertices.enableBuffer(gl, true);
if(null!=readTextureCoords) {
readTextureCoords.enableBuffer(gl, true);
}
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, readTextureVertices.getElementNumber());
+ /**
+ if(null!=readTextureCoords) {
+ readTextureCoords.enableBuffer(gl, false);
+ }
+ readTextureVertices.enableBuffer(gl, false); */
readBufferUtil.getTexture().disable();
}
@@ -148,6 +162,8 @@ public class ReadBuffer2Screen extends ReadBufferBase {
if(force || null==readTextureCoords) {
readTextureCoords = GLArrayDataServer.createFixed(gl, GLPointerFunc.GL_TEXTURE_COORD_ARRAY, "mgl_MultiTexCoord0",
2, GL.GL_FLOAT, true, 4, GL.GL_STATIC_DRAW);
+ readTextureCoords.setEnableAlways(enableBufferAlways);
+ readTextureCoords.setVBOUsage(enableBufferVBO);
{
TextureCoords coords = readBufferUtil.getTexture().getImageTexCoords();
FloatBuffer cb = (FloatBuffer)readTextureCoords.getBuffer();
@@ -157,6 +173,7 @@ public class ReadBuffer2Screen extends ReadBufferBase {
cb.put(coords.right()); cb.put(coords.top());
}
readTextureCoords.seal(gl, true);
+ System.out.println(readTextureCoords);
}
}
diff --git a/src/demos/readbuffer/ReadBufferUtil.java b/src/demos/readbuffer/ReadBufferUtil.java
index 96f4b06..1e79915 100755
--- a/src/demos/readbuffer/ReadBufferUtil.java
+++ b/src/demos/readbuffer/ReadBufferUtil.java
@@ -64,7 +64,8 @@ public class ReadBufferUtil {
readPixelSizeLast = readPixelSize ;
try {
readTextureData = new TextureData(
- gl.GL_RGBA,
+ // gl.isGL2GL3()?gl.GL_RGBA:gl.GL_RGB,
+ gl.GL_RGB,
drawable.getWidth(), drawable.getHeight(),
0,
gl.GL_RGB,