| 1652 | } |
| 1653 | |
| 1654 | void GL3PlusRenderSystem::bindVertexElementToGpu(const VertexElement& elem, |
| 1655 | const HardwareVertexBufferSharedPtr& vertexBuffer, |
| 1656 | const size_t vertexStart) |
| 1657 | { |
| 1658 | VertexElementSemantic sem = elem.getSemantic(); |
| 1659 | unsigned short elemIndex = elem.getIndex(); |
| 1660 | |
| 1661 | GLuint attrib = (GLuint)GLSLProgramCommon::getFixedAttributeIndex(sem, elemIndex); |
| 1662 | |
| 1663 | const GL3PlusHardwareBuffer* hwGlBuffer = vertexBuffer->_getImpl<GL3PlusHardwareBuffer>(); |
| 1664 | mStateCacheManager->bindGLBuffer(GL_ARRAY_BUFFER, hwGlBuffer->getGLBufferId()); |
| 1665 | void* pBufferData = VBO_BUFFER_OFFSET(elem.getOffset() + vertexStart * vertexBuffer->getVertexSize()); |
| 1666 | |
| 1667 | if (vertexBuffer->isInstanceData()) |
| 1668 | { |
| 1669 | OGRE_CHECK_GL_ERROR(glVertexAttribDivisor(attrib, vertexBuffer->getInstanceDataStepRate())); |
| 1670 | } |
| 1671 | |
| 1672 | unsigned short typeCount = VertexElement::getTypeCount(elem.getType()); |
| 1673 | GLboolean normalised = GL_FALSE; |
| 1674 | switch(elem.getType()) |
| 1675 | { |
| 1676 | case VET_UBYTE4_NORM: |
| 1677 | case VET_SHORT2_NORM: |
| 1678 | case VET_USHORT2_NORM: |
| 1679 | case VET_SHORT4_NORM: |
| 1680 | case VET_USHORT4_NORM: |
| 1681 | case VET_INT_10_10_10_2_NORM: |
| 1682 | normalised = GL_TRUE; |
| 1683 | break; |
| 1684 | default: |
| 1685 | break; |
| 1686 | }; |
| 1687 | |
| 1688 | switch(elem.getBaseType(elem.getType())) |
| 1689 | { |
| 1690 | default: |
| 1691 | case VET_FLOAT1: |
| 1692 | OGRE_CHECK_GL_ERROR(glVertexAttribPointer(attrib, |
| 1693 | typeCount, |
| 1694 | GL3PlusHardwareBufferManager::getGLType(elem.getType()), |
| 1695 | normalised, |
| 1696 | static_cast<GLsizei>(vertexBuffer->getVertexSize()), |
| 1697 | pBufferData)); |
| 1698 | break; |
| 1699 | case VET_DOUBLE1: |
| 1700 | OGRE_CHECK_GL_ERROR(glVertexAttribLPointer(attrib, |
| 1701 | typeCount, |
| 1702 | GL3PlusHardwareBufferManager::getGLType(elem.getType()), |
| 1703 | static_cast<GLsizei>(vertexBuffer->getVertexSize()), |
| 1704 | pBufferData)); |
| 1705 | break; |
| 1706 | } |
| 1707 | |
| 1708 | // If this attribute hasn't been enabled, do so and keep a record of it. |
| 1709 | OGRE_CHECK_GL_ERROR(glEnableVertexAttribArray(attrib)); |
| 1710 | } |
| 1711 | #if OGRE_NO_QUAD_BUFFER_STEREO == 0 |
nothing calls this directly
no test coverage detected