git-svn-id: svn://db.shs.com.ru/libs@52 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -120,24 +120,25 @@ void GLVBO::draw(GLenum type, QGLShaderProgram * prog, bool simplest) {
|
||||
//qDebug() << "draw" << vert_count;
|
||||
void * offset = (void*)(vert_count * 3 * sizeof(GLfloat));
|
||||
//glBindVertexArray(va_);
|
||||
|
||||
void * offsets[5] = {0, 0, 0, 0, 0};
|
||||
if (has_normals) {
|
||||
offsets[0] = offset;
|
||||
offset = (void*)(llong(offset) + vert_count * 3 * sizeof(GLfloat));
|
||||
}
|
||||
if (has_texcoords) {
|
||||
offsets[1] = offset;
|
||||
offset = (void*)(llong(offset) + vert_count * 2 * sizeof(GLfloat));
|
||||
}
|
||||
if (has_colors) {
|
||||
offsets[2] = offset;
|
||||
offset = (void*)(llong(offset) + vert_count * 4 * sizeof(GLfloat));
|
||||
}
|
||||
if (has_binormals) {
|
||||
offsets[3] = offset;
|
||||
offset = (void*)(llong(offset) + vert_count * 3 * sizeof(GLfloat));
|
||||
offsets[4] = offset;
|
||||
if (!simplest) {
|
||||
if (has_normals) {
|
||||
offsets[0] = offset;
|
||||
offset = (void*)(llong(offset) + vert_count * 3 * sizeof(GLfloat));
|
||||
}
|
||||
if (has_texcoords) {
|
||||
offsets[1] = offset;
|
||||
offset = (void*)(llong(offset) + vert_count * 2 * sizeof(GLfloat));
|
||||
}
|
||||
if (has_colors) {
|
||||
offsets[2] = offset;
|
||||
offset = (void*)(llong(offset) + vert_count * 4 * sizeof(GLfloat));
|
||||
}
|
||||
if (has_binormals) {
|
||||
offsets[3] = offset;
|
||||
offset = (void*)(llong(offset) + vert_count * 3 * sizeof(GLfloat));
|
||||
offsets[4] = offset;
|
||||
}
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer_);
|
||||
@@ -147,42 +148,44 @@ void GLVBO::draw(GLenum type, QGLShaderProgram * prog, bool simplest) {
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
int loc = prog->attributeLocation("_qgl_Vertex"), loc2 = 0;
|
||||
int loc = prog->attributeLocation("_qgl_Vertex");
|
||||
glEnableVertexAttribArray(loc);
|
||||
glVertexAttribPointer(loc, 3, GL_FLOAT, 0, 0, 0);
|
||||
loc = prog->attributeLocation("qgl_Normal");
|
||||
locs << loc;
|
||||
if (has_normals) {
|
||||
glEnableVertexAttribArray(loc);
|
||||
glVertexAttribPointer(loc, 3, GL_FLOAT, 0, 0, offsets[0]);
|
||||
locs << loc;
|
||||
} else
|
||||
glDisableVertexAttribArray(loc);
|
||||
loc = prog->attributeLocation("qgl_Texture");
|
||||
if (has_texcoords) {
|
||||
glEnableVertexAttribArray(loc);
|
||||
glVertexAttribPointer(loc, 2, GL_FLOAT, 0, 0, offsets[1]);
|
||||
locs << loc;
|
||||
} else
|
||||
glDisableVertexAttribArray(loc);
|
||||
loc = prog->attributeLocation("qgl_Color");
|
||||
if (has_colors) {
|
||||
glEnableVertexAttribArray(loc);
|
||||
glVertexAttribPointer(loc, 4, GL_FLOAT, 0, 0, offsets[2]);
|
||||
locs << loc;
|
||||
} else
|
||||
glDisableVertexAttribArray(loc);
|
||||
loc = prog->attributeLocation("qgl_Tangent");
|
||||
loc2 = prog->attributeLocation("qgl_Bitangent");
|
||||
if (has_binormals) {
|
||||
glEnableVertexAttribArray(loc);
|
||||
glEnableVertexAttribArray(loc2);
|
||||
glVertexAttribPointer(loc, 3, GL_FLOAT, 0, 0, offsets[3]);
|
||||
glVertexAttribPointer(loc2, 3, GL_FLOAT, 0, 0, offsets[4]);
|
||||
locs << loc << loc2;
|
||||
} else {
|
||||
glDisableVertexAttribArray(loc);
|
||||
glDisableVertexAttribArray(loc2);
|
||||
if (!simplest) {
|
||||
loc = prog->attributeLocation("qgl_Normal");
|
||||
if (has_normals) {
|
||||
glEnableVertexAttribArray(loc);
|
||||
glVertexAttribPointer(loc, 3, GL_FLOAT, 0, 0, offsets[0]);
|
||||
locs << loc;
|
||||
} else
|
||||
glDisableVertexAttribArray(loc);
|
||||
loc = prog->attributeLocation("qgl_Texture");
|
||||
if (has_texcoords) {
|
||||
glEnableVertexAttribArray(loc);
|
||||
glVertexAttribPointer(loc, 2, GL_FLOAT, 0, 0, offsets[1]);
|
||||
locs << loc;
|
||||
} else
|
||||
glDisableVertexAttribArray(loc);
|
||||
loc = prog->attributeLocation("qgl_Color");
|
||||
if (has_colors) {
|
||||
glEnableVertexAttribArray(loc);
|
||||
glVertexAttribPointer(loc, 4, GL_FLOAT, 0, 0, offsets[2]);
|
||||
locs << loc;
|
||||
} else
|
||||
glDisableVertexAttribArray(loc);
|
||||
loc = prog->attributeLocation("qgl_Tangent");
|
||||
int loc2 = prog->attributeLocation("qgl_Bitangent");
|
||||
if (has_binormals) {
|
||||
glEnableVertexAttribArray(loc);
|
||||
glEnableVertexAttribArray(loc2);
|
||||
glVertexAttribPointer(loc, 3, GL_FLOAT, 0, 0, offsets[3]);
|
||||
glVertexAttribPointer(loc2, 3, GL_FLOAT, 0, 0, offsets[4]);
|
||||
locs << loc << loc2;
|
||||
} else {
|
||||
glDisableVertexAttribArray(loc);
|
||||
glDisableVertexAttribArray(loc2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
Reference in New Issue
Block a user