动画多边形

时间:2015-05-01 19:37:41

标签: java opengl jogl

我正在尝试为GL_POLYGON制作动画。圆圈被正确绘制,甚至动画师似乎工作正常。我只是在动画运行时看到一个空白屏幕。以前,我曾尝试动画GL_TRIANGLE,它似乎毫无障碍地工作。

    private void drawCircle() {
        while(angle <= 360.0) {
            s = Math.sin(Math.toRadians(angle));
            c = Math.cos(Math.toRadians(angle));
            gl.glColor3d(0.0, 1.0, 0.0);
            gl.glVertex3d(c * radius, s * radius, 0.0);
            angle += delangle;
        }
    }

    @Override
    public void display(GLAutoDrawable arg0) {
        rangle = (rangle + rdelangle) % 360;

        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        gl.glPointSize(5f);
        gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2.GL_FILL);

        gl.glPushMatrix();
        gl.glRotated(rangle, 0.0, 1.0, 0.0);

        gl.glBegin(GL2.GL_POLYGON);
        drawCircle();
        gl.glEnd();

        gl.glPopMatrix();
    }

动画:

FPSAnimator animator = new FPSAnimator(canvas, 5);
animator.start();

0 个答案:

没有答案