Implement GL_LINE_LOOP primitive handling
TRAC #11823
Signed-off-by: Nicolas Capens
Signed-off-by: Daniel Koch
Author: Andrew Lewycky
git-svn-id: https://angleproject.googlecode.com/svn/trunk@173 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/geometry/IndexDataManager.cpp b/src/libGLESv2/geometry/IndexDataManager.cpp
index 8e5ea88..e50ca6b 100644
--- a/src/libGLESv2/geometry/IndexDataManager.cpp
+++ b/src/libGLESv2/geometry/IndexDataManager.cpp
@@ -39,8 +39,9 @@
template <class InputIndexType>
void copyIndices(const InputIndexType *in, GLsizei count, Index *out, GLuint *minIndex, GLuint *maxIndex)
{
- GLuint minIndexSoFar = *in;
- GLuint maxIndexSoFar = *in;
+ Index first = *in;
+ GLuint minIndexSoFar = first;
+ GLuint maxIndexSoFar = first;
for (GLsizei i = 0; i < count; i++)
{
@@ -50,6 +51,9 @@
*out++ = *in++;
}
+ // It might be a line loop, so copy the loop index.
+ *out = first;
+
*minIndex = minIndexSoFar;
*maxIndex = maxIndexSoFar;
}
@@ -65,7 +69,7 @@
translated.count = count;
- std::size_t requiredSpace = spaceRequired(mode, type, count);
+ std::size_t requiredSpace = spaceRequired(type, count);
if (requiredSpace > mStreamBuffer->size())
{
@@ -112,9 +116,9 @@
return translated;
}
-std::size_t IndexDataManager::spaceRequired(GLenum mode, GLenum type, GLsizei count)
+std::size_t IndexDataManager::spaceRequired(GLenum type, GLsizei count)
{
- return count * sizeof(Index);
+ return (count + 1) * sizeof(Index); // +1 because we always leave an extra for line loops
}
}