diff options
author | SmileTheory <SmileTheory@gmail.com> | 2014-10-23 16:51:10 -0700 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2015-03-17 11:38:54 +0000 |
commit | 5b2ae40e135fda8ecba622ce1fe8b75087abca51 (patch) | |
tree | e6da3e2b86e1dd396026ec320a6987d794d99ce2 /src/renderergl2/tr_surface.c | |
parent | c95e4d4b9ac8a6e944f584563a0ba1a5de636cab (diff) |
OpenGL2: Fix corrupt models.
Diffstat (limited to 'src/renderergl2/tr_surface.c')
-rw-r--r-- | src/renderergl2/tr_surface.c | 61 |
1 files changed, 49 insertions, 12 deletions
diff --git a/src/renderergl2/tr_surface.c b/src/renderergl2/tr_surface.c index a07484ca..6d2cb4ca 100644 --- a/src/renderergl2/tr_surface.c +++ b/src/renderergl2/tr_surface.c @@ -1590,8 +1590,8 @@ void RB_SurfaceVaoMdvMesh(srfVaoMdvMesh_t * surface) tess.useInternalVao = qfalse; - tess.numIndexes += surface->numIndexes; - tess.numVertexes += surface->numVerts; + tess.numIndexes = surface->numIndexes; + tess.numVertexes = surface->numVerts; tess.minIndex = surface->minIndex; tess.maxIndex = surface->maxIndex; @@ -1600,20 +1600,57 @@ void RB_SurfaceVaoMdvMesh(srfVaoMdvMesh_t * surface) refEnt = &backEnd.currentEntity->e; - if(refEnt->oldframe == refEnt->frame) - { - glState.vertexAttribsInterpolation = 0; - } - else - { - glState.vertexAttribsInterpolation = refEnt->backlerp; - } + glState.vertexAttribsInterpolation = (refEnt->oldframe == refEnt->frame) ? 0.0f : refEnt->backlerp; - glState.vertexAttribsOldFrame = refEnt->oldframe; - glState.vertexAttribsNewFrame = refEnt->frame; if (surface->mdvModel->numFrames > 1) + { + int frameOffset, attribIndex; + vaoAttrib_t *vAtb; + glState.vertexAnimation = qtrue; + if (glRefConfig.vertexArrayObject) + { + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, surface->vao->vertexesVBO); + } + + frameOffset = refEnt->frame * surface->vao->frameSize; + + attribIndex = ATTR_INDEX_POSITION; + vAtb = &surface->vao->attribs[attribIndex]; + qglVertexAttribPointerARB(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); + + attribIndex = ATTR_INDEX_NORMAL; + vAtb = &surface->vao->attribs[attribIndex]; + qglVertexAttribPointerARB(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); + + attribIndex = ATTR_INDEX_TANGENT; + vAtb = &surface->vao->attribs[attribIndex]; + qglVertexAttribPointerARB(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); + + frameOffset = refEnt->oldframe * surface->vao->frameSize; + + attribIndex = ATTR_INDEX_POSITION2; + vAtb = &surface->vao->attribs[attribIndex]; + qglVertexAttribPointerARB(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); + + attribIndex = ATTR_INDEX_NORMAL2; + vAtb = &surface->vao->attribs[attribIndex]; + qglVertexAttribPointerARB(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); + + attribIndex = ATTR_INDEX_TANGENT2; + vAtb = &surface->vao->attribs[attribIndex]; + qglVertexAttribPointerARB(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset + frameOffset)); + + + if (!glRefConfig.vertexArrayObject) + { + attribIndex = ATTR_INDEX_TEXCOORD; + vAtb = &surface->vao->attribs[attribIndex]; + qglVertexAttribPointerARB(attribIndex, vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, BUFFER_OFFSET(vAtb->offset)); + } + } + RB_EndSurface(); // So we don't lerp surfaces that shouldn't be lerped |