Implement GL_OES_element_index_uint
TRAC #11951
Signed-off-by: Nicolas Capens
Signed-off-by: Daniel Koch
Author: Andrew Lewycky
git-svn-id: https://angleproject.googlecode.com/svn/trunk@240 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 9c3b232..0d87a7e 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -239,6 +239,8 @@
if (!mHasBeenCurrent)
{
+ initExtensionString();
+
mState.viewportX = 0;
mState.viewportY = 0;
mState.viewportWidth = surface->getWidth();
@@ -1731,23 +1733,6 @@
}
}
-// The indices parameter to glDrawElements can have two interpretations:
-// - as a pointer into client memory
-// - as an offset into the current GL_ELEMENT_ARRAY_BUFFER buffer
-// Handle these cases here and return a pointer to the index data.
-const Index *Context::adjustIndexPointer(const void *indices)
-{
- if (mState.elementArrayBuffer)
- {
- Buffer *buffer = getBuffer(mState.elementArrayBuffer);
- return reinterpret_cast<const Index*>(static_cast<unsigned char*>(buffer->data()) + reinterpret_cast<GLsizei>(indices));
- }
- else
- {
- return static_cast<const Index*>(indices);
- }
-}
-
void Context::applyVertexBuffer(GLint first, GLsizei count)
{
TranslatedAttribute translated[MAX_VERTEX_ATTRIBS];
@@ -1763,7 +1748,7 @@
{
TranslatedAttribute translated[MAX_VERTEX_ATTRIBS];
- mVertexDataManager->preRenderValidate(indexInfo, translated);
+ mVertexDataManager->preRenderValidate(indexInfo.minIndex, indexInfo.maxIndex-indexInfo.minIndex+1, translated);
lookupAttributeMapping(translated);
@@ -2256,7 +2241,7 @@
if (!cullSkipsDraw(mode))
{
display->startScene();
- device->DrawIndexedPrimitive(primitiveType, -(INT)indexInfo.minIndex, indexInfo.minIndex, indexInfo.maxIndex-indexInfo.minIndex+1, indexInfo.offset/sizeof(Index), primitiveCount);
+ device->DrawIndexedPrimitive(primitiveType, -(INT)indexInfo.minIndex, indexInfo.minIndex, indexInfo.maxIndex-indexInfo.minIndex+1, indexInfo.offset/indexInfo.indexSize, primitiveCount);
}
}
@@ -2575,6 +2560,25 @@
mVertexDataManager->dirtyCurrentValues();
}
+void Context::initExtensionString()
+{
+ if (mBufferBackEnd->supportIntIndices())
+ {
+ mExtensionString += "GL_OES_element_index_uint ";
+ }
+
+ std::string::size_type end = mExtensionString.find_last_not_of(' ');
+ if (end != std::string::npos)
+ {
+ mExtensionString.resize(end+1);
+ }
+}
+
+const char *Context::getExtensionString() const
+{
+ return mExtensionString.c_str();
+}
+
}
extern "C"