diff options
author | Sven Gothel <[email protected]> | 2012-07-20 09:27:54 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-07-20 09:27:54 +0200 |
commit | d1a1ad3599c3760d4e7ceecf35d15de485c8b652 (patch) | |
tree | 2874056c517536cd583f807e83760236bc2344a3 /src | |
parent | 2365d7278bc5a64b4ff7856fd01d75214ea0f555 (diff) |
Adapt to FBObject changes
Diffstat (limited to 'src')
-rwxr-xr-x | src/demos/cubefbo/FBCubes.java | 28 | ||||
-rwxr-xr-x | src/demos/es1/cubefbo/FBCubes.java | 48 |
2 files changed, 30 insertions, 46 deletions
diff --git a/src/demos/cubefbo/FBCubes.java b/src/demos/cubefbo/FBCubes.java index 765c37f..af5eeb4 100755 --- a/src/demos/cubefbo/FBCubes.java +++ b/src/demos/cubefbo/FBCubes.java @@ -36,16 +36,14 @@ package demos.cubefbo; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; -import javax.media.opengl.GLProfile; -import javax.media.opengl.DebugGL2; import javax.media.opengl.GL; -import javax.media.opengl.GL2ES1; import javax.media.opengl.GL2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; -import javax.media.opengl.awt.GLCanvas; -import com.jogamp.opengl.util.FBObject; +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.Attachment; +import com.jogamp.opengl.FBObject.TextureAttachment; class FBCubes implements GLEventListener, MouseListener, MouseMotionListener { @@ -55,19 +53,19 @@ class FBCubes implements GLEventListener, MouseListener, MouseMotionListener { cubeInner = new CubeObject(false); cubeMiddle = new CubeObject(true); cubeOuter = new CubeObject(true); - fbo1 = new FBObject(FBO_SIZE, FBO_SIZE); - fbo2 = new FBObject(FBO_SIZE, FBO_SIZE); + fbo1 = new FBObject(); + fbo2 = new FBObject(); } public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); - // drawable.setGL(new DebugGL2(gl)); - // gl = drawable.getGL().getGL2(); - fbo1.init(gl); - fbo1.attachTexture2D(gl, 0, gl.GL_NEAREST, gl.GL_NEAREST, 0, 0); + fbo1.reset(gl, FBO_SIZE, FBO_SIZE); + fbo1.attachTexture2D(gl, 0, true); + fbo1.attachRenderbuffer(gl, Attachment.Type.DEPTH, 32); fbo1.unbind(gl); - fbo2.init(gl); - fbo2.attachTexture2D(gl, 0, gl.GL_NEAREST, gl.GL_NEAREST, 0, 0); + fbo2.reset(gl, FBO_SIZE, FBO_SIZE); + fbo2.attachTexture2D(gl, 0, true); + fbo2.attachRenderbuffer(gl, Attachment.Type.DEPTH, 32); fbo2.unbind(gl); } @@ -115,7 +113,7 @@ class FBCubes implements GLEventListener, MouseListener, MouseMotionListener { for (int i = 0; i < MAX_ITER; i++) { rend.bind(gl); gl.glEnable (GL.GL_TEXTURE_2D); - tex.use(gl, 0); + tex.use(gl, (TextureAttachment)tex.getColorbuffer(0)); cubeMiddle.reshape(gl, 0, 0, FBO_SIZE, FBO_SIZE); cubeMiddle.display(gl, xRot, yRot); tex.unuse(gl); @@ -134,7 +132,7 @@ class FBCubes implements GLEventListener, MouseListener, MouseMotionListener { gl.glClearColor(0, 0, 0, 1); gl.glEnable (GL.GL_TEXTURE_2D); - tex.use(gl, 0); + tex.use(gl, (TextureAttachment)tex.getColorbuffer(0)); cubeOuter.display(gl, xRot, yRot); // System.out.println("display .. p8"); tex.unuse(gl); diff --git a/src/demos/es1/cubefbo/FBCubes.java b/src/demos/es1/cubefbo/FBCubes.java index b658798..5bdea5c 100755 --- a/src/demos/es1/cubefbo/FBCubes.java +++ b/src/demos/es1/cubefbo/FBCubes.java @@ -33,11 +33,17 @@ package demos.es1.cubefbo; +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.Attachment; +import com.jogamp.opengl.FBObject.TextureAttachment; +import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil; + import demos.es1.cube.Cube; -import java.nio.*; -import javax.media.opengl.*; -import com.jogamp.opengl.util.FBObject; -import com.jogamp.opengl.util.glsl.fixedfunc.*; public class FBCubes implements GLEventListener { private static final int FBO_SIZE = 256; @@ -45,7 +51,7 @@ public class FBCubes implements GLEventListener { public FBCubes () { cubeOuter = new Cube(true, false); - fbo1 = new FBObject(FBO_SIZE, FBO_SIZE); + fbo1 = new FBObject(); cubeInner = new Cube(false, true); // JAU cubeMiddle = new Cube(true, false); @@ -56,29 +62,9 @@ public class FBCubes implements GLEventListener { GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(drawable.getGL()); System.out.println(gl); - gl.glGetError(); // flush error .. - /* - if(gl.isGLES2()) { - GLES2 gles2 = gl.getGLES2(); - - // Debug .. - //DebugGLES2 gldbg = new DebugGLES2(gles2); - //gles2.getContext().setGL(gldbg); - //gles2 = gldbg; - - // Trace .. - //TraceGLES2 gltrace = new TraceGLES2(gles2, System.err); - gles2.getContext().setGL(gltrace); - gl = gltrace; - }*/ - - fbo1.init(gl); - fbo1.attachTexture2D(gl, 0, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, 0, 0); - fbo1.attachDepthBuffer(gl, GL.GL_DEPTH_COMPONENT16); - //fbo1.init(gl, GL.GL_RGB, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, 0, 0); // faster - //fbo1.init(gl, GL.GL_RGBA, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, 0, 0); // GLES2 default - //fbo1.init(gl, GL.GL_RGBA, GL.GL_RGBA, GL.GL_UNSIGNED_SHORT_5_5_5_1, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, 0, 0); // useless (1bit alpha) - //fbo1.init(gl, GL.GL_RGBA8, GL2.GL_BGRA, GL2.GL_UNSIGNED_INT_8_8_8_8_REV, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, 0, 0); // GL2 default + fbo1.reset(gl, FBO_SIZE, FBO_SIZE); + fbo1.attachTexture2D(gl, 0, true); + fbo1.attachRenderbuffer(gl, Attachment.Type.DEPTH, 32); fbo1.unbind(gl); cubeInner.init(drawable); @@ -116,12 +102,12 @@ public class FBCubes implements GLEventListener { gl.glFinish(); fbo1.unbind(gl); - gl.glEnable (gl.GL_TEXTURE_2D); - fbo1.use(gl, 0); + gl.glEnable (GL.GL_TEXTURE_2D); + fbo1.use(gl, (TextureAttachment)fbo1.getColorbuffer(0)); cubeOuter.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); cubeOuter.display(drawable); fbo1.unuse(gl); - gl.glDisable (gl.GL_TEXTURE_2D); + gl.glDisable (GL.GL_TEXTURE_2D); // JAUFBObject tex = fbo1; // JAU FBObject rend = fbo2; |