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
|
import java.awt.*;
import javax.swing.*;
import gl4java.*;
import gl4java.swing.*;
public class CrossColorJPanel extends GLJPanel
{
public CrossColorJPanel( )
{
super();
}
public void init() {
reshape(getSize().width, getSize().height);
}
public void display()
{
System.out.println("i");
int i;
gl.glPushMatrix();
gl.glClear(GL_COLOR_BUFFER_BIT);
gl.glBegin(GLEnum.GL_LINES);
gl.glColor4f(0f, 0f, 1f, 1f);
gl.glVertex3i( 0, 0, 0);
gl.glVertex3i( 10, 10, 0);
gl.glColor4f(0f, 1f, 0f, 1f);
gl.glVertex3i( 0, 10, 0);
gl.glVertex3i( 10, 0, 0);
gl.glColor4f(1f, 0f, 0f, 1f);
gl.glVertex3i( 0, 5, 0);
gl.glVertex3i( 10, 5, 0);
gl.glColor4f(1f, 1f, 1f, 1f);
gl.glVertex3i( 5, 0, 0);
gl.glVertex3i( 5, 10, 0);
gl.glEnd();
gl.glPopMatrix();
}
public void reshape( int width, int height )
{
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0, 10, 0, 10, -50.0,50.0);
gl.glMatrixMode(GL_MODELVIEW);
}
}
|