void Buffer::data(unsigned sz, const void *d)
{
- const Buffer *old = current(type);
- bind();
+ BindRestore _bind(this, type);
glBufferData(type, sz, d, usage);
size = sz;
- restore(old, type);
}
void Buffer::sub_data(unsigned off, unsigned sz, const void *d)
{
- const Buffer *old = current(type);
- bind();
+ BindRestore _bind(this, type);
glBufferSubData(type, off, sz, d);
- restore(old, type);
}
BufferRange *Buffer::create_range(unsigned s, unsigned o)
return true;
}
-void Buffer::restore(const Buffer *buf, BufferType type)
-{
- if(buf!=current(type))
- {
- if(buf)
- buf->bind_to(type);
- else
- unbind_from(type);
- }
-}
-
vector<const BufferRange *> BufferRange::bound_uniform;
private:
static const Buffer *&binding(BufferType);
static bool set_current(BufferType, const Buffer *);
- static void restore(const Buffer *, BufferType);
};
unsigned unit = renderer.allocate_effect_texunit();
shdata.uniform("environment", static_cast<int>(unit));
- env_tex.bind_to(unit);
+ Bind _bind_env(env_tex, unit);
const Matrix &view_matrix = renderer.get_camera()->get_matrix();
// XXX The camera should maybe have store its own object matrix
renderer.add_shader_data(shdata);
renderer.render(renderable, tag);
-
- env_tex.unbind_from(unit);
}
} // namespace GL
shdata.uniform("shadow", iunit);
shdata.uniform("shadow_unit", iunit);
- depth_buf.bind_to(unit);
+ Bind _bind_depth(depth_buf, unit);
TexGen tg_s, tg_t, tg_r;
tg_s.set_plane(Vector4(shadow_matrix(0, 0), shadow_matrix(0, 1), shadow_matrix(0, 2), shadow_matrix(0, 3)));
tg_t.set_plane(Vector4(shadow_matrix(1, 0), shadow_matrix(1, 1), shadow_matrix(1, 2), shadow_matrix(1, 3)));
renderer.add_shader_data(shdata);
renderer.render(renderable, tag);
- Texture::unbind_from(unit);
TexGen::unbind_from(unit, SCOORD);
TexGen::unbind_from(unit, TCOORD);
TexGen::unbind_from(unit, RCOORD);