简体   繁体   中英

glTranslate error in simple JOGL program

I am trying to create a simple JOGL program, and have run into a problem. I just imported all of the necessary packages into my class file, however now, every time I use the glTranslate function, it is being flagged red as an error, for example at the end of this block of code.

public void lab2a(GLAutoDrawable drawable) {
    GL gl = drawable.getGL();
    gl.glTranslatef(-1.0f, -1.0f, -6f);

    // Drawing first rectangle (blue)
    gl.glBegin(GL.GL_QUADS);
    gl.glColor3f(0f, 0f, 1f);   // sets color to blue
    gl.glVertex3f(-0.5f, 0.5f, 0.0f);   //Top left vertice
    gl.glVertex3f(0.5f, 0.5f, 0.0f);    //Top right vertice
    gl.glVertex3f(-0.5f, -0.5f, 0.0f);  //Bottom left vertice
    gl.glVertex3f(0.5f, -0.5f, 0.0f);   //Bottom right vertice
    gl.glEnd();
    gl.glTranslate(1.1f, 0f, 0f);

The flag reads: "cannot find symbol", and is present for each use of glTranslate I use. Does anybody have any idea how to fix this?

Your source code is obsolete, it uses JOGL 1 whose maintenance was stopped in 2010.

Please switch to JOGL 2, go to jogamp.org . Replace GL.GL_QUADS by GL2.GL_QUADS, replace GL gl = drawable.getGL() by GL2 gl = drawable.getGL().getGL2(), etc... Look at the API documentation here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM