From 2d62cbeca1e965654627b84c03e2422f31fa7c40 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Fri, 9 Nov 2007 22:28:29 +0000 Subject: Fixed Issue 326: TextRenderer corruption with certain text Fixed four issues: - Regression in new segmenting and punting code causing ArrayIndexOutOfBoundsException due to not resetting the glyph uploader during punt. - Issue in same code where length and total advance were not being reset properly. - Incorrect handling in glyph-by-glyph rendering when backing store was using NPOT texture and GL_ARB_texture_rectangle. - Failure to punt when glyph code was out of bounds. Checked in two regression tests for these issues. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1434 232f8b59-042b-4e1e-8c03-345bb8c30851 --- test/Issue326Test1.java | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 test/Issue326Test1.java (limited to 'test/Issue326Test1.java') diff --git a/test/Issue326Test1.java b/test/Issue326Test1.java new file mode 100755 index 000000000..42b6ec0c7 --- /dev/null +++ b/test/Issue326Test1.java @@ -0,0 +1,91 @@ +import java.awt.Frame; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.Random; + +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCanvas; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.glu.GLU; + +import com.sun.opengl.util.Animator; +import com.sun.opengl.util.j2d.TextRenderer; + +/** + * Demonstrates corruption with older versions of TextRenderer. Two + * problems: errors when punting from glyph-based renderer to + * string-by-string renderer, and failure of glyph-based renderer when + * backing store was NPOT using GL_ARB_texture_rectangle. + * + * @author emzic + */ + +public class Issue326Test1 extends Frame implements GLEventListener { + + int width, height; + + public static void main(String[] args) { + new Issue326Test1(); + } + + GLCanvas canvas; + TextRenderer tr ; + + public Issue326Test1() { + super("TextTest"); + this.setSize(800, 800); + canvas = new GLCanvas(); + canvas.addGLEventListener(this); + add(canvas); + + setVisible(true); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + } + + public void display(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); + gl.glClearColor(0, 0, 0, 0); + gl.glClear(GL.GL_COLOR_BUFFER_BIT|GL.GL_DEPTH_BUFFER_BIT); + + + gl.glMatrixMode(GL.GL_PROJECTION); + gl.glLoadIdentity(); + //new GLU().gluPerspective(45f, (float)width/(float)height, 0.1f, 1000f); + gl.glOrtho(0.0, 800, 0.0, 800, -100.0, 100.0); + gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glLoadIdentity(); + + tr.beginRendering(800,800); + tr.draw( "die Marktwirtschaft. Da regelt sich – angeblich", 16, 32); + tr.draw( "Hello World! This text is scrambled", 16, 16); + tr.endRendering(); + + } + + public void init(GLAutoDrawable arg0) { + tr = new TextRenderer(new java.awt.Font("Verdana", java.awt.Font.PLAIN, 12), true, false, null, false); + tr.setColor(1, 1, 1 ,1); + } + + public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { + width = arg3; + height = arg4; + GL gl = arg0.getGL(); + gl.glViewport(0, 0, width, height); + gl.glMatrixMode(GL.GL_PROJECTION); + gl.glLoadIdentity(); + gl.glOrtho(0.0, 800, 0.0, 200, -100.0, 100.0); + gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glLoadIdentity(); + } + public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) {} +} -- cgit v1.2.3