My question connected with another my question: How to render large number of similar objects?
I trying to render set of points. For one point I using this code:
glUseProgram(programId);
glUniformMatrix4fv(matrixId, 1, GL_FALSE, &(vp * getModelMatrix(pos, scale))[0][0]);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glDrawArrays(GL_POINTS, 0, 1);
glDisableVertexAttribArray(0);
I slightly puzzled with task about set of points. I allocated more memory for vertices:
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, totalParticleCount * 3 * sizeof(GLfloat), gVertexBufferData, GL_STATIC_DRAW);
And I using this draw call for rendering:
glDrawArrays(GL_POINTS, 0, totalParticleCount);
But I don't understand which transformation I must use for glUniformMatrix4fv
function and how I must set vertices. I'm trying do this:
for (int i = 0; i < totalParticleCount; i++) {
gVertexBufferData[3 * i + 0] = hState[i].pos.x;
gVertexBufferData[3 * i + 1] = hState[i].pos.y;
gVertexBufferData[3 * i + 2] = hState[i].pos.z;
}
And set uniform matrix:
glUniformMatrix4fv(matrixId, 1, GL_FALSE, &vp[0][0]);
In my case I see nothing and I can't understand whats wrong.