static RenderTarget *rtmirror;
+static int cur_vport[4];
Renderer::Renderer()
{
if(DO_MIRRORS && current_render_target() != rtmirror) {
// check if the render target needs resizing
if(rtmirror->get_width() != vp_width || rtmirror->get_height() != vp_height) {
+ info_log("resizing mirror render target to %dx%d\n", vp_width, vp_height);
if(!rtmirror->resize(vp_width, vp_height)) {
error_log("failed to resize mirror render target (%dx%d)\n", vp_width, vp_height);
goto abort_mirrors;
}
}
+ glGetIntegerv(GL_VIEWPORT, cur_vport);
+
FlatMirror *mir = mscn->mirrors;
while(mir) {
draw_mirror(mir);
if(use_mask & USE_MIRROR) {
float sx = 1.0f / rtmirror->texture()->get_width();
float sy = 1.0f / rtmirror->texture()->get_height();
+ set_uniform_float2(sdr, "mirtex_offs", -cur_vport[0], -cur_vport[1]);
set_uniform_float2(sdr, "mirtex_scale", sx, sy);
set_uniform_float(sdr, "reflectivity", obj->mtl.reflect);
}
void Renderer::draw_mirror(FlatMirror *mir) const
{
push_render_target(rtmirror);
- glClearColor(1, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glClearColor(1, 1, 1, 1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
// TODO update mirror plane for movable mirrors?
Mat4 mirmat;
- mirmat.mirror(mir->wplane.normal, dot(mir->wplane.normal, mir->wplane.pt));
+ mirmat.mirror(mir->wplane.normal, -dot(mir->wplane.normal, mir->wplane.pt));
glMultMatrixf(mirmat[0]);
glFrontFace(GL_CW);