aboutsummaryrefslogtreecommitdiffstats
path: root/demos/RectRenderSpeed/GL4JTests2.java
blob: 8352c96e330f20f371843a983a6dd134b89f95eb (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149

import GL4JCanvas;

import java.awt.*;
import java.awt.event.*;

//----------------------------------------------
// class definition.
//----------------------------------------------
public class GL4JTests2 implements ActionListener
{
  private GL4JCanvas _glcanvas;
  TextField tf_renderMode;

//----------------------------------------------
// method constructor.
//----------------------------------------------
public GL4JTests2 (String [] args) 
{
  boolean debug = true;
  Frame outer_frame;
  Frame inner_frame;
  Panel inner_panel;
  Container outer_container;
  Container inner_container;
  Button button;
  int modes[]=new int[args.length];
  int mode_number=0;
  boolean dblBuffer=false;

  if(args.length>0)
  {
  	int i;
	for (i=0; i<args.length; i++)
	{
		if(args[i].equals("help"))
		{
			System.out.println(
				"Arguments:\n"+
				"\thelp - print this help\n"+
				"\tdbl  - use doublebuffer\n"+
				"\t<mode> - render mode, where mode is one of the following integer values :\n"+ GL4JCanvas.modes);
		} else if(args[i].equals("dbl"))
		{
			dblBuffer=true;
		} else {
		   try {
			modes[mode_number] = 
				Integer.valueOf(args[i]).intValue();
			mode_number++;
		   } catch (Exception ex) {
			System.out.println("wrong mode: "+args[i]);
			return;
		   }
		} 
	}
  } else {
	  System.out.println ("GL4JTests`constructor- begin\n modes:\n"+
			      _glcanvas.modes);
  }

  // build outer most frame and container.
  outer_frame = new Frame ("The GL4Java Canvas Window");

  // create a new canvas from GL4Java...
  // _glcanvas = new GL4JCanvas (1250, 800);
  // JAU: I have just a little screen at my place now :-) !
  _glcanvas = new GL4JCanvas (640, 480);
  outer_frame.add ("Center",_glcanvas);

  _glcanvas.preSetDblBuffer(dblBuffer);

  Panel renderPanel = new Panel();

  if(mode_number==0)
  {
  	  // interactive mode 
	  //
	  button = new Button ("Paint");
	  button.setActionCommand ("Button Pressed");
	  button.addActionListener (this);
	  renderPanel.add(button);
	  tf_renderMode = new TextField("0");
	  renderPanel.add(tf_renderMode);
	  outer_frame.add ("South", renderPanel);

  } 

  outer_frame.pack ();
  outer_frame.setVisible (true);

  if(mode_number>0)
  {
  	// scripting mode 
	//
  	_glcanvas.setScriptModes(modes, mode_number);
	_glcanvas.setRefreshGL(true);
  	_glcanvas.repaint();

  }

}


//----------------------------------------------
// method actionPerformed.
//----------------------------------------------
public void actionPerformed (ActionEvent event) 
{

  String action_command;
 
  /*
   * Let's do the repaint thread save ...
   */
   int mode=0;
   try {
   	mode = Integer.valueOf(tf_renderMode.getText()).intValue();
   } catch (Exception ex) {
   	System.out.println("wrong mode: "+tf_renderMode.getText());
	return;
   }
  if(_glcanvas.setRenderMode(mode)==false)
  {
   	System.out.println("render mode not supported !");
   	System.out.println("use one of the following:\n"+
				_glcanvas.modes);
	return;
  }
  _glcanvas.setRefreshGL(true);
  _glcanvas.repaint();

}
//----------------------------------------------
// method main.
//----------------------------------------------
public static void main (String[] args)
{
  boolean debug = true;

  GL4JTests2 gl4JTests1 = new GL4JTests2 (args);
  //GL4JTests2 gl4JTests2 = new GL4JTests2 (args);

}

//----------------------------------------------
// end of class GL4JTests.
//----------------------------------------------
}