I'm trying to get some legacy OpenGL code to run with a shader pipeline,
The legacy code uses glVertexPointer(), glColorPointer(), glNormalPointer() and glTexCoordPointer() to supply the vertex information.
I know that it should be using setVertexAttribPointer() etc to clearly define the layout but that is not an option right now since the legacy code can't be modified to that extent.
I've got a version 330 vertex shader to somewhat work:
#version 330
uniform mat4 osg_ModelViewProjectionMatrix;
uniform mat4 osg_ModelViewMatrix;
layout(location = 0) in vec4 Vertex;
layout(location = 2) in vec4 Normal; // Velocity
layout(location = 3) in vec3 TexCoord; // TODO: is this the right layout location?
out VertexData {
vec4 color;
vec3 velocity;
float size;
} VertexOut;
void main(void)
{
vec4 p0 = Vertex;
vec4 p1 = Vertex + vec4(Normal.x, Normal.y, Normal.z, 0.0f);
vec3 velocity = (osg_ModelViewProjectionMatrix * p1 - osg_ModelViewProjectionMatrix * p0).xyz;
VertexOut.velocity = velocity;
VertexOut.size = TexCoord.y;
gl_Position = osg_ModelViewMatrix * Vertex;
}
What works is the Vertex and Normal information that the legacy C++ OpenGL code seem to provide in layout location 0 and 2. This is fine.
What I'm not getting to work is the TexCoord information that is supplied by a glTexCoordPointer() call in C++.
Question:
What layout location is the old standard pipeline using for glTexCoordPointer()? Or is this undefined?
Side note: I'm trying to get an OpenSceneGraph 3.4.0 particle system to use custom vertex, geometry and fragment shaders for rendering the particles.
↧