diff options
author | Kenneth Russel <[email protected]> | 2009-06-15 23:05:16 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2009-06-15 23:05:16 +0000 |
commit | 935d2596c13371bb745d921dbcb9f05b0c11a010 (patch) | |
tree | 7fcc310618ae5a90edc734dc821e75afc0f080aa /src/demos/es1 | |
parent | e2332d2f2908e68f1e77454c73f329f8ff2b400d (diff) |
Deleted obsolete source code in preparation for copying JOGL_2_SANDBOX
on to trunk
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@351 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/es1')
-rwxr-xr-x | src/demos/es1/RedSquare.java | 151 | ||||
-rwxr-xr-x | src/demos/es1/angeles/Angeles.java | 855 | ||||
-rwxr-xr-x | src/demos/es1/angeles/CamTrack.java | 71 | ||||
-rwxr-xr-x | src/demos/es1/angeles/Main.java | 115 | ||||
-rwxr-xr-x | src/demos/es1/angeles/SuperShape.java | 57 | ||||
-rwxr-xr-x | src/demos/es1/cubefbo/CubeObject.java | 250 | ||||
-rwxr-xr-x | src/demos/es1/cubefbo/FBCubes.java | 111 | ||||
-rwxr-xr-x | src/demos/es1/cubefbo/FBObject.java | 151 | ||||
-rwxr-xr-x | src/demos/es1/cubefbo/Main.java | 169 |
9 files changed, 0 insertions, 1930 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java deleted file mode 100755 index 81713ea..0000000 --- a/src/demos/es1/RedSquare.java +++ /dev/null @@ -1,151 +0,0 @@ -package demos.es1; - -import java.nio.*; -import javax.media.opengl.*; -import javax.media.opengl.util.*; -import javax.media.opengl.glu.*; - -import com.sun.javafx.newt.*; - -public class RedSquare implements MouseListener { - - public boolean quit = false; - public boolean toggleFS = false; - - public void mouseClicked(MouseEvent e) { - switch(e.getClickCount()) { - case 1: - toggleFS=true; - break; - default: - quit=true; - break; - } - } - public void mouseEntered(MouseEvent e) { - } - public void mouseExited(MouseEvent e) { - } - public void mousePressed(MouseEvent e) { - } - public void mouseReleased(MouseEvent e) { - } - public void mouseMoved(MouseEvent e) { - } - public void mouseDragged(MouseEvent e) { - } - - public static void main(String[] args) { - System.out.println("RedSquare.main()"); - GLProfile.setProfileGL2ES1(); - try { - Display display = NewtFactory.createDisplay(null); // local display - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Window window = NewtFactory.createWindow(screen, 0); // dummy VisualID - - RedSquare ml = new RedSquare(); - window.addMouseListener(ml); - - // Size OpenGL to Video Surface - int width = 800; - int height = 480; - window.setSize(width, height); - window.setFullscreen(true); - - // Hook this into EGL - GLDrawableFactory factory = GLDrawableFactory.getFactory(window); - GLCapabilities caps = new GLCapabilities(); - // For emulation library, use 16 bpp - caps.setRedBits(5); - caps.setGreenBits(6); - caps.setBlueBits(5); - caps.setDepthBits(16); - GLDrawable drawable = factory.createGLDrawable(window, caps, null); - window.setVisible(true); - drawable.setRealized(true); - GLContext context = drawable.createContext(null); - context.makeCurrent(); - - GL2ES1 gl = context.getGL().getGL2ES1(); - GLU glu = GLU.createGLU(gl); - - //---------------------------------------------------------------------- - // Code for GLEventListener.init() - // - - System.out.println("Entering initialization"); - System.out.println("GL_VERSION=" + gl.glGetString(GL2ES1.GL_VERSION)); - System.out.println("GL_EXTENSIONS:"); - System.out.println(" " + gl.glGetString(GL2ES1.GL_EXTENSIONS)); - - // Allocate vertex arrays - FloatBuffer colors = BufferUtil.newFloatBuffer(16); - FloatBuffer vertices = BufferUtil.newFloatBuffer(12); - // Fill them up - colors.put( 0, 1); colors.put( 1, 0); colors.put( 2, 0); colors.put( 3, 1); - colors.put( 4, 1); colors.put( 5, 0); colors.put( 6, 0); colors.put( 7, 1); - colors.put( 8, 1); colors.put( 9, 0); colors.put(10, 0); colors.put(11, 1); - colors.put(12, 1); colors.put(13, 0); colors.put(14, 0); colors.put(15, 1); - vertices.put(0, -2); vertices.put( 1, 2); vertices.put( 2, 0); - vertices.put(3, 2); vertices.put( 4, 2); vertices.put( 5, 0); - 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(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(GL2ES1.GL_DEPTH_TEST); - - //---------------------------------------------------------------------- - // Code for GLEventListener.display() - // - - long startTime = System.currentTimeMillis(); - long curTime; - while (!ml.quit && ((curTime = System.currentTimeMillis()) - startTime) < 20000) { - 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(GL2ES1.GL_PROJECTION); - gl.glLoadIdentity(); - glu.gluPerspective(45.0f, (float)width / (float)height, 1.0f, 100.0f); - gl.glMatrixMode(GL2ES1.GL_MODELVIEW); - gl.glLoadIdentity(); - gl.glTranslatef(0, 0, -10); - // One rotation every four seconds - float ang = (((float) (curTime - startTime)) * 360.0f) / 4000.0f; - gl.glRotatef(ang, 0, 0, 1); - - // Draw a square - gl.glDrawArrays(GL2ES1.GL_TRIANGLE_STRIP, 0, 4); - - drawable.swapBuffers(); - - if(ml.toggleFS) { - window.setFullscreen(!window.isFullscreen()); - ml.toggleFS=false; - } - - window.pumpMessages(); - } - - // Shut things down cooperatively - context.release(); - context.destroy(); - drawable.destroy(); - factory.shutdown(); - System.out.println("RedSquare shut down cleanly."); - } catch (Throwable t) { - t.printStackTrace(); - } - - System.exit(0); - } -} diff --git a/src/demos/es1/angeles/Angeles.java b/src/demos/es1/angeles/Angeles.java deleted file mode 100755 index e793be2..0000000 --- a/src/demos/es1/angeles/Angeles.java +++ /dev/null @@ -1,855 +0,0 @@ -/* San Angeles Observation OpenGL ES version example - * Copyright 2004-2005 Jetro Lauha - * All rights reserved. - * Web: http://iki.fi/jetro/ - * - * This source is free software; you can redistribute it and/or - * modify it under the terms of EITHER: - * (1) The GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. The text of the GNU Lesser - * General Public License is included with this source in the - * file LICENSE-LGPL.txt. - * (2) The BSD-style license that is included with this source in - * the file LICENSE-BSD.txt. - * - * This source is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details. - * - * $Id$ - * $Revision$ - */ - -package demos.es1.angeles; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import java.nio.*; - -public class Angeles /* implements GLEventListener */ { - - public Angeles() { - quadVertices = BufferUtil.newIntBuffer(12); - quadVertices.put(new int[]{ - -0x10000, -0x10000, - 0x10000, -0x10000, - -0x10000, 0x10000, - 0x10000, -0x10000, - 0x10000, 0x10000, - -0x10000, 0x10000 - }); - quadVertices.rewind(); - - light0Position=BufferUtil.newIntBuffer(4); - light0Diffuse=BufferUtil.newIntBuffer(4); - light1Position=BufferUtil.newIntBuffer(4); - light1Diffuse=BufferUtil.newIntBuffer(4); - light2Position=BufferUtil.newIntBuffer(4); - light2Diffuse=BufferUtil.newIntBuffer(4); - materialSpecular=BufferUtil.newIntBuffer(4); - - light0Position.put(new int[] { -0x40000, 0x10000, 0x10000, 0 }); - light0Diffuse.put(new int[] { 0x10000, 0x6666, 0, 0x10000 }); - light1Position.put(new int[] { 0x10000, -0x20000, -0x10000, 0 }); - light1Diffuse.put(new int[] { 0x11eb, 0x23d7, 0x5999, 0x10000 }); - light2Position.put(new int[] { -0x10000, 0, -0x40000, 0 }); - light2Diffuse.put(new int[] { 0x11eb, 0x2b85, 0x23d7, 0x10000 }); - materialSpecular.put(new int[] { 0x10000, 0x10000, 0x10000, 0x10000 }); - - light0Position.rewind(); - light0Diffuse.rewind(); - light1Position.rewind(); - light1Diffuse.rewind(); - light2Position.rewind(); - light2Diffuse.rewind(); - materialSpecular.rewind(); - - seedRandom(15); - - width=0; - height=0; - x=0; - y=0; - } - - public void init(GL gl) { - // FIXME: gl.setSwapInterval(1); - - this.gl = gl; - gl.glEnable(gl.GL_NORMALIZE); - gl.glEnable(gl.GL_DEPTH_TEST); - gl.glDisable(gl.GL_CULL_FACE); - gl.glShadeModel(gl.GL_FLAT); - - gl.glEnable(gl.GL_LIGHTING); - gl.glEnable(gl.GL_LIGHT0); - gl.glEnable(gl.GL_LIGHT1); - gl.glEnable(gl.GL_LIGHT2); - - gl.glEnableClientState(gl.GL_VERTEX_ARRAY); - gl.glEnableClientState(gl.GL_COLOR_ARRAY); - - for (int a = 0; a < SuperShape.COUNT; ++a) - { - sSuperShapeObjects[a] = createSuperShape(SuperShape.sParams[a]); - } - sGroundPlane = createGroundPlane(); - - gAppAlive = 1; - - sStartTick = System.currentTimeMillis(); - frames=0; - } - - public void reshape(GL gl, int x, int y, int width, int height) { - this.width = width; - this.height=height; - this.x = x; - this.y = y; - - this.gl = gl; - - gl.glMatrixMode(gl.GL_MODELVIEW); - gl.glLoadIdentity(); - - gl.glClearColorx((int)(0.1f * 65536), - (int)(0.2f * 65536), - (int)(0.3f * 65536), 0x10000); - - gl.glCullFace(GL.GL_FRONT); - - gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST); - - //gl.glShadeModel(GL.GL_SMOOTH); - gl.glShadeModel(GL.GL_FLAT); - gl.glDisable(GL.GL_DITHER); - - //gl.glMatrixMode(gl.GL_PROJECTION); - //gl.glLoadIdentity(); - //gluPerspective(45.0f, (float)width / (float)height, 0.5f, 150.0f); - - System.out.println("reshape .."); - } - - public void display(GL gl) { - long tick = System.currentTimeMillis(); - - if (gAppAlive==0) - return; - - this.gl = gl; - - // Actual tick value is "blurred" a little bit. - sTick = (sTick + tick - sStartTick) >> 1; - - // Terminate application after running through the demonstration once. - if (sTick >= RUN_LENGTH) - { - gAppAlive = 0; - return; - } - - gl.glClear(gl.GL_DEPTH_BUFFER_BIT | gl.GL_COLOR_BUFFER_BIT); - - gl.glMatrixMode(gl.GL_PROJECTION); - gl.glLoadIdentity(); - gluPerspective(45.0f, (float)width / (float)height, 0.5f, 150.0f); - - // Update the camera position and set the lookat. - camTrack(); - - // Configure environment. - configureLightAndMaterial(); - - // Draw the reflection by drawing models with negated Z-axis. - gl.glPushMatrix(); - drawModels(-1); - gl.glPopMatrix(); - - // Blend the ground plane to the window. - drawGroundPlane(); - - // Draw all the models normally. - drawModels(1); - - // Draw fade quad over whole window (when changing cameras). - drawFadeQuad(); - - frames++; - tick = System.currentTimeMillis(); - long dT = tick - sStartTick; - // System.out.println(frames+"f, "+dT+"ms "+ (frames*1000)/dT +"fps"); - } - - public void displayChanged(GL gl, boolean modeChanged, boolean deviceChanged) { - } - - private GL gl; - - // Total run length is 20 * camera track base unit length (see cams.h). - private int RUN_LENGTH = (20 * CamTrack.CAMTRACK_LEN) ; - private int RANDOM_UINT_MAX = 65535 ; - - private long sRandomSeed = 0; - -void seedRandom(long seed) -{ - sRandomSeed = seed; -} - -int randomUInt() -{ - sRandomSeed = sRandomSeed * 0x343fd + 0x269ec3; - return Math.abs((int) (sRandomSeed >> 16)); -} - - -// Capped conversion from float to fixed. -int FIXED(float value) -{ - if (value < -32768) value = -32768; - if (value > 32767) value = 32767; - return (int)(value * 65536); -} - -// Definition of one GL object in this demo. -public class GLObject { - /* Vertex array and color array are enabled for all objects, so their - * pointers must always be valid and non-null. Normal array is not - * used by the ground plane, so when its pointer is null then normal - * array usage is disabled. - * - * Vertex array is supposed to use gl.GL_FIXED datatype and stride 0 - * (i.e. tightly packed array). Color array is supposed to have 4 - * components per color with gl.GL_UNSIGNED_BYTE datatype and stride 0. - * Normal array is supposed to use gl.GL_FIXED datatype and stride 0. - */ - IntBuffer vertexArray; - ByteBuffer colorArray; - IntBuffer normalArray; - int vertexComponents; - int count; - int vbo[]; - - public GLObject(int vertices, int vertexComponents, - boolean useNormalArray) { - this.count = vertices; - this.vertexComponents = vertexComponents; - this.vertexArray = BufferUtil.newIntBuffer( vertices * vertexComponents ); - this.colorArray = BufferUtil.newByteBuffer (vertices * 4 ); - if (useNormalArray) - { - this.normalArray = BufferUtil.newIntBuffer (vertices * 3 ); - } else { - this.normalArray = null; - } - } - - void seal() - { - flip(); - vbo = new int[3]; - gl.glGenBuffers(3, vbo, 0); - - gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[0]); - gl.glBufferData(GL.GL_ARRAY_BUFFER, vertexArray.capacity() * BufferUtil.SIZEOF_INT, vertexArray, GL.GL_STATIC_DRAW); - gl.glVertexPointer(vertexComponents, gl.GL_FLOAT, 0, 0); - - gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[1]); - gl.glBufferData(GL.GL_ARRAY_BUFFER, colorArray.capacity() * BufferUtil.SIZEOF_BYTE, colorArray, GL.GL_STATIC_DRAW); - gl.glColorPointer(4, gl.GL_UNSIGNED_BYTE, 0, 0); - - 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); - } else { - gl.glDisableClientState(gl.GL_NORMAL_ARRAY); - } - } - - void draw() - { - gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[0]); - gl.glVertexPointer(vertexComponents, gl.GL_FIXED, 0, 0); - gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[1]); - gl.glColorPointer(4, gl.GL_UNSIGNED_BYTE, 0, 0); - - if (null!=normalArray) - { - gl.glEnableClientState(gl.GL_NORMAL_ARRAY); - gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[2]); - gl.glNormalPointer(gl.GL_FIXED, 0, 0); - } - else - gl.glDisableClientState(gl.GL_NORMAL_ARRAY); - gl.glDrawArrays(gl.GL_TRIANGLES, 0, count); - } - - void rewind() { - vertexArray.rewind(); - colorArray.rewind(); - if (normalArray != null) { - normalArray.rewind(); - } - } - void flip() { - vertexArray.flip(); - colorArray.flip(); - if (normalArray != null) { - normalArray.flip(); - } - } -} - -long sStartTick = 0; -long sTick = 0; - -int sCurrentCamTrack = 0; -long sCurrentCamTrackStartTick = 0; -long sNextCamTrackStartTick = 0x7fffffff; - -GLObject sSuperShapeObjects[] = new GLObject[SuperShape.COUNT]; -GLObject sGroundPlane; - - -public class VECTOR3 { - float x, y, z; - - public VECTOR3() { - x=0f; y=0f; z=0f; - } - public VECTOR3(float x, float y, float z) { - this.x=x; - this.y=y; - this.z=z; - } -} - - - -static void vector3Sub(VECTOR3 dest, VECTOR3 v1, VECTOR3 v2) -{ - dest.x = v1.x - v2.x; - dest.y = v1.y - v2.y; - dest.z = v1.z - v2.z; -} - - -static void superShapeMap(VECTOR3 point, float r1, float r2, float t, float p) -{ - // sphere-mapping of supershape parameters - point.x = (float)(Math.cos(t) * Math.cos(p) / r1 / r2); - point.y = (float)(Math.sin(t) * Math.cos(p) / r1 / r2); - point.z = (float)(Math.sin(p) / r2); -} - - -float ssFunc(final float t, final float p[]) -{ - return ssFunc(t, p, 0); -} - -float ssFunc(final float t, final float p[], int pOff) -{ - return (float)(Math.pow(Math.pow(Math.abs(Math.cos(p[0+pOff] * t / 4)) / p[1+pOff], p[4+pOff]) + - Math.pow(Math.abs(Math.sin(p[0+pOff] * t / 4)) / p[2+pOff], p[5+pOff]), 1 / p[3+pOff])); -} - - -// Creates and returns a supershape object. -// Based on Paul Bourke's POV-Ray implementation. -// http://astronomy.swin.edu.au/~pbourke/povray/supershape/ -GLObject createSuperShape(final float params[]) -{ - final int resol1 = (int)params[SuperShape.PARAMS - 3]; - final int resol2 = (int)params[SuperShape.PARAMS - 2]; - // latitude 0 to pi/2 for no mirrored bottom - // (latitudeBegin==0 for -pi/2 to pi/2 originally) - final int latitudeBegin = resol2 / 4; - final int latitudeEnd = resol2 / 2; // non-inclusive - final int longitudeCount = resol1; - final int latitudeCount = latitudeEnd - latitudeBegin; - final int triangleCount = longitudeCount * latitudeCount * 2; - final int vertices = triangleCount * 3; - GLObject result; - float baseColor[] = new float[3]; - int a, longitude, latitude; - int currentVertex, currentQuad; - - result = new GLObject(vertices, 3, true); - if (result == null) - return null; - - for (a = 0; a < 3; ++a) - baseColor[a] = ((randomUInt() % 155) + 100) / 255.f; - - currentQuad = 0; - currentVertex = 0; - - // longitude -pi to pi - for (longitude = 0; longitude < longitudeCount; ++longitude) - { - - // latitude 0 to pi/2 - for (latitude = latitudeBegin; latitude < latitudeEnd; ++latitude) - { - float t1 = (float) ( -Math.PI + longitude * 2 * Math.PI / resol1 ); - float t2 = (float) ( -Math.PI + (longitude + 1) * 2 * Math.PI / resol1 ); - float p1 = (float) ( -Math.PI / 2 + latitude * 2 * Math.PI / resol2 ); - float p2 = (float) ( -Math.PI / 2 + (latitude + 1) * 2 * Math.PI / resol2 ); - float r0, r1, r2, r3; - - r0 = ssFunc(t1, params); - r1 = ssFunc(p1, params, 6); - r2 = ssFunc(t2, params); - r3 = ssFunc(p2, params, 6); - - if (r0 != 0 && r1 != 0 && r2 != 0 && r3 != 0) - { - VECTOR3 pa=new VECTOR3(), pb=new VECTOR3(), pc=new VECTOR3(), pd=new VECTOR3(); - VECTOR3 v1=new VECTOR3(), v2=new VECTOR3(), n=new VECTOR3(); - float ca; - int i; - //float lenSq, invLenSq; - - superShapeMap(pa, r0, r1, t1, p1); - superShapeMap(pb, r2, r1, t2, p1); - superShapeMap(pc, r2, r3, t2, p2); - superShapeMap(pd, r0, r3, t1, p2); - - // kludge to set lower edge of the object to fixed level - if (latitude == latitudeBegin + 1) - pa.z = pb.z = 0; - - vector3Sub(v1, pb, pa); - vector3Sub(v2, pd, pa); - - // Calculate normal with cross product. - /* i j k i j - * v1.x v1.y v1.z | v1.x v1.y - * v2.x v2.y v2.z | v2.x v2.y - */ - - n.x = v1.y * v2.z - v1.z * v2.y; - n.y = v1.z * v2.x - v1.x * v2.z; - n.z = v1.x * v2.y - v1.y * v2.x; - - /* Pre-normalization of the normals is disabled here because - * they will be normalized anyway later due to automatic - * normalization (gl.GL_NORMALIZE). It is enabled because the - * objects are scaled with glScale. - */ - /* - lenSq = n.x * n.x + n.y * n.y + n.z * n.z; - invLenSq = (float)(1 / sqrt(lenSq)); - n.x *= invLenSq; - n.y *= invLenSq; - n.z *= invLenSq; - */ - - ca = pa.z + 0.5f; - - for (i = currentVertex * 3; - i < (currentVertex + 6) * 3; - i += 3) - { - result.normalArray.put(i , FIXED(n.x)); - result.normalArray.put(i + 1, FIXED(n.y)); - result.normalArray.put(i + 2, FIXED(n.z)); - } - for (i = currentVertex * 4; - i < (currentVertex + 6) * 4; - i += 4) - { - int j, color[] = new int[3]; - for (j = 0; j < 3; ++j) - { - color[j] = (int)(ca * baseColor[j] * 255); - if (color[j] > 255) color[j] = 255; - } - result.colorArray.put(i , (byte)color[0]); - result.colorArray.put(i + 1, (byte)color[1]); - result.colorArray.put(i + 2, (byte)color[2]); - result.colorArray.put(i + 3, (byte)0); - } - result.vertexArray.put(currentVertex * 3, FIXED(pa.x)); - result.vertexArray.put(currentVertex * 3 + 1, FIXED(pa.y)); - result.vertexArray.put(currentVertex * 3 + 2, FIXED(pa.z)); - ++currentVertex; - result.vertexArray.put(currentVertex * 3, FIXED(pb.x)); - result.vertexArray.put(currentVertex * 3 + 1, FIXED(pb.y)); - result.vertexArray.put(currentVertex * 3 + 2, FIXED(pb.z)); - ++currentVertex; - result.vertexArray.put(currentVertex * 3, FIXED(pd.x)); - result.vertexArray.put(currentVertex * 3 + 1, FIXED(pd.y)); - result.vertexArray.put(currentVertex * 3 + 2, FIXED(pd.z)); - ++currentVertex; - result.vertexArray.put(currentVertex * 3, FIXED(pb.x)); - result.vertexArray.put(currentVertex * 3 + 1, FIXED(pb.y)); - result.vertexArray.put(currentVertex * 3 + 2, FIXED(pb.z)); - ++currentVertex; - result.vertexArray.put(currentVertex * 3, FIXED(pc.x)); - result.vertexArray.put(currentVertex * 3 + 1, FIXED(pc.y)); - result.vertexArray.put(currentVertex * 3 + 2, FIXED(pc.z)); - ++currentVertex; - result.vertexArray.put(currentVertex * 3, FIXED(pd.x)); - result.vertexArray.put(currentVertex * 3 + 1, FIXED(pd.y)); - result.vertexArray.put(currentVertex * 3 + 2, FIXED(pd.z)); - ++currentVertex; - } // r0 && r1 && r2 && r3 - ++currentQuad; - } // latitude - } // longitude - - // Set number of vertices in object to the actual amount created. - result.count = currentVertex; - result.seal(); - return result; -} - - -GLObject createGroundPlane() -{ - final int scale = 4; - final int yBegin = -15, yEnd = 15; // ends are non-inclusive - final int xBegin = -15, xEnd = 15; - final int triangleCount = (yEnd - yBegin) * (xEnd - xBegin) * 2; - final int vertices = triangleCount * 3; - GLObject result; - int x, y; - int currentVertex, currentQuad; - - result = new GLObject(vertices, 2, false); - if (result == null) - return null; - - currentQuad = 0; - currentVertex = 0; - - for (y = yBegin; y < yEnd; ++y) - { - for (x = xBegin; x < xEnd; ++x) - { - byte color; - int i, a; - color = (byte)((randomUInt() & 0x5f) + 81); // 101 1111 - for (i = currentVertex * 4; i < (currentVertex + 6) * 4; i += 4) - { - result.colorArray.put(i, color); - result.colorArray.put(i + 1, color); - result.colorArray.put(i + 2, color); - result.colorArray.put(i + 3, (byte)0); - } - - // Axis bits for quad triangles: - // x: 011100 (0x1c), y: 110001 (0x31) (clockwise) - // x: 001110 (0x0e), y: 100011 (0x23) (counter-clockwise) - for (a = 0; a < 6; ++a) - { - 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, FIXED(xm * scale + m)); - result.vertexArray.put(currentVertex * 2 + 1, FIXED(ym * scale + m)); - ++currentVertex; - } - ++currentQuad; - } - } - result.seal(); - return result; -} - - -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); - - sGroundPlane.draw(); - - gl.glEnable(gl.GL_LIGHTING); - gl.glDisable(gl.GL_BLEND); - gl.glEnable(gl.GL_DEPTH_TEST); -} - -void drawFadeQuad() -{ - final int beginFade = (int) (sTick - sCurrentCamTrackStartTick); - final int endFade = (int) (sNextCamTrackStartTick - sTick); - final int minFade = beginFade < endFade ? beginFade : endFade; - - if (minFade < 1024) - { - final int fadeColor = minFade << 7; - gl.glColor4x(fadeColor, fadeColor, fadeColor, 0); - - 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.glMatrixMode(gl.GL_MODELVIEW); - gl.glLoadIdentity(); - - gl.glMatrixMode(gl.GL_PROJECTION); - gl.glLoadIdentity(); - - gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - gl.glDisableClientState(gl.GL_COLOR_ARRAY); - gl.glDisableClientState(gl.GL_NORMAL_ARRAY); - gl.glVertexPointer(2, gl.GL_FIXED, 0, quadVertices); - gl.glDrawArrays(gl.GL_TRIANGLES, 0, 6); - - gl.glEnableClientState(gl.GL_COLOR_ARRAY); - - gl.glMatrixMode(gl.GL_MODELVIEW); - - gl.glEnable(gl.GL_LIGHTING); - gl.glDisable(gl.GL_BLEND); - gl.glEnable(gl.GL_DEPTH_TEST); - } -} - -IntBuffer quadVertices; -IntBuffer light0Position; -IntBuffer light0Diffuse; -IntBuffer light1Position; -IntBuffer light1Diffuse; -IntBuffer light2Position; -IntBuffer light2Diffuse; -IntBuffer materialSpecular; - -void configureLightAndMaterial() -{ - gl.glLightxv(gl.GL_LIGHT0, gl.GL_POSITION, light0Position); - gl.glLightxv(gl.GL_LIGHT0, gl.GL_DIFFUSE, light0Diffuse); - gl.glLightxv(gl.GL_LIGHT1, gl.GL_POSITION, light1Position); - gl.glLightxv(gl.GL_LIGHT1, gl.GL_DIFFUSE, light1Diffuse); - gl.glLightxv(gl.GL_LIGHT2, gl.GL_POSITION, light2Position); - gl.glLightxv(gl.GL_LIGHT2, gl.GL_DIFFUSE, light2Diffuse); - gl.glMaterialxv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR, materialSpecular); - - gl.glMaterialx(gl.GL_FRONT_AND_BACK, gl.GL_SHININESS, 60 << 16); - gl.glEnable(gl.GL_COLOR_MATERIAL); -} - - -void drawModels(float zScale) -{ - final int translationScale = 9; - int x, y; - - seedRandom(9); - - gl.glScalex(1 << 16, 1 << 16, (int)(zScale * 65536)); - - for (y = -5; y <= 5; ++y) - { - for (x = -5; x <= 5; ++x) - { - float buildingScale; - int fixedScale; - - int curShape = randomUInt() % SuperShape.COUNT; - buildingScale = SuperShape.sParams[curShape][SuperShape.PARAMS - 1]; - fixedScale = (int)(buildingScale * 65536); - - gl.glPushMatrix(); - gl.glTranslatex((x * translationScale) * 65536, - (y * translationScale) * 65536, - 0); - gl.glRotatex((int)((randomUInt() % 360) << 16), 0, 0, 1 << 16); - gl.glScalex(fixedScale, fixedScale, fixedScale); - - sSuperShapeObjects[curShape].draw(); - gl.glPopMatrix(); - } - } - - for (x = -2; x <= 2; ++x) - { - final int shipScale100 = translationScale * 500; - final int offs100 = x * shipScale100 + (int)(sTick % shipScale100); - float offs = offs100 * 0.01f; - int fixedOffs = (int)(offs * 65536); - gl.glPushMatrix(); - gl.glTranslatex(fixedOffs, -4 * 65536, 2 << 16); - sSuperShapeObjects[SuperShape.COUNT - 1].draw(); - gl.glPopMatrix(); - gl.glPushMatrix(); - gl.glTranslatex(-4 * 65536, fixedOffs, 4 << 16); - gl.glRotatex(90 << 16, 0, 0, 1 << 16); - sSuperShapeObjects[SuperShape.COUNT - 1].draw(); - gl.glPopMatrix(); - } -} - - -void camTrack() -{ - float lerp[]= new float[5]; - float eX, eY, eZ, cX, cY, cZ; - float trackPos; - CamTrack cam; - long currentCamTick; - int a; - - if (sNextCamTrackStartTick <= sTick) - { - ++sCurrentCamTrack; - sCurrentCamTrackStartTick = sNextCamTrackStartTick; - } - sNextCamTrackStartTick = sCurrentCamTrackStartTick + - CamTrack.sCamTracks[sCurrentCamTrack].len * CamTrack.CAMTRACK_LEN; - - cam = CamTrack.sCamTracks[sCurrentCamTrack]; - currentCamTick = sTick - sCurrentCamTrackStartTick; - trackPos = (float)currentCamTick / (CamTrack.CAMTRACK_LEN * cam.len); - - for (a = 0; a < 5; ++a) - lerp[a] = (cam.src[a] + cam.dest[a] * trackPos) * 0.01f; - - if (cam.dist>0) - { - float dist = cam.dist * 0.1f; - cX = lerp[0]; - cY = lerp[1]; - cZ = lerp[2]; - eX = cX - (float)Math.cos(lerp[3]) * dist; - eY = cY - (float)Math.sin(lerp[3]) * dist; - eZ = cZ - lerp[4]; - } - else - { - eX = lerp[0]; - eY = lerp[1]; - eZ = lerp[2]; - cX = eX + (float)Math.cos(lerp[3]); - cY = eY + (float)Math.sin(lerp[3]); - cZ = eZ + lerp[4]; - } - gluLookAt(eX, eY, eZ, cX, cY, cZ, 0, 0, 1); -} - -private int gAppAlive = 0; -private int width, height, x, y, frames; - -/* Following gluLookAt implementation is adapted from the - * Mesa 3D Graphics library. http://www.mesa3d.org - */ -void gluLookAt(float eyex, float eyey, float eyez, - float centerx, float centery, float centerz, - float upx, float upy, float upz) -{ - float m[] = new float[16]; - float x[] = new float[3], y[] = new float[3], z[] = new float[3]; - float mag; - - /* Make rotation matrix */ - - /* Z vector */ - z[0] = eyex - centerx; - z[1] = eyey - centery; - z[2] = eyez - centerz; - mag = (float)Math.sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]); - if (mag!=0.0) { /* mpichler, 19950515 */ - z[0] /= mag; - z[1] /= mag; - z[2] /= mag; - } - - /* Y vector */ - y[0] = upx; - y[1] = upy; - y[2] = upz; - - /* X vector = Y cross Z */ - x[0] = y[1] * z[2] - y[2] * z[1]; - x[1] = -y[0] * z[2] + y[2] * z[0]; - x[2] = y[0] * z[1] - y[1] * z[0]; - - /* Recompute Y = Z cross X */ - y[0] = z[1] * x[2] - z[2] * x[1]; - y[1] = -z[0] * x[2] + z[2] * x[0]; - y[2] = z[0] * x[1] - z[1] * x[0]; - - /* mpichler, 19950515 */ - /* cross product gives area of parallelogram, which is < 1.0 for - * non-perpendicular unit-length vectors; so normalize x, y here - */ - - mag = (float)Math.sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]); - if (mag!=0.0) { - x[0] /= mag; - x[1] /= mag; - x[2] /= mag; - } - - mag = (float)Math.sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]); - if (mag!=0.0) { - y[0] /= mag; - y[1] /= mag; - y[2] /= mag; - } - - m[0 + 0*4] = x[0]; - m[0 + 1*4] = x[1]; - m[0 + 2*4] = x[2]; - m[0 + 3*4] = 0.0f; - m[1 + 0*4] = y[0]; - m[1 + 1*4] = y[1]; - m[1 + 2*4] = y[2]; - m[1 + 3*4] = 0.0f; - m[2 + 0*4] = z[0]; - m[2 + 1*4] = z[1]; - m[2 + 2*4] = z[2]; - m[2 + 3*4] = 0.0f; - m[3 + 0*4] = 0.0f; - m[3 + 1*4] = 0.0f; - m[3 + 2*4] = 0.0f; - m[3 + 3*4] = 1.0f; - { - int a; - int fixedM[] = new int[16]; - for (a = 0; a < 16; ++a) - fixedM[a] = (int)(m[a] * 65536); - - IntBuffer nioM = BufferUtil.newIntBuffer(16); - nioM.put(fixedM); - nioM.rewind(); - gl.glMultMatrixx(nioM); - } - - /* Translate Eye to Origin */ - gl.glTranslatex((int)(-eyex * 65536), - (int)(-eyey * 65536), - (int)(-eyez * 65536)); -} - -void gluPerspective(float fovy, float aspect, - float zNear, float zFar) -{ - float xmin, xmax, ymin, ymax; - - ymax = zNear * (float)Math.tan(fovy * Math.PI / 360.0); - ymin = -ymax; - xmin = ymin * aspect; - xmax = ymax * aspect; - - gl.glFrustumx((int)(xmin * 65536), (int)(xmax * 65536), - (int)(ymin * 65536), (int)(ymax * 65536), - (int)(zNear * 65536), (int)(zFar * 65536)); -} - - -} - diff --git a/src/demos/es1/angeles/CamTrack.java b/src/demos/es1/angeles/CamTrack.java deleted file mode 100755 index df1678c..0000000 --- a/src/demos/es1/angeles/CamTrack.java +++ /dev/null @@ -1,71 +0,0 @@ -/* San Angeles Observation OpenGL ES version example - * Copyright 2004-2005 Jetro Lauha - * All rights reserved. - * Web: http://iki.fi/jetro/ - * - * This source is free software; you can redistribute it and/or - * modify it under the terms of EITHER: - * (1) The GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. The text of the GNU Lesser - * General Public License is included with this source in the - * file LICENSE-LGPL.txt. - * (2) The BSD-style license that is included with this source in - * the file LICENSE-BSD.txt. - * - * This source is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details. - * - * $Id$ - * $Revision$ - */ - -package demos.es1.angeles; - -// Camera track definition for one camera trucking shot. -public class CamTrack -{ - /* Length in milliseconds of one camera track base unit. - * The value originates from the music synchronization. - */ - static final int CAMTRACK_LEN = 5442; - - /* Five parameters of src[5] and dest[5]: - * eyeX, eyeY, eyeZ, viewAngle, viewHeightOffs - */ - short src[], dest[]; - int dist; // if >0, cam rotates around eye xy on dist * 0.1 - int len; // length multiplier - - public CamTrack() { - src = new short[5]; - dest = new short[5]; - } - public CamTrack(short s[], short d[], int dx, int l) { - src=s; - dest=d; - dist=dx; - len=l; - } - -static CamTrack sCamTracks[] = - { new CamTrack( new short[]{ 4500, 2700, 100, 70, -30 }, new short[]{ 50, 50, -90, -100, 0 }, 20, 1 ), - new CamTrack( new short[]{ -1448, 4294, 25, 363, 0 }, new short[]{ -136, 202, 125, -98, 100 }, 0, 1 ), - new CamTrack( new short[]{ 1437, 4930, 200, -275, -20 }, new short[]{ 1684, 0, 0, 9, 0 }, 0, 1 ), - new CamTrack( new short[]{ 1800, 3609, 200, 0, 675 }, new short[]{ 0, 0, 0, 300, 0 }, 0, 1 ), - new CamTrack( new short[]{ 923, 996, 50, 2336, -80 }, new short[]{ 0, -20, -50, 0, 170 }, 0, 1 ), - new CamTrack( new short[]{ -1663, -43, 600, 2170, 0 }, new short[]{ 20, 0, -600, 0, 100 }, 0, 1 ), - new CamTrack( new short[]{ 1049, -1420, 175, 2111, -17 }, new short[]{ 0, 0, 0, -334, 0 }, 0, 2 ), - new CamTrack( new short[]{ 0, 0, 50, 300, 25 }, new short[]{ 0, 0, 0, 300, 0 }, 70, 2 ), - new CamTrack( new short[]{ -473, -953, 3500, -353, -350 }, new short[]{ 0, 0, -2800, 0, 0 }, 0, 2 ), - new CamTrack( new short[]{ 191, 1938, 35, 1139, -17 }, new short[]{ 1205, -2909, 0, 0, 0 }, 0, 2 ), - new CamTrack( new short[]{ -1449, -2700, 150, 0, 0 }, new short[]{ 0, 2000, 0, 0, 0 }, 0, 2 ), - new CamTrack( new short[]{ 5273, 4992, 650, 373, -50 }, new short[]{ -4598, -3072, 0, 0, 0 }, 0, 2 ), - new CamTrack( new short[]{ 3223, -3282, 1075, -393, -25 }, new short[]{ 1649, -1649, 0, 0, 0 }, 0, 2 ) }; - -static final int CAMTRACK_COUNT = 13; - -} - diff --git a/src/demos/es1/angeles/Main.java b/src/demos/es1/angeles/Main.java deleted file mode 100755 index 563e554..0000000 --- a/src/demos/es1/angeles/Main.java +++ /dev/null @@ -1,115 +0,0 @@ -package demos.es1.angeles; - -import java.nio.*; -import javax.media.opengl.*; -import com.sun.javafx.newt.*; - -public class Main implements MouseListener { - - public boolean quit = false; - public boolean toggleFS = false; - - public void mouseClicked(MouseEvent e) { - switch(e.getClickCount()) { - case 1: - toggleFS=true; - break; - default: - quit=true; - break; - } - } - public void mouseEntered(MouseEvent e) { - } - public void mouseExited(MouseEvent e) { - } - public void mousePressed(MouseEvent e) { - } - public void mouseReleased(MouseEvent e) { - } - public void mouseMoved(MouseEvent e) { - } - public void mouseDragged(MouseEvent e) { - } - - public static void main(String[] args) { - System.out.println("Angeles Main"); - try { - Display display = NewtFactory.createDisplay(null); // local display - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Window window = NewtFactory.createWindow(screen, 0); // dummy VisualID - - Main ml = new Main(); - window.addMouseListener(ml); - - // Size OpenGL to Video Surface - int width = 800; - int height = 480; - window.setSize(width, height); - window.setFullscreen(true); - - // Hook this into EGL - GLDrawableFactory factory = GLDrawableFactory.getFactory(GLDrawableFactory.PROFILE_GLES1, window); - GLCapabilities caps = new GLCapabilities(); - // For emulation library, use 16 bpp - caps.setRedBits(5); - caps.setGreenBits(6); - caps.setBlueBits(5); - caps.setDepthBits(16); - GLDrawable drawable = factory.createGLDrawable(window, caps, null); - window.setVisible(true); - drawable.setRealized(true); - GLContext context = drawable.createContext(null); - context.makeCurrent(); - - GL gl = context.getGL(); - - Angeles angel = new Angeles(); - angel.init(gl); - angel.reshape(gl, 0, 0, window.getWidth(), window.getHeight()); - - long startTime = System.currentTimeMillis(); - long lastTime = startTime, curTime = 0, dt0, dt1; - int totalFrames = 0, lastFrames = 0; - - do { - angel.display(gl); - drawable.swapBuffers(); - - totalFrames++; lastFrames++; - curTime = System.currentTimeMillis(); - dt0 = curTime-lastTime; - if ( (curTime-lastTime) > 5000 ) { - dt1 = curTime-startTime; - System.out.println(dt1/1000+"s, 5s: "+ (lastFrames*1000)/dt0 + " fps, "+ - "total: "+ (totalFrames*1000)/dt1 + " fps"); - lastTime=curTime; - lastFrames=0; - } - - if(ml.toggleFS) { - window.setFullscreen(!window.isFullscreen()); - ml.toggleFS=false; - } - - window.pumpMessages(); - - // Thread.yield(); - - // try{ - // Thread.sleep(10); - // } catch(InterruptedException ie) {} - } while (!ml.quit && (curTime - startTime) < 215000); - - // Shut things down cooperatively - context.release(); - context.destroy(); - drawable.destroy(); - factory.shutdown(); - System.out.println("Angeles shut down cleanly."); - } catch (GLException e) { - e.printStackTrace(); - } - System.exit(0); - } -} diff --git a/src/demos/es1/angeles/SuperShape.java b/src/demos/es1/angeles/SuperShape.java deleted file mode 100755 index 5f419d6..0000000 --- a/src/demos/es1/angeles/SuperShape.java +++ /dev/null @@ -1,57 +0,0 @@ -/* San Angeles Observation OpenGL ES version example - * Copyright 2004-2005 Jetro Lauha - * All rights reserved. - * Web: http://iki.fi/jetro/ - * - * This source is free software; you can redistribute it and/or - * modify it under the terms of EITHER: - * (1) The GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. The text of the GNU Lesser - * General Public License is included with this source in the - * file LICENSE-LGPL.txt. - * (2) The BSD-style license that is included with this source in - * the file LICENSE-BSD.txt. - * - * This source is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details. - * - * $Id$ - * $Revision$ - */ - -package demos.es1.angeles; - -public class SuperShape { - -public static final int PARAMS = 15 ; - -public static final float sParams[][/*SUPERSHAPE_PARAMS*/] = -{ - // m a b n1 n2 n3 m a b n1 n2 n3 res1 res2 scale (org.res1,res2) - new float[]{ 10, 1, 2, 90, 1, -45, 8, 1, 1, -1, 1, -0.4f, 20, 30, 2 }, // 40, 60 - new float[]{ 10, 1, 2, 90, 1, -45, 4, 1, 1, 10, 1, -0.4f, 20, 20, 4 }, // 40, 40 - new float[]{ 10, 1, 2, 60, 1, -10, 4, 1, 1, -1, -2, -0.4f, 41, 41, 1 }, // 82, 82 - new float[]{ 6, 1, 1, 60, 1, -70, 8, 1, 1, 0.4f, 3, 0.25f, 20, 20, 1 }, // 40, 40 - new float[]{ 4, 1, 1, 30, 1, 20, 12, 1, 1, 0.4f, 3, 0.25f, 10, 30, 1 }, // 20, 60 - new float[]{ 8, 1, 1, 30, 1, -4, 8, 2, 1, -1, 5, 0.5f, 25, 26, 1 }, // 60, 60 - new float[]{ 13, 1, 1, 30, 1, -4, 13, 1, 1, 1, 5, 1, 30, 30, 6 }, // 60, 60 - new float[]{ 10, 1, 1.1f, -0.5f, 0.1f, 70, 60, 1, 1, -90, 0, -0.25f, 20, 60, 8 }, // 60, 180 - new float[]{ 7, 1, 1, 20, -0.3f, -3.5f, 6, 1, 1, -1, 4.5f, 0.5f, 10, 20, 4 }, // 60, 80 - new float[]{ 4, 1, 1, 10, 10, 10, 4, 1, 1, 10, 10, 10, 10, 20, 1 }, // 20, 40 - new float[]{ 4, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 10, 10, 2 }, // 10, 10 - new float[]{ 1, 1, 1, 38, -0.25f, 19, 4, 1, 1, 10, 10, 10, 10, 15, 2 }, // 20, 40 - new float[]{ 2, 1, 1, 0.7f, 0.3f, 0.2f, 3, 1, 1, 100, 100, 100, 10, 25, 2 }, // 20, 50 - new float[]{ 6, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 30, 30, 2 }, // 60, 60 - new float[]{ 3, 1, 1, 1, 1, 1, 6, 1, 1, 2, 1, 1, 10, 20, 2 }, // 20, 40 - new float[]{ 6, 1, 1, 6, 5.5f, 100, 6, 1, 1, 25, 10, 10, 30, 20, 2 }, // 60, 40 - new float[]{ 3, 1, 1, 0.5f, 1.7f, 1.7f, 2, 1, 1, 10, 10, 10, 20, 20, 2 }, // 40, 40 - new float[]{ 5, 1, 1, 0.1f, 1.7f, 1.7f, 1, 1, 1, 0.3f, 0.5f, 0.5f, 20, 20, 4 }, // 40, 40 - new float[]{ 2, 1, 1, 6, 5.5f, 100, 6, 1, 1, 4, 10, 10, 10, 22, 1 }, // 40, 40 - new float[]{ 6, 1, 1, -1, 70, 0.1f, 9, 1, 0.5f, -98, 0.05f, -45, 20, 30, 4 }, // 60, 91 - new float[]{ 6, 1, 1, -1, 90, -0.1f, 7, 1, 1, 90, 1.3f, 34, 13, 16, 1 }, // 32, 60 -}; - public static final int COUNT = 21; -} diff --git a/src/demos/es1/cubefbo/CubeObject.java b/src/demos/es1/cubefbo/CubeObject.java deleted file mode 100755 index 8eb9c7f..0000000 --- a/src/demos/es1/cubefbo/CubeObject.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package demos.es1.cubefbo; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import java.nio.*; - -class CubeObject { - public CubeObject (boolean useTexCoords) { - // Initialize data Buffers - this.cubeVertices = BufferUtil.newShortBuffer(s_cubeVertices.length); - cubeVertices.put(s_cubeVertices); - cubeVertices.rewind(); - - this.cubeColors = BufferUtil.newByteBuffer(s_cubeColors.length); - cubeColors.put(s_cubeColors); - cubeColors.rewind(); - - this.cubeNormals = BufferUtil.newByteBuffer(s_cubeNormals.length); - cubeNormals.put(s_cubeNormals); - cubeNormals.rewind(); - - this.cubeIndices = BufferUtil.newByteBuffer(s_cubeIndices.length); - cubeIndices.put(s_cubeIndices); - cubeIndices.rewind(); - - if (useTexCoords) { - this.cubeTexCoords = BufferUtil.newShortBuffer(s_cubeTexCoords.length); - cubeTexCoords.put(s_cubeTexCoords); - cubeTexCoords.rewind(); - } - } - - private void perspective(GL gl, float fovy, float aspect, float zNear, float zFar) { - float xmin; - float xmax; - float ymin; - float ymax; - - ymax = zNear * (float)Math.tan((fovy * Math.PI) / 360.0); - ymin = -ymax; - xmin = ymin * aspect; - xmax = ymax * aspect; - - gl.glFrustumf(xmin, xmax, ymin, ymax, zNear, zFar); - } - - static final float[] light_position = { -50.f, 50.f, 50.f, 0.f }; - static final float[] light_ambient = { 0.125f, 0.125f, 0.125f, 1.f }; - static final float[] light_diffuse = { 1.0f, 1.0f, 1.0f, 1.f }; - static final float[] material_spec = { 1.0f, 1.0f, 1.0f, 0.f }; - static final float[] zero_vec4 = { 0.0f, 0.0f, 0.0f, 0.f }; - - public void reshape(GL gl, int x, int y, int width, int height) { - float aspect = (height != 0) ? ((float)width / (float)height) : 1.0f; - - gl.glViewport(0, 0, width, height); - gl.glScissor(0, 0, width, height); - - gl.glMatrixMode(GL.GL_MODELVIEW); - gl.glLoadIdentity(); - - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_position, 0); - 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(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.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST); - - gl.glShadeModel(GL.GL_SMOOTH); - gl.glDisable(GL.GL_DITHER); - - gl.glClearColor(0.0f, 0.1f, 0.0f, 1.0f); - - gl.glEnableClientState(GL.GL_VERTEX_ARRAY); - gl.glEnableClientState(GL.GL_NORMAL_ARRAY); - gl.glEnableClientState(GL.GL_COLOR_ARRAY); - if (cubeTexCoords != null) { - gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); - } else { - gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY); - } - - gl.glMatrixMode(GL.GL_PROJECTION); - gl.glLoadIdentity(); - - float fovy = 55.f; - if (aspect < 1) { - // Compute this as fovx instead - float fovx = fovy; - fovy = (float) Math.toDegrees(Math.atan(Math.tan(Math.toRadians(fovx)) / aspect)); - } - - perspective(gl, fovy, aspect, 0.1f, 100.f); - gl.glCullFace(GL.GL_BACK); - } - - public void display(GL gl, float xRot, float yRot) { - // System.out.println("CubeObject .. p1: "+this); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - - gl.glMatrixMode(GL.GL_MODELVIEW); - gl.glLoadIdentity(); - - gl.glTranslatef(0.f, 0.f, -30.f); - // gl.glTranslatef(0.f, 0.f, -30.f); - // gl.glRotatef((float)(time * 29.77f), 1.0f, 2.0f, 0.0f); - // gl.glRotatef((float)(time * 22.311f), -0.1f, 0.0f, -5.0f); - gl.glRotatef(yRot, 0, 1, 0); - gl.glRotatef(xRot, 1, 0, 0); - - gl.glVertexPointer(3, GL.GL_SHORT, 0, cubeVertices); - gl.glColorPointer(4, GL.GL_UNSIGNED_BYTE, 0, cubeColors); - gl.glNormalPointer(GL.GL_BYTE, 0, cubeNormals); - if (cubeTexCoords != null) { - gl.glTexCoordPointer(2, GL.GL_SHORT, 0, cubeTexCoords); - gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); - } - - // System.out.println("CubeObject .. p8: "+this); - gl.glDrawElements(GL.GL_TRIANGLES, 6 * 6, GL.GL_UNSIGNED_BYTE, cubeIndices); - // System.out.println("CubeObject .. p9: "+this); - - // time += 0.01f; - } - - boolean initialized = false; - // float time = 0.0f; - - ShortBuffer cubeVertices; - ShortBuffer cubeTexCoords; - ByteBuffer cubeColors; - ByteBuffer cubeNormals; - ByteBuffer cubeIndices; - - private static final short[] s_cubeVertices = - { - -10, 10, 10, 10, -10, 10, 10, 10, 10, -10, -10, 10, - - -10, 10, -10, 10, -10, -10, 10, 10, -10, -10, -10, -10, - - -10, -10, 10, 10, -10, -10, 10, -10, 10, -10, -10, -10, - - -10, 10, 10, 10, 10, -10, 10, 10, 10, -10, 10, -10, - - 10, -10, 10, 10, 10, -10, 10, 10, 10, 10, -10, -10, - - -10, -10, 10, -10, 10, -10, -10, 10, 10, -10, -10, -10 - }; - - private static final short[] s_cubeTexCoords = - { - 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, - - 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, - - 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, - - 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, - - 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, - - 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, - }; - - private static final byte[] s_cubeColors = - { - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255, - (byte) 0, (byte) 128, (byte) 0, (byte) 255, (byte) 0, (byte) 128, (byte) 0, (byte) 255 - }; - - private static final byte[] s_cubeIndices = - { - 0, 3, 1, 2, 0, 1, /* front */ - 6, 5, 4, 5, 7, 4, /* back */ - 8, 11, 9, 10, 8, 9, /* top */ - 15, 12, 13, 12, 14, 13, /* bottom */ - 16, 19, 17, 18, 16, 17, /* right */ - 23, 20, 21, 20, 22, 21 /* left */ - }; - private static final byte[] s_cubeNormals = - { - 0, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 127, - - 0, 0, -128, 0, 0, -128, 0, 0, -128, 0, 0, -128, - - 0, -128, 0, 0, -128, 0, 0, -128, 0, 0, -128, 0, - - 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 127, 0, - - 127, 0, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, - - -128, 0, 0, -128, 0, 0, -128, 0, 0, -128, 0, 0 - }; -} - diff --git a/src/demos/es1/cubefbo/FBCubes.java b/src/demos/es1/cubefbo/FBCubes.java deleted file mode 100755 index 724b798..0000000 --- a/src/demos/es1/cubefbo/FBCubes.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package demos.es1.cubefbo; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import java.nio.*; - -class FBCubes { - private static final int FBO_SIZE = 128; - - public FBCubes () { - cubeInner = new CubeObject(false); - cubeMiddle = new CubeObject(true); - cubeOuter = new CubeObject(true); - - // cubeOuter = new CubeObject(false); - - fbo1 = new FBObject(FBO_SIZE, FBO_SIZE); - fbo2 = new FBObject(FBO_SIZE, FBO_SIZE); - } - - public void init(GL gl) { - fbo1.init(gl); - fbo2.init(gl); - } - - public void reshape(GL gl, int x, int y, int width, int height) { - cubeOuter.reshape(gl, x, y, width, height); - } - - public void display(GL gl, float xRot, float yRot) { - - fbo1.bind(gl); - cubeInner.reshape(gl, 0, 0, FBO_SIZE, FBO_SIZE); - cubeInner.display(gl, xRot, yRot); - fbo1.unbind(gl); - - FBObject tex = fbo1; - FBObject rend = fbo2; - - int MAX_ITER = 1; - - for (int i = 0; i < MAX_ITER; i++) { - rend.bind(gl); - gl.glEnable (GL.GL_TEXTURE_2D); - gl.glBindTexture(GL.GL_TEXTURE_2D, tex.getTextureName()); // to use it .. - cubeMiddle.reshape(gl, 0, 0, FBO_SIZE, FBO_SIZE); - cubeMiddle.display(gl, xRot, yRot); - gl.glBindTexture(GL.GL_TEXTURE_2D, 0); - gl.glDisable (GL.GL_TEXTURE_2D); - rend.unbind(gl); - FBObject tmp = tex; - tex = rend; - rend = tmp; - } - - // System.out.println("display .. p6"); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - gl.glClearColor(0, 0, 0, 1); - - gl.glEnable (GL.GL_TEXTURE_2D); - gl.glBindTexture(GL.GL_TEXTURE_2D, tex.getTextureName()); // to use it .. - cubeOuter.display(gl, xRot, yRot); - // System.out.println("display .. p7"); - gl.glBindTexture(GL.GL_TEXTURE_2D, 0); - gl.glDisable (GL.GL_TEXTURE_2D); - } - - public void displayChanged(GL gl, boolean modeChanged, boolean deviceChanged) { - } - - float time = 0.0f; - CubeObject cubeInner; - CubeObject cubeMiddle; - CubeObject cubeOuter; - FBObject fbo1; - FBObject fbo2; -} - diff --git a/src/demos/es1/cubefbo/FBObject.java b/src/demos/es1/cubefbo/FBObject.java deleted file mode 100755 index 13d5b01..0000000 --- a/src/demos/es1/cubefbo/FBObject.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package demos.es1.cubefbo; - -import javax.media.opengl.*; -import com.sun.opengl.util.*; -import java.nio.*; - -class FBObject { - private int fb, fbo_tex, depth_rb, stencil_rb, width, height; - - public FBObject(int width, int height) { - this.width = width; - this.height = height; - } - - public void init(GL gl) { - // generate fbo .. - int name[] = new int[1]; - - gl.glGenTextures(1, name, 0); - fbo_tex = name[0]; - System.out.println("fbo_tex: "+fbo_tex); - - gl.glBindTexture(GL.GL_TEXTURE_2D, fbo_tex); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB8_OES, width, height, 0, - GL.GL_RGB, GL.GL_UNSIGNED_BYTE, null); - - gl.glGenRenderbuffersOES(1, name, 0); - depth_rb = name[0]; - System.out.println("depth_rb: "+depth_rb); - - // Initialize the depth buffer: - gl.glBindRenderbufferOES(GL.GL_RENDERBUFFER_OES, depth_rb); - gl.glRenderbufferStorageOES(GL.GL_RENDERBUFFER_OES, - GL.GL_DEPTH_COMPONENT16_OES, width, height); - - // gl.glGenRenderbuffersOES(1, name, 0); - // stencil_rb = name[0]; - stencil_rb = 0; - System.out.println("stencil_rb: "+stencil_rb); - - gl.glGenFramebuffersOES(1, name, 0); - fb = name[0]; - System.out.println("fb: "+fb); - - // bind fbo .. - gl.glBindFramebufferOES(GL.GL_FRAMEBUFFER_OES, fb); - - // Set up the color buffer for use as a renderable texture: - gl.glFramebufferTexture2DOES(GL.GL_FRAMEBUFFER_OES, - GL.GL_COLOR_ATTACHMENT0_OES, - GL.GL_TEXTURE_2D, fbo_tex, 0); - - // Set up the depth buffer attachment: - gl.glFramebufferRenderbufferOES(GL.GL_FRAMEBUFFER_OES, - GL.GL_DEPTH_ATTACHMENT_OES, - GL.GL_RENDERBUFFER_OES, depth_rb); - - // bind fbo .. - gl.glBindFramebufferOES(GL.GL_FRAMEBUFFER_OES, fb); - - // Setup the color buffer for use as a renderable texture: - gl.glBindTexture(GL.GL_TEXTURE_2D, fbo_tex); - - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB8_OES, width, height, 0, - GL.GL_RGB, GL.GL_UNSIGNED_BYTE, null); - - gl.glFramebufferTexture2DOES(GL.GL_FRAMEBUFFER_OES, - GL.GL_COLOR_ATTACHMENT0_OES, - GL.GL_TEXTURE_2D, fbo_tex, 0); - - // Initialize the depth buffer: - gl.glBindRenderbufferOES(GL.GL_RENDERBUFFER_OES, depth_rb); - - gl.glRenderbufferStorageOES(GL.GL_RENDERBUFFER_OES, - GL.GL_DEPTH_COMPONENT16_OES, width, height); - - gl.glFramebufferRenderbufferOES(GL.GL_FRAMEBUFFER_OES, - GL.GL_DEPTH_ATTACHMENT_OES, - GL.GL_RENDERBUFFER_OES, depth_rb); - - if(stencil_rb!=0) { - // Initialize the stencil buffer: - gl.glBindRenderbufferOES(GL.GL_RENDERBUFFER_OES, stencil_rb); - - gl.glRenderbufferStorageOES(GL.GL_RENDERBUFFER_OES, - GL.GL_STENCIL_INDEX8_OES, width, height); - - gl.glFramebufferRenderbufferOES(GL.GL_FRAMEBUFFER_OES, - GL.GL_STENCIL_ATTACHMENT_OES, - GL.GL_RENDERBUFFER_OES, stencil_rb); - } - - // Check the FBO for completeness - int res = gl.glCheckFramebufferStatusOES(fb); - if (res == GL.GL_FRAMEBUFFER_COMPLETE_OES) { - System.out.println("Framebuffer " + fb + " is complete"); - } else { - System.out.println("Framebuffer " + fb + " is incomplete: status = 0x" + Integer.toHexString(res)); - } - } - - public void bind(GL gl) { - gl.glBindFramebufferOES(GL.GL_FRAMEBUFFER_OES, fb); - } - - public void unbind(GL gl) { - gl.glBindFramebufferOES(GL.GL_FRAMEBUFFER_OES, 0); - } - - public int getFBName() { - return fb; - } - public int getTextureName() { - return fbo_tex; - } -} diff --git a/src/demos/es1/cubefbo/Main.java b/src/demos/es1/cubefbo/Main.java deleted file mode 100755 index 857f183..0000000 --- a/src/demos/es1/cubefbo/Main.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package demos.es1.cubefbo; - -import java.nio.*; -import javax.media.opengl.*; -import com.sun.javafx.newt.*; - -public class Main implements MouseListener { - - private boolean quit = false; - private boolean toggleFS = false; - private Window window; - - private boolean dragging; - private int lastDragX; - private int lastDragY; - private float motionIncr; - private float xRot, yRot; - - public void mouseClicked(MouseEvent e) { - switch(e.getClickCount()) { - case 1: - toggleFS=true; - break; - default: - quit=true; - break; - } - } - public void mouseEntered(MouseEvent e) { - } - public void mouseExited(MouseEvent e) { - } - public void mousePressed(MouseEvent e) { - } - public void mouseReleased(MouseEvent e) { - dragging = false; - } - public void mouseMoved(MouseEvent e) { - } - public void mouseDragged(MouseEvent e) { - if (!dragging) { - dragging = true; - lastDragX = e.getX(); - lastDragY = e.getY(); - } else { - yRot += (e.getX() - lastDragX) * motionIncr; - xRot += (e.getY() - lastDragY) * motionIncr; - lastDragX = e.getX(); - lastDragY = e.getY(); - } - } - - public void run() { - System.out.println("CubeFBO Main"); - try { - Display display = NewtFactory.createDisplay(null); // local display - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - window = NewtFactory.createWindow(screen, 0); // dummy VisualID - - window.addMouseListener(this); - - // Size OpenGL to Video Surface - int width = 800; - int height = 480; - window.setSize(width, height); - window.setFullscreen(true); - - // Hook this into EGL - GLDrawableFactory factory = GLDrawableFactory.getFactory(GLDrawableFactory.PROFILE_GLES1, window); - GLCapabilities caps = new GLCapabilities(); - // For emulation library, use 16 bpp - caps.setRedBits(5); - caps.setGreenBits(6); - caps.setBlueBits(5); - caps.setDepthBits(16); - GLDrawable drawable = factory.createGLDrawable(window, caps, null); - window.setVisible(true); - drawable.setRealized(true); - GLContext context = drawable.createContext(null); - context.makeCurrent(); - - GL gl = context.getGL(); - - motionIncr = 180.f / Math.max(window.getWidth(), window.getHeight()); - FBCubes cubes = new FBCubes(); - cubes.init(gl); - - long startTime = System.currentTimeMillis(); - long lastTime = startTime, curTime = 0, dt0, dt1; - int totalFrames = 0, lastFrames = 0; - - do { - cubes.reshape(gl, 0, 0, window.getWidth(), window.getHeight()); - cubes.display(gl, xRot, yRot); - drawable.swapBuffers(); - totalFrames++; lastFrames++; - curTime = System.currentTimeMillis(); - dt0 = curTime-lastTime; - if ( (curTime-lastTime) > 5000 ) { - dt1 = curTime-startTime; - System.out.println(dt1/1000+"s, 5s: "+ (lastFrames*1000)/dt0 + " fps, "+ - "total: "+ (totalFrames*1000)/dt1 + " fps"); - lastTime=curTime; - lastFrames=0; - } - if(toggleFS) { - window.setFullscreen(!window.isFullscreen()); - toggleFS=false; - } - - window.pumpMessages(); - - // Thread.yield(); - - // try{ - // Thread.sleep(10); - // } catch(InterruptedException ie) {} - } while (!quit && (curTime - startTime) < 215000); - - // Shut things down cooperatively - context.release(); - context.destroy(); - drawable.destroy(); - factory.shutdown(); - System.out.println("CubeFBO shut down cleanly."); - } catch (GLException e) { - e.printStackTrace(); - } - } - - - public static void main(String[] args) { - new Main().run(); - System.exit(0); - } -} |