Я пишу свою первую программу opengl и хочу, чтобы щелкнув мышью, цвет моей фигуры изменился, но он не работает.
это мой код .... в чем моя вина?
float red = 1.0f, green = 1.0f, blue = 1.0f;
public void init(GLAutoDrawable drawable)
{
GL2 gl=drawable.getGL().getGL2();
gl.glClearColor(0.0f,0.0f,0.0f,0.0f);
}
public void display(GLAutoDrawable drawable)
{
GL2 gl=drawable.getGL().getGL2();
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
gl.glColor3f (red, green, blue);
gl.glBegin(GL2.GL_LINES);
gl.glVertex3f(0.5f,0.5f,0.1f);
gl.glVertex3f(-0.5f,-0.5f,0.0f);
gl.glEnd();
gl.glFlush();
gl.glRectf(0.0f,0.0f,0.5f,-0.5f);
gl.glRectf(0.0f,0.0f,-0.5f,0.5f);
gl.glFlush();
}
public void reshape(GLAutoDrawable drawable, int x,int y,int width,int height){}
public void dispose(GLAutoDrawable drawable){}
public void mouseClicked(MouseEvent e) {
red = 1.0f; green = 0.0f; blue = 1.0f;
}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}