我正在尝试使用 openGL 和 processing2.0 库来实现一个发光的立方体。但是,当我尝试从处理库(lights()、directionalLight() 等)调用任何照明方法时,当我尝试运行它时会出现空指针错误。这是方法:
private void render(GLAutoDrawable drawable)
{
GL2 gl = drawable.getGL().getGL2();
//Gets the drawable object which performs the rendering
PGraphics3D pg = new PGraphics3D();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
//Clears the color buffer
pg.directionalLight(51, 102, 126, 0, -1, 0);
pg.ambientLight(51, 102, 126);
pg.specular(204, 102, 0);
pg.ambient(51, 26, 0);
glutSolidCube(1);
// pg.box(1);
}