X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fpipelinestate.cpp;h=673fa701e6cb6c5d5860648bab880cda117a2a87;hb=8e063e6def7412f85a26f829b641f28d3476062f;hp=cfeed9ab26fcd29a1734e225e82a3a33a02a04dc;hpb=fe9836f2d8d7abb0480582c544611a5b248310cc;p=libs%2Fgl.git diff --git a/source/core/pipelinestate.cpp b/source/core/pipelinestate.cpp index cfeed9ab..673fa701 100644 --- a/source/core/pipelinestate.cpp +++ b/source/core/pipelinestate.cpp @@ -39,49 +39,39 @@ PipelineState::~PipelineState() last_applied = 0; } -void PipelineState::set_shader_program(const Program *p) +template +void PipelineState::set(T &target, T value, unsigned flag) { - if(p!=shprog) + if(value!=target) { - shprog = p; - changes |= SHPROG; + target = value; + changes |= flag; } } +void PipelineState::set_shader_program(const Program *p) +{ + set(shprog, p, SHPROG); +} + void PipelineState::set_vertex_setup(const VertexSetup *s) { - if(s!=vertex_setup) - { - vertex_setup = s; - changes |= VERTEX_SETUP; - } + set(vertex_setup, s, VERTEX_SETUP); } void PipelineState::set_front_face(FaceWinding w) { - if(w!=front_face) - { - front_face = w; - changes |= FACE_CULL; - } + set(front_face, w, FACE_CULL); } void PipelineState::set_face_cull(CullMode c) { - if(c!=face_cull) - { - face_cull = c; - changes |= FACE_CULL; - } + set(face_cull, c, FACE_CULL); } void PipelineState::set_enabled_clip_planes(unsigned p) { - if(p!=enabled_clip_planes) - { - enabled_clip_planes = p; - changes |= CLIP_PLANES; - } + set(enabled_clip_planes, p, CLIP_PLANES); } void PipelineState::set_texture(unsigned binding, const Texture *tex, const Sampler *samp) @@ -145,7 +135,7 @@ void PipelineState::apply(unsigned mask) const { glFrontFace(front_face==CLOCKWISE ? GL_CW : GL_CCW); - if(face_cull!=NO_CULL) + if(face_cull!=NO_CULL && front_face!=NON_MANIFOLD) { glEnable(GL_CULL_FACE); glCullFace(face_cull==CULL_FRONT ? GL_FRONT : GL_BACK); @@ -198,7 +188,7 @@ void PipelineState::apply(unsigned mask) const } for(vector::const_iterator i=textures.begin(); i!=textures.end(); ++i) - if(i->changed) + if(i->changed || mask==~0U) { if(i->texture && i->sampler) { @@ -255,7 +245,7 @@ void PipelineState::apply(unsigned mask) const } for(vector::const_iterator i=uniform_blocks.begin(); i!=uniform_blocks.end(); ++i) - if(i->changed) + if(i->changed || mask==~0U) { if(i->block) {