From 8d3fc6fbdfe77debab4ff51ce7d4476e500f2e04 Mon Sep 17 00:00:00 2001 From: benfry Date: Wed, 22 Mar 2006 23:19:19 +0000 Subject: [PATCH] more opengl jsr-231 work --- core/PGraphics3.java | 9 +++++---- core/todo.txt | 2 ++ opengl/PGraphicsGL.java | 25 +++++++++++++++++++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/core/PGraphics3.java b/core/PGraphics3.java index 9763292e3..339497172 100644 --- a/core/PGraphics3.java +++ b/core/PGraphics3.java @@ -237,16 +237,17 @@ public class PGraphics3 extends PGraphics { // init lights (in resize() instead of allocate() b/c needed by opengl) lightType = new int[MAX_LIGHTS]; - lightPosition = new float[3][MAX_LIGHTS]; - lightDiffuse = new float[3][MAX_LIGHTS]; - lightNormal = new float[3][MAX_LIGHTS]; - lightSpecular = new float[3][MAX_LIGHTS]; + lightPosition = new float[MAX_LIGHTS][3]; + lightDiffuse = new float[MAX_LIGHTS][3]; + lightNormal = new float[MAX_LIGHTS][3]; + lightSpecular = new float[MAX_LIGHTS][3]; lightFalloffConstant = new float[MAX_LIGHTS]; lightFalloffLinear = new float[MAX_LIGHTS]; lightFalloffQuadratic = new float[MAX_LIGHTS]; lightSpotAngle = new float[MAX_LIGHTS]; lightSpotAngleCos = new float[MAX_LIGHTS]; lightSpotConcentration = new float[MAX_LIGHTS]; + currentLightSpecular = new float[3]; // reset the cameraMode if PERSPECTIVE or ORTHOGRAPHIC // will just be ignored if CUSTOM, the user's hosed anyways diff --git a/core/todo.txt b/core/todo.txt index 6754df262..a2fedb147 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,5 +1,6 @@ 0110 core + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -19,6 +20,7 @@ _ http://developer.apple.com/qa/qa2005/qa1295.html _ find/build universal version of jogl _ find/build universal version of rxtx _ need to have a better way of getting/figuring out the endian +_ use ByteOrder class in jdk 1.4, since issue is local to JOGL _ security ex when run as an applet _ also can no longer assume that macosx is big endian _ fix non-bound textures from mangling everything else diff --git a/opengl/PGraphicsGL.java b/opengl/PGraphicsGL.java index 3ec5cfe65..1e5266b14 100644 --- a/opengl/PGraphicsGL.java +++ b/opengl/PGraphicsGL.java @@ -129,7 +129,12 @@ public class PGraphicsGL extends PGraphics3 { canvas.addGLEventListener(new GLEventListener() { public void display(GLAutoDrawable drawable) { + System.out.println("calling display"); + // need to get a fresh opengl object here + //gl = canvas.getGL(); + //gl = drawable.getGL(); parent.display(); // this means it's time to go + System.out.println("done calling display"); } public void init(GLAutoDrawable drawable) { } @@ -186,6 +191,7 @@ public class PGraphicsGL extends PGraphics3 { lightBuffer = BufferUtil.newFloatBuffer(4); lightBuffer.put(3, 1.0f); + lightBuffer.rewind(); //System.out.println("done creating gl"); } @@ -196,9 +202,9 @@ public class PGraphicsGL extends PGraphics3 { // main applet thread requests an update, // but PGraphics has to respond back by calling PApplet.display() public void requestDisplay(PApplet parent) { - //System.out.println("requesting display"); + System.out.println("requesting display"); - if (!displayed) { + //if (!displayed) { // these two method calls (and explanations) were taken from // the FpsAnimator implementation from the jogl hoo-ha @@ -224,13 +230,14 @@ public class PGraphicsGL extends PGraphics3 { //canvas.requestFocus(); // done with this business - displayed = true; - } + //displayed = true; + //} // request a display from the gl canvas. when it happens, // we'll hear about it from the GLEventListener, which will // in turn call PApplet.display()... hold your breath... try { canvas.display(); + System.out.println("out of canvas display"); } catch (GLException e) { Throwable t = e.getCause(); @@ -311,8 +318,10 @@ public class PGraphicsGL extends PGraphics3 { public void beginFrame() { + System.out.println("beginframe1"); super.beginFrame(); + System.out.println("beginframe2"); report("top beginFrame()"); gl.glDisable(GL.GL_LIGHTING); @@ -357,6 +366,7 @@ public class PGraphicsGL extends PGraphics3 { } //gl.glLoadMatrixf(projectionFloats); projectionFloatBuffer.put(projectionFloats); + projectionFloatBuffer.rewind(); gl.glLoadMatrixf(projectionFloatBuffer); gl.glMatrixMode(GL.GL_MODELVIEW); @@ -941,6 +951,7 @@ public class PGraphicsGL extends PGraphics3 { } } tbuffer.put(tpixels); + tbuffer.rewind(); } } @@ -1468,6 +1479,7 @@ public class PGraphicsGL extends PGraphics3 { protected void glLightAmbient(int num) { lightBuffer.put(lightDiffuse[num]); + lightBuffer.rewind(); gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_AMBIENT, lightBuffer); } @@ -1482,6 +1494,7 @@ public class PGraphicsGL extends PGraphics3 { protected void glLightDiffuse(int num) { lightBuffer.put(lightDiffuse[num]); + lightBuffer.rewind(); gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_DIFFUSE, lightBuffer); } @@ -1489,6 +1502,7 @@ public class PGraphicsGL extends PGraphics3 { protected void glLightDirection(int num) { lightBuffer.put(lightNormal[num]); + lightBuffer.rewind(); if (lightType[num] == DIRECTIONAL) { // TODO this expects a fourth arg that will be set to 1 @@ -1522,6 +1536,7 @@ public class PGraphicsGL extends PGraphics3 { protected void glLightPosition(int num) { lightBuffer.put(lightPosition[num]); + lightBuffer.rewind(); gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_POSITION, lightBuffer); //new float[] { lightsX[num], lightsY[num], lightsZ[num] }); } @@ -1529,6 +1544,7 @@ public class PGraphicsGL extends PGraphics3 { protected void glLightSpecular(int num) { lightBuffer.put(lightSpecular[num]); + lightBuffer.rewind(); gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_SPECULAR, lightBuffer); //GL.GL_SPECULAR, new float[] { lightsSpecularR[num], // lightsSpecularG[num], @@ -1575,6 +1591,7 @@ public class PGraphicsGL extends PGraphics3 { colorBuffer.put(1, calcG); colorBuffer.put(2, calcB); colorBuffer.put(3, calcA); + colorBuffer.rewind(); }