imagetexturesjogl

JOGL: some GL constants can not be resolved


i've written a java program with JOGL included. Everything worked fine, until i wanted to render an image (jpg,gif,png) with a texture. i found following code snippet:

import javax.media.opengl.*;
...
GL2 gl = drawable.getGL().getGL2();

gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, w, h, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, bb);

int left = 100;
int top = 100;
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glBindTexture(GL.GL_TEXTURE_2D, 13);
gl.glBegin(GL.GL_POLYGON);
...

the problem is that Eclipse can't resolve GL.GL_CLAMP, GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE and GL.GL_POLYGON. as an alternative for GL.GL_CLAMP there is just GL.GL_CLAMP_TO_EDGE. i can't even find GL.GL_QUAD, just GL.GL_TRIANGLE. what is wrong? do i missed an import? other GL constants can be resolved.

regards, peter


Solution

  • The proper way in JOGL2 is GL2.GL_CLAMP (not GL.GL_CLAMP). API Docs