diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-12-01 22:29:50 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-12-01 22:29:50 +0300 |
commit | eff09ae3966575b139402607387f75b0120fad51 (patch) | |
tree | efc6f854716234559f357d414fb682e1a3d7bff7 /source/blender/src | |
parent | f06872d493dec309c963908e0079b454f4e38110 (diff) |
For the OpenGL render option in the 3d view, if a camera is active,
it now sets the viewport exactly the same as if rendering.
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/drawview.c | 19 | ||||
-rw-r--r-- | source/blender/src/renderwin.c | 22 |
2 files changed, 30 insertions, 11 deletions
diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index bfccd0b77ff..a02f1065b5b 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -3090,22 +3090,25 @@ void drawview3dspace(ScrArea *sa, void *spacedata) } -void drawview3d_render(struct View3D *v3d, int winx, int winy) +void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4]) { Base *base; Scene *sce; - float winmat[4][4]; - - update_for_newframe_muted(); /* first, since camera can be animated */ - - setwinmatrixview3d(winx, winy, NULL); + float v3dwinmat[4][4]; setviewmatrixview3d(); myloadmatrix(v3d->viewmat); + + /* when winmat is not NULL, it overrides the regular window matrix */ glMatrixMode(GL_PROJECTION); - mygetmatrix(winmat); + if(winmat) + myloadmatrix(winmat); + else + setwinmatrixview3d(winx, winy, NULL); + mygetmatrix(v3dwinmat); glMatrixMode(GL_MODELVIEW); - Mat4MulMat4(v3d->persmat, v3d->viewmat, winmat); + + Mat4MulMat4(v3d->persmat, v3d->viewmat, v3dwinmat); Mat4Invert(v3d->persinv, v3d->persmat); Mat4Invert(v3d->viewinv, v3d->viewmat); diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c index 4de80414d46..40306e6073f 100644 --- a/source/blender/src/renderwin.c +++ b/source/blender/src/renderwin.c @@ -1241,6 +1241,21 @@ void BIF_do_render(int anim) if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_POSTRENDER); } +void do_ogl_view3d_render(Render *re, View3D *v3d, int winx, int winy) +{ + float winmat[4][4]; + + update_for_newframe_muted(); /* here, since camera can be animated */ + + if(v3d->camera) { + /* in camera view, use actual render winmat */ + RE_GetCameraWindow(re, v3d->camera, CFRA, winmat); + drawview3d_render(v3d, winx, winy, winmat); + } + else + drawview3d_render(v3d, winx, winy, NULL); +} + /* set up display, render the current area view in an image */ /* the RE_Render is only used to make sure we got the picture in the result */ void BIF_do_ogl_render(View3D *v3d, int anim) @@ -1256,7 +1271,7 @@ void BIF_do_ogl_render(View3D *v3d, int anim) winy= (G.scene->r.size*G.scene->r.ysch)/100; RE_InitState(re, &G.scene->r, winx, winy, NULL); - + /* for now, result is defaulting to floats still... */ rr= RE_GetResult(re); if(rr->rect32==NULL) @@ -1282,7 +1297,8 @@ void BIF_do_ogl_render(View3D *v3d, int anim) /* user event can close window */ if(render_win==NULL) break; - drawview3d_render(v3d, winx, winy); + + do_ogl_view3d_render(re, v3d, winx, winy); glReadPixels(0, 0, winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, rr->rect32); BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty); window_swap_buffers(render_win->win); @@ -1322,7 +1338,7 @@ void BIF_do_ogl_render(View3D *v3d, int anim) CFRA= cfrao; } else { - drawview3d_render(v3d, winx, winy); + do_ogl_view3d_render(re, v3d, winx, winy); glReadPixels(0, 0, winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, rr->rect32); BKE_stamp_buf((unsigned char *)rr->rect32, rr->rectf, rr->rectx, rr->recty); window_swap_buffers(render_win->win); |