Hi,
I have just started with geometric shaders and stuck-up at basics only
I am trying to draw GL_TRIANGLE_STRIP.
My vertex array:
const GLfloat data[] =
{
-0.9f, -0.2f,
-0.9f, -0.9f,
-0.2f, -0.9f,
-0.2f, -0.2f,
-0.1f,-0.2f,
-0.1f,-0.9f,
0.4f,-0.9f,
0.4f,-0.2f,
0.5, -0.2,
0.5, -0.9,
0.8, -0.9,
0.8, -0.2
};
Vertex shader:
in vec4 v_color;
flat varying vec4 out_color;
in vec2 Position;
void main()
{
gl_Position = vec4(Position,0.0,1.0);
out_color = v_color;
}
geo shader
in vec4 pos[3];
void main()
{
int i;
vec4 vertex;
gl_Position = pos[0];
EmitVertex();
gl_Position = pos[1];
EmitVertex();
gl_Position = pos[2];
EmitVertex();
gl_Position = pos[0] + vec4(0.0,0.5,0.0,0.0);
EmitVertex();
EndPrimitive();
}
Also, i am setting input and output modes for geo shader and making call to glDrawArrays
glProgramParameteriEXT(shader_data.psId, GL_GEOMETRY_INPUT_TYPE_EXT, GL_TRIANGLES);
glProgramParameteriEXT(shader_data.psId, GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_TRIANGLE_STRIP);
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
Here, the program is behaving like geo shaders are not included. In geo shader, i am assigning my own coords to 4th vertex but it is taking the one from data array. Geo shader is compiling with success but whatever changes done in geo shader are not getting reflected while rendering. What am i missing here?
Also, as i dont want to mess with colors passed to vert shader, i have not included them in geo shader. And it applies colors successfully to geometry.
When i call glDraw with 3 instead of 4 (as shown above) it renders 1 triangle.