//-------------------------------------------------------------------------------------------------- /// Render primitives in this primitive set using vertex arrays /// /// \warning Requires at least OpenGL 1.5 //-------------------------------------------------------------------------------------------------- void PrimitiveSetIndexedUShort::render(OpenGLContext* oglContext) const { CVF_CALLSITE_OPENGL(oglContext); CVF_TIGHT_ASSERT(BufferObjectManaged::supportedOpenGL(oglContext)); if (m_indices.isNull()) { return; } GLsizei numIndices = static_cast<GLsizei>(m_indices->size()); if (numIndices <= 0) { return; } const GLvoid* ptrOrOffset = 0; if (m_indicesBO.notNull() && m_indicesBO->isUploaded()) { m_indicesBO->bindBuffer(oglContext); } else { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); ptrOrOffset = m_indices->ptr(); } #ifdef CVF_OPENGL_ES glDrawElements(primitiveTypeOpenGL(), numIndices, GL_UNSIGNED_SHORT, ptrOrOffset); #else glDrawRangeElements(primitiveTypeOpenGL(), m_minIndex, m_maxIndex, numIndices, GL_UNSIGNED_SHORT, ptrOrOffset); #endif }
//-------------------------------------------------------------------------------------------------- /// Render primitives in this primitive set using vertex arrays /// /// \warning Requires at least OpenGL 1.5 //-------------------------------------------------------------------------------------------------- void PrimitiveSetIndexedUShortScoped::render(OpenGLContext* oglContext) const { CVF_CALLSITE_OPENGL(oglContext); CVF_ASSERT(BufferObjectManaged::supportedOpenGL(oglContext)); if (m_indices.isNull()) { return; } GLsizei numIndices = static_cast<GLsizei>(m_elementCount); if (numIndices <= 0) { return; } const GLvoid* ptrOrOffset = 0; if (m_indicesBO.notNull() && m_indicesBO->isUploaded()) { m_indicesBO->bindBuffer(oglContext); ptrOrOffset = reinterpret_cast<GLvoid*>(m_firstElement*sizeof(GLushort)); } else { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); ptrOrOffset = m_indices->ptr() + m_firstElement; } glDrawElements(primitiveTypeOpenGL(), numIndices, GL_UNSIGNED_SHORT, ptrOrOffset); CVF_CHECK_OGL(oglContext); }