GL4中是否存在glTranslatef?

问题描述

我试图在JOGL中使用glTranslatef(),但是在NetBeans中使用glTranslatef()时收到“找不到符号”错误。 JOGL 2中是否存在glTranslatef()?我错过了进口商品吗?

这是我的进口货

import com.jogamp.opengl.GL4;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
import com.jogamp.opengl.util.*;

这是受影响的代码

@Override
public void display(GLAutoDrawable drawable) {
    final GL4 gl = drawable.getGL().getGL4();

    // clears the window to black
    gl.glClear(GL4.GL_COLOR_BUFFER_BIT);
    // draw the shape
    gl.glBindVertexArray(triangleVaoHandle[0]);
    gl.glDrawArrays(GL4.GL_TRIANGLES,3);
    gl.glTranslatef(0.0f,0.0f,0.0f); // the error is here,cannot find symbol glTranslatef(float,float,float)

    // ensure completed rendering is pushed onto the screen
    gl.glFlush();
} 

解决方法

glTranslate在向后兼容的上下文中仍然可用,如果您确实想使用固定管道,请使用GL4bc而不是GL4

没有名为“ JOGL 4.0”的内容,请阅读this article以了解OpenGL和JOGL版本号等。 2020年8月的最新稳定版本为JOGL 2.3.2,当前的最新候选版本为JOGL 2.4.0。

请在our official forum上询问JOGL具体问题。 StackOverflow非常适合一般的OpenGL问题,但不适用于有关JogAmp的问题,因为这里只有很少的维护者和贡献者。

我建议您也查看我们的Wiki,以找到简单的示例using the fixed pipelinethe programmable pipeline

,

在jogl 中,可以通过glTranslatef 访问GL2。 您可以使用 drawable.getGL().getGL2() 获取 GL2 的实例。