Hello Guest

LWJGL and GLSL Geometry Shaders

  • 7 Replies
  • 13043 Views
LWJGL and GLSL Geometry Shaders
« on: January 23, 2009, 12:22:19 »
Hi everyone,

Did any of you ever use a Geometry shader written in GLSL using LWJGL ?
I successfully use Vertex and Fragment Shaders all the time, and I'm now trying, via the "ARBGeometryShader4" class, to use Geometry shaders.
Looks like Shaders loading is ok, cause "printLogInfo" (See wiki) does not give any error.
But When I do render a Shape using this shader, nothing appears.

Then, I've tried to use this method :

ARBGeometryShader4.glProgramParameteriARB(...)

....gives me an exception at the very first use of it:

java.lang.IllegalStateException: Function is not supported
   at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:64)
   at org.lwjgl.opengl.ARBGeometryShader4.glProgramParameteriARB(ARBGeometryShader4.java:68)

I know Geometry shaders should work on my Nvidia 8800 GT with DirectX 10.

So, any idea what's going on ?
It seems to me that LWJGL does not implements Geometry Shaders functions...

Thanks.

Estraven


*

Offline spasi

  • *****
  • 2208
    • WebHotelier
Re: LWJGL and GLSL Geometry Shaders
« Reply #1 on: January 23, 2009, 16:59:37 »
Are you sure GL_ARB_geometry_shader4 in ContextCapabilities is true?

edit: If it isn't, make sure you have the latest drivers. Try NVemulate to see if you can enable OpenGL 3.0 too.
« Last Edit: January 23, 2009, 17:04:19 by spasi »

Re: LWJGL and GLSL Geometry Shaders
« Reply #2 on: January 24, 2009, 13:19:22 »
Quote
Are you sure GL_ARB_geometry_shader4 in ContextCapabilities is true?

Indeed, it was not...

Quote
If it isn't, make sure you have the latest drivers.

I did.

Quote
Try NVemulate to see if you can enable OpenGL 3.0 too.

It does work. And finaly, the method "ARBGeometryShader4.glProgramParameteriARB(...)" is now working, thank you Spasi !

Still my object does not render with my geometry shader enabled... i think is now related to my shader code. I'll try to debug, but much easier when openGL methods do work  ;)

Thanks again.

Estraven.

Re: LWJGL and GLSL Geometry Shaders
« Reply #3 on: April 05, 2009, 16:21:58 »
Here we go again.

Like i said in my last message, my object does not render. I though it was because of my shaders, but it seems it's not the issue.

Here is my main steps :

Code: [Select]
create programObjectID  -   glCreateProgramObjectARB

create VertexProgramID  -   glCreateShaderObjectARB(ARBVertexShader.GL_VERTEX_SHADER_ARB);

load VPcode  -   glShaderSourceARB

compile VPcode  -   glCompileShaderARB

Check compilation status  -   glGetObjectParameterARB(vertexShader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB, bfr);

attach object  -   glAttachObjectARB(programObject, vertexShader);

Validate VPshader  -   ARBShaderObjects.glValidateProgramARB(vertexShader);

link programObject  -   glLinkProgramARB(programObject);

validate program objets


Then I do exactly the same steps (using the same programObject...) for Geometry shader, and then again for fragment shader.

Finally, I set up some Geometry shader stuff :

Code: [Select]
ARBGeometryShader4.glProgramParameteriARB(geometryShader,ARBGeometryShader4.GL_GEOMETRY_INPUT_TYPE_ARB,GL11.GL_TRIANGLES);
ARBGeometryShader4.glProgramParameteriARB(geometryShader,ARBGeometryShader4.GL_GEOMETRY_OUTPUT_TYPE_ARB,GL11.GL_TRIANGLES);
ARBGeometryShader4.glProgramParameteriARB(geometryShader,ARBGeometryShader4.GL_GEOMETRY_VERTICES_OUT_ARB,64);

I get no compilation error, validation is OK, for ALL shaders.

but nothing appears on screen.

my shaders :

VP
Code: [Select]
void main(void)
{
gl_Position = ftransform();
}

GS
Code: [Select]

#version 120
#extension GL_EXT_geometry_shader4 : enable

void main(void)
{

int i;

for(i=0; i< gl_VerticesIn; i++){
gl_Position =  gl_PositionIn[i];
EmitVertex();
}
EndPrimitive();


}


FS
Code: [Select]
void main(void)
{
gl_FragColor = vec4(1,1,1,1);
}


using only VP + FS I get a white object.
using VP + GS + FS, screen remains black

Any idea ? I don't know what to try next.

Estraven

Re: LWJGL and GLSL Geometry Shaders
« Reply #4 on: April 05, 2009, 16:41:42 »
You should read Section 2.16.2 in the ARB_geometry_shader4 spec.

And always set the number of output vertices as small as possible.

Ciao Matthias

Re: LWJGL and GLSL Geometry Shaders
« Reply #5 on: April 05, 2009, 18:05:01 »
Thank you,

I knew this documentation, nothing new, still not working.

Does any one did get geometry shaders to work with LWJGL. I mean, really work ? Or is it just not possible because of LWJGL ?

Share some experience please. I've tried for weeks, no results.

Thank you all.

Estraven


Re: LWJGL and GLSL Geometry Shaders
« Reply #6 on: April 05, 2009, 18:18:31 »
Of course they work. I have used them myself. If you would READ the chapter I told you then you would see why it's not working.

Also it might help if you check for GL errors. You can even use the "new" lwjgl_debug.jar for that.

Re: LWJGL and GLSL Geometry Shaders
« Reply #7 on: April 05, 2009, 20:10:44 »
I did READ it ! :p This doc says nothing I haven't red before...

BUT !! I just tried to use lwjgl_debug.jar, and after some troubleshooting, I finally got it to work.

I had totaly forgot about this jar file. Turns out I only had some Mistakes in the shaders compilation process... mea culpa

Thanks you Matthias.

--Estraven