From 3da9fe0e9448e2a070eb5fc081396492ede857ff Mon Sep 17 00:00:00 2001 From: Shyotl Date: Wed, 25 Dec 2013 02:09:36 -0600 Subject: [PATCH] Avoid calling a few deprecated gl functions when shaders are enabled. --- indra/llrender/llvertexbuffer.cpp | 24 +++++++------------ indra/newview/llface.cpp | 36 ++++++---------------------- indra/newview/llspatialpartition.cpp | 17 ++++--------- 3 files changed, 20 insertions(+), 57 deletions(-) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index b5c1603a0..e32589412 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -589,16 +589,8 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector& pos, con if (shader) { - S32 loc = LLVertexBuffer::TYPE_VERTEX; - if (loc > -1) - { - glVertexAttribPointerARB(loc, 3, GL_FLOAT, GL_FALSE, 0, pos[0].mV); - } - loc = LLVertexBuffer::TYPE_NORMAL; - if (loc > -1) - { - glVertexAttribPointerARB(loc, 3, GL_FLOAT, GL_FALSE, 0, norm[0].mV); - } + glVertexAttribPointerARB(TYPE_VERTEX, 3, GL_FLOAT, GL_FALSE, 0, pos[0].mV); + glVertexAttribPointerARB(TYPE_NORMAL, 3, GL_FLOAT, GL_FALSE, 0, norm[0].mV); } else { @@ -628,19 +620,19 @@ void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVecto if (LLGLSLShader::sNoFixedFunction) { - S32 loc = LLVertexBuffer::TYPE_VERTEX; - glVertexAttribPointerARB(loc, 3, GL_FLOAT, GL_FALSE, 16, pos); - + glVertexAttribPointerARB(TYPE_VERTEX, 3, GL_FLOAT, GL_FALSE, 16, pos); if (tc) { - loc = LLVertexBuffer::TYPE_TEXCOORD0; - glVertexAttribPointerARB(loc, 2, GL_FLOAT, GL_FALSE, 0, tc); + glVertexAttribPointerARB(TYPE_TEXCOORD0, 2, GL_FLOAT, GL_FALSE, 0, tc); } } else { - glTexCoordPointer(2, GL_FLOAT, 0, tc); glVertexPointer(3, GL_FLOAT, 16, pos); + if (tc) + { + glTexCoordPointer(2, GL_FLOAT, 0, tc); + } } glDrawElements(sGLMode[mode], num_indices, GL_UNSIGNED_SHORT, indicesp); diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 43ff1335a..b7147b9f6 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -554,46 +554,24 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) glDrawElements(GL_TRIANGLES, vol_face.mNumIndices, GL_UNSIGNED_SHORT, vol_face.mIndices); glDisableClientState(GL_TEXTURE_COORD_ARRAY); #else - LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr; + LLGLSLShader* prev_shader = NULL; if(LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE)) { - if(cur_shader != &gHighlightProgram) + if(LLGLSLShader::sCurBoundShaderPtr != &gHighlightProgram) { + prev_shader = LLGLSLShader::sCurBoundShaderPtr; gHighlightProgram.bind(); } } gGL.diffuseColor4fv(color.mV); - LLPointer temp = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, 0); - - temp->allocateBuffer(vol_face.mNumVertices, vol_face.mNumIndices, true); - - LLStrider indicesp; - LLStrider verticesp; - LLStrider texcoordsp; - temp->getIndexStrider(indicesp); - temp->getVertexStrider(verticesp); - temp->getTexCoord0Strider(texcoordsp); - - S32 vert_size = vol_face.mNumVertices*sizeof(LLVector4a); - S32 idx_size = (vol_face.mNumIndices*sizeof(U16)+0xF) & ~0xF; - S32 tc_size = (vol_face.mNumVertices*sizeof(LLVector2)+0xF) & ~0xF; - - LLVector4a::memcpyNonAliased16((F32*)verticesp.get(), (F32*) vol_face.mPositions, vert_size); - LLVector4a::memcpyNonAliased16((F32*)indicesp.get(), (F32*) vol_face.mIndices, idx_size); - LLVector4a::memcpyNonAliased16((F32*)texcoordsp.get(), (F32*) vol_face.mTexCoords, tc_size); - - temp->setBuffer(temp->getTypeMask()); - temp->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); - - if(LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_INTERFACE)) + LLVertexBuffer::drawElements(LLRender::TRIANGLES, vol_face.mPositions, vol_face.mTexCoords, vol_face.mNumIndices, vol_face.mIndices); + + if(prev_shader) { - if(cur_shader != &gHighlightProgram) - { - cur_shader->bind(); - } + prev_shader->bind(); } #endif } diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index d08f847a8..69814446d 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3312,16 +3312,12 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume) if (phys_volume->mHullPoints && phys_volume->mHullIndices) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - llassert(!LLGLSLShader::sNoFixedFunction || LLGLSLShader::sCurBoundShader != 0); - LLVertexBuffer::unbind(); - glVertexPointer(3, GL_FLOAT, 16, phys_volume->mHullPoints); gGL.diffuseColor4fv(line_color.mV); - gGL.syncMatrices(); - glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices); - - gGL.diffuseColor4fv(color.mV); + LLVertexBuffer::drawElements(LLRender::TRIANGLES, phys_volume->mHullPoints, NULL, phys_volume->mNumHullIndices, phys_volume->mHullIndices); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glDrawElements(GL_TRIANGLES, phys_volume->mNumHullIndices, GL_UNSIGNED_SHORT, phys_volume->mHullIndices); + gGL.diffuseColor4fv(color.mV); + LLVertexBuffer::drawElements(LLRender::TRIANGLES, phys_volume->mHullPoints, NULL, phys_volume->mNumHullIndices, phys_volume->mHullIndices); } else { @@ -3713,11 +3709,8 @@ void renderRaycast(LLDrawable* drawablep) { //render face positions - LLVertexBuffer::unbind(); gGL.diffuseColor4f(0,1,1,0.5f); - glVertexPointer(3, GL_FLOAT, sizeof(LLVector4a), face.mPositions); - gGL.syncMatrices(); - glDrawElements(GL_TRIANGLES, face.mNumIndices, GL_UNSIGNED_SHORT, face.mIndices); + LLVertexBuffer::drawElements(LLRender::TRIANGLES, face.mPositions, NULL, face.mNumIndices, face.mIndices); } if (!volume->isUnique())