state(&state_stack.back()),
vertex_array(0),
vertex_array_changed(false),
- element_buffer(0),
- winding_test(0)
+ element_buffer(0)
{
MatrixStack::modelview().push();
if(camera)
Material::unbind();
Program::unbind();
Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
+ WindingTest::unbind();
}
void Renderer::set_texture(const Texture *t)
void Renderer::set_winding_test(const WindingTest *w)
{
- winding_test = w;
+ state->winding_test = w;
}
void Renderer::push_state()
{
apply_state();
Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
- WindingTest::unbind();
}
void Renderer::draw(const Batch &batch)
// Until VertexArray acquires VAO support and becomes Bindable
if(vertex_array_changed)
+ {
vertex_array->apply();
+ vertex_array_changed = false;
+ }
if(element_buffer)
element_buffer->bind_to(ELEMENT_ARRAY_BUFFER);
else
Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
- if(winding_test)
- winding_test->bind();
- else
- WindingTest::unbind();
-
batch.draw();
}
else
Program::unbind();
+ if(state->winding_test)
+ state->winding_test->bind();
+ else
+ WindingTest::unbind();
+
if(mtx_changed)
{
MatrixStack::modelview() = mtx_stack.top();
texture(0),
texturing(0),
material(0),
- shprog(0)
+ shprog(0),
+ winding_test(0)
{ }
const Material *material;
const Program *shprog;
std::vector<const ProgramData *> shdata;
+ const WindingTest *winding_test;
State();
};
const VertexArray *vertex_array;
bool vertex_array_changed;
const Buffer *element_buffer;
- const WindingTest *winding_test;
public:
Renderer(const Camera *);