[QUOTE=john_connor;1284491]a hidden error:
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(glm::mat4), (void*)(sizeof(GL_FLOAT) * 0));
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(glm::mat4), (void*)(sizeof(GL_FLOAT) * 4));
glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(glm::mat4), (void*)(sizeof(GL_FLOAT) * 8));
glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, sizeof(glm::mat4), (void*)(sizeof(GL_FLOAT) * 12));
GL_FLOAT is not a floating-point variable (GLfloat is!), its an openGL-internal enum to identify the variable type, like GL_INT (not GLint!)
[/QUOTE]
:doh:
:doh:
[QUOTE=john_connor;1284491]
and there is nowhere a vertexattribdivisor set, so the openGL will send PER-VERTEX a model matrix, thats certainly not what you want
these instanced “pipes” (attributes) have to have trhe divisor “1”, meaning that only per drawcall instance the vertex shader will get a new model-to-world matrix
glVertexAttribDivisor(2, 1);
glVertexAttribDivisor(3, 1);
glVertexAttribDivisor(4, 1);
glVertexAttribDivisor(5, 1);[/QUOTE]
I wanted to first test to not drawing instanced. But i think that’s a stupid idea. So i now changed it to instanced. It crashes -.-
But i think i know why it does. I have a few questions:
- why do we need 4 pipes for just one matrix??
in the shader (from your example codes):
layout (location = 2) in mat4 in_model;
//layout (location = 3) in use ...
//layout (location = 4) in use ...
//layout (location = 5) in use ...
in the cpp:
glVertexAttribPointer(2, 4, GL_FLOAT, false, sizeof(ModelInstance), (void*)(sizeof(float) * 0));
glVertexAttribPointer(3, 4, GL_FLOAT, false, sizeof(ModelInstance), (void*)(sizeof(float) * 4));
glVertexAttribPointer(4, 4, GL_FLOAT, false, sizeof(ModelInstance), (void*)(sizeof(float) * 8));
glVertexAttribPointer(5, 4, GL_FLOAT, false, sizeof(ModelInstance), (void*)(sizeof(float) * 12));
For me it looks like you give the matrix on 4 pipes, but take it just from one. Why don’t we put the whole matrix on one pipe and take it from one??
- Where and how to i tell the shader when to use what instance and who does it know what vertex belong to which instance?? I gave no information about it to the shader and i don’t find something about it in your example code. I think that this is the reason for my crash.
I changed the permission for gitlab. You can now view my code, pull and clone, but not push (i made the master branch a protected branch)