summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2008-06-25 09:40:13 +0000
committerSven Gothel <[email protected]>2008-06-25 09:40:13 +0000
commit7c1206b1833d973b30e1b26d978d0d95315b55b6 (patch)
tree1290309417627a3db9c80a0730c52454d0550a23
parent665ee403e75d7024f660993713a537234a2d0826 (diff)
JOGL2 GLES1 NEWT X11 - RedSquare - working
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@245 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
-rw-r--r--make/build.xml53
-rw-r--r--setenv-jogl.sh42
-rwxr-xr-xsrc/demos/es1/RedSquare.java31
-rwxr-xr-xsrc/demos/es1/angeles/Angeles.java13
-rwxr-xr-xsrc/demos/es1/angeles/Main.java4
5 files changed, 118 insertions, 25 deletions
diff --git a/make/build.xml b/make/build.xml
index 8306309..60c3268 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -57,7 +57,20 @@
</target>
<target name="init" depends="java.class.path.validate,setup.gles,setup.cg.excludes,skip.cg.excludes">
- <property name="jogl.jar" value="../../jogl/build/jogl.jar" />
+ <property name="jogl.core.jar" value="../../jogl/build/jogl.core.jar" />
+ <property name="jogl.oswin.jar" value="../../jogl/build/jogl.oswin.jar" />
+ <property name="jogl.gles1.jar" value="../../jogl/build/jogl.gles1.jar" />
+ <property name="jogl.gles1.dbg.jar" value="../../jogl/build/jogl.gles1.dbg.jar" />
+ <property name="jogl.gles2.jar" value="../../jogl/build/jogl.gles2.jar" />
+ <property name="jogl.gles2.dbg.jar" value="../../jogl/build/jogl.gles2.dbg.jar" />
+ <property name="jogl.egl.jar" value="../../jogl/build/jogl.egl.jar" />
+ <property name="jogl.gl2.jar" value="../../jogl/build/jogl.gl2.jar" />
+ <property name="jogl.gl2.dbg.jar" value="../../jogl/build/jogl.gl2.dbg.jar" />
+ <property name="jogl.awt.jar" value="../../jogl/build/jogl.awt.jar" />
+ <property name="jogl.util.jar" value="../../jogl/build/jogl.util.jar" />
+ <property name="jogl.util.awt.jar" value="../../jogl/build/jogl.util.awt.jar" />
+ <property name="jogl.util.gl2.jar" value="../../jogl/build/jogl.util.gl2.jar" />
+ <property name="newt.jar" value="../../jogl/build/newt.jar" />
<property name="joal.jar" value="../lib/joal.jar" />
<property name="joal-demos.jar" value="../lib/joal-demos.jar" />
<property name="simple-xml.jar" value="../lib/simple-xml-1.1.1.jar" />
@@ -93,7 +106,20 @@
<target name="all-desktop" unless="isGLES">
<mkdir dir="${classes}" />
<path id="jogl-demos.classpath">
- <pathelement location="${jogl.jar}" />
+ <pathelement location="${jogl.core.jar}" />
+ <pathelement location="${jogl.oswin.jar}" />
+ <pathelement location="${jogl.gles1.jar}" />
+ <pathelement location="${jogl.gles1.dbg.jar}" />
+ <pathelement location="${jogl.gles2.jar}" />
+ <pathelement location="${jogl.gles2.dbg.jar}" />
+ <pathelement location="${jogl.egl.jar}" />
+ <pathelement location="${jogl.gl2.jar}" />
+ <pathelement location="${jogl.gl2.dbg.jar}" />
+ <pathelement location="${jogl.awt.jar}" />
+ <pathelement location="${jogl.util.jar}" />
+ <pathelement location="${jogl.util.awt.jar}" />
+ <pathelement location="${jogl.util.gl2.jar}" />
+ <pathelement location="${newt.jar}" />
<pathelement location="${joal.jar}" />
<pathelement location="${joal-demos.jar}" />
<pathelement location="${simple-xml.jar}" />
@@ -143,11 +169,21 @@
</target>
<target name="all-gles1" if="isGLES1">
+ <echo message="classes destdir ${classes}" />
<mkdir dir="${classes}" />
<path id="jogl-demos.classpath">
- <pathelement location="${jogl.jar}" />
+ <pathelement location="${jogl.core.jar}" />
+ <pathelement location="${jogl.gles1.jar}" />
+ <pathelement location="${jogl.gles1.dbg.jar}" />
+ <pathelement location="${jogl.egl.jar}" />
+ <pathelement location="${newt.jar}" />
</path>
- <javac destdir="${classes}" includes="demos/es1/**" source="1.4" target="1.4" debug="true" debuglevel="source,lines"
+ <!--javac destdir="${classes}" includes="demos/es1/**" source="1.4" target="1.4" debug="true" debuglevel="source,lines"
+ bootclasspath="../../gluegen/make/lib/cdc_fp.jar">
+ <src path="${src}" />
+ <classpath refid="jogl-demos.classpath" />
+ </javac-->
+ <javac destdir="${classes}" includes="demos/es1/RedSquare.java" source="1.4" target="1.4" debug="true" debuglevel="source,lines"
bootclasspath="../../gluegen/make/lib/cdc_fp.jar">
<src path="${src}" />
<classpath refid="jogl-demos.classpath" />
@@ -156,13 +192,20 @@
<fileset dir="${classes}">
<include name="**" />
</fileset>
+ <fileset dir="${src}">
+ <include name="demos/es1/bump/*.brs" />
+ </fileset>
</jar>
</target>
<target name="all-gles2" if="isGLES2">
<mkdir dir="${classes}" />
<path id="jogl-demos.classpath">
- <pathelement location="${jogl.jar}" />
+ <pathelement location="${jogl.core.jar}" />
+ <pathelement location="${jogl.gles2.jar}" />
+ <pathelement location="${jogl.gles2.dbg.jar}" />
+ <pathelement location="${jogl.egl.jar}" />
+ <pathelement location="${newt.jar}" />
</path>
<javac destdir="${classes}" includes="demos/es2/**" source="1.4" target="1.4" debug="true" debuglevel="source,lines"
bootclasspath="../../gluegen/make/lib/cdc_fp.jar">
diff --git a/setenv-jogl.sh b/setenv-jogl.sh
new file mode 100644
index 0000000..3a58512
--- /dev/null
+++ b/setenv-jogl.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+if [ -z "$1" ] ; then
+ echo "Usage: $0 {JOGL_ALL|JOGL_ES1_MIN|JOGL_ES1_MAX|JOGL_ES2_MIN|JOGL_ES2_MAX|JOGL_GL2_MIN|JOGL_GL2_MAX}"
+else
+
+JOGL_PROFILE=$1
+shift
+
+CVSROOT=":pserver:[email protected]:/cvs"
+THISDIR="/usr/local/projects/SUN/JOGL2/jogl-demos"
+export CVSROOT THISDIR
+
+. /devtools/etc/profile.ant
+
+J2RE_HOME=/opt-linux-x86/jre-dev
+JAVA_HOME=/usr/local/projects/SUN/JDK6/control/build/linux-i586/j2sdk-image
+CP_SEP=:
+
+export LIBXCB_ALLOW_SLOPPY_LOCK=1
+
+PATH=/devtools/i686-unknown-linux-gnu/gcc-4.2.1-glibc-2.3.6/i686-unknown-linux-gnu/i686-unknown-linux-gnu/bin:$JAVA_HOME/bin:$PATH
+export PATH
+
+. $THISDIR/../jogl/etc/profile.jogl $THISDIR/../jogl/build $THISDIR/../jogl/build/obj $JOGL_PROFILE
+
+GLUEGEN_JAR=$THISDIR/../gluegen/build/gluegen-rt.jar
+GLUEGEN_OS=$THISDIR/../gluegen/build/obj
+
+LIB=$THISDIR/lib
+
+# CLASSPATH=$JAVA_HOME/jre/lib/rt.jar:.:build/classes
+CLASSPATH=.:$THISDIR/build/classes:$GLUEGEN_JAR:$JOGL_CLASSPATH
+for i in $LIB/*jar ; do
+ CLASSPATH=$CLASSPATH:$i
+done
+export CLASSPATH
+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GLUEGEN_OS:$THISDIR/../jogl/build/obj
+
+fi
+
+
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;
}