summaryrefslogtreecommitdiffstats
path: root/test/Issue344Base.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-06-15 22:57:38 +0000
committerKenneth Russel <[email protected]>2009-06-15 22:57:38 +0000
commita959c53b7ac91e489bf0959391e892790b9ff248 (patch)
tree4664742a4f9f6daa694364292e376ad2e6ee97d1 /test/Issue344Base.java
parent506b634b780dcd23aa61015c2ceba3e687196abf (diff)
Copied JOGL_2_SANDBOX r1957 on to trunk; JOGL_2_SANDBOX branch is now closed
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1959 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'test/Issue344Base.java')
-rwxr-xr-xtest/Issue344Base.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/test/Issue344Base.java b/test/Issue344Base.java
new file mode 100755
index 000000000..548e3ec21
--- /dev/null
+++ b/test/Issue344Base.java
@@ -0,0 +1,107 @@
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.event.*;
+import java.awt.geom.*;
+
+import javax.media.opengl.*;
+import javax.media.opengl.glu.*;
+import com.sun.opengl.util.*;
+import com.sun.opengl.util.j2d.*;
+
+/** Test Code adapted from TextCube.java (in JOGL demos)
+ *
+ * @author spiraljetty
+ * @author kbr
+ */
+
+public abstract class Issue344Base implements GLEventListener
+{
+ GLU glu = new GLU();
+ TextRenderer renderer;
+
+ float textScaleFactor;
+ Font font;
+ boolean useMipMaps;
+
+ protected Issue344Base() {
+ font = new Font("default", Font.PLAIN, 200);
+ useMipMaps = true; //false
+ }
+
+ protected abstract String getText();
+
+ protected void run(String[] args) {
+ Frame frame = new Frame(getClass().getName());
+ frame.setLayout(new BorderLayout());
+
+ GLCanvas canvas = new GLCanvas();
+ canvas.addGLEventListener(this);
+ frame.add(canvas, BorderLayout.CENTER);
+
+ frame.setSize(512, 512);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ new Thread(new Runnable() {
+ public void run() {
+ System.exit(0);
+ }
+ }).start();
+ }
+ });
+ frame.show();
+ }
+
+ public void init(GLAutoDrawable drawable)
+ {
+ GL gl = drawable.getGL();
+
+ gl.glEnable(GL.GL_DEPTH_TEST);
+
+ renderer = new TextRenderer(font, useMipMaps);
+
+ Rectangle2D bounds = renderer.getBounds(getText());
+ float w = (float) bounds.getWidth();
+ float h = (float) bounds.getHeight();
+ textScaleFactor = 2.0f / (w * 1.1f);
+ gl.setSwapInterval(0);
+ }
+
+ public void display(GLAutoDrawable drawable)
+ {
+ GL gl = drawable.getGL();
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
+ gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glLoadIdentity();
+ glu.gluLookAt(0, 0, 10,
+ 0, 0, 0,
+ 0, 1, 0);
+
+ renderer.begin3DRendering();
+ Rectangle2D bounds = renderer.getBounds(getText());
+ float w = (float) bounds.getWidth();
+ float h = (float) bounds.getHeight();
+ renderer.draw3D(getText(),
+ w / -2.0f * textScaleFactor,
+ h / -2.0f * textScaleFactor,
+ 3f,
+ textScaleFactor);
+
+ renderer.end3DRendering();
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
+ {
+ GL gl = drawable.getGL();
+ gl.glMatrixMode(GL.GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(15, (float) width / (float) height, 5, 15);
+ }
+
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged,
+ boolean deviceChanged)
+ {
+ }
+}