I recently created a game (LD21) that uses a geometry shader to convert points into textured triangles/culling. Since I was under the impression that the support for #330 was widespread I only wrote #330 shaders, but it seems that a lot of not so old hardware only support #130 (according to GLView)
Now, since I'm only familiar with the #330 core functionality I am having trouble rewriting my shaders to #130. The fragment shader was quite trivial to rewrite, but I've only managed to get my vertex and geometry shader down to #150.
So, is it possible to rewrite the shaders, or would it require a lot of changes in my rendering engine?
Geometry shader
#version 150
layout(points) in;
layout(triangle_strip, max_vertices = 4) out;
uniform mat4 oMatrix;
in VertexData
{
vec4 position;
vec4 texcoord;
vec4 size;
} vert;
out vec2 gTexCoord;
void main()
{
if(vert.position.x>-4f && vert.position.x<4f && vert.position.y>-2f && vert.position.y<2f)
{
gTexCoord=vec2(vert.texcoord.z,vert.texcoord.y);
gl_Position = vert.position + vec4(vert.size.x,vert.size.y,0,0);
EmitVertex();
gTexCoord=vec2(vert.texcoord.x,vert.texcoord.y);
gl_Position = vert.position + vec4(0.0,vert.size.y,0,0);
EmitVertex();
gTexCoord=vec2(vert.texcoord.z,vert.texcoord.w);
gl_Position = vert.position + vec4(vert.size.x,0.0,0,0);
EmitVertex();
gTexCoord=vec2(vert.texcoord.x,vert.texcoord.w);
gl_Position = vert.position;
EmitVertex();
EndPrimitive();
}
}
Vertex shader
#version 150
#extension GL_ARB_explicit_attrib_location : enable
layout (location = 0) in vec2 position;
layout (location = 1) in vec4 textureCoord;
layout (location = 2) in vec2 size;
uniform mat4 oMatrix;
uniform vec2 offset;
out VertexData
{
vec4 position;
vec4 texcoord;
vec4 size;
} outData;
void main()
{
outData.position = oMatrix * vec4(position.x+offset.x,position.y+offset.y,0,1);
outData.texcoord = textureCoord;
outData.size = oMatrix * vec4(size.x,size.y,0,0);
}