git-svn-id: svn://db.shs.com.ru/libs@47 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -142,6 +142,7 @@ void GLVBO::draw(GLenum type, QGLShaderProgram * prog, bool simplest) {
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer_);
|
||||
if (prog) {
|
||||
locs.clear();
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
@@ -150,21 +151,25 @@ void GLVBO::draw(GLenum type, QGLShaderProgram * prog, bool simplest) {
|
||||
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");
|
||||
@@ -174,6 +179,7 @@ void GLVBO::draw(GLenum type, QGLShaderProgram * prog, bool simplest) {
|
||||
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);
|
||||
@@ -200,6 +206,8 @@ void GLVBO::draw(GLenum type, QGLShaderProgram * prog, bool simplest) {
|
||||
glDrawArrays(type, 0, vert_count);
|
||||
//qDebug() << "draw" << vert_count << buffer_ << "done";
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
foreach (int l, locs)
|
||||
glDisableVertexAttribArray(l);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user