summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/demos/es1/angeles/AngelesES1.java37
-rwxr-xr-xsrc/demos/es1/angeles/AngelesGL.java92
-rwxr-xr-xsrc/demos/es1/angeles/Main.java28
-rw-r--r--src/demos/es1/cube/Cube.java1
-rwxr-xr-xsrc/demos/es1/cubefbo/FBCubes.java16
-rwxr-xr-xwince/angeles-es2-args.txt2
-rwxr-xr-xwince/angeles-es2-noblend-args.txt1
-rwxr-xr-xwince/angeles-es2-noblend.lnk1
8 files changed, 119 insertions, 59 deletions
diff --git a/src/demos/es1/angeles/AngelesES1.java b/src/demos/es1/angeles/AngelesES1.java
index 19a1900..8638317 100755
--- a/src/demos/es1/angeles/AngelesES1.java
+++ b/src/demos/es1/angeles/AngelesES1.java
@@ -31,7 +31,8 @@ import java.nio.*;
public class AngelesES1 implements GLEventListener {
- public AngelesES1() {
+ public AngelesES1(boolean enableBlending) {
+ blendingEnabled = enableBlending;
quadVertices = BufferUtil.newIntBuffer(12);
quadVertices.put(new int[]{
-0x10000, -0x10000,
@@ -165,19 +166,23 @@ public class AngelesES1 implements GLEventListener {
// Configure environment.
configureLightAndMaterial();
- // Draw the reflection by drawing models with negated Z-axis.
- gl.glPushMatrix();
- drawModels(-1);
- gl.glPopMatrix();
+ if(blendingEnabled) {
+ // Draw the reflection by drawing models with negated Z-axis.
+ gl.glPushMatrix();
+ drawModels(-1);
+ gl.glPopMatrix();
+ }
- // Blend the ground plane to the window.
+ // Draw the ground plane to the window. (opt. blending)
drawGroundPlane();
// Draw all the models normally.
drawModels(1);
- // Draw fade quad over whole window (when changing cameras).
- drawFadeQuad();
+ if(blendingEnabled) {
+ // Draw fade quad over whole window (when changing cameras).
+ drawFadeQuad();
+ }
frames++;
tick = System.currentTimeMillis();
@@ -188,6 +193,7 @@ public class AngelesES1 implements GLEventListener {
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}
+ private boolean blendingEnabled = true;
private GLES1 gl;
private GLU glu;
@@ -563,17 +569,20 @@ GLObject createGroundPlane()
void drawGroundPlane()
{
- gl.glDisable(gl.GL_CULL_FACE);
- gl.glDisable(gl.GL_DEPTH_TEST);
- gl.glEnable(gl.GL_BLEND);
- gl.glBlendFunc(gl.GL_ZERO, gl.GL_SRC_COLOR);
gl.glDisable(gl.GL_LIGHTING);
+ gl.glDisable(gl.GL_DEPTH_TEST);
+ if(blendingEnabled) {
+ gl.glEnable(gl.GL_BLEND);
+ gl.glBlendFunc(gl.GL_ZERO, gl.GL_SRC_COLOR);
+ }
sGroundPlane.draw();
- gl.glEnable(gl.GL_LIGHTING);
- gl.glDisable(gl.GL_BLEND);
+ if(blendingEnabled) {
+ gl.glDisable(gl.GL_BLEND);
+ }
gl.glEnable(gl.GL_DEPTH_TEST);
+ gl.glEnable(gl.GL_LIGHTING);
}
void drawFadeQuad()
diff --git a/src/demos/es1/angeles/AngelesGL.java b/src/demos/es1/angeles/AngelesGL.java
index db2612f..046f5dd 100755
--- a/src/demos/es1/angeles/AngelesGL.java
+++ b/src/demos/es1/angeles/AngelesGL.java
@@ -31,7 +31,8 @@ import java.nio.*;
public class AngelesGL implements GLEventListener {
- public AngelesGL() {
+ public AngelesGL(boolean enableBlending) {
+ blendingEnabled = enableBlending;
quadVertices = BufferUtil.newFloatBuffer(12);
quadVertices.put(new float[]{
-1.0f, -1.0f,
@@ -87,6 +88,7 @@ public class AngelesGL implements GLEventListener {
gl.glEnable(GL2ES1.GL_NORMALIZE);
gl.glEnable(gl.GL_DEPTH_TEST);
gl.glDisable(gl.GL_CULL_FACE);
+ gl.glCullFace(GL.GL_BACK);
gl.glShadeModel(gl.GL_FLAT);
gl.glEnable(gl.GL_LIGHTING);
@@ -107,6 +109,22 @@ public class AngelesGL implements GLEventListener {
sStartTick = System.currentTimeMillis();
frames=0;
+
+ /*
+ 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);
+ gles2 = gltrace;
+ } */
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
@@ -122,9 +140,7 @@ public class AngelesGL implements GLEventListener {
gl.glClearColor(0.1f, 0.2f, 0.3f, 1.0f);
- gl.glCullFace(GL.GL_FRONT);
-
- gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST);
+ // JAU gl.glHint(GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST);
//gl.glShadeModel(GL.GL_SMOOTH);
gl.glShadeModel(gl.GL_FLAT);
@@ -134,7 +150,7 @@ public class AngelesGL implements GLEventListener {
//gl.glLoadIdentity();
//glu.gluPerspective(45.0f, (float)width / (float)height, 0.5f, 150.0f);
- System.out.println("reshape ..");
+ //System.out.println("reshape ..");
}
public void display(GLAutoDrawable drawable) {
@@ -167,19 +183,28 @@ public class AngelesGL implements GLEventListener {
// Configure environment.
configureLightAndMaterial();
- // Draw the reflection by drawing models with negated Z-axis.
- gl.glPushMatrix();
- drawModels(-1);
- gl.glPopMatrix();
+ if(blendingEnabled) {
+ gl.glEnable(gl.GL_CULL_FACE);
+ // Draw the reflection by drawing models with negated Z-axis.
+ gl.glPushMatrix();
+ drawModels(-1);
+ gl.glPopMatrix();
+ }
- // Blend the ground plane to the window.
+ // Draw the ground plane to the window. (opt. blending)
drawGroundPlane();
+ if(blendingEnabled) {
+ gl.glDisable(gl.GL_CULL_FACE);
+ }
+
// Draw all the models normally.
drawModels(1);
- // Draw fade quad over whole window (when changing cameras).
- drawFadeQuad();
+ if(blendingEnabled) {
+ // Draw fade quad over whole window (when changing cameras).
+ drawFadeQuad();
+ }
frames++;
tick = System.currentTimeMillis();
@@ -188,6 +213,7 @@ public class AngelesGL implements GLEventListener {
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}
+ private boolean blendingEnabled = true;
private GL gl;
private GLU glu;
@@ -231,8 +257,10 @@ public class GLObject {
count = vertices;
vertexArray = GLArrayDataServer.createFixed(GL.GL_VERTEX_ARRAY, null, vertexComponents,
GL.GL_FLOAT, false, vertices, GL.GL_STATIC_DRAW);
+ vertexArray.setEnableAlways(true);
colorArray = GLArrayDataServer.createFixed(GL.GL_COLOR_ARRAY, null, 4,
GL.GL_FLOAT, false, vertices, GL.GL_STATIC_DRAW);
+ colorArray.setEnableAlways(true);
if(useNormalArray) {
normalArray = GLArrayDataServer.createFixed(GL.GL_NORMAL_ARRAY, null, 3,
GL.GL_FLOAT, false, vertices, GL.GL_STATIC_DRAW);
@@ -256,8 +284,7 @@ public class GLObject {
if(null!=normalArray) {
normalArray().position( count * normalArray.getComponentNumber() );
normalArray.seal(gl, true);
- } else {
- gl.glDisableClientState(gl.GL_NORMAL_ARRAY);
+ normalArray.enableBuffer(gl, false);
}
}
@@ -273,11 +300,11 @@ public class GLObject {
gl.glDrawArrays(gl.GL_TRIANGLES, 0, vertexArray.getElementNumber());
- vertexArray.enableBuffer(gl, false);
- colorArray.enableBuffer(gl, false);
+ // System.out.println(gl);
+
if(null!=normalArray) {
normalArray.enableBuffer(gl, false);
- }
+ }
}
}
@@ -501,8 +528,9 @@ GLObject createGroundPlane()
GLObject result;
int x, y;
int currentVertex, currentQuad;
+ final int vcomps = 2;
- result = new GLObject(vertices, 2, false);
+ result = new GLObject(vertices, vcomps, false);
if (result == null)
return null;
@@ -515,7 +543,7 @@ GLObject createGroundPlane()
{
float color;
int i, a;
- color = ((float)((randomUInt() & 0x5f) + 81))/255.0f; // 101 1111
+ color = ((float)(randomUInt() % 255))/255.0f;
for (i = currentVertex * 4; i < (currentVertex + 6) * 4; i += 4)
{
result.colorArray().put(i, color);
@@ -532,8 +560,11 @@ GLObject createGroundPlane()
final int xm = x + ((0x1c >> a) & 1);
final int ym = y + ((0x31 >> a) & 1);
final float m = (float)(Math.cos(xm * 2) * Math.sin(ym * 4) * 0.75f);
- result.vertexArray().put(currentVertex * 2, (xm * scale + m));
- result.vertexArray().put(currentVertex * 2 + 1, (ym * scale + m));
+ result.vertexArray().put(currentVertex * vcomps, (xm * scale + m));
+ result.vertexArray().put(currentVertex * vcomps + 1, (ym * scale + m));
+ if(2<vcomps) {
+ result.vertexArray().put(currentVertex * vcomps + 2, 0f);
+ }
++currentVertex;
}
++currentQuad;
@@ -546,17 +577,20 @@ GLObject createGroundPlane()
void drawGroundPlane()
{
- gl.glDisable(gl.GL_CULL_FACE);
- gl.glDisable(gl.GL_DEPTH_TEST);
- gl.glEnable(gl.GL_BLEND);
- gl.glBlendFunc(gl.GL_ZERO, gl.GL_SRC_COLOR);
gl.glDisable(gl.GL_LIGHTING);
+ gl.glDisable(gl.GL_DEPTH_TEST);
+ if(blendingEnabled) {
+ gl.glEnable(gl.GL_BLEND);
+ gl.glBlendFunc(gl.GL_ZERO, gl.GL_SRC_COLOR);
+ }
sGroundPlane.draw();
- gl.glEnable(gl.GL_LIGHTING);
- gl.glDisable(gl.GL_BLEND);
+ if(blendingEnabled) {
+ gl.glDisable(gl.GL_BLEND);
+ }
gl.glEnable(gl.GL_DEPTH_TEST);
+ gl.glEnable(gl.GL_LIGHTING);
}
void drawFadeQuad()
@@ -584,10 +618,10 @@ void drawFadeQuad()
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
gl.glDisableClientState(gl.GL_COLOR_ARRAY);
gl.glDisableClientState(gl.GL_NORMAL_ARRAY);
+ gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
gl.glVertexPointer(2, gl.GL_FLOAT, 0, quadVertices);
gl.glDrawArrays(gl.GL_TRIANGLES, 0, 6);
-
- gl.glEnableClientState(gl.GL_COLOR_ARRAY);
+ gl.glDisableClientState(gl.GL_VERTEX_ARRAY);
gl.glMatrixMode(gl.GL_MODELVIEW);
diff --git a/src/demos/es1/angeles/Main.java b/src/demos/es1/angeles/Main.java
index f4ea346..7e5ed80 100755
--- a/src/demos/es1/angeles/Main.java
+++ b/src/demos/es1/angeles/Main.java
@@ -10,17 +10,7 @@ public class Main implements MouseListener {
public GLWindow window = null;
public void mouseClicked(MouseEvent e) {
- //System.out.println(e);
- switch(e.getClickCount()) {
- case 1:
- if(null!=window) {
- window.setFullscreen(!window.isFullscreen());
- }
- break;
- default:
- quit=true;
- break;
- }
+ quit=true;
}
public void mouseEntered(MouseEvent e) {
}
@@ -55,6 +45,12 @@ public class Main implements MouseListener {
caps.setRedBits(5);
caps.setGreenBits(6);
caps.setBlueBits(5);
+ /*
+ caps.setRedBits(8);
+ caps.setGreenBits(8);
+ caps.setBlueBits(8);
+ caps.setAlphaBits(8);
+ */
caps.setDepthBits(16);
window = GLWindow.create(nWindow, caps);
@@ -68,11 +64,11 @@ public class Main implements MouseListener {
GL gl = window.getGL();
if(gl.isGLES1() && 0==(type&USE_ANGELESF)) {
System.out.println("Using: AngelesES1 .. ");
- AngelesES1 angel = new AngelesES1();
+ AngelesES1 angel = new AngelesES1( 0 == (type&USE_NOBLEND) );
window.addGLEventListener(angel);
} else {
System.out.println("Using: AngelesGL .. ");
- AngelesGL angel = new AngelesGL();
+ AngelesGL angel = new AngelesGL( 0 == (type&USE_NOBLEND) );
window.addGLEventListener(angel);
}
@@ -92,15 +88,17 @@ public class Main implements MouseListener {
public static int USE_NEWT = 0;
public static int USE_AWT = 1 << 0;
public static int USE_ANGELESF = 1 << 1;
+ public static int USE_NOBLEND = 1 << 2;
public static void main(String[] args) {
int type = USE_NEWT ;
for(int i=args.length-1; i>=0; i--) {
if(args[i].equals("-awt")) {
type |= USE_AWT;
- }
- if(args[i].equals("-angelesf")) {
+ } else if(args[i].equals("-angelesf")) {
type |= USE_ANGELESF;
+ } else if(args[i].equals("-noblend")) {
+ type |= USE_NOBLEND;
}
}
new Main().run(type);
diff --git a/src/demos/es1/cube/Cube.java b/src/demos/es1/cube/Cube.java
index ffee97d..d46e87d 100644
--- a/src/demos/es1/cube/Cube.java
+++ b/src/demos/es1/cube/Cube.java
@@ -185,6 +185,7 @@ public class Cube implements GLEventListener {
gl.glDrawElements(gl.GL_TRIANGLES, 6 * 6, gl.GL_UNSIGNED_BYTE, cubeIndices);
// gl.glFinish();
+ // System.err.println(gl);
time += 0.01f;
}
diff --git a/src/demos/es1/cubefbo/FBCubes.java b/src/demos/es1/cubefbo/FBCubes.java
index ed19c0a..a97ee1c 100755
--- a/src/demos/es1/cubefbo/FBCubes.java
+++ b/src/demos/es1/cubefbo/FBCubes.java
@@ -59,6 +59,22 @@ class FBCubes implements GLEventListener {
System.err.println("FBCubes Fixed emu: FIXED_EMULATION_VERTEXCOLORTEXTURE");
}
+ 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.init(gl, GL.GL_RGB, GL.GL_RGB, GL.GL_UNSIGNED_BYTE); // faster
//fbo1.init(gl, GL.GL_RGBA, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE); // GLES2 default
diff --git a/wince/angeles-es2-args.txt b/wince/angeles-es2-args.txt
index 89f6bac..a981e40 100755
--- a/wince/angeles-es2-args.txt
+++ b/wince/angeles-es2-args.txt
@@ -1 +1 @@
-"-Dsun.boot.library.path=\Storage Card\bin" "-Xbootclasspath/a:\Storage Card\gluegen-rt.jar" "-Xbootclasspath/a:\Storage Card\jogl.core.jar" "-Xbootclasspath/a:\Storage Card\jogl.egl.jar" "-Xbootclasspath/a:\Storage Card\jogl.gles2.jar" "-Xbootclasspath/a:\Storage Card\jogl.fixed.jar""-Xbootclasspath/a:\Storage Card\newt.jar" "-Xbootclasspath/a:\Storage Card\jogl-demos.jar" "-Xopt:stdioPrefix=\Storage Card" demos.es1.angeles.Main
+"-Dsun.boot.library.path=\Storage Card\bin" "-Xbootclasspath/a:\Storage Card\gluegen-rt.jar" "-Xbootclasspath/a:\Storage Card\jogl.core.jar" "-Xbootclasspath/a:\Storage Card\jogl.egl.jar" "-Xbootclasspath/a:\Storage Card\jogl.gles2.jar" "-Xbootclasspath/a:\Storage Card\jogl.gles2.dbg.jar" "-Xbootclasspath/a:\Storage Card\jogl.fixed.jar" "-Xbootclasspath/a:\Storage Card\newt.jar" "-Xbootclasspath/a:\Storage Card\jogl-demos.jar" "-Xopt:stdioPrefix=\Storage Card" demos.es1.angeles.Main
diff --git a/wince/angeles-es2-noblend-args.txt b/wince/angeles-es2-noblend-args.txt
new file mode 100755
index 0000000..a54f1c7
--- /dev/null
+++ b/wince/angeles-es2-noblend-args.txt
@@ -0,0 +1 @@
+"-Dsun.boot.library.path=\Storage Card\bin" "-Xbootclasspath/a:\Storage Card\gluegen-rt.jar" "-Xbootclasspath/a:\Storage Card\jogl.core.jar" "-Xbootclasspath/a:\Storage Card\jogl.egl.jar" "-Xbootclasspath/a:\Storage Card\jogl.gles2.jar" "-Xbootclasspath/a:\Storage Card\jogl.gles2.dbg.jar" "-Xbootclasspath/a:\Storage Card\jogl.fixed.jar" "-Xbootclasspath/a:\Storage Card\newt.jar" "-Xbootclasspath/a:\Storage Card\jogl-demos.jar" "-Xopt:stdioPrefix=\Storage Card" demos.es1.angeles.Main -noblend
diff --git a/wince/angeles-es2-noblend.lnk b/wince/angeles-es2-noblend.lnk
new file mode 100755
index 0000000..9ebee78
--- /dev/null
+++ b/wince/angeles-es2-noblend.lnk
@@ -0,0 +1 @@
+01#"\Storage Card\bin\cvm.exe" -f "\Storage Card\angeles-es2-noblend-args.txt"