Difference between revisions of "Jogl API Overview"

From JogampWiki
Jump to navigation Jump to search
Line 18: Line 18:
 
<code>
 
<code>
 
     private int initProgram(GL4 gl4) {
 
     private int initProgram(GL4 gl4) {
         ShaderCode vertexShader = ShaderCode.create(gl4, GL4.GL_VERTEX_SHADER,
+
         ShaderCode vertexShader = ShaderCode.create(gl4, GL4.GL_VERTEX_SHADER, this.getClass(), "src/data", null, "simple", "vert", null, true);
                this.getClass(), "src/data", null, "simple", "vert", null, true);
+
         ShaderCode fragmentShader = ShaderCode.create(gl4, GL4.GL_FRAGMENT_SHADER, this.getClass(), "src/data", null, "simple", "frag", null, true);
         ShaderCode fragmentShader = ShaderCode.create(gl4, GL4.GL_FRAGMENT_SHADER,
 
                this.getClass(), "src/data", null, "simple", "frag", null, true);
 
 
         ShaderProgram program = new ShaderProgram();
 
         ShaderProgram program = new ShaderProgram();
 
         program.add(vertexShader);
 
         program.add(vertexShader);

Revision as of 12:12, 26 July 2015

Before starting, you should know that the JOGL API is not a young API, this means that there are some things that are (very) old, so you should always evaluate what you are looking at.

We will reference all the links to the main jogamp server, but you can click also on the GitHub version (GH) for a better layout, font and support for highlighting or on the API docs (AD).

Preface

The JOGL API offers a lots of deep and detailed utilities for almost all the possible needs regarding OpenGL but most of them aren't used simply because people ignore about their existence. This small overview aims to alleviate this problem.

You can find the most interesting part under com.jogamp.opengl (GH).

Shaders

com.jogamp.opengl.util.glsl (GH).

You can create your own GLSL program in JOGL by simply calling:

   private int initProgram(GL4 gl4) {
       ShaderCode vertexShader = ShaderCode.create(gl4, GL4.GL_VERTEX_SHADER, this.getClass(), "src/data", null, "simple", "vert", null, true);
       ShaderCode fragmentShader = ShaderCode.create(gl4, GL4.GL_FRAGMENT_SHADER, this.getClass(), "src/data", null, "simple", "frag", null, true);
       ShaderProgram program = new ShaderProgram();
       program.add(vertexShader);
       program.add(fragmentShader);
       program.link(gl4, System.out);
       return program.program();
   }