import java.awt.*; import java.awt.event.*; import com.jogamp.opengl.awt.GLCanvas; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.util.glsl.ShaderProgram; public class MyProgram { public MyProgram () { Frame f = new Frame ("Test frame"); f.addWindowListener (new MyWindowAdapter ()); GLProfile glProfile = GLProfile.get (GLProfile.GL2ES2); GLCapabilities glCapabilities = new GLCapabilities (glProfile); GLCanvas glCanvas = new GLCanvas (glCapabilities); glCanvas.addGLEventListener (new MyGLEventListener ()); f.add (glCanvas); f.setSize (300, 300); f.setVisible (true); } public class MyWindowAdapter extends WindowAdapter { public void windowClosing (WindowEvent e) { System.exit (0); } } public class MyGLEventListener implements GLEventListener { public void display (GLAutoDrawable drawable) { System.out.println ("display ()"); GL2ES2 gl = drawable.getGL ().getGL2ES2(); ShaderCode fs; String[][] fsCode = {{"void main (void) { gl_FragColor = vec4 (1.0, 0.0, 0.0, 1.0); }"}}; // Quand on utilise GL2ES2 => 'gl_FragColor' : undeclared identifier fs = new ShaderCode (GL2ES2.GL_FRAGMENT_SHADER, 1, fsCode); fs.compile (gl, System.out); } public void dispose (GLAutoDrawable drawable) { System.out.println ("dispose ()"); } public void init (GLAutoDrawable drawable) { System.out.println ("init ()"); } public void reshape (GLAutoDrawable drawable, int x, int y, int width, int height) { System.out.println ("reshape ()"); } } }