1
public class SimpleJOGL2 implements GLEventListener {
private float x = 0.5f;
private float y = -0.5f;
public static void main(String[] args) {
Frame frame = new Frame("Simple JOGL Application");
GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener(new SimpleJOGL2());
frame.add(canvas);
frame.setSize(640, 640);
final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// Run this on another thread than the AWT event queue to
// make sure the call to Animator.stop() completes before
// exiting
new Thread(new Runnable() {
public void run() {
animator.stop();
System.exit(0);
}
}).start();
}
});
// Center frame
frame.setLocationRelativeTo(null);
frame.setVisible(true);
animator.start();
}
そして...はなぜポリゴンを表示することができますが、ポイントはできません
public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
float a[][] = {{x,y},{x,y-0.05f},{x-0.2f,y-0.15f},{x-0.22f, y-0.17f}};
float b[][] = {{x,y},{x,y-0.05f},{x+0.2f,y-0.15f},{x+0.22f, y-0.17f}};
float c[][]= {{x+0.03f,y-0.25f},{x-0.03f,y-0.25f},{x-0.03f,y-0.4f},{x+0.03f,y-0.4f}};
float col[] ={230/255f,84/255f,109/255f};
drawPolygon(gl,a,col);
drawPolygon(gl,b,col);
drawPolygon(gl,c,col);
gl.glLoadIdentity();
gl.glColor3f(0,0,0);
gl.glPointSize(4.0f);
gl.glBegin(GL.GL_POINT);
gl.glVertex2f(x+0.015f, y-0.33f);
gl.glEnd();
gl.glFlush();
}
。ポリゴンを表示することはできますが、ポイントは表示できません。
public void drawPolygon(GL gl, float a[][], float col[]){
gl.glColor3f(col[0], col[1], col[2]);
gl.glBegin(GL.GL_POLYGON);
gl.glVertex2f(a[0][0], a[0][1]);
gl.glVertex2f(a[1][0], a[1][1]);
gl.glVertex2f(a[2][0], a[2][1]);
gl.glVertex2f(a[3][0], a[3][1]);
gl.glEnd();
}
}
GL_POINTではなくGL_POINTSです。 – gouessej