Jump to content
  • Advertisement
Sign in to follow this  
evillgames

GLSL Geometry Shader does not show anything

This topic is 2125 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



GPUGrassVertex growPoint[1];
  Float3Set(growPoint[0].origin,0,0,0);
  PackNormalizedVector(growPoint[0].growDir,CVector3f(0,0,1));
  growPoint[0].grassTileID[0]=0;

  
  grassGeometryBasedAmbient.Enable();
  grassGeometryBasedAmbient.SetGeometryShaderParameter(GL_GEOMETRY_VERTICES_OUT_ARB, 4);
  grassGeometryBasedAmbient.SetGeometryShaderParameter(GL_GEOMETRY_OUTPUT_TYPE_ARB, GL_TRIANGLE_STRIP);
  grassGeometryBasedAmbient.SetGeometryShaderParameter(GL_GEOMETRY_INPUT_TYPE_ARB, GL_POINTS);
  
  
  glDisable(GL_CULL_FACE);
  glDisable(GL_TEXTURE_2D);
  glDisable(GL_BLEND);

  glPointSize(12);
  glColor3f(1,1,1);

  glEnableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
  glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);

  size_t vbsize = sizeof(GPUGrassVertex);
  glVertexPointer(3, GL_FLOAT, vbsize, &growPoint[0].origin);

  int numIndexes = 1;
  ushort ids[1]={0};
  glDrawElements( GL_POINTS, numIndexes,GL_UNSIGNED_SHORT,ids);

  glEnableClientState(GL_TEXTURE_COORD_ARRAY);  // dont allow to cache this!
  glEnableClientState(GL_VERTEX_ARRAY);
  glEnableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_NORMAL_ARRAY);
  glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
  
  glEnable(GL_TEXTURE_2D);
  glEnable(GL_CULL_FACE);

  grassGeometryBasedAmbient.Disable();




[vertex]

void main()
{
   	gl_Position.xyz = gl_Vertex.xyz;
	gl_FrontColor = gl_Color;
}

[geometry]

void main()
{
	float size_scale = 1;
	float GRASS_HEIGHT = 50 * size_scale;
	float GRASS_WIDTH = 30 * size_scale;
	vec3 origin = vec3(-17.000000, 15.000000, -136.000000); //gl_PositionIn[0].xyz;

	// construct billboard
	vec3 verts[4];
	verts[0]=vec3(-GRASS_WIDTH,0,0);
	verts[1]=vec3(GRASS_WIDTH,0,0);
	verts[2]=vec3(GRASS_WIDTH,0,GRASS_HEIGHT);
	verts[3]=vec3(-GRASS_WIDTH,0,GRASS_HEIGHT);
	//
	
	
	gl_Position = gl_ModelViewProjectionMatrix * vec4(origin + verts[0],1);
	//gl_FrontColor = 1; // gl_FrontColorIn[0];	
	EmitVertex();

	gl_Position = gl_ModelViewProjectionMatrix * vec4(origin + verts[1],1);
	//gl_FrontColor = 1; //gl_FrontColorIn[0];	
	EmitVertex();

	gl_Position = gl_ModelViewProjectionMatrix * vec4(origin + verts[2],1);
	//gl_FrontColor = 1; // gl_FrontColorIn[0];
	EmitVertex();

	gl_Position = gl_ModelViewProjectionMatrix * vec4(origin + verts[3],1);
	//gl_FrontColor = 1; //gl_FrontColorIn[0];
	EmitVertex();
	
	EndPrimitive();
}

hey guys - it just does not work... but i have no errors....
 
here is debug code - some lines are commented out

 

i expect to see quad ,at least....

GS is supported

Share this post


Link to post
Share on other sites
Advertisement

It's difficult to say without seeing the code behind your various classes but I have a hunch.

 

Your use of "_ARB" and "_EXT" suffixes throughout your code suggests that you may also be using the ancient GL_ARB_shader_objects extension.  It's not a great idea to mix this extension with more modern functionality, as the extension was never actually taken up into core OpenGL (GL2.0 shaders use a slightly different API that was never even available as an extension), and as such more modern functionality is not even guaranteed to work with it.

 

If that's the case, then you should rip out all use of this extension and just use the core GL 2.0 entry points and GLenums instead.

Share this post


Link to post
Share on other sites

hm......

 

well - i have one more GS and that is working - loading is the same - SetGeometryShaderParameter same also

 

it is just strange//

Share this post


Link to post
Share on other sites

inline void SetGeometryShaderParameter(GLenum pname, GLint value)
{
if(!m_loaded)
return;

glProgramParameteriARB(programObject,pname, value);
}

Share this post


Link to post
Share on other sites

The critical question is: are you using GL_ARB_shader_objects?

 

You need to answer this because sometimes working/sometimes not, weird stuff happening, etc is exactly the kind of symptom I would expect if you were (I observed it myself once when I accidentally did the same).

Share this post


Link to post
Share on other sites

yes - i do use GL_ARB_shader_objects

)

 

so:

bool CGlslShader::Enable()
{
  if(!m_loaded) return 0; //<! not supported
	
	glUseProgramObjectARB(programObject);
  return 1;
}

void CGlslShader::Disable()
{
  if(!m_loaded) return; //<! not supported

	glUseProgramObjectARB(0);
}

glCreateShaderObjectARB
glCompileShaderARB
glAttachObjectARB
glLinkProgramARB

e.t.c
 

Share this post


Link to post
Share on other sites

So that's your problem then.

 

Because GL_ARB_shader_objects is old and because it was never taken up into core OpenGL, it's not even guaranteed to know what a geometry shader is.

 

I'm going to guess here that you're also using GL_ARB_geometry_shader4, so it's important to note the specification of that extension: http://www.opengl.org/registry/specs/ARB/geometry_shader4.txt

 

This extension is written against the OpenGL 2.0 specification

 

As I said before, GL_ARB_shader_objects is not the same GLSL API that exists in GL2.0, GL_ARB_shader_objects was never promoted to core GL and the GL2.0 shader API had never previously existed as an extension, so while it may work sometimes, you shouldn't expect it to work consistently or robustly all of the time.

 

So if you want to use a geometry shader, you should dump GL_ARB_shader_objects and use the core GL2.0 API instead.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!