summaryrefslogtreecommitdiffstats
path: root/src/demos/es1/cube
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/es1/cube')
-rw-r--r--src/demos/es1/cube/Cube.java41
-rw-r--r--src/demos/es1/cube/CubeImmModeSink.java41
2 files changed, 18 insertions, 64 deletions
diff --git a/src/demos/es1/cube/Cube.java b/src/demos/es1/cube/Cube.java
index cc2f8e8..e472af0 100644
--- a/src/demos/es1/cube/Cube.java
+++ b/src/demos/es1/cube/Cube.java
@@ -37,10 +37,9 @@ 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 com.sun.javafx.newt.*;
+import com.sun.javafx.newt.opengl.*;
public class Cube implements GLEventListener {
boolean quit = false;
@@ -77,20 +76,7 @@ public class Cube implements GLEventListener {
}
public void init(GLAutoDrawable drawable) {
- 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);
- }
- }
+ GL2ES1 gl = GLFixedFuncUtil.getFixedFuncImpl(drawable.getGL());
glu = GLU.createGLU();
@@ -110,11 +96,7 @@ public class Cube 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;
- GLFixedFuncIf gl = GLFixedFuncUtil.getGLFixedFuncIf(drawable.getGL());
- GL2ES1 gl2es1=null;
- if(gl.isGL2ES1()) {
- gl2es1 = drawable.getGL().getGL2ES1();
- }
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
gl.glViewport(0, 0, width, height);
@@ -145,12 +127,10 @@ public class Cube implements GLEventListener {
gl.glDisable(gl.GL_LIGHT0);
}
gl.glEnable(gl.GL_CULL_FACE);
- if(null!=gl2es1) {
- gl.glEnable(gl.GL_NORMALIZE);
+ gl.glEnable(gl.GL_NORMALIZE);
- gl.glShadeModel(gl.GL_SMOOTH);
- gl.glDisable(GL.GL_DITHER);
- }
+ gl.glShadeModel(gl.GL_SMOOTH);
+ gl.glDisable(GL.GL_DITHER);
gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[0]);
@@ -173,17 +153,14 @@ public class Cube implements GLEventListener {
gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeTexCoords.limit() * BufferUtil.SIZEOF_SHORT, cubeTexCoords, GL.GL_STATIC_DRAW);
gl.glTexCoordPointer(2, gl.GL_SHORT, 0, 0);
/* issues an GL_INVALID_ENUM
- if(null!=gl2es1) {
- gl2es1.glTexEnvi(gl2es1.GL_TEXTURE_ENV, gl2es1.GL_TEXTURE_ENV_MODE, gl2es1.GL_INCR);
+ gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_INCR);
} */
} else {
gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY);
}
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
- if(null!=gl2es1) {
- gl2es1.glHint(gl2es1.GL_PERSPECTIVE_CORRECTION_HINT, gl2es1.GL_FASTEST);
- }
+ gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_FASTEST);
gl.glMatrixMode(gl.GL_PROJECTION);
gl.glLoadIdentity();
@@ -201,7 +178,7 @@ public class Cube implements GLEventListener {
}
public void display(GLAutoDrawable drawable) {
- GLFixedFuncIf gl = GLFixedFuncUtil.getGLFixedFuncIf(drawable.getGL());
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
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 235d376..9a9d7cf 100644
--- a/src/demos/es1/cube/CubeImmModeSink.java
+++ b/src/demos/es1/cube/CubeImmModeSink.java
@@ -36,11 +36,11 @@ 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 com.sun.opengl.util.*;
import java.nio.*;
import com.sun.javafx.newt.*;
+import com.sun.javafx.newt.opengl.*;
public class CubeImmModeSink implements GLEventListener {
boolean quit = false;
@@ -53,7 +53,7 @@ public class CubeImmModeSink implements GLEventListener {
ByteBuffer cubeIndices=null;
ImmModeSink vboCubeF = null;
- public void drawCube(GLFixedFuncIf gl, float extent) {
+ public void drawCube(GL2ES1 gl, float extent) {
if(cubeIndices==null) {
cubeIndices = BufferUtil.newByteBuffer(s_cubeIndices);
}
@@ -89,7 +89,7 @@ public class CubeImmModeSink implements GLEventListener {
private GLUquadric sphere=null;
private ImmModeSink vboSphere=null;
- public void drawSphere(GLFixedFuncIf gl, float radius, int slices, int stacks) {
+ public void drawSphere(GL2ES1 gl, float radius, int slices, int stacks) {
if(sphere==null) {
sphere = glu.gluNewQuadric();
sphere.enableImmModeSink(true);
@@ -114,7 +114,7 @@ public class CubeImmModeSink implements GLEventListener {
private GLUquadric cylinder=null;
private ImmModeSink vboCylinder=null;
- public void drawCylinder(GLFixedFuncIf gl, float radius, float halfHeight, int upAxis) {
+ public void drawCylinder(GL2ES1 gl, float radius, float halfHeight, int upAxis) {
if(cylinder==null) {
cylinder = glu.gluNewQuadric();
cylinder.enableImmModeSink(true);
@@ -167,20 +167,7 @@ public class CubeImmModeSink implements GLEventListener {
}
public void init(GLAutoDrawable drawable) {
- 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);
- }
- }
+ GL2ES1 gl = GLFixedFuncUtil.getFixedFuncImpl(drawable.getGL());
glu = GLU.createGLU();
@@ -208,11 +195,7 @@ 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;
- GLFixedFuncIf gl = GLFixedFuncUtil.getGLFixedFuncIf(drawable.getGL());
- GL2ES1 gl2es1=null;
- if(gl.isGL2ES1()) {
- gl2es1 = drawable.getGL().getGL2ES1();
- }
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
gl.glViewport(0, 0, width, height);
@@ -243,9 +226,7 @@ public class CubeImmModeSink implements GLEventListener {
gl.glShadeModel(gl.GL_SMOOTH);
gl.glDisable(gl.GL_DITHER);
- if(null!=gl2es1) {
- gl2es1.glHint(gl2es1.GL_PERSPECTIVE_CORRECTION_HINT, gl2es1.GL_FASTEST);
- }
+ gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_FASTEST);
gl.glMatrixMode(gl.GL_PROJECTION);
gl.glLoadIdentity();
@@ -263,11 +244,7 @@ public class CubeImmModeSink implements GLEventListener {
}
public void display(GLAutoDrawable drawable) {
- GLFixedFuncIf gl = GLFixedFuncUtil.getGLFixedFuncIf(drawable.getGL());
- GL2ES1 gl2es1=null;
- if(gl.isGL2ES1()) {
- gl2es1 = drawable.getGL().getGL2ES1();
- }
+ GL2ES1 gl = drawable.getGL().getGL2ES1();
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);