Jogl API Overview: Difference between revisions

From JogampWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:


[http://jogamp.org/git/?p=jogl.git;a=tree;f=src/jogl/classes/com/jogamp/opengl/util/glsl;h=8e0f6ddfb2817836db16f26ecc8967553d8b6bd7;hb=HEAD com.jogamp.opengl.util.glsl] ([https://github.com/sgothel/jogl/tree/master/src/jogl/classes/com/jogamp/opengl/util/glsl GH]).
[http://jogamp.org/git/?p=jogl.git;a=tree;f=src/jogl/classes/com/jogamp/opengl/util/glsl;h=8e0f6ddfb2817836db16f26ecc8967553d8b6bd7;hb=HEAD com.jogamp.opengl.util.glsl] ([https://github.com/sgothel/jogl/tree/master/src/jogl/classes/com/jogamp/opengl/util/glsl GH]).
You can create your own GLSL program in JOGL by simply calling:
<code>
            shaderName[Shader.vert.ordinal()] = ShaderCode.create(gl3, GL_VERTEX_SHADER,
                    this.getClass(), SHADERS_ROOT, null, SHADERS_SOURCE, "vert", null, true);
            shaderName[Shader.frag.ordinal()] = ShaderCode.create(gl3, GL_FRAGMENT_SHADER,
                    this.getClass(), SHADERS_ROOT, null, SHADERS_SOURCE, "frag", null, true);
            ShaderProgram program = new ShaderProgram();
            program.add(shaderName[Shader.vert.ordinal()]);
            program.add(shaderName[Shader.frag.ordinal()]);
            program.link(gl3, System.out);
            programName = program.program();</code>

Revision as of 11:06, 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:

           shaderName[Shader.vert.ordinal()] = ShaderCode.create(gl3, GL_VERTEX_SHADER,
                   this.getClass(), SHADERS_ROOT, null, SHADERS_SOURCE, "vert", null, true);
           shaderName[Shader.frag.ordinal()] = ShaderCode.create(gl3, GL_FRAGMENT_SHADER,
                   this.getClass(), SHADERS_ROOT, null, SHADERS_SOURCE, "frag", null, true);
           ShaderProgram program = new ShaderProgram();
           program.add(shaderName[Shader.vert.ordinal()]);
           program.add(shaderName[Shader.frag.ordinal()]);
           program.link(gl3, System.out);
           programName = program.program();