summaryrefslogtreecommitdiffstats
path: root/src/demos/es1/cube
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-03-05 01:25:12 +0000
committerSven Gothel <[email protected]>2009-03-05 01:25:12 +0000
commite03aaaf1b14cc40cb2c8f2158acf02390c4fafe6 (patch)
treecf7eacef23ee86b7e1dfddd69800eaa303ce399b /src/demos/es1/cube
parent612955ad82326024f5cb99d9fe4175dce78caa27 (diff)
- Fixed rootrel.build usage, this works properly through gluegen, jogl-demos and this build.
You can say -Drootrel.build=build-x86_64 for example. - Fixed jogl-demos in regard to this changeset - Gluegen - Fixed gluegen BuildComposablePipeline's 'getGL*' methods. Now they return 'this', otherwise the pipeline would be broken/removed. - Add BuildComposablePipeline CustomPipeline, which allows customized class composition with an interface (to be wrapped), prolog class and the downstream class. - Add GlueGen (incl. ant task) 'outputRootDir' to be able to set a top output root dir via ant / commandline. - GL fixed function - Package 'javax.media.opengl.sub.fixed.*' defines some fixed function interfaces. This allows partitioning of custom implementation. - Using gluegen's new CustomPipeline to compose a GLFixedFuncIf implementation, using a GL downstream and a GLFixedFuncHookIf prolog. The latter implements the fixed functionality. Example is the GLFixedFuncImpl. gl.getContext().setGL( new GLFixedFuncImpl(gl, new FixedFuncHook(gl.getGL2ES2())) ) ; or gl.getContext().setGL( new GLFixedFuncImpl(gl, gl.getGL2ES1()) ) ; - The example GLFixedFuncHookIf impl FixedFuncPipeline/ can be instantiated with custom shader code. - ES2 and all other interfaces only contain the original functionality, besides minor convenient data access methods. - Fix: GL2ES2 createCompileShader() and createLoadShader() is moved to ShaderCode util class. - Updated PMVMatrix - Add: GLAutoDrawable.setContext() .. and all it's implementations Necessary to set a new GLContext. - Add: GLContext getAttachedObject(int) and putAttachedObject(int, Object), to allow the user to attach application specific and TLS sensitive objects to the GLContext. - git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JOGL_2_SANDBOX@316 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/es1/cube')
-rw-r--r--src/demos/es1/cube/Cube.java46
-rw-r--r--src/demos/es1/cube/CubeImmModeSink.java56
2 files changed, 65 insertions, 37 deletions
diff --git a/src/demos/es1/cube/Cube.java b/src/demos/es1/cube/Cube.java
index b77c4e9..63bea14 100644
--- a/src/demos/es1/cube/Cube.java
+++ b/src/demos/es1/cube/Cube.java
@@ -31,10 +31,13 @@
*/
package demos.es1.cube;
+import java.nio.*;
import javax.media.opengl.*;
+import javax.media.opengl.sub.fixed.*;
import javax.media.opengl.util.*;
import javax.media.opengl.glu.*;
-import java.nio.*;
+import com.sun.opengl.util.glsl.fixed.*;
+import com.sun.opengl.impl.fixed.GLFixedFuncImpl;
import com.sun.javafx.newt.*;
@@ -71,13 +74,23 @@ public class Cube implements GLEventListener {
}
public void init(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
- glu = GLU.createGLU();
- if(gl.isGLES2()) {
- gl.getGLES2().enableFixedFunctionEmulationMode(GLES2.FIXED_EMULATION_VERTEXCOLORTEXTURE);
- System.err.println("Cubes Fixed emu: FIXED_EMULATION_VERTEXCOLORTEXTURE");
+ GLFixedFuncIf gl;
+ {
+ GL _gl = drawable.getGL();
+ if(!GLFixedFuncUtil.isGLFixedFuncIf(_gl)) {
+ if(_gl.isGLES2()) {
+ gl = new GLFixedFuncImpl(_gl, new FixedFuncHook(_gl.getGL2ES2()));
+ } else {
+ gl = new GLFixedFuncImpl(_gl, _gl.getGL2ES1());
+ }
+ _gl.getContext().setGL(gl);
+ } else {
+ gl = GLFixedFuncUtil.getGLFixedFuncIf(_gl);
+ }
}
+ glu = GLU.createGLU();
+
gl.glGenBuffers(4, vboNames, 0);
if(!innerCube) {
@@ -87,16 +100,17 @@ public class Cube implements GLEventListener {
System.err.println("GL_VERSION=" + gl.glGetString(gl.GL_VERSION));
System.err.println("GL_EXTENSIONS:");
System.err.println(" " + gl.glGetString(gl.GL_EXTENSIONS));
+ System.err.println("GLF:" + gl);
}
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
float aspect = (height != 0) ? ((float)width / (float)height) : 1.0f;
- GL gl = drawable.getGL();
- GL2ES1 glF=null;
+ GLFixedFuncIf gl = GLFixedFuncUtil.getGLFixedFuncIf(drawable.getGL());
+ GL2ES1 gl2es1=null;
if(gl.isGL2ES1()) {
- glF = drawable.getGL().getGL2ES1();
+ gl2es1 = drawable.getGL().getGL2ES1();
}
gl.glViewport(0, 0, width, height);
@@ -128,11 +142,11 @@ public class Cube implements GLEventListener {
gl.glDisable(gl.GL_LIGHT0);
}
gl.glEnable(gl.GL_CULL_FACE);
- if(null!=glF) {
+ if(null!=gl2es1) {
gl.glEnable(gl.GL_NORMALIZE);
gl.glShadeModel(gl.GL_SMOOTH);
- gl.glDisable(gl.GL_DITHER);
+ gl.glDisable(GL.GL_DITHER);
}
gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
@@ -155,16 +169,16 @@ public class Cube implements GLEventListener {
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[3]);
gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeTexCoords.limit() * BufferUtil.SIZEOF_SHORT, cubeTexCoords, GL.GL_STATIC_DRAW);
gl.glTexCoordPointer(2, gl.GL_SHORT, 0, 0);
- if(null!=glF) {
- glF.glTexEnvi(glF.GL_TEXTURE_ENV, glF.GL_TEXTURE_ENV_MODE, glF.GL_INCR);
+ if(null!=gl2es1) {
+ gl2es1.glTexEnvi(gl2es1.GL_TEXTURE_ENV, gl2es1.GL_TEXTURE_ENV_MODE, gl2es1.GL_INCR);
}
} else {
gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY);
}
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
- if(null!=glF) {
- glF.glHint(glF.GL_PERSPECTIVE_CORRECTION_HINT, glF.GL_FASTEST);
+ if(null!=gl2es1) {
+ gl2es1.glHint(gl2es1.GL_PERSPECTIVE_CORRECTION_HINT, gl2es1.GL_FASTEST);
}
gl.glMatrixMode(gl.GL_PROJECTION);
@@ -179,7 +193,7 @@ public class Cube implements GLEventListener {
}
public void display(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
+ GLFixedFuncIf gl = GLFixedFuncUtil.getGLFixedFuncIf(drawable.getGL());
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
diff --git a/src/demos/es1/cube/CubeImmModeSink.java b/src/demos/es1/cube/CubeImmModeSink.java
index a3f1570..c85fed0 100644
--- a/src/demos/es1/cube/CubeImmModeSink.java
+++ b/src/demos/es1/cube/CubeImmModeSink.java
@@ -32,8 +32,11 @@
package demos.es1.cube;
import javax.media.opengl.*;
+import javax.media.opengl.sub.fixed.*;
import javax.media.opengl.util.*;
import javax.media.opengl.glu.*;
+import com.sun.opengl.util.glsl.fixed.*;
+import com.sun.opengl.impl.fixed.GLFixedFuncImpl;
import java.nio.*;
import com.sun.javafx.newt.*;
@@ -47,7 +50,7 @@ public class CubeImmModeSink implements GLEventListener {
ByteBuffer cubeIndices=null;
ImmModeSink vboCubeF = null;
- public void drawCube(GL gl, float extent) {
+ public void drawCube(GLFixedFuncIf gl, float extent) {
if(cubeIndices==null) {
cubeIndices = BufferUtil.newByteBuffer(s_cubeIndices);
}
@@ -83,7 +86,7 @@ public class CubeImmModeSink implements GLEventListener {
private GLUquadric sphere=null;
private ImmModeSink vboSphere=null;
- public void drawSphere(GL gl, float radius, int slices, int stacks) {
+ public void drawSphere(GLFixedFuncIf gl, float radius, int slices, int stacks) {
if(sphere==null) {
sphere = glu.gluNewQuadric();
sphere.enableImmModeSink(true);
@@ -108,7 +111,7 @@ public class CubeImmModeSink implements GLEventListener {
private GLUquadric cylinder=null;
private ImmModeSink vboCylinder=null;
- public void drawCylinder(GL gl, float radius, float halfHeight, int upAxis) {
+ public void drawCylinder(GLFixedFuncIf gl, float radius, float halfHeight, int upAxis) {
if(cylinder==null) {
cylinder = glu.gluNewQuadric();
cylinder.enableImmModeSink(true);
@@ -161,13 +164,23 @@ public class CubeImmModeSink implements GLEventListener {
}
public void init(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
+ GLFixedFuncIf gl;
+ {
+ GL _gl = drawable.getGL();
+ if(!GLFixedFuncUtil.isGLFixedFuncIf(_gl)) {
+ if(_gl.isGLES2()) {
+ gl = new GLFixedFuncImpl(_gl, new FixedFuncHook(_gl.getGL2ES2()));
+ } else {
+ gl = new GLFixedFuncImpl(_gl, _gl.getGL2ES1());
+ }
+ _gl.getContext().setGL(gl);
+ } else {
+ gl = GLFixedFuncUtil.getGLFixedFuncIf(_gl);
+ }
+ }
glu = GLU.createGLU();
- if(gl.isGLES2()) {
- gl.getGLES2().enableFixedFunctionEmulationMode(GLES2.FIXED_EMULATION_VERTEXCOLORTEXTURE);
- System.err.println("CubeImmModeSink Fixed emu: FIXED_EMULATION_VERTEXCOLORTEXTURE");
- }
+
if(!innerCube) {
System.err.println("Entering initialization");
System.err.println("GL Profile: "+GLProfile.getProfile());
@@ -175,6 +188,7 @@ public class CubeImmModeSink implements GLEventListener {
System.err.println("GL_VERSION=" + gl.glGetString(gl.GL_VERSION));
System.err.println("GL_EXTENSIONS:");
System.err.println(" " + gl.glGetString(gl.GL_EXTENSIONS));
+ System.err.println("GLF:" + gl);
}
gl.glGetError(); // flush error ..
@@ -191,10 +205,10 @@ public class CubeImmModeSink implements GLEventListener {
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
float aspect = (height != 0) ? ((float)width / (float)height) : 1.0f;
- GL gl = drawable.getGL();
- GL2ES1 glF=null;
+ GLFixedFuncIf gl = GLFixedFuncUtil.getGLFixedFuncIf(drawable.getGL());
+ GL2ES1 gl2es1=null;
if(gl.isGL2ES1()) {
- glF = drawable.getGL().getGL2ES1();
+ gl2es1 = drawable.getGL().getGL2ES1();
}
gl.glViewport(0, 0, width, height);
@@ -215,19 +229,19 @@ public class CubeImmModeSink implements GLEventListener {
gl.glLightfv(gl.GL_LIGHT0, gl.GL_AMBIENT, light_ambient, 0);
gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, light_diffuse, 0);
gl.glLightfv(gl.GL_LIGHT0, gl.GL_SPECULAR, zero_vec4, 0);
- gl.glMaterialfv(glF.GL_FRONT_AND_BACK, glF.GL_SPECULAR, material_spec, 0);
- gl.glEnable(glF.GL_NORMALIZE);
+ gl.glMaterialfv(GL.GL_FRONT_AND_BACK, gl.GL_SPECULAR, material_spec, 0);
+ gl.glEnable(gl.GL_NORMALIZE);
gl.glEnable(gl.GL_LIGHTING);
gl.glEnable(gl.GL_LIGHT0);
gl.glEnable(gl.GL_COLOR_MATERIAL);
- gl.glEnable(gl.GL_CULL_FACE);
+ gl.glEnable(GL.GL_CULL_FACE);
gl.glShadeModel(gl.GL_SMOOTH);
gl.glDisable(gl.GL_DITHER);
- if(null!=glF) {
- glF.glHint(glF.GL_PERSPECTIVE_CORRECTION_HINT, glF.GL_FASTEST);
+ if(null!=gl2es1) {
+ gl2es1.glHint(gl2es1.GL_PERSPECTIVE_CORRECTION_HINT, gl2es1.GL_FASTEST);
}
gl.glMatrixMode(gl.GL_PROJECTION);
@@ -242,10 +256,10 @@ public class CubeImmModeSink implements GLEventListener {
}
public void display(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
- GL2ES1 glF=null;
+ GLFixedFuncIf gl = GLFixedFuncUtil.getGLFixedFuncIf(drawable.getGL());
+ GL2ES1 gl2es1=null;
if(gl.isGL2ES1()) {
- glF = drawable.getGL().getGL2ES1();
+ gl2es1 = drawable.getGL().getGL2ES1();
}
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
@@ -265,13 +279,13 @@ public class CubeImmModeSink implements GLEventListener {
}
if(true) {
- gl.glDisable(GL.GL_LIGHTING);
+ gl.glDisable(gl.GL_LIGHTING);
gl.glColor4f(0f, 1f, 0f, 1f);
gl.glPushMatrix();
gl.glTranslatef(15.0f, 0.0f, 0.0f);
drawSphere(gl, 5.0f, 10, 10);
gl.glPopMatrix();
- gl.glEnable(GL.GL_LIGHTING);
+ gl.glEnable(gl.GL_LIGHTING);
}
if(true) {