summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/demos/es1/RedSquare.java31
-rwxr-xr-xsrc/demos/es1/angeles/Angeles.java13
-rwxr-xr-xsrc/demos/es1/angeles/Main.java4
3 files changed, 28 insertions, 20 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java
index 4596310..2926746 100755
--- a/src/demos/es1/RedSquare.java
+++ b/src/demos/es1/RedSquare.java
@@ -2,8 +2,8 @@ package demos.es1;
import java.nio.*;
import javax.media.opengl.*;
+import javax.media.opengl.util.*;
import javax.media.opengl.glu.*;
-import com.sun.opengl.util.*;
import com.sun.javafx.newt.*;
@@ -37,6 +37,7 @@ public class RedSquare implements MouseListener {
public static void main(String[] args) {
System.out.println("RedSquare.main()");
+ GLProfile.setProfile(GLProfile.GLES1);
try {
Display display = NewtFactory.createDisplay(null); // local display
Screen screen = NewtFactory.createScreen(display, 0); // screen 0
@@ -52,7 +53,7 @@ public class RedSquare implements MouseListener {
window.setFullscreen(true);
// Hook this into EGL
- GLDrawableFactory factory = GLDrawableFactory.getFactory(GLDrawableFactory.PROFILE_GLES1, window);
+ GLDrawableFactory factory = GLDrawableFactory.getFactory(window);
GLCapabilities caps = new GLCapabilities();
// For emulation library, use 16 bpp
caps.setRedBits(5);
@@ -65,17 +66,17 @@ public class RedSquare implements MouseListener {
GLContext context = drawable.createContext(null);
context.makeCurrent();
- GL gl = context.getGL();
- GLU glu = new GLU();
+ GL2ES1 gl = context.getGL().getGL2ES1();
+ GLU glu = new javax.media.opengl.glu.es1.GLUes1();
//----------------------------------------------------------------------
// Code for GLEventListener.init()
//
System.out.println("Entering initialization");
- System.out.println("GL_VERSION=" + gl.glGetString(GL.GL_VERSION));
+ System.out.println("GL_VERSION=" + gl.glGetString(GL2ES1.GL_VERSION));
System.out.println("GL_EXTENSIONS:");
- System.out.println(" " + gl.glGetString(GL.GL_EXTENSIONS));
+ System.out.println(" " + gl.glGetString(GL2ES1.GL_EXTENSIONS));
// Allocate vertex arrays
FloatBuffer colors = BufferUtil.newFloatBuffer(16);
@@ -90,14 +91,14 @@ public class RedSquare implements MouseListener {
vertices.put(6, -2); vertices.put( 7, -2); vertices.put( 8, 0);
vertices.put(9, 2); vertices.put(10, -2); vertices.put(11, 0);
- gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
- gl.glVertexPointer(3, GL.GL_FLOAT, 0, vertices);
- gl.glEnableClientState(GL.GL_COLOR_ARRAY);
- gl.glColorPointer(4, GL.GL_FLOAT, 0, colors);
+ gl.glEnableClientState(GL2ES1.GL_VERTEX_ARRAY);
+ gl.glVertexPointer(3, GL2ES1.GL_FLOAT, 0, vertices);
+ gl.glEnableClientState(GL2ES1.GL_COLOR_ARRAY);
+ gl.glColorPointer(4, GL2ES1.GL_FLOAT, 0, colors);
// OpenGL Render Settings
gl.glClearColor(0, 0, 0, 1);
- gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glEnable(GL2ES1.GL_DEPTH_TEST);
//----------------------------------------------------------------------
// Code for GLEventListener.display()
@@ -106,16 +107,16 @@ public class RedSquare implements MouseListener {
long startTime = System.currentTimeMillis();
long curTime;
while (!ml.quit && ((curTime = System.currentTimeMillis()) - startTime) < 20000) {
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+ gl.glClear(GL2ES1.GL_COLOR_BUFFER_BIT | GL2ES1.GL_DEPTH_BUFFER_BIT);
// Set location in front of camera
width = window.getWidth();
height = window.getHeight();
gl.glViewport(0, 0, width, height);
- gl.glMatrixMode(GL.GL_PROJECTION);
+ gl.glMatrixMode(GL2ES1.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45.0f, (float)width / (float)height, 1.0f, 100.0f);
- gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0, 0, -10);
// One rotation every four seconds
@@ -123,7 +124,7 @@ public class RedSquare implements MouseListener {
gl.glRotatef(ang, 0, 0, 1);
// Draw a square
- gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
+ gl.glDrawArrays(GL2ES1.GL_TRIANGLE_STRIP, 0, 4);
drawable.swapBuffers();
diff --git a/src/demos/es1/angeles/Angeles.java b/src/demos/es1/angeles/Angeles.java
index c298adb..e793be2 100755
--- a/src/demos/es1/angeles/Angeles.java
+++ b/src/demos/es1/angeles/Angeles.java
@@ -249,7 +249,7 @@ public class GLObject {
void seal()
{
- rewind();
+ flip();
vbo = new int[3];
gl.glGenBuffers(3, vbo, 0);
@@ -263,10 +263,10 @@ public class GLObject {
if (null!=normalArray)
{
+ gl.glEnableClientState(gl.GL_NORMAL_ARRAY);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[2]);
gl.glBufferData(GL.GL_ARRAY_BUFFER, normalArray.capacity() * BufferUtil.SIZEOF_INT, normalArray, GL.GL_STATIC_DRAW);
gl.glNormalPointer(gl.GL_FLOAT, 0, 0);
- gl.glEnableClientState(gl.GL_NORMAL_ARRAY);
} else {
gl.glDisableClientState(gl.GL_NORMAL_ARRAY);
}
@@ -281,9 +281,9 @@ public class GLObject {
if (null!=normalArray)
{
+ gl.glEnableClientState(gl.GL_NORMAL_ARRAY);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[2]);
gl.glNormalPointer(gl.GL_FIXED, 0, 0);
- gl.glEnableClientState(gl.GL_NORMAL_ARRAY);
}
else
gl.glDisableClientState(gl.GL_NORMAL_ARRAY);
@@ -297,6 +297,13 @@ public class GLObject {
normalArray.rewind();
}
}
+ void flip() {
+ vertexArray.flip();
+ colorArray.flip();
+ if (normalArray != null) {
+ normalArray.flip();
+ }
+ }
}
long sStartTick = 0;
diff --git a/src/demos/es1/angeles/Main.java b/src/demos/es1/angeles/Main.java
index 20a9f0a..563e554 100755
--- a/src/demos/es1/angeles/Main.java
+++ b/src/demos/es1/angeles/Main.java
@@ -81,8 +81,8 @@ public class Main implements MouseListener {
dt0 = curTime-lastTime;
if ( (curTime-lastTime) > 5000 ) {
dt1 = curTime-startTime;
- System.out.println(curTime/1000+"s, 5s: "+ (lastFrames*1000)/dt0 + " fps, "+
- "total: "+ (totalFrames*1000)/dt1 + " fps");
+ System.out.println(dt1/1000+"s, 5s: "+ (lastFrames*1000)/dt0 + " fps, "+
+ "total: "+ (totalFrames*1000)/dt1 + " fps");
lastTime=curTime;
lastFrames=0;
}