Fix crash when adding a texture on QML

When texture was attached on the qmlsurface example, the smoothUVs was
called before the actual model mesh was created.

Change-Id: I5a62b06291232df54ce08d586d8794b332a4eece
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
This commit is contained in:
Mika Salmela 2014-11-21 14:33:28 +02:00
parent cf47756e17
commit 6939d7e10a
1 changed files with 7 additions and 5 deletions

View File

@ -325,12 +325,14 @@ void SurfaceObject::smoothUVs(const QSurfaceDataArray &dataArray,
}
}
glBindBuffer(GL_ARRAY_BUFFER, m_uvTextureBuffer);
glBufferData(GL_ARRAY_BUFFER, uvs.size() * sizeof(QVector2D),
&uvs.at(0), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
if (uvs.size() > 0) {
glBindBuffer(GL_ARRAY_BUFFER, m_uvTextureBuffer);
glBufferData(GL_ARRAY_BUFFER, uvs.size() * sizeof(QVector2D),
&uvs.at(0), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
m_returnTextureBuffer = true;
m_returnTextureBuffer = true;
}
}
void SurfaceObject::updateSmoothRow(const QSurfaceDataArray &dataArray, int rowIndex, bool polar)