---------------------------------------------------------------------
| 2723 | |
| 2724 | //--------------------------------------------------------------------- |
| 2725 | void GLRenderSystem::bindVertexElementToGpu(const VertexElement& elem, |
| 2726 | const HardwareVertexBufferSharedPtr& vertexBuffer, |
| 2727 | const size_t vertexStart) |
| 2728 | { |
| 2729 | void* pBufferData = 0; |
| 2730 | const GLHardwareBuffer* hwGlBuffer = vertexBuffer->_getImpl<GLHardwareBuffer>(); |
| 2731 | |
| 2732 | mStateCacheManager->bindGLBuffer(GL_ARRAY_BUFFER_ARB, |
| 2733 | hwGlBuffer->getGLBufferId()); |
| 2734 | pBufferData = VBO_BUFFER_OFFSET(elem.getOffset()); |
| 2735 | |
| 2736 | if (vertexStart) |
| 2737 | { |
| 2738 | pBufferData = static_cast<char*>(pBufferData) + vertexStart * vertexBuffer->getVertexSize(); |
| 2739 | } |
| 2740 | |
| 2741 | VertexElementSemantic sem = elem.getSemantic(); |
| 2742 | bool multitexturing = (getCapabilities()->getNumTextureUnits() > 1); |
| 2743 | |
| 2744 | bool isCustomAttrib = false; |
| 2745 | if (mCurrentVertexProgram) |
| 2746 | { |
| 2747 | isCustomAttrib = !mEnableFixedPipeline || mCurrentVertexProgram->isAttributeValid(sem, elem.getIndex()); |
| 2748 | |
| 2749 | if (vertexBuffer->isInstanceData()) |
| 2750 | { |
| 2751 | GLint attrib = GLSLProgramCommon::getFixedAttributeIndex(sem, elem.getIndex()); |
| 2752 | glVertexAttribDivisorARB(attrib, vertexBuffer->getInstanceDataStepRate() ); |
| 2753 | mRenderInstanceAttribsBound.push_back(attrib); |
| 2754 | } |
| 2755 | } |
| 2756 | |
| 2757 | |
| 2758 | // Custom attribute support |
| 2759 | // tangents, binormals, blendweights etc always via this route |
| 2760 | // builtins may be done this way too |
| 2761 | if (isCustomAttrib) |
| 2762 | { |
| 2763 | GLint attrib = GLSLProgramCommon::getFixedAttributeIndex(sem, elem.getIndex()); |
| 2764 | unsigned short typeCount = VertexElement::getTypeCount(elem.getType()); |
| 2765 | GLboolean normalised = GL_FALSE; |
| 2766 | switch(elem.getType()) |
| 2767 | { |
| 2768 | case VET_UBYTE4_NORM: |
| 2769 | case VET_SHORT2_NORM: |
| 2770 | case VET_USHORT2_NORM: |
| 2771 | case VET_SHORT4_NORM: |
| 2772 | case VET_USHORT4_NORM: |
| 2773 | normalised = GL_TRUE; |
| 2774 | break; |
| 2775 | default: |
| 2776 | break; |
| 2777 | }; |
| 2778 | |
| 2779 | glVertexAttribPointerARB( |
| 2780 | attrib, |
| 2781 | typeCount, |
| 2782 | GLHardwareBufferManager::getGLType(elem.getType()), |
no test coverage detected