I'm trying to pass a single float to my vertex shader so I can set gl_PointSize to be that float. However, it's not working and I think it's due to me using glVertexAttribPointer:
glVertexAttribPointer(1, 1, GLenum(GL_FLOAT), GLboolean(GL_FALSE), GLsizei(MemoryLayout<Vertex>.size), BUFFER_OFFSET(2 * MemoryLayout<Float>.size))
I need the buffer offset since I'm also setting the position using glVertexAttribPointer before that using this:
glVertexAttribPointer(0, 2, GLenum(GL_FLOAT), GLboolean(GL_FALSE), GLsizei(MemoryLayout<Vertex>.size), BUFFER_OFFSET(0))
This is my vertex structure:
struct Vertex {
var x, y, size: Float
}
This is the vertex shader:
attribute vec4 Position;
attribute float Size; // I tried vec4, no luck
void main(void) {
gl_PointSize = Size;
gl_Position = Position;
}
Reto Koradi had the answer! You need to call glBindAttribLocation beforehand when compiling the shader to bind it correctly.