diff options
Diffstat (limited to 'src/graphics/opengl')
-rw-r--r-- | src/graphics/opengl/gldevice.cpp | 42 | ||||
-rw-r--r-- | src/graphics/opengl/gldevice.h | 10 |
2 files changed, 29 insertions, 23 deletions
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 78a77bd..dbf91c7 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -853,7 +853,8 @@ GLenum TranslateGfxPrimitive(PrimitiveType type) return flag; } -void CGLDevice::DrawPrimitive(PrimitiveType type, const Vertex *vertices, int vertexCount) +void CGLDevice::DrawPrimitive(PrimitiveType type, const Vertex *vertices, int vertexCount, + Color color) { Vertex* vs = const_cast<Vertex*>(vertices); @@ -867,7 +868,7 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const Vertex *vertices, int ve glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].texCoord)); - glColor3f(1.0f, 1.0f, 1.0f); + glColor4fv(color.Array()); glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount); @@ -876,23 +877,8 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const Vertex *vertices, int ve glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE0 } -void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount) -{ - VertexCol* vs = const_cast<VertexCol*>(vertices); - - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].coord)); - - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(4, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].color)); - - glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); -} - -void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount) +void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount, + Color color) { VertexTex2* vs = const_cast<VertexTex2*>(vertices); @@ -910,7 +896,7 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, in glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord2)); - glColor3f(1.0f, 1.0f, 1.0f); + glColor4fv(color.Array()); glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount); @@ -921,6 +907,22 @@ void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, in glDisableClientState(GL_TEXTURE_COORD_ARRAY); } +void CGLDevice::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount) +{ + VertexCol* vs = const_cast<VertexCol*>(vertices); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].coord)); + + glEnableClientState(GL_COLOR_ARRAY); + glColorPointer(4, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].color)); + + glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); +} + bool InPlane(Math::Vector normal, float originPlane, Math::Vector center, float radius) { float distance = (originPlane + Math::DotProduct(normal, center)) / normal.Length(); diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h index 8af864e..cda7b02 100644 --- a/src/graphics/opengl/gldevice.h +++ b/src/graphics/opengl/gldevice.h @@ -119,9 +119,13 @@ public: virtual void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT); - virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices, int vertexCount); - virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount); - virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount); + //! Renders primitive composed of vertices with single texture + virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount, + Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)); + //! Renders primitive composed of vertices with multitexturing (2 textures) + virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount, + Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)); + virtual void DrawPrimitive(PrimitiveType type, const VertexCol *vertices , int vertexCount); virtual int ComputeSphereVisibility(const Math::Vector ¢er, float radius); |