From d4521943269ea8a2ad8a2297fdd9bd115c35ca10 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 3 May 2012 23:00:26 +0000 Subject: [PATCH] gpu: activate backface culling on OpenGL to remain consistent with the Direct3D backend. --- src/gpu/vertexbuffer.cpp | 2 ++ src/gradient.cpp | 2 +- src/tileset.cpp | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/gpu/vertexbuffer.cpp b/src/gpu/vertexbuffer.cpp index 0ba232e0..6d4cc67b 100644 --- a/src/gpu/vertexbuffer.cpp +++ b/src/gpu/vertexbuffer.cpp @@ -136,6 +136,8 @@ void VertexDeclaration::DrawElements(MeshPrimitive type, int skip, int count) break; } #else + glFrontFace(GL_CCW); + glEnable(GL_CULL_FACE); # if defined HAVE_GL_2X && !defined __APPLE__ glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GEQUAL, 0.01f); diff --git a/src/gradient.cpp b/src/gradient.cpp index a5211b17..f7ae69a3 100644 --- a/src/gradient.cpp +++ b/src/gradient.cpp @@ -63,8 +63,8 @@ void Gradient::TickDraw(float seconds) float const vertex[] = { 0.0f, 0.0f, 0.0f, 640.0f, 0.0f, 0.0f, 0.0f, 480.0f, 0.0f, - 0.0f, 480.0f, 0.0f, 640.0f, 480.0f, 0.0f, + 0.0f, 480.0f, 0.0f, 640.0f, 0.0f, 0.0f, }; float const color[] = { 0.73f, 0.85f, 0.85f, 1.0f, diff --git a/src/tileset.cpp b/src/tileset.cpp index 055b9d44..7ef04bd5 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -278,36 +278,36 @@ void TileSet::BlitTile(uint32_t id, vec3 pos, int o, vec2 scale, { float tmp[10]; - *vertex++ = tmp[0] = pos.x; - *vertex++ = tmp[1] = pos.y + dy; - *vertex++ = tmp[2] = pos.z + dz; - *texture++ = tmp[3] = tx; - *texture++ = tmp[4] = ty; - *vertex++ = pos.x + dx; *vertex++ = pos.y + dy; *vertex++ = pos.z + dz; *texture++ = tx + data->tx; *texture++ = ty; + *vertex++ = tmp[0] = pos.x; + *vertex++ = tmp[1] = pos.y + dy; + *vertex++ = tmp[2] = pos.z + dz; + *texture++ = tmp[3] = tx; + *texture++ = tmp[4] = ty; + *vertex++ = tmp[5] = pos.x + dx; *vertex++ = tmp[6] = pos.y; *vertex++ = tmp[7] = pos.z; *texture++ = tmp[8] = tx + data->tx; *texture++ = tmp[9] = ty + data->ty; - *vertex++ = tmp[0]; - *vertex++ = tmp[1]; - *vertex++ = tmp[2]; - *texture++ = tmp[3]; - *texture++ = tmp[4]; - *vertex++ = tmp[5]; *vertex++ = tmp[6]; *vertex++ = tmp[7]; *texture++ = tmp[8]; *texture++ = tmp[9]; + *vertex++ = tmp[0]; + *vertex++ = tmp[1]; + *vertex++ = tmp[2]; + *texture++ = tmp[3]; + *texture++ = tmp[4]; + *vertex++ = pos.x; *vertex++ = pos.y; *vertex++ = pos.z;