LWJGL and GLSL Geometry Shaders

Started by Estraven, January 23, 2009, 12:22:19

Previous topic - Next topic

Estraven

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


spasi

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.

Estraven

QuoteAre you sure GL_ARB_geometry_shader4 in ContextCapabilities is true?

Indeed, it was not...

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

I did.

QuoteTry 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.

Estraven

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 :

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 :

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
void main(void)
{
	gl_Position = ftransform();	
}


GS
#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
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

Matthias

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

Estraven

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


Matthias

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.

Estraven

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