@@ -237,18 +237,19 @@ void Sprite3D::onDraw(const Matrix &transform, bool transformUpdated)
237237 for (int i = 0 ; i < _model->getMeshPartCount (); i++) {
238238 auto meshPart = _model->getMeshPart (i);
239239 auto programstate = _programState[i];
240- programstate->setVertexAttribPointer (" a_position" , 3 , GL_FLOAT, GL_FALSE, 8 * sizeof (float ), _model->getVertexPointer ());
241- programstate->setVertexAttribPointer (" a_texCoord" , 2 , GL_FLOAT, GL_FALSE, 8 * sizeof (float ), ((char *)_model->getVertexPointer () + 6 * sizeof (float )));
240+ size_t offset = (size_t )_model->getVertexPointer ();
241+ programstate->setVertexAttribPointer (" a_position" , 3 , GL_FLOAT, GL_FALSE, 8 * sizeof (float ), (void *)offset);
242+ programstate->setVertexAttribPointer (" a_texCoord" , 2 , GL_FLOAT, GL_FALSE, 8 * sizeof (float ), (void *)(offset + 6 * sizeof (float )));
242243
243- // programstate->setUniformVec4("u_color", Vector4(color.r, color.g, color.b, color.a));
244+ programstate->setUniformVec4 (" u_color" , Vector4 (color.r , color.g , color.b , color.a ));
244245 if (_textures.at (i))
245246 {
246247 GL::bindTexture2D (_textures.at (i)->getName ());
247248 }
248249 programstate->apply (transform);
249250
250- // glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, meshPart->getIndexBuffer());
251- glDrawElements (meshPart->getPrimitiveType (), meshPart->getIndexCount (), meshPart->getIndexFormat (), _model-> getIndexPointer (i) );
251+ glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, meshPart->getIndexBuffer ());
252+ glDrawElements (meshPart->getPrimitiveType (), meshPart->getIndexCount (), meshPart->getIndexFormat (), 0 );
252253 }
253254 }
254255
0 commit comments