I have a vertex shader that I'm trying to render the content from, using a vertex shader. I had it working when I was using plain vec3 "in" attribute, but now I need to pass certain informations. I made a struct that I'm going to use for the vertex shader, a geometry shader and a compute shader.
struct StellarEntity
{
vec3 position;
vec3 velocity;
double mass;
double radius;
};
Here's my vertex shader (of course the struct is in there) :
#version 430
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 modelMatrix;
layout(location = 0) in StellarEntity in_entity;
void main()
{
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(in_entity.position, 1.0);
}
What I think the problem may be, is the way I bind my vertex attribute.
vao = new VAO();
//"entities" is a StellarEntity[256] with all data initialized
vao.BufferData(BufferTarget.ArrayBuffer, entities, BufferUsageHint.StaticDraw);
vao.VertexAttribPointer(0, 3, VertexAttribPointerType.Double, false, 0, 0);
vao.VertexAttribPointer(0, 3, VertexAttribPointerType.Double, false, 0, 0);
vao.VertexAttribPointer(0, 1, VertexAttribPointerType.Double, false, 0, 0);
vao.VertexAttribPointer(0, 1, VertexAttribPointerType.Double, false, 0, 0);
I don't really understand the stride and offset (last two parameters of VertexAttribPointer), so I put them at 0...
EDIT : forgot to put my BindAttributeLocation call, so here it is :
//"program" being my shaderprogram, after the linking (worked fine for simple shaders)
program.BindAttribLocation(0, "in_entity");