summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/demos/es1/cubefbo/FBCubes.java30
-rw-r--r--src/demos/gears/Gears.java103
-rw-r--r--src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java117
-rwxr-xr-xsrc/demos/j2d/CustomText.java120
-rwxr-xr-xsrc/demos/j2d/FlyingText.java93
-rwxr-xr-xsrc/demos/j2d/TestOverlay.java67
-rwxr-xr-xsrc/demos/j2d/TestTextRenderer.java62
-rwxr-xr-xsrc/demos/j2d/TestTextureRenderer.java66
-rwxr-xr-xsrc/demos/j2d/TextFlow.java65
-rw-r--r--src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java76
-rwxr-xr-xsrc/demos/readbuffer/ReadBufferUtil.java34
-rwxr-xr-xsrc/demos/testContextDestruction/TestContextDestruction.java65
-rwxr-xr-xsrc/demos/util/FPSCounter.java40
-rw-r--r--src/gleem/ExaminerViewer.java71
-rw-r--r--src/redbook/src/glredbook10/jfont.java52
15 files changed, 615 insertions, 446 deletions
diff --git a/src/demos/es1/cubefbo/FBCubes.java b/src/demos/es1/cubefbo/FBCubes.java
index 9da8e07..8fe9c9f 100755
--- a/src/demos/es1/cubefbo/FBCubes.java
+++ b/src/demos/es1/cubefbo/FBCubes.java
@@ -1,21 +1,21 @@
/*
* 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
@@ -28,7 +28,7 @@
* 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;
@@ -59,7 +59,8 @@ public class FBCubes implements GLEventListener {
// JAU fbo2 = new FBObject(FBO_SIZE, FBO_SIZE);
}
- public void init(GLAutoDrawable drawable) {
+ @Override
+ public void init(GLAutoDrawable drawable) {
GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(drawable.getGL(), ShaderSelectionMode.AUTO, null);
System.out.println(gl);
@@ -68,11 +69,12 @@ public class FBCubes implements GLEventListener {
fbo1.attachRenderbuffer(gl, Attachment.Type.DEPTH, 32);
fbo1.unbind(gl);
cubeInner.init(drawable);
-
+
cubeOuter.init(drawable);
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
cubeOuter.reshape(drawable, x, y, width, height);
}
@@ -84,7 +86,8 @@ public class FBCubes implements GLEventListener {
this.yRot = yRot;
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+ public void dispose(GLAutoDrawable drawable) {
GL2ES1 gl = drawable.getGL().getGL2ES1();
fbo1.destroy(gl);
fbo1=null;
@@ -94,7 +97,8 @@ public class FBCubes implements GLEventListener {
cubeOuter=null;
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+ public void display(GLAutoDrawable drawable) {
GL2ES1 gl = drawable.getGL().getGL2ES1();
fbo1.bind(gl);
@@ -105,7 +109,7 @@ public class FBCubes implements GLEventListener {
gl.glEnable (GL.GL_TEXTURE_2D);
fbo1.use(gl, (TextureAttachment)fbo1.getColorbuffer(0));
- cubeOuter.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight());
+ cubeOuter.reshape(drawable, 0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
cubeOuter.display(drawable);
fbo1.unuse(gl);
gl.glDisable (GL.GL_TEXTURE_2D);
@@ -145,7 +149,7 @@ public class FBCubes implements GLEventListener {
public void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}
-
+
float time = 0.0f;
Cube cubeInner=null;
// JAU Cube cubeMiddle=null;
diff --git a/src/demos/gears/Gears.java b/src/demos/gears/Gears.java
index 4b1b7f9..b477ffc 100644
--- a/src/demos/gears/Gears.java
+++ b/src/demos/gears/Gears.java
@@ -6,7 +6,6 @@ import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
-import com.jogamp.opengl.util.Animator;
import com.jogamp.newt.Window;
import com.jogamp.newt.event.KeyAdapter;
@@ -17,6 +16,7 @@ import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import com.jogamp.newt.event.awt.AWTKeyAdapter;
import com.jogamp.newt.event.awt.AWTMouseAdapter;
+import com.jogamp.opengl.util.Animator;
/**
* Gears.java <BR>
@@ -26,10 +26,11 @@ import com.jogamp.newt.event.awt.AWTMouseAdapter;
*/
public class Gears implements GLEventListener {
- private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
+ private float view_rotx = 20.0f, view_roty = 30.0f;
+private final float view_rotz = 0.0f;
private int gear1=0, gear2=0, gear3=0;
private float angle = 0.0f;
- private int swapInterval;
+ private final int swapInterval;
private boolean mouseRButtonDown = false;
private int prevMouseX, prevMouseY;
@@ -37,7 +38,7 @@ public class Gears implements GLEventListener {
public static void main(String[] args) {
// set argument 'NotFirstUIActionOnProcess' in the JNLP's application-desc tag for example
// <application-desc main-class="demos.j2d.TextCube"/>
- // <argument>NotFirstUIActionOnProcess</argument>
+ // <argument>NotFirstUIActionOnProcess</argument>
// </application-desc>
// boolean firstUIActionOnProcess = 0==args.length || !args[0].equals("NotFirstUIActionOnProcess") ;
@@ -47,12 +48,14 @@ public class Gears implements GLEventListener {
final Animator animator = new Animator();
frame.addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent e) {
+ @Override
+ public void windowClosing(java.awt.event.WindowEvent e) {
// Run this on another thread than the AWT event queue to
// make sure the call to Animator.stop() completes before
// exiting
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
animator.stop();
System.exit(0);
}
@@ -74,7 +77,7 @@ public class Gears implements GLEventListener {
frame.setVisible(true);
animator.start();
}
-
+
public Gears(int swapInterval) {
this.swapInterval = swapInterval;
}
@@ -82,7 +85,7 @@ public class Gears implements GLEventListener {
public Gears() {
this.swapInterval = 1;
}
-
+
public void setGears(int g1, int g2, int g3) {
gear1 = g1;
gear2 = g2;
@@ -104,7 +107,8 @@ public class Gears implements GLEventListener {
*/
public int getGear3() { return gear3; }
- public void init(GLAutoDrawable drawable) {
+ @Override
+public void init(GLAutoDrawable drawable) {
System.err.println("Gears: Init: "+drawable);
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));
@@ -127,7 +131,7 @@ public class Gears implements GLEventListener {
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0);
gl.glEnable(GL2.GL_DEPTH_TEST);
-
+
/* make the gears */
if(0>=gear1) {
gear1 = gl.glGenLists(1);
@@ -139,7 +143,7 @@ public class Gears implements GLEventListener {
} else {
System.err.println("gear1 list reused: "+gear1);
}
-
+
if(0>=gear2) {
gear2 = gl.glGenLists(1);
gl.glNewList(gear2, GL2.GL_COMPILE);
@@ -150,7 +154,7 @@ public class Gears implements GLEventListener {
} else {
System.err.println("gear2 list reused: "+gear2);
}
-
+
if(0>=gear3) {
gear3 = gl.glGenLists(1);
gl.glNewList(gear3, GL2.GL_COMPILE);
@@ -161,11 +165,11 @@ public class Gears implements GLEventListener {
} else {
System.err.println("gear3 list reused: "+gear3);
}
-
+
gl.glEnable(GL2.GL_NORMALIZE);
-
+
// MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter());
- MouseListener gearsMouse = new GearsMouseAdapter();
+ MouseListener gearsMouse = new GearsMouseAdapter();
KeyListener gearsKeys = new GearsKeyAdapter();
if (drawable instanceof Window) {
@@ -178,15 +182,16 @@ public class Gears implements GLEventListener {
new AWTKeyAdapter(gearsKeys).addTo(comp);
}
}
-
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+
+ @Override
+public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height);
GL2 gl = drawable.getGL().getGL2();
gl.setSwapInterval(swapInterval);
float h = (float)height / (float)width;
-
+
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
@@ -196,12 +201,14 @@ public class Gears implements GLEventListener {
gl.glTranslatef(0.0f, 0.0f, -40.0f);
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+public void dispose(GLAutoDrawable drawable) {
System.err.println("Gears: Dispose");
setGears(0, 0, 0);
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+public void display(GLAutoDrawable drawable) {
// Turn the gears' teeth
angle += 2.0f;
@@ -212,7 +219,7 @@ public class Gears implements GLEventListener {
// Special handling for the case where the GLJPanel is translucent
// and wants to be composited with other Java 2D content
- if (GLProfile.isAWTAvailable() &&
+ if (GLProfile.isAWTAvailable() &&
(drawable instanceof javax.media.opengl.awt.GLJPanel) &&
!((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() &&
((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) {
@@ -220,35 +227,35 @@ public class Gears implements GLEventListener {
} else {
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
}
-
+
// Rotate the entire assembly of gears based on how the user
// dragged the mouse around
gl.glPushMatrix();
gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
-
+
// Place the first gear and call its display list
gl.glPushMatrix();
gl.glTranslatef(-3.0f, -2.0f, 0.0f);
gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
gl.glCallList(gear1);
gl.glPopMatrix();
-
+
// Place the second gear and call its display list
gl.glPushMatrix();
gl.glTranslatef(3.1f, -2.0f, 0.0f);
gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
gl.glCallList(gear2);
gl.glPopMatrix();
-
+
// Place the third gear and call its display list
gl.glPushMatrix();
gl.glTranslatef(-3.1f, 4.2f, 0.0f);
gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
gl.glCallList(gear3);
gl.glPopMatrix();
-
+
// Remember that every push needs a pop; this one is paired with
// rotating the entire gear assembly
gl.glPopMatrix();
@@ -269,9 +276,9 @@ public class Gears implements GLEventListener {
r0 = inner_radius;
r1 = outer_radius - tooth_depth / 2.0f;
r2 = outer_radius + tooth_depth / 2.0f;
-
+
da = 2.0f * (float) Math.PI / teeth / 4.0f;
-
+
gl.glShadeModel(GL2.GL_FLAT);
gl.glNormal3f(0.0f, 0.0f, 1.0f);
@@ -302,7 +309,7 @@ public class Gears implements GLEventListener {
gl.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), width * 0.5f);
}
gl.glEnd();
-
+
/* draw back face */
gl.glBegin(GL2.GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++)
@@ -314,7 +321,7 @@ public class Gears implements GLEventListener {
gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
}
gl.glEnd();
-
+
/* draw back sides of teeth */
gl.glBegin(GL2.GL_QUADS);
for (i = 0; i < teeth; i++)
@@ -326,7 +333,7 @@ public class Gears implements GLEventListener {
gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
}
gl.glEnd();
-
+
/* draw outward faces of teeth */
gl.glBegin(GL2.GL_QUAD_STRIP);
for (i = 0; i < teeth; i++)
@@ -355,9 +362,9 @@ public class Gears implements GLEventListener {
gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), width * 0.5f);
gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f);
gl.glEnd();
-
+
gl.glShadeModel(GL2.GL_SMOOTH);
-
+
/* draw inside radius cylinder */
gl.glBegin(GL2.GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++)
@@ -370,8 +377,9 @@ public class Gears implements GLEventListener {
gl.glEnd();
}
- class GearsKeyAdapter extends KeyAdapter {
- public void keyPressed(KeyEvent e) {
+ class GearsKeyAdapter extends KeyAdapter {
+ @Override
+ public void keyPressed(KeyEvent e) {
int kc = e.getKeyCode();
if(KeyEvent.VK_LEFT == kc) {
view_roty -= 1;
@@ -384,31 +392,38 @@ public class Gears implements GLEventListener {
}
}
}
-
+
class GearsMouseAdapter extends MouseAdapter {
- public void mousePressed(MouseEvent e) {
+ @Override
+ public void mousePressed(MouseEvent e) {
prevMouseX = e.getX();
prevMouseY = e.getY();
if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
mouseRButtonDown = true;
}
}
-
- public void mouseReleased(MouseEvent e) {
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
if ((e.getModifiers() & e.BUTTON3_MASK) != 0) {
mouseRButtonDown = false;
}
}
-
- public void mouseDragged(MouseEvent e) {
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
int x = e.getX();
int y = e.getY();
int width=0, height=0;
Object source = e.getSource();
if(source instanceof Window) {
Window window = (Window) source;
- width=window.getWidth();
- height=window.getHeight();
+ width=window.getSurfaceWidth();
+ height=window.getSurfaceHeight();
+ } else if(source instanceof GLAutoDrawable) {
+ GLAutoDrawable glad = (GLAutoDrawable) source;
+ width=glad.getSurfaceWidth();
+ height=glad.getSurfaceHeight();
} else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) {
java.awt.Component comp = (java.awt.Component) source;
width=comp.getWidth();
@@ -418,7 +433,7 @@ public class Gears implements GLEventListener {
}
float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height);
-
+
prevMouseX = x;
prevMouseY = y;
diff --git a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
index d6b6c2f..a53c140 100644
--- a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
+++ b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
@@ -33,11 +33,6 @@
package demos.hwShadowmapsSimple;
-import com.jogamp.opengl.util.gl2.GLUT;
-import com.jogamp.opengl.util.texture.Texture;
-import com.jogamp.opengl.util.texture.TextureIO;
-import demos.common.Demo;
-import demos.common.DemoListener;
import gleem.BSphere;
import gleem.BSphereProvider;
import gleem.CameraParameters;
@@ -47,6 +42,7 @@ import gleem.ManipManager;
import gleem.linalg.Mat4f;
import gleem.linalg.Rotf;
import gleem.linalg.Vec3f;
+
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.KeyAdapter;
@@ -55,6 +51,7 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.util.ArrayList;
+
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
@@ -67,6 +64,13 @@ import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;
import javax.swing.JOptionPane;
+import com.jogamp.opengl.util.gl2.GLUT;
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureIO;
+
+import demos.common.Demo;
+import demos.common.DemoListener;
+
/** This demo is a simple illustration of ARB_shadow and ARB_depth_texture. <P>
Cass Everitt <BR>
@@ -84,17 +88,20 @@ public class HWShadowmapsSimple extends Demo {
canvas.addGLEventListener(demo);
canvas.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
+ @Override
+ public void keyPressed(KeyEvent e) {
demo.dispatchKey(e.getKeyChar());
demo.demoListener.repaint();
}
});
demo.setDemoListener(new DemoListener() {
- public void shutdownDemo() {
+ @Override
+ public void shutdownDemo() {
runExit();
}
- public void repaint() {
+ @Override
+ public void repaint() {
canvas.repaint();
}
});
@@ -108,7 +115,8 @@ public class HWShadowmapsSimple extends Demo {
canvas.requestFocus();
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
+ @Override
+ public void windowClosing(WindowEvent e) {
runExit();
}
});
@@ -118,7 +126,8 @@ public class HWShadowmapsSimple extends Demo {
// Internals only below this point
//
- public void shutdownDemo() {
+ @Override
+public void shutdownDemo() {
ManipManager.getManipManager().unregisterWindow((AWTGLAutoDrawable) drawable);
drawable.removeGLEventListener(this);
super.shutdownDemo();
@@ -129,9 +138,9 @@ public class HWShadowmapsSimple extends Demo {
private GLU glu;
private GLUT glut;
- private float[] light_ambient = { 0, 0, 0, 0 };
- private float[] light_intensity = { 1, 1, 1, 1 };
- private float[] light_pos = { 0, 0, 0, 1 };
+ private final float[] light_ambient = { 0, 0, 0, 0 };
+ private final float[] light_intensity = { 1, 1, 1, 1 };
+ private final float[] light_pos = { 0, 0, 0, 1 };
static class Tweak {
String name;
@@ -144,7 +153,7 @@ public class HWShadowmapsSimple extends Demo {
this.incr = incr;
}
};
- private java.util.List<Tweak> tweaks = new ArrayList<Tweak>();
+ private final java.util.List<Tweak> tweaks = new ArrayList<Tweak>();
private static final int R_COORDINATE_SCALE = 0;
private static final int R_COORDINATE_BIAS = 1;
private static final int POLYGON_OFFSET_SCALE = 2;
@@ -175,9 +184,9 @@ public class HWShadowmapsSimple extends Demo {
private int geometry;
// Shadowing light
- private float lightshaper_fovy = 60.0f;
- private float lightshaper_zNear = 0.5f;
- private float lightshaper_zFar = 5.0f;
+ private final float lightshaper_fovy = 60.0f;
+ private final float lightshaper_zNear = 0.5f;
+ private final float lightshaper_zFar = 5.0f;
// Manipulators
private GLAutoDrawable drawable;
@@ -185,20 +194,21 @@ public class HWShadowmapsSimple extends Demo {
private boolean doViewAll = true;
// private float zNear = 0.5f;
// private float zFar = 5.0f;
- private float zNear = 0.5f;
- private float zFar = 50.0f;
+ private final float zNear = 0.5f;
+ private final float zFar = 50.0f;
private HandleBoxManip object;
private HandleBoxManip spotlight;
- private Mat4f cameraPerspective = new Mat4f();
- private Mat4f cameraTransform = new Mat4f();
- private Mat4f cameraInverseTransform = new Mat4f();
- private Mat4f spotlightTransform = new Mat4f();
- private Mat4f spotlightInverseTransform = new Mat4f();
- private Mat4f objectTransform = new Mat4f();
+ private final Mat4f cameraPerspective = new Mat4f();
+ private final Mat4f cameraTransform = new Mat4f();
+ private final Mat4f cameraInverseTransform = new Mat4f();
+ private final Mat4f spotlightTransform = new Mat4f();
+ private final Mat4f spotlightInverseTransform = new Mat4f();
+ private final Mat4f objectTransform = new Mat4f();
private int viewportX;
private int viewportY;
- public void init(GLAutoDrawable drawable) {
+ @Override
+public void init(GLAutoDrawable drawable) {
// Use debug/trace pipeline
/**
GL _gl = drawable.getGL();
@@ -222,7 +232,7 @@ public class HWShadowmapsSimple extends Demo {
e.printStackTrace();
throw(e);
}
-
+
gl.glClearColor(.5f, .5f, .5f, .5f);
try {
@@ -275,7 +285,7 @@ public class HWShadowmapsSimple extends Demo {
// init pbuffer
GLCapabilities caps = new GLCapabilities(gl.getGLProfile());
caps.setDoubleBuffered(false);
-
+
if (!GLDrawableFactory.getFactory(gl.getGLProfile()).canCreateGLPbuffer(null, gl.getGLProfile())) {
unavailableExtension("Can not create pbuffer");
}
@@ -307,7 +317,8 @@ public class HWShadowmapsSimple extends Demo {
viewer = new ExaminerViewer();
viewer.setUpVector(Vec3f.Y_AXIS);
viewer.attach((AWTGLAutoDrawable) drawable, new BSphereProvider() {
- public BSphere getBoundingSphere() {
+ @Override
+ public BSphere getBoundingSphere() {
return new BSphere(object.getTranslation(), 2.0f);
}
});
@@ -326,12 +337,14 @@ public class HWShadowmapsSimple extends Demo {
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+public void dispose(GLAutoDrawable drawable) {
glu = null;
glut = null;
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+public void display(GLAutoDrawable drawable) {
viewer.update();
// Grab these values once per render to avoid multithreading
@@ -385,7 +398,8 @@ public class HWShadowmapsSimple extends Demo {
}
// Unused routines
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ @Override
+public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
viewportX = x;
viewportY = y;
}
@@ -428,7 +442,8 @@ public class HWShadowmapsSimple extends Demo {
}
class PbufferListener implements GLEventListener {
- public void init(GLAutoDrawable drawable) {
+ @Override
+ public void init(GLAutoDrawable drawable) {
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));
@@ -438,7 +453,7 @@ public class HWShadowmapsSimple extends Demo {
int[] depth_bits = new int[1];
gl.glGetIntegerv(GL2.GL_DEPTH_BITS, depth_bits, 0);
-
+
if (depth_bits[0] == 16) depth_format = GL2.GL_DEPTH_COMPONENT16;
else depth_format = GL2.GL_DEPTH_COMPONENT24;
@@ -451,10 +466,12 @@ public class HWShadowmapsSimple extends Demo {
fullyInitialized = true;
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+ public void dispose(GLAutoDrawable drawable) {
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+ public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
@@ -466,7 +483,7 @@ public class HWShadowmapsSimple extends Demo {
render_scene_from_light_view(gl, drawable, 0, 0);
gl.glDisable(GL2.GL_POLYGON_OFFSET_FILL);
-
+
gl.glBindTexture(GL2.GL_TEXTURE_2D, light_view_depth);
// trying different ways of getting the depth info over
@@ -474,7 +491,8 @@ public class HWShadowmapsSimple extends Demo {
}
// Unused routines
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
}
@@ -624,7 +642,7 @@ public class HWShadowmapsSimple extends Demo {
gl.glPushMatrix();
applyTransform(gl, cameraInverseTransform);
- eye_linear_texgen(gl);
+ eye_linear_texgen(gl);
texgen(gl, true);
gl.glPopMatrix();
@@ -643,7 +661,7 @@ public class HWShadowmapsSimple extends Demo {
gl.glActiveTexture(GL2.GL_TEXTURE0);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
- gl.glViewport(viewportX, viewportY, drawable.getWidth(), drawable.getHeight());
+ gl.glViewport(viewportX, viewportY, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
applyTransform(gl, cameraPerspective);
gl.glMatrixMode(GL2.GL_MODELVIEW);
render_scene(gl, cameraTransform, drawable, params);
@@ -671,7 +689,7 @@ public class HWShadowmapsSimple extends Demo {
gl.glPushMatrix();
applyTransform(gl, cameraInverseTransform);
- eye_linear_texgen(gl);
+ eye_linear_texgen(gl);
texgen(gl, true);
gl.glPopMatrix();
@@ -692,7 +710,7 @@ public class HWShadowmapsSimple extends Demo {
gl.glPushMatrix();
applyTransform(gl, cameraInverseTransform);
- eye_linear_texgen(gl);
+ eye_linear_texgen(gl);
texgen(gl, true);
gl.glPopMatrix();
@@ -707,12 +725,12 @@ public class HWShadowmapsSimple extends Demo {
gl.glBindTexture(GL2.GL_TEXTURE_2D, light_view_depth);
gl.glEnable(GL2.GL_TEXTURE_2D);
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE);
-
+
gl.glActiveTexture(GL2.GL_TEXTURE0);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
- gl.glViewport(viewportX, viewportY, drawable.getWidth(), drawable.getHeight());
+ gl.glViewport(viewportX, viewportY, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
applyTransform(gl, cameraPerspective);
gl.glMatrixMode(GL2.GL_MODELVIEW);
render_scene(gl, cameraTransform, drawable, params);
@@ -729,7 +747,7 @@ public class HWShadowmapsSimple extends Demo {
}
private void largest_square_power_of_two_viewport(GL2 gl, GLAutoDrawable drawable, int viewportX, int viewportY) {
- float min = Math.min(drawable.getWidth(), drawable.getHeight());
+ float min = Math.min(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
float log2min = (float) Math.log(min) / (float) Math.log(2.0);
float pow2 = (float) Math.floor(log2min);
int size = 1 << (int) pow2;
@@ -747,7 +765,7 @@ public class HWShadowmapsSimple extends Demo {
gl.glActiveTexture(GL2.GL_TEXTURE1);
gl.glPushMatrix();
- eye_linear_texgen(gl);
+ eye_linear_texgen(gl);
texgen(gl, true);
gl.glPopMatrix();
@@ -806,13 +824,13 @@ public class HWShadowmapsSimple extends Demo {
m.set(0, 0, (right - left) / (2 * zNear));
m.set(0, 3, (right + left) / (2 * zNear));
-
+
m.set(1, 1, (top - bottom) / (2 * zNear));
m.set(1, 3, (top + bottom) / (2 * zNear));
m.set(2, 2, 0);
m.set(2, 3, -1);
-
+
m.set(3, 2, -(zFar - zNear) / (2 * zFar * zNear));
m.set(3, 3, (zFar + zNear) / (2 * zFar * zNear));
@@ -826,7 +844,8 @@ public class HWShadowmapsSimple extends Demo {
// routines cause a global AWT lock to be grabbed. Run the
// exit routine in another thread.
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
System.exit(0);
}
}).start();
diff --git a/src/demos/j2d/CustomText.java b/src/demos/j2d/CustomText.java
index 8405b6e..d324a0e 100755
--- a/src/demos/j2d/CustomText.java
+++ b/src/demos/j2d/CustomText.java
@@ -1,21 +1,21 @@
/*
* Copyright (c) 2006 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
@@ -28,26 +28,19 @@
* 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.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
package demos.j2d;
-import com.jogamp.opengl.util.awt.TextRenderer;
-import com.jogamp.opengl.util.texture.Texture;
-import com.jogamp.opengl.util.texture.TextureCoords;
-import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
-import demos.common.Demo;
-import demos.util.FPSCounter;
-import demos.util.SystemTime;
-import demos.util.Time;
import gleem.linalg.Vec2f;
+
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
@@ -68,17 +61,28 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
+
import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES1;
import javax.media.opengl.GL2;
+import javax.media.opengl.GL2ES1;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;
-import com.jogamp.opengl.util.Animator;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.awt.TextRenderer;
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureCoords;
+import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
+
+import demos.common.Demo;
+import demos.util.FPSCounter;
+import demos.util.SystemTime;
+import demos.util.Time;
+
/** Illustrates more advanced use of the TextRenderer class; shows how
to do text filled with a linear Java 2D gradient. */
@@ -103,12 +107,14 @@ public class CustomText extends Demo {
final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
+ @Override
+ public void windowClosing(WindowEvent e) {
// Run this on another thread than the AWT event queue to
// make sure the call to Animator.stop() completes before
// exiting
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
animator.stop();
System.exit(0);
}
@@ -135,12 +141,12 @@ public class CustomText extends Demo {
String text;
}
- private List<TextInfo> textInfo = new ArrayList<TextInfo>();
+ private final List<TextInfo> textInfo = new ArrayList<TextInfo>();
private Time time;
private Texture backgroundTexture;
private TextRenderer renderer;
- private Random random = new Random();
- private GLU glu = new GLU();
+ private final Random random = new Random();
+ private final GLU glu = new GLU();
private int width;
private int height;
@@ -153,14 +159,16 @@ public class CustomText extends Demo {
JPanel panel = new JPanel();
JButton button = new JButton("Less Text");
button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
lessText();
}
});
panel.add(button);
button = new JButton("More Text");
button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
moreText();
}
});
@@ -188,7 +196,8 @@ public class CustomText extends Demo {
}
}
- public void init(GLAutoDrawable drawable) {
+ @Override
+public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
// Create the background texture
@@ -214,8 +223,8 @@ public class CustomText extends Demo {
// Create the FPS counter
fps = new FPSCounter(drawable, 36);
- width = drawable.getWidth();
- height = drawable.getWidth();
+ width = drawable.getSurfaceWidth();
+ height = drawable.getSurfaceWidth();
// Compute maximum width of text we're going to draw to avoid
// popping in/out at edges
@@ -237,10 +246,12 @@ public class CustomText extends Demo {
gl.setSwapInterval(0);
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+public void dispose(GLAutoDrawable drawable) {
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+public void display(GLAutoDrawable drawable) {
time.update();
// Update velocities and positions of all text
@@ -270,14 +281,14 @@ public class CustomText extends Demo {
// Use maxTextWidth to avoid popping in/out at edges
// Would be better to do oriented bounding rectangle computation
if (info.position.x() < -maxTextWidth) {
- info.position.setX(info.position.x() + drawable.getWidth() + 2 * maxTextWidth);
- } else if (info.position.x() > drawable.getWidth() + maxTextWidth) {
- info.position.setX(info.position.x() - drawable.getWidth() - 2 * maxTextWidth);
+ info.position.setX(info.position.x() + drawable.getSurfaceWidth() + 2 * maxTextWidth);
+ } else if (info.position.x() > drawable.getSurfaceWidth() + maxTextWidth) {
+ info.position.setX(info.position.x() - drawable.getSurfaceWidth() - 2 * maxTextWidth);
}
if (info.position.y() < -maxTextWidth) {
- info.position.setY(info.position.y() + drawable.getHeight() + 2 * maxTextWidth);
- } else if (info.position.y() > drawable.getHeight() + maxTextWidth) {
- info.position.setY(info.position.y() - drawable.getHeight() - 2 * maxTextWidth);
+ info.position.setY(info.position.y() + drawable.getSurfaceHeight() + 2 * maxTextWidth);
+ } else if (info.position.y() > drawable.getSurfaceHeight() + maxTextWidth) {
+ info.position.setY(info.position.y() - drawable.getSurfaceHeight() - 2 * maxTextWidth);
}
}
@@ -285,7 +296,7 @@ public class CustomText extends Demo {
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glMatrixMode(GL2ES1.GL_PROJECTION);
gl.glLoadIdentity();
- glu.gluOrtho2D(0, drawable.getWidth(), 0, drawable.getHeight());
+ glu.gluOrtho2D(0, drawable.getSurfaceWidth(), 0, drawable.getSurfaceHeight());
gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
gl.glLoadIdentity();
@@ -293,8 +304,8 @@ public class CustomText extends Demo {
backgroundTexture.enable(gl);
backgroundTexture.bind(gl);
TextureCoords coords = backgroundTexture.getImageTexCoords();
- int w = drawable.getWidth();
- int h = drawable.getHeight();
+ int w = drawable.getSurfaceWidth();
+ int h = drawable.getSurfaceHeight();
float fw = w / 100.0f;
float fh = h / 100.0f;
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
@@ -311,7 +322,7 @@ public class CustomText extends Demo {
backgroundTexture.disable(gl);
// Render all text
- renderer.beginRendering(drawable.getWidth(), drawable.getHeight());
+ renderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
// Note we're doing some slightly fancy stuff to position the text.
// We tell the text renderer to render the text at the origin, and
@@ -336,7 +347,8 @@ public class CustomText extends Demo {
fps.draw();
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ @Override
+public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
this.width = width;
this.height = height;
}
@@ -387,10 +399,10 @@ public class CustomText extends Demo {
private static final Color DROP_SHADOW_COLOR = new Color(0, 0, 0, 0.5f);
class CustomRenderDelegate implements TextRenderer.RenderDelegate {
- private float gradientSize;
- private int dropShadowDepth;
- private Color color1;
- private Color color2;
+ private final float gradientSize;
+ private final int dropShadowDepth;
+ private final Color color1;
+ private final Color color2;
CustomRenderDelegate(float gradientSize, int dropShadowDepth, Color color1, Color color2) {
@@ -400,31 +412,36 @@ public class CustomText extends Demo {
this.color2 = color2;
}
- public boolean intensityOnly() {
+ @Override
+ public boolean intensityOnly() {
return false;
}
- public Rectangle2D getBounds(CharSequence str,
+ @Override
+ public Rectangle2D getBounds(CharSequence str,
Font font,
FontRenderContext frc) {
return getBounds(str.toString(), font, frc);
}
- public Rectangle2D getBounds(String str,
+ @Override
+ public Rectangle2D getBounds(String str,
Font font,
FontRenderContext frc) {
return getBounds(font.createGlyphVector(frc, str), frc);
}
- public Rectangle2D getBounds(GlyphVector gv, FontRenderContext frc) {
+ @Override
+ public Rectangle2D getBounds(GlyphVector gv, FontRenderContext frc) {
Rectangle2D stringBounds = gv.getPixelBounds(frc, 0, 0);
return new Rectangle2D.Double(stringBounds.getX(),
stringBounds.getY(),
stringBounds.getWidth() + dropShadowDepth,
stringBounds.getHeight() + dropShadowDepth);
}
-
- public void drawGlyphVector(Graphics2D graphics, GlyphVector str, int x, int y) {
+
+ @Override
+ public void drawGlyphVector(Graphics2D graphics, GlyphVector str, int x, int y) {
graphics.setColor(DROP_SHADOW_COLOR);
graphics.drawGlyphVector(str, x + dropShadowDepth, y + dropShadowDepth);
graphics.setColor(Color.WHITE);
@@ -434,7 +451,8 @@ public class CustomText extends Demo {
graphics.drawGlyphVector(str, x, y);
}
- public void draw(Graphics2D graphics, String str, int x, int y) {
+ @Override
+ public void draw(Graphics2D graphics, String str, int x, int y) {
graphics.setColor(DROP_SHADOW_COLOR);
graphics.drawString(str, x + dropShadowDepth, y + dropShadowDepth);
graphics.setColor(Color.WHITE);
diff --git a/src/demos/j2d/FlyingText.java b/src/demos/j2d/FlyingText.java
index 949a231..de4df71 100755
--- a/src/demos/j2d/FlyingText.java
+++ b/src/demos/j2d/FlyingText.java
@@ -1,21 +1,21 @@
/*
* Copyright (c) 2006 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
@@ -28,26 +28,19 @@
* 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.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
package demos.j2d;
-import com.jogamp.opengl.util.awt.TextRenderer;
-import com.jogamp.opengl.util.texture.Texture;
-import com.jogamp.opengl.util.texture.TextureCoords;
-import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
-import demos.common.Demo;
-import demos.util.FPSCounter;
-import demos.util.SystemTime;
-import demos.util.Time;
import gleem.linalg.Vec2f;
+
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
@@ -64,12 +57,12 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
+
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;
-import com.jogamp.opengl.util.Animator;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
@@ -77,6 +70,17 @@ import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.awt.TextRenderer;
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureCoords;
+import com.jogamp.opengl.util.texture.awt.AWTTextureIO;
+
+import demos.common.Demo;
+import demos.util.FPSCounter;
+import demos.util.SystemTime;
+import demos.util.Time;
+
/** Illustrates more advanced use of the TextRenderer class; shows how
@@ -103,12 +107,14 @@ public class FlyingText extends Demo {
final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
+ @Override
+ public void windowClosing(WindowEvent e) {
// Run this on another thread than the AWT event queue to
// make sure the call to Animator.stop() completes before
// exiting
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
animator.stop();
System.exit(0);
}
@@ -147,13 +153,13 @@ public class FlyingText extends Demo {
String text;
}
- private List<TextInfo> textInfo = new ArrayList<TextInfo>();
+ private final List<TextInfo> textInfo = new ArrayList<TextInfo>();
private int dropShadowDistance = DEFAULT_DROP_SHADOW_DIST;
private Time time;
private Texture backgroundTexture;
private TextRenderer renderer;
- private Random random = new Random();
- private GLU glu = new GLU();
+ private final Random random = new Random();
+ private final GLU glu = new GLU();
private int width;
private int height;
@@ -166,7 +172,8 @@ public class FlyingText extends Demo {
JPanel panel = new JPanel();
JButton button = new JButton("Less Text");
button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
lessText();
}
});
@@ -176,14 +183,16 @@ public class FlyingText extends Demo {
getMaxDropShadowDistance(),
getDropShadowDistance());
slider.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent e) {
+ @Override
+ public void stateChanged(ChangeEvent e) {
setDropShadowDistance(slider.getValue());
}
});
panel.add(slider);
button = new JButton("More Text");
button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
moreText();
}
});
@@ -227,7 +236,8 @@ public class FlyingText extends Demo {
dropShadowDistance = dist;
}
- public void init(GLAutoDrawable drawable) {
+ @Override
+public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
// Create the background texture
BufferedImage bgImage = new BufferedImage(2, 2, BufferedImage.TYPE_BYTE_GRAY);
@@ -251,8 +261,8 @@ public class FlyingText extends Demo {
// Create the FPS counter
fps = new FPSCounter(drawable, 36);
- width = drawable.getWidth();
- height = drawable.getWidth();
+ width = drawable.getSurfaceWidth();
+ height = drawable.getSurfaceHeight();
// Compute maximum width of text we're going to draw to avoid
// popping in/out at edges
@@ -274,14 +284,16 @@ public class FlyingText extends Demo {
gl.setSwapInterval(0);
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+public void dispose(GLAutoDrawable drawable) {
backgroundTexture = null;
renderer = null;
fps = null;
time = null;
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+public void display(GLAutoDrawable drawable) {
time.update();
// Update velocities and positions of all text
@@ -323,14 +335,14 @@ public class FlyingText extends Demo {
// Use maxTextWidth to avoid popping in/out at edges
// Would be better to do oriented bounding rectangle computation
if (info.position.x() < -maxTextWidth) {
- info.position.setX(info.position.x() + drawable.getWidth() + 2 * maxTextWidth);
- } else if (info.position.x() > drawable.getWidth() + maxTextWidth) {
- info.position.setX(info.position.x() - drawable.getWidth() - 2 * maxTextWidth);
+ info.position.setX(info.position.x() + drawable.getSurfaceWidth() + 2 * maxTextWidth);
+ } else if (info.position.x() > drawable.getSurfaceWidth() + maxTextWidth) {
+ info.position.setX(info.position.x() - drawable.getSurfaceWidth() - 2 * maxTextWidth);
}
if (info.position.y() < -maxTextWidth) {
- info.position.setY(info.position.y() + drawable.getHeight() + 2 * maxTextWidth);
- } else if (info.position.y() > drawable.getHeight() + maxTextWidth) {
- info.position.setY(info.position.y() - drawable.getHeight() - 2 * maxTextWidth);
+ info.position.setY(info.position.y() + drawable.getSurfaceHeight() + 2 * maxTextWidth);
+ } else if (info.position.y() > drawable.getSurfaceHeight() + maxTextWidth) {
+ info.position.setY(info.position.y() - drawable.getSurfaceHeight() - 2 * maxTextWidth);
}
}
@@ -338,7 +350,7 @@ public class FlyingText extends Demo {
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
- glu.gluOrtho2D(0, drawable.getWidth(), 0, drawable.getHeight());
+ glu.gluOrtho2D(0, drawable.getSurfaceWidth(), 0, drawable.getSurfaceHeight());
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
@@ -346,8 +358,8 @@ public class FlyingText extends Demo {
backgroundTexture.enable(gl);
backgroundTexture.bind(gl);
TextureCoords coords = backgroundTexture.getImageTexCoords();
- int w = drawable.getWidth();
- int h = drawable.getHeight();
+ int w = drawable.getSurfaceWidth();
+ int h = drawable.getSurfaceHeight();
float fw = w / 100.0f;
float fh = h / 100.0f;
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
@@ -364,7 +376,7 @@ public class FlyingText extends Demo {
backgroundTexture.disable(gl);
// Render all text
- renderer.beginRendering(drawable.getWidth(), drawable.getHeight());
+ renderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
// Note we're doing some slightly fancy stuff to position the text.
// We tell the text renderer to render the text at the origin, and
@@ -406,7 +418,8 @@ public class FlyingText extends Demo {
fps.draw();
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ @Override
+public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
this.width = width;
this.height = height;
}
diff --git a/src/demos/j2d/TestOverlay.java b/src/demos/j2d/TestOverlay.java
index 13cb39e..bc2bcef 100755
--- a/src/demos/j2d/TestOverlay.java
+++ b/src/demos/j2d/TestOverlay.java
@@ -1,21 +1,21 @@
/*
* Copyright (c) 2006 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
@@ -28,21 +28,19 @@
* 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.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
package demos.j2d;
-import com.jogamp.opengl.util.awt.Overlay;
-import demos.gears.Gears;
-import demos.util.*;
-import gleem.linalg.*;
+import gleem.linalg.Vec2f;
+
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
@@ -54,12 +52,19 @@ import java.awt.event.WindowEvent;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.text.DecimalFormat;
+
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLCanvas;
+
import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.awt.Overlay;
+
+import demos.gears.Gears;
+import demos.util.SystemTime;
+import demos.util.Time;
/** A simple test of the Overlay utility class. Draws gears underneath
with moving Java 2D-rendered text on top. */
@@ -76,12 +81,14 @@ public class TestOverlay implements GLEventListener {
frame.setSize(512, 512);
final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
+ @Override
+ public void windowClosing(WindowEvent e) {
// Run this on another thread than the AWT event queue to
// make sure the call to Animator.stop() completes before
// exiting
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
animator.stop();
System.exit(0);
}
@@ -95,21 +102,22 @@ public class TestOverlay implements GLEventListener {
private Overlay overlay;
private Time time;
private Font font;
- private Color TRANSPARENT_BLACK = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+ private final Color TRANSPARENT_BLACK = new Color(0.0f, 0.0f, 0.0f, 0.0f);
private FontRenderContext frc;
private GlyphVector gv;
- private Vec2f velocity = new Vec2f(100.0f, 150.0f);
+ private final Vec2f velocity = new Vec2f(100.0f, 150.0f);
private Vec2f position;
private Rectangle textBounds;
private Rectangle lastTextBounds;
- private String TEST_STRING = "Java 2D Text";
+ private final String TEST_STRING = "Java 2D Text";
private long startTime;
private int frameCount;
- private DecimalFormat format = new DecimalFormat("####.00");
+ private final DecimalFormat format = new DecimalFormat("####.00");
private Rectangle fpsBounds;
- public void init(GLAutoDrawable drawable) {
+ @Override
+public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.setSwapInterval(0);
@@ -118,20 +126,22 @@ public class TestOverlay implements GLEventListener {
((SystemTime) time).rebase();
// Start the text half way up the left side
- position = new Vec2f(0.0f, drawable.getHeight() / 2);
+ position = new Vec2f(0.0f, drawable.getSurfaceHeight() / 2);
// Create the font, render context, and glyph vector
font = new Font("SansSerif", Font.BOLD, 36);
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+public void dispose(GLAutoDrawable drawable) {
font = null;
overlay = null;
time = null;
position = null;
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+public void display(GLAutoDrawable drawable) {
if (startTime == 0) {
startTime = System.currentTimeMillis();
}
@@ -140,7 +150,7 @@ public class TestOverlay implements GLEventListener {
if (++frameCount == 30) {
long endTime = System.currentTimeMillis();
- float fps = 30.0f / (float) (endTime - startTime) * 1000;
+ float fps = 30.0f / (endTime - startTime) * 1000;
frameCount = 0;
startTime = System.currentTimeMillis();
@@ -148,8 +158,8 @@ public class TestOverlay implements GLEventListener {
String fpsString = "FPS: " + format.format(fps);
GlyphVector gv = font.createGlyphVector(frc, TEST_STRING);
fpsBounds = gv.getPixelBounds(frc, 0, 0);
- int x = drawable.getWidth() - fpsBounds.width - 20;
- int y = drawable.getHeight() - 20;
+ int x = drawable.getSurfaceWidth() - fpsBounds.width - 20;
+ int y = drawable.getSurfaceHeight() - 20;
g2d.setFont(font);
g2d.setComposite(AlphaComposite.Src);
g2d.setColor(TRANSPARENT_BLACK);
@@ -174,12 +184,12 @@ public class TestOverlay implements GLEventListener {
textBounds = gv.getPixelBounds(frc, position.x(), position.y());
if (textBounds.getMinX() < 0) {
velocity.setX(Math.abs(velocity.x()));
- } else if (textBounds.getMaxX() > drawable.getWidth()) {
+ } else if (textBounds.getMaxX() > drawable.getSurfaceWidth()) {
velocity.setX(-1.0f * Math.abs(velocity.x()));
}
if (textBounds.getMinY() < 0) {
velocity.setY(Math.abs(velocity.y()));
- } else if (textBounds.getMaxY() > drawable.getHeight()) {
+ } else if (textBounds.getMaxY() > drawable.getSurfaceHeight()) {
velocity.setY(-1.0f * Math.abs(velocity.y()));
}
@@ -190,7 +200,7 @@ public class TestOverlay implements GLEventListener {
(int) (lastTextBounds.getWidth() + 1), (int) (lastTextBounds.getHeight() + 1));
} else if (overlay.contentsLost()) {
g2d.setColor(TRANSPARENT_BLACK);
- g2d.fillRect(0, 0, drawable.getWidth(), drawable.getHeight());
+ g2d.fillRect(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
}
g2d.setColor(Color.WHITE);
g2d.drawString(TEST_STRING, position.x(), position.y());
@@ -213,6 +223,7 @@ public class TestOverlay implements GLEventListener {
}
// Unused methods
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
+ @Override
+public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
}
diff --git a/src/demos/j2d/TestTextRenderer.java b/src/demos/j2d/TestTextRenderer.java
index 4779522..0898ceb 100755
--- a/src/demos/j2d/TestTextRenderer.java
+++ b/src/demos/j2d/TestTextRenderer.java
@@ -1,21 +1,21 @@
/*
* Copyright (c) 2006 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
@@ -28,34 +28,38 @@
* 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.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
package demos.j2d;
-import com.jogamp.opengl.util.awt.TextRenderer;
-import demos.gears.Gears;
-import demos.util.FPSCounter;
-import demos.util.SystemTime;
-import demos.util.Time;
import gleem.linalg.Vec2f;
+
import java.awt.Font;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Rectangle2D;
+
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLCanvas;
+
import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.awt.TextRenderer;
+
+import demos.gears.Gears;
+import demos.util.FPSCounter;
+import demos.util.SystemTime;
+import demos.util.Time;
@@ -74,12 +78,14 @@ public class TestTextRenderer implements GLEventListener {
frame.setSize(512, 512);
final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
+ @Override
+ public void windowClosing(WindowEvent e) {
// Run this on another thread than the AWT event queue to
// make sure the call to Animator.stop() completes before
// exiting
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
animator.stop();
System.exit(0);
}
@@ -94,14 +100,15 @@ public class TestTextRenderer implements GLEventListener {
private TextRenderer renderer;
private Time time;
// private Font font;
- private Vec2f velocity = new Vec2f(100.0f, 150.0f);
+ private final Vec2f velocity = new Vec2f(100.0f, 150.0f);
private Vec2f position;
- private String TEST_STRING = "Java 2D Text";
+ private final String TEST_STRING = "Java 2D Text";
private int textWidth;
private int textHeight;
private FPSCounter fps;
- public void init(GLAutoDrawable drawable) {
+ @Override
+public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
// Don't artificially slow us down, at least on platforms where we
@@ -115,7 +122,7 @@ public class TestTextRenderer implements GLEventListener {
((SystemTime) time).rebase();
// Start the text half way up the left side
- position = new Vec2f(0.0f, drawable.getHeight() / 2);
+ position = new Vec2f(0.0f, drawable.getSurfaceHeight() / 2);
Rectangle2D textBounds = renderer.getBounds(TEST_STRING);
textWidth = (int) textBounds.getWidth();
textHeight = (int) textBounds.getHeight();
@@ -123,13 +130,15 @@ public class TestTextRenderer implements GLEventListener {
fps = new FPSCounter(drawable, 36);
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+public void dispose(GLAutoDrawable drawable) {
renderer = null;
position = null;
time = null;
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+public void display(GLAutoDrawable drawable) {
time.update();
// Compute the next position of the text
@@ -137,17 +146,17 @@ public class TestTextRenderer implements GLEventListener {
// Figure out whether we have to switch directions
if (position.x() < 0) {
velocity.setX(Math.abs(velocity.x()));
- } else if (position.x() + textWidth > drawable.getWidth()) {
+ } else if (position.x() + textWidth > drawable.getSurfaceWidth()) {
velocity.setX(-1.0f * Math.abs(velocity.x()));
- }
+ }
if (position.y() < 0) {
velocity.setY(Math.abs(velocity.y()));
- } else if (position.y() + textHeight > drawable.getHeight()) {
+ } else if (position.y() + textHeight > drawable.getSurfaceHeight()) {
velocity.setY(-1.0f * Math.abs(velocity.y()));
- }
+ }
// Prepare to draw text
- renderer.beginRendering(drawable.getWidth(), drawable.getHeight());
+ renderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
// Draw text
renderer.draw(TEST_STRING, (int) position.x(), (int) position.y());
@@ -160,6 +169,7 @@ public class TestTextRenderer implements GLEventListener {
}
// Unused methods
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
+ @Override
+public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
}
diff --git a/src/demos/j2d/TestTextureRenderer.java b/src/demos/j2d/TestTextureRenderer.java
index a217c7b..ccf3dbf 100755
--- a/src/demos/j2d/TestTextureRenderer.java
+++ b/src/demos/j2d/TestTextureRenderer.java
@@ -1,21 +1,21 @@
/*
* Copyright (c) 2006 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
@@ -28,22 +28,19 @@
* 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.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
package demos.j2d;
-import com.jogamp.opengl.util.awt.TextureRenderer;
-import demos.gears.Gears;
-import demos.util.SystemTime;
-import demos.util.Time;
import gleem.linalg.Vec2f;
+
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
@@ -55,13 +52,20 @@ import java.awt.event.WindowEvent;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.text.DecimalFormat;
+
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
+
import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.awt.TextureRenderer;
+
+import demos.gears.Gears;
+import demos.util.SystemTime;
+import demos.util.Time;
@@ -81,12 +85,14 @@ public class TestTextureRenderer implements GLEventListener {
frame.setSize(512, 512);
final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
+ @Override
+ public void windowClosing(WindowEvent e) {
// Run this on another thread than the AWT event queue to
// make sure the call to Animator.stop() completes before
// exiting
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
animator.stop();
System.exit(0);
}
@@ -100,17 +106,18 @@ public class TestTextureRenderer implements GLEventListener {
private TextureRenderer renderer;
private Time time;
private Font font;
- private Color TRANSPARENT_BLACK = new Color(0.0f, 0.0f, 0.0f, 0.0f);
- private Vec2f velocity = new Vec2f(100.0f, 150.0f);
+ private final Color TRANSPARENT_BLACK = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+ private final Vec2f velocity = new Vec2f(100.0f, 150.0f);
private Vec2f position;
private Rectangle textBounds;
private Rectangle fpsBounds;
- private String TEST_STRING = "Java 2D Text";
+ private final String TEST_STRING = "Java 2D Text";
private long startTime;
private int frameCount;
- private DecimalFormat format = new DecimalFormat("####.00");
+ private final DecimalFormat format = new DecimalFormat("####.00");
- public void init(GLAutoDrawable drawable) {
+ @Override
+public void init(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.setSwapInterval(0);
@@ -119,7 +126,7 @@ public class TestTextureRenderer implements GLEventListener {
((SystemTime) time).rebase();
// Start the text half way up the left side
- position = new Vec2f(0.0f, drawable.getHeight() / 2);
+ position = new Vec2f(0.0f, drawable.getSurfaceHeight() / 2);
// Create the font, render context, and glyph vector
font = new Font("SansSerif", Font.BOLD, 36);
@@ -136,21 +143,23 @@ public class TestTextureRenderer implements GLEventListener {
renderer.markDirty(textBounds.x, textBounds.y, textBounds.width, textBounds.height);
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+public void dispose(GLAutoDrawable drawable) {
renderer = null;
textBounds = null;
position = null;
time = null;
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+public void display(GLAutoDrawable drawable) {
if (startTime == 0) {
startTime = System.currentTimeMillis();
}
if (++frameCount == 100) {
long endTime = System.currentTimeMillis();
- float fps = 100.0f / (float) (endTime - startTime) * 1000;
+ float fps = 100.0f / (endTime - startTime) * 1000;
frameCount = 0;
startTime = System.currentTimeMillis();
@@ -177,17 +186,17 @@ public class TestTextureRenderer implements GLEventListener {
textBounds.width, textBounds.height);
if (tmpBounds.getMinX() < 0) {
velocity.setX(Math.abs(velocity.x()));
- } else if (tmpBounds.getMaxX() > drawable.getWidth()) {
+ } else if (tmpBounds.getMaxX() > drawable.getSurfaceWidth()) {
velocity.setX(-1.0f * Math.abs(velocity.x()));
}
if (tmpBounds.getMinY() < 0) {
velocity.setY(Math.abs(velocity.y()));
- } else if (tmpBounds.getMaxY() > drawable.getHeight()) {
+ } else if (tmpBounds.getMaxY() > drawable.getSurfaceHeight()) {
velocity.setY(-1.0f * Math.abs(velocity.y()));
}
// Prepare to draw from the renderer's texture
- renderer.beginOrthoRendering(drawable.getWidth(), drawable.getHeight());
+ renderer.beginOrthoRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
// Draw from the renderer's texture
renderer.drawOrthoRect((int) position.x(), (int) position.y(),
@@ -198,19 +207,20 @@ public class TestTextureRenderer implements GLEventListener {
// If we have the FPS, draw it
if (fpsBounds != null) {
- renderer.drawOrthoRect(drawable.getWidth() - fpsBounds.width,
+ renderer.drawOrthoRect(drawable.getSurfaceWidth() - fpsBounds.width,
20,
fpsBounds.x,
renderer.getHeight() - fpsBounds.y - fpsBounds.height,
fpsBounds.width,
fpsBounds.height);
}
-
+
// Clean up rendering
renderer.endOrthoRendering();
}
// Unused methods
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
+ @Override
+public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
}
diff --git a/src/demos/j2d/TextFlow.java b/src/demos/j2d/TextFlow.java
index 395554b..39283b3 100755
--- a/src/demos/j2d/TextFlow.java
+++ b/src/demos/j2d/TextFlow.java
@@ -1,21 +1,21 @@
/*
* Copyright (c) 2006 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
@@ -28,21 +28,17 @@
* 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.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
package demos.j2d;
-import com.jogamp.opengl.util.awt.TextRenderer;
-import demos.common.Demo;
-import demos.util.SystemTime;
-import demos.util.Time;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Frame;
@@ -57,12 +53,19 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
-import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.awt.GLCanvas;
+
import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.awt.TextRenderer;
+
+import demos.common.Demo;
+import demos.util.SystemTime;
+import demos.util.Time;
/** Illustrates both the TextRenderer's capability for handling
@@ -87,12 +90,14 @@ public class TextFlow extends Demo {
frame.setSize(512, 512);
final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
+ @Override
+ public void windowClosing(WindowEvent e) {
// Run this on another thread than the AWT event queue to
// make sure the call to Animator.stop() completes before
// exiting
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
animator.stop();
System.exit(0);
}
@@ -103,15 +108,15 @@ public class TextFlow extends Demo {
animator.start();
}
- private List<String> lines = new ArrayList<String>();
+ private final List<String> lines = new ArrayList<String>();
private Time time;
private TextRenderer renderer;
private int curParagraph;
- private float x = 30;
+ private final float x = 30;
private float y;
- private float velocity = 100; // pixels/sec
+ private final float velocity = 100; // pixels/sec
private int lineSpacing;
- private int EXTRA_LINE_SPACING = 5;
+ private final int EXTRA_LINE_SPACING = 5;
private void reflow(float width) {
lines.clear();
@@ -140,40 +145,43 @@ public class TextFlow extends Demo {
}
lineSpacing = (int) ((float) lineSpacing / (float) numLines) + EXTRA_LINE_SPACING;
}
-
- public void init(GLAutoDrawable drawable) {
+
+ @Override
+public void init(GLAutoDrawable drawable) {
renderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 36), true, false);
time = new SystemTime();
((SystemTime) time).rebase();
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+public void dispose(GLAutoDrawable drawable) {
renderer = null;
time = null;
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+public void display(GLAutoDrawable drawable) {
time.update();
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
-
+
float deltaT = (float) time.deltaT();
y += velocity * deltaT;
// Draw text starting at the specified paragraph
int paragraph = 0;
float curY = y;
- renderer.beginRendering(drawable.getWidth(), drawable.getHeight());
+ renderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
boolean renderedOne = false;
for (int i = 0; i < lines.size(); i++) {
- String line = (String) lines.get(i);
+ String line = lines.get(i);
if (line == null) {
++paragraph;
if (paragraph >= curParagraph) {
// If this paragraph has scrolled off the top of the screen,
// don't draw it the next frame
- if (paragraph > curParagraph && curY > drawable.getHeight()) {
+ if (paragraph > curParagraph && curY > drawable.getSurfaceHeight()) {
++curParagraph;
y = curY;
}
@@ -182,7 +190,7 @@ public class TextFlow extends Demo {
} else {
if (paragraph >= curParagraph) {
curY -= lineSpacing;
- if (curY < drawable.getHeight() + lineSpacing) {
+ if (curY < drawable.getSurfaceHeight() + lineSpacing) {
renderer.draw(line, (int) x, (int) curY);
renderedOne = true;
}
@@ -201,7 +209,8 @@ public class TextFlow extends Demo {
}
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ @Override
+public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
reflow(Math.max(100, width - 60));
}
diff --git a/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java b/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java
index dcc063b..c39dddb 100644
--- a/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java
+++ b/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java
@@ -32,15 +32,13 @@
*/
package demos.proceduralTexturePhysics;
-import demos.common.Demo;
-import demos.common.DemoListener;
-import demos.util.DurationTimer;
import gleem.BSphere;
import gleem.BSphereProvider;
import gleem.CameraParameters;
import gleem.ExaminerViewer;
import gleem.ManipManager;
import gleem.linalg.Vec3f;
+
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.KeyAdapter;
@@ -50,16 +48,22 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+
import javax.media.opengl.GL;
-import javax.media.opengl.GL2ES1;
import javax.media.opengl.GL2;
+import javax.media.opengl.GL2ES1;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLException;
import javax.media.opengl.awt.AWTGLAutoDrawable;
import javax.media.opengl.awt.GLCanvas;
-import com.jogamp.opengl.util.Animator;
import javax.swing.JOptionPane;
+import com.jogamp.opengl.util.Animator;
+
+import demos.common.Demo;
+import demos.common.DemoListener;
+import demos.util.DurationTimer;
+
/**
* Water demonstration by NVidia Corporation - <a href =
* "http://developer.nvidia.com/view.asp?IO=ogl_dynamic_bumpreflection">http://developer.nvidia.com/view.asp?IO=ogl_dynamic_bumpreflection</a>
@@ -81,24 +85,28 @@ public class ProceduralTexturePhysics extends Demo {
canvas.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
+ @Override
+ public void keyPressed(KeyEvent e) {
demo.dispatchKey(e.getKeyChar());
}
});
canvas.addMouseListener(new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
+ @Override
+ public void mousePressed(MouseEvent e) {
demo.dispatchMousePress(e);
}
- public void mouseReleased(MouseEvent e) {
+ @Override
+ public void mouseReleased(MouseEvent e) {
demo.dispatchMouseRelease(e);
}
});
canvas.addMouseMotionListener(new MouseMotionAdapter() {
- public void mouseDragged(MouseEvent e) {
+ @Override
+ public void mouseDragged(MouseEvent e) {
demo.dispatchMouseDrag(e);
}
});
@@ -106,11 +114,13 @@ public class ProceduralTexturePhysics extends Demo {
final Animator animator = new Animator(canvas);
demo.setDemoListener(new DemoListener() {
- public void shutdownDemo() {
+ @Override
+ public void shutdownDemo() {
runExit(animator);
}
- public void repaint() {
+ @Override
+ public void repaint() {
}
});
@@ -124,7 +134,8 @@ public class ProceduralTexturePhysics extends Demo {
frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
+ @Override
+ public void windowClosing(WindowEvent e) {
runExit(animator);
}
});
@@ -132,7 +143,8 @@ public class ProceduralTexturePhysics extends Demo {
animator.start();
}
- public void shutdownDemo() {
+ @Override
+ public void shutdownDemo() {
viewer.detach();
ManipManager.getManipManager().unregisterWindow((AWTGLAutoDrawable) drawable);
drawable.removeGLEventListener(this);
@@ -144,18 +156,19 @@ public class ProceduralTexturePhysics extends Demo {
private GLAutoDrawable drawable;
private Water water = new Water();
private volatile ExaminerViewer viewer;
- private boolean[] b = new boolean[256];
+ private final boolean[] b = new boolean[256];
private boolean doViewAll = true;
- private float zNear = 0.1f;
- private float zFar = 10.0f;
+ private final float zNear = 0.1f;
+ private final float zFar = 10.0f;
private DurationTimer timer = new DurationTimer();
private boolean firstRender = true;
private int frameCount;
- private float blurIncrement = 0.01f;
- private float bumpIncrement = 0.01f;
- private float frequencyIncrement = 0.1f;
+ private final float blurIncrement = 0.01f;
+ private final float bumpIncrement = 0.01f;
+ private final float frequencyIncrement = 0.1f;
- public void init(GLAutoDrawable drawable) {
+ @Override
+ public void init(GLAutoDrawable drawable) {
water.destroy();
water.initialize("demos/data/images/nvfixed.tga",
"demos/data/images/nvspin.tga",
@@ -198,7 +211,8 @@ public class ProceduralTexturePhysics extends Demo {
viewer.setAutoRedrawMode(false);
viewer.attach((AWTGLAutoDrawable) drawable, new BSphereProvider() {
- public BSphere getBoundingSphere() {
+ @Override
+ public BSphere getBoundingSphere() {
return new BSphere(new Vec3f(0, 0, 0), 1.2f);
}
});
@@ -210,14 +224,16 @@ public class ProceduralTexturePhysics extends Demo {
}
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+ public void dispose(GLAutoDrawable drawable) {
water.destroy();
water = null;
viewer = null;
timer = null;
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+ public void display(GLAutoDrawable drawable) {
if (++frameCount == 30) {
timer.stop();
System.err.println("Frames per second: " + (30.0f / timer.getDurationAsSeconds()));
@@ -240,8 +256,8 @@ public class ProceduralTexturePhysics extends Demo {
ManipManager.getManipManager().render((AWTGLAutoDrawable) drawable, gl);
if (drawing) {
- int w = drawable.getWidth();
- int h = drawable.getHeight();
+ int w = drawable.getSurfaceWidth();
+ int h = drawable.getSurfaceHeight();
water.addDroplet(new Water.Droplet(2 * (mousePosX / (float) w - 0.5f),
-2 * (mousePosY / (float) h - 0.5f),
0.08f));
@@ -252,7 +268,8 @@ public class ProceduralTexturePhysics extends Demo {
water.draw(gl, params.getOrientation().inverse());
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
}
// Unused routines
@@ -260,11 +277,11 @@ public class ProceduralTexturePhysics extends Demo {
}
private void setFlag(char key, boolean val) {
- b[((int) key) & 0xFF] = val;
+ b[(key) & 0xFF] = val;
}
private boolean getFlag(char key) {
- return b[((int) key) & 0xFF];
+ return b[(key) & 0xFF];
}
private void checkExtension(GL gl, String extensionName) {
@@ -415,7 +432,8 @@ public class ProceduralTexturePhysics extends Demo {
// exit routine in another thread.
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
animator.stop();
System.exit(0);
}
diff --git a/src/demos/readbuffer/ReadBufferUtil.java b/src/demos/readbuffer/ReadBufferUtil.java
index e271767..6af4ba4 100755
--- a/src/demos/readbuffer/ReadBufferUtil.java
+++ b/src/demos/readbuffer/ReadBufferUtil.java
@@ -1,21 +1,21 @@
/*
* 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
@@ -28,15 +28,17 @@
* 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.readbuffer;
-import com.jogamp.opengl.util.GLBuffers;
-import java.nio.*;
-import javax.media.opengl.*;
+import java.nio.Buffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GLDrawable;
+import com.jogamp.opengl.util.GLBuffers;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureData;
@@ -57,7 +59,7 @@ public class ReadBufferUtil {
}
public void fetchOffscreenTexture(GLDrawable drawable, GL gl) {
- int readPixelSize = drawable.getWidth() * drawable.getHeight() * 3 ; // RGB
+ int readPixelSize = drawable.getSurfaceWidth() * drawable.getSurfaceHeight() * 3 ; // RGB
boolean newData = false;
if(readPixelSize>readPixelSizeLast) {
readPixelBuffer = GLBuffers.newDirectGLBuffer(GL.GL_UNSIGNED_BYTE, readPixelSize);
@@ -67,11 +69,11 @@ public class ReadBufferUtil {
gl.getGLProfile(),
// gl.isGL2GL3()?gl.GL_RGBA:gl.GL_RGB,
gl.GL_RGB,
- drawable.getWidth(), drawable.getHeight(),
- 0,
+ drawable.getSurfaceWidth(), drawable.getSurfaceHeight(),
+ 0,
gl.GL_RGB,
gl.GL_UNSIGNED_BYTE,
- false, false,
+ false, false,
false /* flip */,
readPixelBuffer,
null /* Flusher */);
@@ -85,15 +87,15 @@ public class ReadBufferUtil {
}
if(null!=readPixelBuffer) {
readPixelBuffer.clear();
- gl.glReadPixels(0, 0, drawable.getWidth(), drawable.getHeight(), GL.GL_RGB, GL.GL_UNSIGNED_BYTE, readPixelBuffer);
+ gl.glReadPixels(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), GL.GL_RGB, GL.GL_UNSIGNED_BYTE, readPixelBuffer);
readPixelBuffer.rewind();
if(newData) {
readTexture.updateImage(gl, readTextureData);
} else {
- readTexture.updateSubImage(gl, readTextureData, 0,
+ readTexture.updateSubImage(gl, readTextureData, 0,
0, 0, // src offset
0, 0, // dst offset
- drawable.getWidth(), drawable.getHeight());
+ drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
}
readPixelBuffer.rewind();
}
diff --git a/src/demos/testContextDestruction/TestContextDestruction.java b/src/demos/testContextDestruction/TestContextDestruction.java
index 060c2cf..4d5c2ff 100755
--- a/src/demos/testContextDestruction/TestContextDestruction.java
+++ b/src/demos/testContextDestruction/TestContextDestruction.java
@@ -1,21 +1,21 @@
/*
* Copyright (c) 2003 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
@@ -28,11 +28,11 @@
* 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.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
@@ -50,15 +50,17 @@ import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
+
import javax.media.opengl.DebugGL2;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLCanvas;
-import com.jogamp.opengl.util.Animator;
import javax.swing.JButton;
import javax.swing.JFrame;
+import com.jogamp.opengl.util.Animator;
+
/** A simple demonstration exercising context creation and destruction
@@ -104,12 +106,13 @@ public class TestContextDestruction {
frame2.pack();
frame2.setVisible(true);
frame2.setLocation(256 + BORDER_WIDTH, 0);
-
+
JFrame uiFrame = new JFrame("Controls");
uiFrame.getContentPane().setLayout(new GridLayout(3, 1));
JButton button = new JButton("Toggle Frame 1's component");
button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
if (frame1ContainedComponent == null) {
frame1ContainedComponent = frame1RemovedComponent;
frame1RemovedComponent = null;
@@ -124,7 +127,8 @@ public class TestContextDestruction {
uiFrame.getContentPane().add(button);
button = new JButton("Swap Frame 1's and Frame 2's components");
button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
System.out.println("Swapping Frame 1's and Frame 2's components");
Component t1 = null, t2 = null;
t1 = frame1ContainedComponent;
@@ -151,7 +155,8 @@ public class TestContextDestruction {
uiFrame.getContentPane().add(button);
button = new JButton("Toggle Frame 2's component");
button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
if (frame2ContainedComponent == null) {
frame2ContainedComponent = frame2RemovedComponent;
frame2RemovedComponent = null;
@@ -170,12 +175,14 @@ public class TestContextDestruction {
final Animator animator = new Animator(canvas);
WindowListener windowListener = new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
+ @Override
+ public void windowClosing(WindowEvent e) {
// Run this on another thread than the AWT event queue to
// make sure the call to Animator.stop() completes before
// exiting
new Thread(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
animator.stop();
System.exit(0);
}
@@ -189,7 +196,8 @@ public class TestContextDestruction {
}
class Listener implements GLEventListener {
- public void init(GLAutoDrawable drawable) {
+ @Override
+ public void init(GLAutoDrawable drawable) {
System.out.println("Listener.init()");
@@ -209,14 +217,16 @@ public class TestContextDestruction {
gl.glEnable(GL2.GL_NORMALIZE);
- reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight());
+ reshape(drawable, 0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
}
- public void dispose(GLAutoDrawable drawable) {
+ @Override
+ public void dispose(GLAutoDrawable drawable) {
System.out.println("Listener.dispose()");
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+ public void display(GLAutoDrawable drawable) {
angle += 2.0f;
GL2 gl = drawable.getGL().getGL2();
@@ -229,12 +239,13 @@ public class TestContextDestruction {
gl.glPopMatrix();
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
System.out.println("Listener.reshape()");
GL2 gl = drawable.getGL().getGL2();
float h = (float)height / (float)width;
-
+
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f);
@@ -278,9 +289,9 @@ public class TestContextDestruction {
r0 = inner_radius;
r1 = outer_radius - tooth_depth / 2.0f;
r2 = outer_radius + tooth_depth / 2.0f;
-
+
da = 2.0f * (float) Math.PI / teeth / 4.0f;
-
+
gl.glShadeModel(GL2.GL_FLAT);
gl.glNormal3f(0.0f, 0.0f, 1.0f);
@@ -311,7 +322,7 @@ public class TestContextDestruction {
gl.glVertex3f(r1 * (float)Math.cos(angle + 3.0f * da), r1 * (float)Math.sin(angle + 3.0f * da), width * 0.5f);
}
gl.glEnd();
-
+
/* draw back face */
gl.glBegin(GL2.GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++)
@@ -323,7 +334,7 @@ public class TestContextDestruction {
gl.glVertex3f(r0 * (float)Math.cos(angle), r0 * (float)Math.sin(angle), -width * 0.5f);
}
gl.glEnd();
-
+
/* draw back sides of teeth */
gl.glBegin(GL2.GL_QUADS);
for (i = 0; i < teeth; i++)
@@ -335,7 +346,7 @@ public class TestContextDestruction {
gl.glVertex3f(r1 * (float)Math.cos(angle), r1 * (float)Math.sin(angle), -width * 0.5f);
}
gl.glEnd();
-
+
/* draw outward faces of teeth */
gl.glBegin(GL2.GL_QUAD_STRIP);
for (i = 0; i < teeth; i++)
@@ -364,9 +375,9 @@ public class TestContextDestruction {
gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), width * 0.5f);
gl.glVertex3f(r1 * (float)Math.cos(0), r1 * (float)Math.sin(0), -width * 0.5f);
gl.glEnd();
-
+
gl.glShadeModel(GL2.GL_SMOOTH);
-
+
/* draw inside radius cylinder */
gl.glBegin(GL2.GL_QUAD_STRIP);
for (i = 0; i <= teeth; i++)
diff --git a/src/demos/util/FPSCounter.java b/src/demos/util/FPSCounter.java
index a625b3b..b0721d2 100755
--- a/src/demos/util/FPSCounter.java
+++ b/src/demos/util/FPSCounter.java
@@ -1,21 +1,21 @@
/*
* Copyright (c) 2007 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
@@ -28,25 +28,27 @@
* 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.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
package demos.util;
-import com.jogamp.opengl.util.awt.TextRenderer;
-import com.jogamp.opengl.util.texture.Texture;
import java.awt.Font;
import java.awt.geom.Rectangle2D;
import java.text.DecimalFormat;
+
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLException;
+import com.jogamp.opengl.util.awt.TextRenderer;
+import com.jogamp.opengl.util.texture.Texture;
+
/** A simple class which uses the TextRenderer to provide an FPS
@@ -60,9 +62,9 @@ public class FPSCounter {
public static final int LOWER_RIGHT = 4;
private int textLocation = LOWER_RIGHT;
- private GLDrawable drawable;
- private TextRenderer renderer;
- private DecimalFormat format = new DecimalFormat("####.00");
+ private final GLDrawable drawable;
+ private final TextRenderer renderer;
+ private final DecimalFormat format = new DecimalFormat("####.00");
private int frameCount;
private long startTime;
private String fpsText;
@@ -70,7 +72,7 @@ public class FPSCounter {
private int fpsWidth;
private int fpsHeight;
private int fpsOffset;
-
+
/** Creates a new FPSCounter with the given font size. An OpenGL
context must be current at the time the constructor is called.
@@ -157,7 +159,7 @@ public class FPSCounter {
if (++frameCount >= 100) {
long endTime = System.currentTimeMillis();
- float fps = 100.0f / (float) (endTime - startTime) * 1000;
+ float fps = 100.0f / (endTime - startTime) * 1000;
recomputeFPSSize(fps);
frameCount = 0;
startTime = System.currentTimeMillis();
@@ -166,19 +168,19 @@ public class FPSCounter {
}
if (fpsText != null) {
- renderer.beginRendering(drawable.getWidth(), drawable.getHeight());
+ renderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
// Figure out the location at which to draw the text
int x = 0;
int y = 0;
switch (textLocation) {
case UPPER_LEFT:
x = fpsOffset;
- y = drawable.getHeight() - fpsHeight - fpsOffset;
+ y = drawable.getSurfaceHeight() - fpsHeight - fpsOffset;
break;
case UPPER_RIGHT:
- x = drawable.getWidth() - fpsWidth - fpsOffset;
- y = drawable.getHeight() - fpsHeight - fpsOffset;
+ x = drawable.getSurfaceWidth() - fpsWidth - fpsOffset;
+ y = drawable.getSurfaceHeight() - fpsHeight - fpsOffset;
break;
case LOWER_LEFT:
@@ -187,7 +189,7 @@ public class FPSCounter {
break;
case LOWER_RIGHT:
- x = drawable.getWidth() - fpsWidth - fpsOffset;
+ x = drawable.getSurfaceWidth() - fpsWidth - fpsOffset;
y = fpsOffset;
break;
}
diff --git a/src/gleem/ExaminerViewer.java b/src/gleem/ExaminerViewer.java
index a99e555..e88ecf7 100644
--- a/src/gleem/ExaminerViewer.java
+++ b/src/gleem/ExaminerViewer.java
@@ -39,13 +39,20 @@
package gleem;
-import java.awt.Dimension;
-import java.awt.event.*;
-import java.util.*;
+import gleem.linalg.Mat4f;
+import gleem.linalg.MathUtil;
+import gleem.linalg.Rotf;
+import gleem.linalg.Vec3f;
-import gleem.linalg.*;
-import javax.media.opengl.*;
-import javax.media.opengl.awt.*;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionAdapter;
+
+import javax.media.opengl.GL2;
+import javax.media.opengl.GL2ES1;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.awt.AWTGLAutoDrawable;
/** <P> This is an application-level class, not part of the
manipulator hierarchy. It is an example of how you might integrate
@@ -89,29 +96,31 @@ public class ExaminerViewer {
private int lastY;
/** Camera parameters */
- private float minFocalDist = 1.0f;
- private Vec3f dolly = new Vec3f(0, 0, 10); // Amount we have "backed up" from focal point
- private Vec3f center = new Vec3f(0, 0, 0); // Position of focal point in world coordinates
+ private final float minFocalDist = 1.0f;
+ private final Vec3f dolly = new Vec3f(0, 0, 10); // Amount we have "backed up" from focal point
+ private final Vec3f center = new Vec3f(0, 0, 0); // Position of focal point in world coordinates
private Rotf orientation = new Rotf();
private Vec3f upVector = null;
private float rotateSpeed = 1.0f;
- private float minRotateSpeed = 0.0001f;
+ private final float minRotateSpeed = 0.0001f;
private float dollySpeed = 2.0f;
- private float minDollySpeed = 0.0001f;
+ private final float minDollySpeed = 0.0001f;
private float zNear = 1.0f;
private float zFar = 100.0f;
private float vertFOVScale = 1.0f;
- private CameraParameters params = new CameraParameters();
+ private final CameraParameters params = new CameraParameters();
/** Our bounding sphere provider (for viewAll()) */
private BSphereProvider provider;
- private MouseMotionAdapter mouseMotionListener = new MouseMotionAdapter() {
- public void mouseDragged(MouseEvent e) {
+ private final MouseMotionAdapter mouseMotionListener = new MouseMotionAdapter() {
+ @Override
+ public void mouseDragged(MouseEvent e) {
motionMethod(e, e.getX(), e.getY());
}
- public void mouseMoved(MouseEvent e) {
+ @Override
+ public void mouseMoved(MouseEvent e) {
if (interactionUnderway && iOwnInteraction) {
// Hack for AWT behavior where Ctrl + Alt + Left mouse button is treated
// as motion instead of drag
@@ -122,21 +131,27 @@ public class ExaminerViewer {
}
};
- private MouseAdapter mouseListener = new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
+ private final MouseAdapter mouseListener = new MouseAdapter() {
+ @Override
+ public void mousePressed(MouseEvent e) {
mouseMethod(e, e.getModifiersEx(), true, e.getX(), e.getY());
}
- public void mouseReleased(MouseEvent e) {
+ @Override
+ public void mouseReleased(MouseEvent e) {
mouseMethod(e, e.getModifiersEx(), false, e.getX(), e.getY());
}
};
- private GLEventListener glListener = new GLEventListener() {
- public void init(GLAutoDrawable drawable) {}
- public void display(GLAutoDrawable drawable) {}
- public void dispose(GLAutoDrawable drawable) { }
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ private final GLEventListener glListener = new GLEventListener() {
+ @Override
+ public void init(GLAutoDrawable drawable) {}
+ @Override
+ public void display(GLAutoDrawable drawable) {}
+ @Override
+ public void dispose(GLAutoDrawable drawable) { }
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
reshapeMethod(width, height);
}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
@@ -170,7 +185,7 @@ public class ExaminerViewer {
this.window = null;
this.provider = null;
}
-
+
/** Call this at the end of your display() method to cause the
Modelview matrix to be recomputed for the next frame. */
public void update(GL2 gl) {
@@ -377,8 +392,8 @@ public class ExaminerViewer {
button1Down = false;
button2Down = false;
- int xSize = window.getWidth();
- int ySize = window.getHeight();
+ int xSize = window.getSurfaceWidth();
+ int ySize = window.getSurfaceHeight();
params.setOrientation(orientation);
params.setPosition(computePosition(new Vec3f()));
params.setForwardDirection(Vec3f.NEG_Z_AXIS);
@@ -395,7 +410,7 @@ public class ExaminerViewer {
} else {
int dx = x - lastX;
int dy = y - lastY;
-
+
lastX = x;
lastY = y;
@@ -412,7 +427,7 @@ public class ExaminerViewer {
(button2Down && !button1Down && !button3Down);
boolean doZoom =
(button3Down && !button1Down && !button2Down);
-
+
// Hack to allow us to use Ctrl + Alt + LMB to translate so
// that we can do that gesture on the trackpad
if (e.isControlDown() && (doRotation || doZoom ||
diff --git a/src/redbook/src/glredbook10/jfont.java b/src/redbook/src/glredbook10/jfont.java
index f3b9b26..11524ec 100644
--- a/src/redbook/src/glredbook10/jfont.java
+++ b/src/redbook/src/glredbook10/jfont.java
@@ -3,21 +3,26 @@ package glredbook10;
/**
* Draws some text in using GlyphVector.<br>
* This example is my replacement for xfont.c.
- *
+ *
* @author Kiet Le (Java port) Ported to JOGL 2.x by Claudio Eduardo Goes
*/
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
import java.awt.font.GlyphVector;
import java.awt.geom.PathIterator;
-import javax.swing.*;
-
-
-import javax.media.opengl.*;
-
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLJPanel;
+import javax.swing.JFrame;
public class jfont //
extends GLSkeleton<GLJPanel>
@@ -54,21 +59,23 @@ public class jfont //
this.frame = frame;
}
- public void init(GLAutoDrawable drawable) {
- GL2 gl = drawable.getGL().getGL2();
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ GL2 gl = drawable.getGL().getGL2();
//
gl.glShadeModel(GL2.GL_FLAT);
gl.glEnable(GL2.GL_POLYGON_SMOOTH);
}
- public void display(GLAutoDrawable drawable) {
+ @Override
+ public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
//
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glPushMatrix();
- gl.glTranslatef(frame.getWidth() / 2 - frame.getWidth() / 4, //
- frame.getHeight() / 2, 0);
+ gl.glTranslatef(drawable.getSurfaceWidth() / 2 - drawable.getSurfaceWidth() / 4, //
+ drawable.getSurfaceHeight() / 2, 0);
// GL has lower left origin compare java's upper left
gl.glScalef(5, -5, 0);
@@ -86,13 +93,14 @@ public class jfont //
gl.glFlush();
}
- public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
GL2 gl = drawable.getGL().getGL2();
//
gl.glViewport(0, 0, w, h);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
- gl.glOrtho(0, (float) w, 0, (float) h, -1.0, 1.0);
+ gl.glOrtho(0, w, 0, h, -1.0, 1.0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
@@ -136,10 +144,12 @@ public class jfont //
gl.glEnd();
}
- public void keyTyped(KeyEvent key) {
+ @Override
+ public void keyTyped(KeyEvent key) {
}
- public void keyPressed(KeyEvent key) {
+ @Override
+ public void keyPressed(KeyEvent key) {
switch (key.getKeyCode()) {
case KeyEvent.VK_ESCAPE:
System.exit(0);
@@ -150,11 +160,13 @@ public class jfont //
}
}
- public void keyReleased(KeyEvent key) {
+ @Override
+ public void keyReleased(KeyEvent key) {
}
- public void dispose(GLAutoDrawable arg0) {
-
+ @Override
+ public void dispose(GLAutoDrawable arg0) {
+
}
}