aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp/opengl/test/bugs/Issue326Test1.java
blob: 802bd65d524d32cd6bc3d2d623ad21f269d77293 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.jogamp.opengl.test.bugs;

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.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.fixedfunc.GLMatrixFunc;
import javax.media.opengl.glu.GLU;

import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.awt.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(final 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(final WindowEvent e) {
                    System.exit(0);
                }
            });
    }

    public void display(final GLAutoDrawable drawable) {
        final GL2 gl = drawable.getGL().getGL2();
        gl.glClearColor(0, 0, 0, 0);
        gl.glClear(GL.GL_COLOR_BUFFER_BIT|GL.GL_DEPTH_BUFFER_BIT);


        gl.glMatrixMode(GLMatrixFunc.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(GLMatrixFunc.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(final 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(final GLAutoDrawable arg0, final int arg1, final int arg2, final int arg3, final int arg4) {
        width = arg3;
        height = arg4;
        final GL2 gl = arg0.getGL().getGL2();
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glOrtho(0.0, 800, 0.0, 200, -100.0, 100.0);
        gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
        gl.glLoadIdentity();
    }

    public void dispose(final GLAutoDrawable drawable) {}
}