Jump to content

  • Log In with Google      Sign In   
  • Create Account

GLSL Geometry Shader does not show anything


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
21 replies to this topic

#1 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 25 September 2013 - 01:23 PM



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



Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 8276

Like
0Likes
Like

Posted 25 September 2013 - 02:14 PM

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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 25 September 2013 - 02:37 PM

hm......

 

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

 

it is just strange//



#4 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 25 September 2013 - 02:39 PM

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

glProgramParameteriARB(programObject,pname, value);
}



#5 mhagain   Crossbones+   -  Reputation: 8276

Like
0Likes
Like

Posted 25 September 2013 - 02:49 PM

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


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#6 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 25 September 2013 - 03:22 PM

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
 



#7 mhagain   Crossbones+   -  Reputation: 8276

Like
1Likes
Like

Posted 25 September 2013 - 04:42 PM

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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#8 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 26 September 2013 - 01:46 AM

that is strange...

but i attach geometry to whole program - why it does not work.....



#9 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 26 September 2013 - 01:50 AM

ya - i do use GL_ARB_geometry_shader4

 

why do these extensions exist if they do not work correctly ?



#10 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 26 September 2013 - 02:00 AM

who needs these extensions if all features are in core



#11 BitMaster   Crossbones+   -  Reputation: 4432

Like
0Likes
Like

Posted 26 September 2013 - 02:09 AM

Extensions don't happen for something that is already in Core. Extensions happen for something that does not exist (yet). In many cases useful extensions get promoted to Core with little or no changes. Sometimes they don't for a variety of reasons. In all cases it is a bad idea to just mix extensions and Core, for example by sending Core constants to ARB functions.

#12 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 26 September 2013 - 02:48 AM

i use GL1.xxx core - but extensions....

they do not exist in gl1 core



#13 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 26 September 2013 - 02:49 AM

and as i learned - do not work



#14 mhagain   Crossbones+   -  Reputation: 8276

Like
0Likes
Like

Posted 26 September 2013 - 03:41 AM

Ah, I see.

 

That all functionality provided by GL versions above 1.1 is provided by extensions is actually a misconception; that's not the way things work and maybe some of the terminology used by GL documentation and tutorials is to blame for fostering it.

 

A new GL version is not just 1.1 plus a bunch of extensions.  Sometimes extensions are promoted, which means that the "ARB", "EXT", etc suffixes get removed.  Sometimes they're unchanged when promoted, sometimes they're radically changed.  Sometimes a new GL version gets new functionality that was never available as an extension, sometimes an extension is never promoted.

 

The potentially confusing terminology I mentioned above is that the GL docs tell you to use the extension loading mechanism for accessing new functionality.  That's not the same thing as using extensions - you use the loading mechanism, not extensions themselves.

 

So in the case of the GL2.0 shader API, it doesn't mean that you need to use GL_ARB_shader_objects.  What it means is that you check if your GL_VERSION is 2.0 or higher, then (e.g. on Windows) do a bunch of wglGetProcAddress calls for glCreateProgram, glCreateShader, glAttachShader, and friends.  Then you check if they're all non-NULL, and if so you can use the core GL2.0 shader API.  Note the no -ARB suffixes, note that it's glCreateProgram, not glCreateProgramObjectARB; it's a different API.

 

So why was this allowed to happen with shaders?  One probable reason is simply this: somebody cocked-up.  The ARB made plenty of cock-ups in the GL2.0/2.1/3.0 timeframe, so we shouldn't be surprised to find another one here.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#15 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 26 September 2013 - 04:12 AM

it is working now

 

just changed  points on triangles



#16 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 26 September 2013 - 04:22 AM

in other words, when i will switch myself to gl3

i will:

- create context with 3.0

- will check if extension is supported

- then will do getprocaddress (glCreateProgram) - NOT glCreateProgramARB

- will use that just like extension

am i right ?



#17 mhagain   Crossbones+   -  Reputation: 8276

Like
0Likes
Like

Posted 26 September 2013 - 04:41 AM

Don't check if an extension is present, check the GL_VERSION.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#18 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 26 September 2013 - 04:45 AM

ok

and how to learn , which functions to use ?

 



#19 BitMaster   Crossbones+   -  Reputation: 4432

Like
0Likes
Like

Posted 26 September 2013 - 04:54 AM

Unless you have very specific constraints, I would not call wglGetProcAdress myself. Use something like GLEW. Getting all the extension information you need for a non-trivial project is a lot of work and there is quite a bit of potential for annoying screwups when doing something by hand.

#20 evillgames   Members   -  Reputation: 154

Like
0Likes
Like

Posted 26 September 2013 - 05:53 AM

in other words

i can use extension - getprocaddress "arb" - which can be fucked up, as i see
or i can say - create context 4.0 - and get procaddres with NO ARB ; or if i use glew - #define GL_VERSION_2_0; .... #define GL_VERSION_3_0; .... #define GL_VERSION_4_0 - lot of versions which opengl4 consists from

glew is cool but mine project can not be as GPL(AFAIK glew goes under GPL) - well - copy/paste then )))


and how about mobiles and glES ?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS