I'm having trouble running example from: https://raw.github.com/progschj/OpenGL-Examples/master/07geometry_shader_blending.cpp My graphics card supports only #130 shaders version so I have to rewrite shaders.
I figured out how to fix vertex and fragment shaders. I removed:
layout(location = 0)
from
layout(location = 0) in vec4 vposition;
and added this into my source code:
glBindAttribLocation(shader_program, 0, "vposition");
However I have no idea how to rewrite geometry shader...
#version 130
uniform mat4 View;
uniform mat4 Projection;
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
out vec2 txcoord;
void main() {
vec4 pos = View*gl_PositionIn[0].gl_Position;
txcoord = vec2(-1,-1);
gl_Position = Projection*(pos+vec4(txcoord,0,0));
EmitVertex();
txcoord = vec2( 1,-1);
gl_Position = Projection*(pos+vec4(txcoord,0,0));
EmitVertex();
txcoord = vec2(-1, 1);
gl_Position = Projection*(pos+vec4(txcoord,0,0));
EmitVertex();
txcoord = vec2( 1, 1);
gl_Position = Projection*(pos+vec4(txcoord,0,0));
EmitVertex();
}
The main problem is how to get rid of location
here:
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
Can someone help me?
EDIT: @melak47 - I edited shader, now I'm not getting any error, but window is black.
#version 130
#extension GL_EXT_geometry_shader4 : enable
precision mediump float;
uniform mat4 View;
uniform mat4 Projection;
out vec2 txcoord;
void main() {
vec4 pos = View*gl_PositionIn[0];
txcoord = vec2(-1,-1);
gl_Position = Projection*(pos+vec4(txcoord,0,0));
EmitVertex();
txcoord = vec2( 1,-1);
gl_Position = Projection*(pos+vec4(txcoord,0,0));
EmitVertex();
txcoord = vec2(-1, 1);
gl_Position = Projection*(pos+vec4(txcoord,0,0));
EmitVertex();
txcoord = vec2( 1, 1);
gl_Position = Projection*(pos+vec4(txcoord,0,0));
EmitVertex();
};
#extension GL_EXT_geometry_shader4 : enable
, and replacinggl_PositionIn[0].gl_Position
withgl_PositionIn[0]
. Maybe you will also have to addgl_FrontColor = gl_FrontColorIn[0];
\$\endgroup\$