LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: kramer on March 12, 2006, 12:27:10

Title: GL shading language
Post by: kramer on March 12, 2006, 12:27:10
Hi All,

Does anyone have a simple example of using GLSL with LWJGL that they'd be willing to share?

If it's too long to post here, please email it to kramer99@gmail.com

Thanks for your help.
Title: GL shading language
Post by: spasi on March 12, 2006, 14:47:05
See the org.lwjgl.test.opengl.shaders package in the LWJGL source. It contains a simple GLSL example. Note that it uses the ARB interface and not the GL2.0 one, though it's easy to convert if you wish so.
Title: GL shading language
Post by: kramer on March 14, 2006, 04:37:05
Ahh, thanks spasi...
so the GLSL one is the "FSH" one, and the others are the more primitive card specific versions that you need to precompile yourself - have i got that right?
Title: GL shading language
Post by: spasi on March 14, 2006, 14:59:20
Yes, but let me explain further, just to be clear:

The vp/fp are low-level vertex & fragment programs using the (old) ARB_vertex/fragment_program extensions.

GLSL is used by the vsh/fsh ones, which are high-level vertex & fragments shaders. These examples use the (newer) ARB_vertex_shader, ARB_fragment_shader and ARB_shader_objects extensions, which expose the initial GLSL API. Most recent drivers support GL version 2.0 though, which exposes a (newest) slightly different API for GLSL and is what you'd probably want to use.
Title: GL shading language
Post by: kramer on March 15, 2006, 04:26:34
Thanks for the explanation.

Do you find RenderMonkey to be of any use for this sort of stuff at all?
Title: GL shading language
Post by: spasi on March 15, 2006, 11:05:51
It's very good for quick tests and learning. It would be good for production shaders too, but unfortunately it doesn't support multiple shader objects per program (at least it didn't last time I checked). By this I mean linking a number of "utility" shaders to a main vertex/fragment shader pair, to produce the final shader program. This is what we do extensively in Marathon (lower complexity, higher reusability).