X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fpipelinestate.cpp;h=cfeed9ab26fcd29a1734e225e82a3a33a02a04dc;hp=a3b9e640fafee04308a9ed397c84ca3e933bbaed;hb=fe9836f2d8d7abb0480582c544611a5b248310cc;hpb=9b3bce7ae76ff8c0c81315d2505ea96bf422a318 diff --git a/source/core/pipelinestate.cpp b/source/core/pipelinestate.cpp index a3b9e640..cfeed9ab 100644 --- a/source/core/pipelinestate.cpp +++ b/source/core/pipelinestate.cpp @@ -12,7 +12,6 @@ #include "texture.h" #include "uniformblock.h" #include "vertexsetup.h" -#include "windingtest.h" using namespace std; @@ -25,7 +24,8 @@ vector PipelineState::bound_tex_targets; PipelineState::PipelineState(): shprog(0), vertex_setup(0), - winding_test(0), + front_face(COUNTERCLOCKWISE), + face_cull(NO_CULL), enabled_clip_planes(0), changes(0) { @@ -57,12 +57,21 @@ void PipelineState::set_vertex_setup(const VertexSetup *s) } } -void PipelineState::set_winding_test(const WindingTest *w) +void PipelineState::set_front_face(FaceWinding w) { - if(w!=winding_test) + if(w!=front_face) { - winding_test = w; - changes |= WINDING_TEST; + front_face = w; + changes |= FACE_CULL; + } +} + +void PipelineState::set_face_cull(CullMode c) +{ + if(c!=face_cull) + { + face_cull = c; + changes |= FACE_CULL; } } @@ -132,12 +141,14 @@ void PipelineState::apply(unsigned mask) const vertex_setup->refresh(); } - if(mask&WINDING_TEST) + if(mask&FACE_CULL) { - if(winding_test) + glFrontFace(front_face==CLOCKWISE ? GL_CW : GL_CCW); + + if(face_cull!=NO_CULL) { glEnable(GL_CULL_FACE); - glFrontFace(winding_test->get_winding()); + glCullFace(face_cull==CULL_FRONT ? GL_FRONT : GL_BACK); } else glDisable(GL_CULL_FACE);