I'm pretty confused and sick of failing, I searched like crazy and resisted the urge to make a new thread for a long time but here it is.
I don't feel like my attributes are getting passed into my shaders properly. Here is my code for when I bind objects to VBOs
(this is LWJGL)
int vaoId = glGenVertexArrays();
glBindVertexArray(vaoId);
int vboVertexHandle = glGenBuffers();
int vboTextureHandle = glGenBuffers();
int vboNormalHandle = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, vboTextureHandle);
glBufferData(GL_ARRAY_BUFFER, textureCoordinates, GL_STATIC_DRAW);
glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, vboNormalHandle);
glBufferData(GL_ARRAY_BUFFER, normals, GL_STATIC_DRAW);
glVertexAttribPointer(2, 3, GL_FLOAT, false, 0, 0);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
return vaoId;
when I call glVertexAttribute(), the first number can be whatever I want...right? It is the position that I want to find that information at in the VAO in the future?
and then I did this
glBindAttribLocation(shaderProgram, 0, "VertexPosition");
glBindAttribLocation(shaderProgram, 1, "TextureCoordinate");
glBindAttribLocation(shaderProgram, 2, "Normals");
before using the shader, and tried initialize access of the information in the vertex shader like this
in vec3 VertexPosition;
Is this right? What is missing?
Also, if I'm using GLSL 4.0 is using the location like this
layout (location = 0) in vec3 VertexPosition;
a direct replacement for this?
glBindAttribLocation(shaderProgram, 0, "VertexPosition");