Jump to content
  • Advertisement
Sign in to follow this  
slicer4ever

OpenGL GLSL Geometry problem.

This topic is 2298 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all, i'm having a very weird problem with openGL glsl.

i'm just starting out with geometry shaders, so i have this:



#version 150
#extension GL_EXT_geometry_shader4: enable
layout(triangles) in;
layout(triangle_strip , max_vertices=3) out;
uniform mat4 View;
uniform mat4 Proj;
void main(){
for(int i=0;i<gl_VerticesIn;i++){
gl_Position = Proj*View*(gl_in.gl_Position+vec4(60.0,0.0,0.0,0.0));
gl_FrontColor = gl_in.gl_FrontColor;
EmitVertex();
}
EndPrimitive();
for(int i=0;i<gl_VerticesIn;i++){
gl_Position = Proj*View*gl_in.gl_Position;
gl_FrontColor = gl_in.gl_FrontColor;
EmitVertex();
}
EndPrimitive();
return;
}


but it's behaving..weirdly...

essentially, it seem to behave like it end's the geometry shader after the first EndPrimitive() call.

i can swap the two around loops around, and it'll draw the other primitive correctly. it just won't draw them both.

my gpu is an nvidia gtx560m, with the latest 296.10 drivers.

Share this post


Link to post
Share on other sites
Advertisement
Hi!

A geometry shader must know how many vertices are written at most.
That's what you define in this line (aside from the output topology):
layout(triangle_strip , max_vertices=3) out;

Currently you output only at most 3 vertices, which would be exactly one triangle. No more.
If you want to output a second triangle, you'd have to tell GL that at most 6 vertices are written:
layout(triangle_strip , max_vertices=6) out;


That should do the trick. smile.png
Cheers!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!