This is useful for transparency effects.
state->winding_test = w;
}
+void Renderer::set_reverse_winding(bool r)
+{
+ state->reverse_winding = r;
+}
+
void Renderer::push_state()
{
state_stack.push_back(state_stack.back());
Program::unbind();
if(state->winding_test)
- state->winding_test->bind();
+ {
+ if(state->reverse_winding)
+ state->winding_test->get_reverse().bind();
+ else
+ state->winding_test->bind();
+ }
else
WindingTest::unbind();
void set_vertex_array(const VertexArray *);
void set_element_buffer(const Buffer *);
void set_winding_test(const WindingTest *);
+ void set_reverse_winding(bool);
/** Saves the current state so it can be restored later. */
void push_state();
shprog(0),
shdata(0),
material(0),
- texturing(0)
+ texturing(0),
+ back_faces(false)
{ }
RenderPass::RenderPass(const RenderPass &other):
shdata(other.shdata ? new ProgramData(*other.shdata) : 0),
material(other.material),
texturing(other.texturing ? new Texturing(*other.texturing) : 0),
- tex_names(other.tex_names)
+ tex_names(other.tex_names),
+ back_faces(other.back_faces)
{ }
RenderPass::~RenderPass()
renderer.set_texturing(texturing);
renderer.set_material(material.get());
renderer.set_shader_program(shprog, shdata.get());
+ renderer.set_reverse_winding(back_faces);
}
add("shader", &RenderPass::shprog);
add("material", &Loader::material_inline);
add("material", &Loader::material);
+ add("back_faces",&RenderPass::back_faces);
add("texunit", &Loader::texunit);
add("texunit", &Loader::texunit_named);
add("uniforms", &Loader::uniforms);
RefPtr<const Material> material;
Texturing *texturing;
std::map<std::string, unsigned> tex_names;
+ bool back_faces;
RenderPass &operator=(const RenderPass &);
public:
void set_texture(unsigned, const Texture *);
const Texturing *get_texturing() const { return texturing; }
int get_texture_index(const std::string &) const;
+ void set_back_faces(bool);
+ bool get_back_faces() const { return back_faces; }
void apply(Renderer &) const;
};
glDisable(GL_CULL_FACE);
}
-WindingTest &WindingTest::clockwise()
+const WindingTest &WindingTest::get_reverse() const
+{
+ if(!test)
+ return *this;
+ else if(winding==CLOCKWISE)
+ return counterclockwise();
+ else
+ return clockwise();
+}
+
+const WindingTest &WindingTest::clockwise()
{
static WindingTest test(CLOCKWISE);
return test;
}
-WindingTest &WindingTest::counterclockwise()
+const WindingTest &WindingTest::counterclockwise()
{
static WindingTest test(COUNTERCLOCKWISE);
return test;
static void unbind();
- static WindingTest &clockwise();
- static WindingTest &counterclockwise();
+ const WindingTest &get_reverse() const;
+
+ static const WindingTest &clockwise();
+ static const WindingTest &counterclockwise();
};
} // namespace GL