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
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 @@ void copyIndices(const InputIndexType *in, GLsizei count, Index *out, GLuint *mi
*out++ = *in++;
}
// It might be a line loop, so copy the loop index.
*out = first;
*minIndex = minIndexSoFar;
*maxIndex = maxIndexSoFar;
}
......@@ -65,7 +69,7 @@ TranslatedIndexData IndexDataManager::preRenderValidate(GLenum mode, GLenum type
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 @@ TranslatedIndexData IndexDataManager::preRenderValidate(GLenum mode, GLenum type
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
TranslatedIndexData preRenderValidate(GLenum mode, GLenum type, GLsizei count, Buffer *arrayElementBuffer, const void *indices);
private:
std::size_t spaceRequired(GLenum mode, GLenum type, GLsizei count);
std::size_t spaceRequired(GLenum type, GLsizei count);
Context *mContext;
BufferBackEnd *mBackend;
......
......@@ -329,8 +329,7 @@ bool ConvertPrimitiveType(GLenum primitiveType, GLsizei primitiveCount,
*d3dPrimitiveCount = primitiveCount / 2;
break;
case GL_LINE_LOOP:
UNIMPLEMENTED(); // FIXME: Emulate using an index buffer
*d3dPrimitiveType = D3DPT_LINELIST;
*d3dPrimitiveType = D3DPT_LINESTRIP;
*d3dPrimitiveCount = primitiveCount;
break;
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