summaryrefslogtreecommitdiffstats
path: root/src/graphics/opengl/gldevice.cpp
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-07-30 22:32:28 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-07-30 22:32:28 +0200
commitd8a0c8d32e160e7ae86bb5b85ead8e5f71b1fd01 (patch)
treec4723373e5e070b28983a262bd136fd30c69a507 /src/graphics/opengl/gldevice.cpp
parent220ff9fe52fb2940f71592f121e6238203eae902 (diff)
downloadcolobot-d8a0c8d32e160e7ae86bb5b85ead8e5f71b1fd01.tar.gz
colobot-d8a0c8d32e160e7ae86bb5b85ead8e5f71b1fd01.tar.bz2
colobot-d8a0c8d32e160e7ae86bb5b85ead8e5f71b1fd01.zip
Lines and line strip primitives
Will probably be useful
Diffstat (limited to 'src/graphics/opengl/gldevice.cpp')
-rw-r--r--src/graphics/opengl/gldevice.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index 1fd6a18..e80b101 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -746,14 +746,24 @@ Gfx::Color Gfx::CGLDevice::GetTextureFactor()
return Gfx::Color(color[0], color[1], color[2], color[3]);
}
+GLenum TranslateGfxPrimitive(Gfx::PrimitiveType type)
+{
+ GLenum flag = 0;
+ switch (type)
+ {
+ case Gfx::PRIMITIVE_POINTS: flag = GL_POINTS; break;
+ case Gfx::PRIMITIVE_LINES: flag = GL_LINES; break;
+ case Gfx::PRIMITIVE_LINE_STRIP: flag = GL_LINE_STRIP; break;
+ case Gfx::PRIMITIVE_TRIANGLES: flag = GL_TRIANGLES; break;
+ case Gfx::PRIMITIVE_TRIANGLE_STRIP: flag = GL_TRIANGLE_STRIP; break;
+ default: assert(false); break;
+ }
+ return flag;
+}
+
void Gfx::CGLDevice::DrawPrimitive(Gfx::PrimitiveType type, const Vertex *vertices, int vertexCount)
{
- if (type == Gfx::PRIMITIVE_LINES)
- glBegin(GL_LINES);
- else if (type == Gfx::PRIMITIVE_TRIANGLES)
- glBegin(GL_TRIANGLES);
- else if (type == Gfx::PRIMITIVE_TRIANGLE_STRIP)
- glBegin(GL_TRIANGLE_STRIP);
+ glBegin(TranslateGfxPrimitive(type));
glColor3f(1.0f, 1.0f, 1.0f);
@@ -769,12 +779,7 @@ void Gfx::CGLDevice::DrawPrimitive(Gfx::PrimitiveType type, const Vertex *vertic
void Gfx::CGLDevice::DrawPrimitive(Gfx::PrimitiveType type, const Gfx::VertexCol *vertices, int vertexCount)
{
- if (type == Gfx::PRIMITIVE_LINES)
- glBegin(GL_LINES);
- else if (type == Gfx::PRIMITIVE_TRIANGLES)
- glBegin(GL_TRIANGLES);
- else if (type == Gfx::PRIMITIVE_TRIANGLE_STRIP)
- glBegin(GL_TRIANGLE_STRIP);
+ glBegin(TranslateGfxPrimitive(type));
for (int i = 0; i < vertexCount; ++i)
{
@@ -789,12 +794,7 @@ void Gfx::CGLDevice::DrawPrimitive(Gfx::PrimitiveType type, const Gfx::VertexCol
void Gfx::CGLDevice::DrawPrimitive(Gfx::PrimitiveType type, const VertexTex2 *vertices, int vertexCount)
{
- if (type == Gfx::PRIMITIVE_LINES)
- glBegin(GL_LINES);
- else if (type == Gfx::PRIMITIVE_TRIANGLES)
- glBegin(GL_TRIANGLES);
- else if (type == Gfx::PRIMITIVE_TRIANGLE_STRIP)
- glBegin(GL_TRIANGLE_STRIP);
+ glBegin(TranslateGfxPrimitive(type));
glColor3f(1.0f, 1.0f, 1.0f);