Bugzilla – Attachment 123 Details for
Bug 352
distortion using TextRenderer (sometimes)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
Test class
TextDistortion.java (text/plain), 3.83 KB, created by
Sven Gothel
on 2008-03-30 05:52:00 CEST
(
hide
)
Description:
Test class
Filename:
MIME Type:
Creator:
Sven Gothel
Created:
2008-03-30 05:52:00 CEST
Size:
3.83 KB
patch
obsolete
>package bugs; > >import java.awt.Font; >import java.awt.Frame; >import java.awt.event.KeyEvent; >import java.awt.event.KeyListener; >import java.awt.event.WindowAdapter; >import java.awt.event.WindowEvent; > >import javax.media.opengl.GL; >import javax.media.opengl.GLAutoDrawable; >import javax.media.opengl.GLCanvas; >import javax.media.opengl.GLCapabilities; >import javax.media.opengl.GLEventListener; >import javax.media.opengl.glu.GLU; > >import com.sun.opengl.util.j2d.TextRenderer; > >/** > * shows a window containing the string "ARGH". > * press space to toggle a redraw. > * sometimes, the third letter will be distorted > * > * > */ >public class TextDistortion implements GLEventListener, KeyListener { > > GLAutoDrawable drawable; > TextRenderer tr; > static GLCanvas canvas; > > > public TextDistortion(GLAutoDrawable drawable) { > this.drawable = drawable; > drawable.addGLEventListener(this); > } > > > /** > * {@inheritDoc} > * @see javax.media.opengl.GLEventListener#display(javax.media.opengl.GLAutoDrawable) > */ > public void display(GLAutoDrawable arg0) { > System.out.println("display"); > GL gl = arg0.getGL(); > gl.glClear(GL.GL_COLOR_BUFFER_BIT); > > tr.beginRendering(arg0.getWidth(), arg0.getHeight()); > tr.setColor(0.0f, 1, 0, 1f); > tr.draw("ARGH", arg0.getWidth() / 2 - 2, arg0.getHeight() - 28); > tr.endRendering(); > > gl.glFlush(); > } > > > /** > * {@inheritDoc} > * @see javax.media.opengl.GLEventListener#displayChanged(javax.media.opengl.GLAutoDrawable, > * boolean, boolean) > */ > public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) { > } > > > /** > * {@inheritDoc} > * @see javax.media.opengl.GLEventListener#init(javax.media.opengl.GLAutoDrawable) > */ > public void init(GLAutoDrawable arg0) { > tr = new TextRenderer(new Font("Verdana", Font.PLAIN, 26)); > > } > > > /** > * {@inheritDoc} > * @see javax.media.opengl.GLEventListener#reshape(javax.media.opengl.GLAutoDrawable, int, int, > * int, int) > */ > public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int width, int height) { > GL gl = arg0.getGL(); > GLU glu = new GLU(); > > final float h = (float) width / (float) height; > gl.glViewport(0, 0, width, height); > gl.glMatrixMode(GL.GL_PROJECTION); > gl.glLoadIdentity(); > glu.gluPerspective(45.0f, h, 0.1, 20.0); > > gl.glMatrixMode(GL.GL_MODELVIEW); > gl.glLoadIdentity(); > > } > > > /** > * @param args > */ > public static void main(String[] args) { > > try { > > System.loadLibrary("jogl"); > System.out.println("Hello World! (The native libraries are installed.)"); > GLCapabilities caps = new GLCapabilities(); > > canvas = new GLCanvas(caps, null, null, null); > > TextDistortion td = new TextDistortion(canvas); > canvas.addKeyListener(td); > > final Frame frame = new Frame(); > > frame.setBounds(100, 100, 600, 600); > frame.add(canvas); > frame.setVisible(true); > canvas.requestFocus(); > canvas.requestFocusInWindow(); > > frame.addWindowListener(new WindowAdapter() { > > public void windowClosing(WindowEvent e) { > System.out.println("eek"); > frame.setVisible(false); > System.exit(0); > > } > > }); > System.out.println("Hello JOGL! (The jar appears to be available.)" + caps); > } catch (Exception e) { > System.out.println(e); > } > } > > > /** > * {@inheritDoc} > * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent) > */ > @Override > public void keyPressed(KeyEvent e) { > if (e.getKeyChar() == ' ') { > drawable.display(); > } > } > > > /** > * {@inheritDoc} > * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent) > */ > @Override > public void keyReleased(KeyEvent e) { > } > > > /** > * {@inheritDoc} > * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent) > */ > @Override > public void keyTyped(KeyEvent e) { > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 352
: 123 |
124