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
parent 93a8147f
...@@ -39,8 +39,9 @@ namespace ...@@ -39,8 +39,9 @@ namespace
template <class InputIndexType> template <class InputIndexType>
void copyIndices(const InputIndexType *in, GLsizei count, Index *out, GLuint *minIndex, GLuint *maxIndex) void copyIndices(const InputIndexType *in, GLsizei count, Index *out, GLuint *minIndex, GLuint *maxIndex)
{ {
GLuint minIndexSoFar = *in; Index first = *in;
GLuint maxIndexSoFar = *in; GLuint minIndexSoFar = first;
GLuint maxIndexSoFar = first;
for (GLsizei i = 0; i < count; i++) for (GLsizei i = 0; i < count; i++)
{ {
...@@ -50,6 +51,9 @@ void copyIndices(const InputIndexType *in, GLsizei count, Index *out, GLuint *mi ...@@ -50,6 +51,9 @@ void copyIndices(const InputIndexType *in, GLsizei count, Index *out, GLuint *mi
*out++ = *in++; *out++ = *in++;
} }
// It might be a line loop, so copy the loop index.
*out = first;
*minIndex = minIndexSoFar; *minIndex = minIndexSoFar;
*maxIndex = maxIndexSoFar; *maxIndex = maxIndexSoFar;
} }
...@@ -65,7 +69,7 @@ TranslatedIndexData IndexDataManager::preRenderValidate(GLenum mode, GLenum type ...@@ -65,7 +69,7 @@ TranslatedIndexData IndexDataManager::preRenderValidate(GLenum mode, GLenum type
translated.count = count; translated.count = count;
std::size_t requiredSpace = spaceRequired(mode, type, count); std::size_t requiredSpace = spaceRequired(type, count);
if (requiredSpace > mStreamBuffer->size()) if (requiredSpace > mStreamBuffer->size())
{ {
...@@ -112,9 +116,9 @@ TranslatedIndexData IndexDataManager::preRenderValidate(GLenum mode, GLenum type ...@@ -112,9 +116,9 @@ TranslatedIndexData IndexDataManager::preRenderValidate(GLenum mode, GLenum type
return translated; 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
} }
} }
...@@ -47,7 +47,7 @@ class IndexDataManager ...@@ -47,7 +47,7 @@ class IndexDataManager
TranslatedIndexData preRenderValidate(GLenum mode, GLenum type, GLsizei count, Buffer *arrayElementBuffer, const void *indices); TranslatedIndexData preRenderValidate(GLenum mode, GLenum type, GLsizei count, Buffer *arrayElementBuffer, const void *indices);
private: private:
std::size_t spaceRequired(GLenum mode, GLenum type, GLsizei count); std::size_t spaceRequired(GLenum type, GLsizei count);
Context *mContext; Context *mContext;
BufferBackEnd *mBackend; BufferBackEnd *mBackend;
......
...@@ -329,8 +329,7 @@ bool ConvertPrimitiveType(GLenum primitiveType, GLsizei primitiveCount, ...@@ -329,8 +329,7 @@ bool ConvertPrimitiveType(GLenum primitiveType, GLsizei primitiveCount,
*d3dPrimitiveCount = primitiveCount / 2; *d3dPrimitiveCount = primitiveCount / 2;
break; break;
case GL_LINE_LOOP: case GL_LINE_LOOP:
UNIMPLEMENTED(); // FIXME: Emulate using an index buffer *d3dPrimitiveType = D3DPT_LINESTRIP;
*d3dPrimitiveType = D3DPT_LINELIST;
*d3dPrimitiveCount = primitiveCount; *d3dPrimitiveCount = primitiveCount;
break; break;
case GL_LINE_STRIP: case GL_LINE_STRIP:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment