From ce4c8eb731e2546705c6b0a246afe502f489dfdd Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 14 Jun 2012 00:52:02 +0000 Subject: [PATCH] gpu: add GL points support to the primitive rendering. --- src/gpu/vertexbuffer.cpp | 16 ++++++++++++++++ src/gpu/vertexbuffer.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/gpu/vertexbuffer.cpp b/src/gpu/vertexbuffer.cpp index 203adf1d..f5fe3e81 100644 --- a/src/gpu/vertexbuffer.cpp +++ b/src/gpu/vertexbuffer.cpp @@ -138,6 +138,10 @@ void VertexDeclaration::DrawElements(MeshPrimitive type, int skip, int count) if (FAILED(g_d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST, skip, count))) Abort(); break; + case MeshPrimitive::Points: + if (FAILED(g_d3ddevice->DrawPrimitive(D3DPT_POINTLIST, skip, count))) + Abort(); + break; } #else glFrontFace(GL_CCW); @@ -154,6 +158,9 @@ void VertexDeclaration::DrawElements(MeshPrimitive type, int skip, int count) case MeshPrimitive::Triangles: glDrawArrays(GL_TRIANGLES, skip * 3, count * 3); break; + case MeshPrimitive::Points: + glDrawArrays(GL_POINTS, skip, count); + break; } #endif } @@ -176,6 +183,10 @@ void VertexDeclaration::DrawIndexedElements(MeshPrimitive type, int vbase, if (FAILED(g_d3ddevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vbase, vskip, vcount, skip, count))) Abort(); break; + case MeshPrimitive::Points: + if (FAILED(g_d3ddevice->DrawIndexedPrimitive(D3DPT_POINTLIST, vbase, vskip, vcount, skip, count))) + Abort(); + break; } #else # if defined HAVE_GL_2X && !defined __APPLE__ @@ -191,6 +202,10 @@ void VertexDeclaration::DrawIndexedElements(MeshPrimitive type, int vbase, /* FIXME: ignores most of the arguments! */ glDrawElements(GL_TRIANGLES, count * 3, GL_UNSIGNED_SHORT, 0); break; + case MeshPrimitive::Points: + /* FIXME: ignores most of the arguments! */ + glDrawElements(GL_POINTS, count, GL_UNSIGNED_SHORT, 0); + break; } #endif } @@ -535,6 +550,7 @@ void VertexBuffer::Unlock() glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo); glBufferData(GL_ARRAY_BUFFER, m_data->m_size, m_data->m_memory, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); #endif } diff --git a/src/gpu/vertexbuffer.h b/src/gpu/vertexbuffer.h index f7203cee..9e457366 100644 --- a/src/gpu/vertexbuffer.h +++ b/src/gpu/vertexbuffer.h @@ -66,6 +66,7 @@ struct MeshPrimitive enum Value { Triangles, + Points, } m_value;