Hi again!
I did some more testing on this issue. There are still some problem when switching the arguments for top and bottom, that I don´t understand.
I wrote this code:
public class CoordinateTest implements GLEventListener
{
public void init(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
gl.glFrontFace(GL.GL_CW);
gl.glEnable(GL.GL_CULL_FACE);
gl.glCullFace(GL.GL_BACK);
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
}
public void display(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glColor3f(0.0f, 0.0f, 0.0f);
gl.glBegin(GL.GL_POINTS);
gl.glVertex2i(0, 0);
gl.glEnd();
gl.glBegin(GL.GL_QUADS);
gl.glVertex2i(10, 0);
gl.glVertex2i(20, 0);
gl.glVertex2i(20, 10);
gl.glVertex2i(10, 10);
gl.glVertex2i( 0, 10);
gl.glVertex2i(10, 10);
gl.glVertex2i(10, 20);
gl.glVertex2i( 0, 20);
gl.glEnd();
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
{
GL gl = drawable.getGL();
GLU glu = new GLU();
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluOrtho2D(0, width, height - 1, -1);
}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
{
}
public static void main(String[] args)
{
GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener(new CoordinateTest());
Frame frame = new Frame("Coordinate Test");
frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } });
frame.setSize(100, 100);
frame.add(canvas);
frame.setVisible(true);
}
}
The result is strange. It seems that the y coordinate for a single vertex does not mean the same as for vertices of a quad (see attached file).
Can someone help?
olli73