It's been a long time since I last used OpenGL and I can't figure out VAOs anymore... I want to make a simple voxel engine using geometry shaders. This is what I want to do:
vbo1: array of GLfloat for the positions (3 floats per vertex)
vbo2: array of GLfloat for the size of the cube (1 float per vertex)
vbo3: array of GLbyte for the type of voxel (1 byte per vertex)
-> vao: GLfloat x, GLfloat y, GLfloat z, GLfloat size, GLbyte type
Here's my code:
float *positions = new GLfloat[size * 3];
positions[0] = 0.5;
positions[1] = 0.5;
positions[2] = 0;
glGenBuffers(1, &positionsId);
glBindBuffer(GL_ARRAY_BUFFER, positionsId);
glBufferData(GL_ARRAY_BUFFER, size * 3 * sizeof(GLfloat), positions, GL_STATIC_DRAW);
byte * voxelValues = new GLubyte[size];
voxelValues[0] = 0;
glGenBuffers(1, &voxelValuesId);
glBindBuffer(GL_ARRAY_BUFFER, voxelValuesId);
glBufferData(GL_ARRAY_BUFFER, size * sizeof(GLubyte), voxelValues, GL_STATIC_DRAW);
float * sizes = new GLfloat[size];
sizes[0] = 1;
glGenBuffers(1, &sizesId);
glBindBuffer(GL_ARRAY_BUFFER, sizesId);
glBufferData(GL_ARRAY_BUFFER, size * sizeof(GLfloat), sizes, GL_STATIC_DRAW);
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, positionsId);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, sizesId);
glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, voxelValuesId);
glVertexAttribPointer(2, 1, GL_UNSIGNED_BYTE, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
Is the code even doing what I want it to do? And is it even possible to use different datatypes in the vao?