Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2017-03-30 09:32:33 +0300
committerMike Erwin <significant.bit@gmail.com>2017-03-30 09:32:33 +0300
commit126ee42a304202743f3b349f2103ba2658426e35 (patch)
treef1f78b8e23ecd3590e9ba6e6ca145537d9a43998
parent0dc30e9dd8daab7c5afd833bf117c4838bf6100d (diff)
fix OpenGL Render to image (T51082)
This restores the feature for legacy viewport only. Modern viewport, Clay, Eevee, etc. will need further work. Eventually we should rename this something other than "OpenGL".
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 27e4dec9d23..3d43bc011e6 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -1777,18 +1777,11 @@ static void view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar)
{
glClear(GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_PROJECTION);
- gpuLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- gpuLoadIdentity();
-
if (scene->world && (v3d->flag3 & V3D_SHOW_WORLD)) {
VP_view3d_draw_background_world(scene, v3d, ar->regiondata);
}
else {
VP_view3d_draw_background_none();
-
- glEnable(GL_DEPTH_TEST);
}
}
@@ -1805,8 +1798,6 @@ void ED_view3d_draw_offscreen(
bool do_compositing = false;
RegionView3D *rv3d = ar->regiondata;
- gpuPushMatrix();
-
/* set temporary new size */
int bwinx = ar->winx;
int bwiny = ar->winy;
@@ -1832,7 +1823,22 @@ void ED_view3d_draw_offscreen(
GPU_free_images_anim();
}
- /* setup view matrices before fx or unbinding the offscreen buffers will cause issues */
+ glMatrixMode(GL_PROJECTION);
+ gpuPushMatrix();
+ gpuLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ gpuPushMatrix();
+ gpuLoadIdentity();
+
+ /* clear opengl buffers */
+ if (do_sky) {
+ view3d_main_region_clear(scene, v3d, ar);
+ }
+ else {
+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ }
+
if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera)
view3d_stereo3d_setup_offscreen(scene, v3d, ar, winmat, viewname);
else
@@ -1853,15 +1859,6 @@ void ED_view3d_draw_offscreen(
v3d->fx_settings.ssao = ssao;
}
- /* clear opengl buffers */
- if (do_sky) {
- view3d_main_region_clear(scene, v3d, ar);
- }
- else {
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- }
-
/* main drawing call */
view3d_draw_objects(NULL, scene, v3d, ar, NULL, do_bgpic, true, do_compositing ? fx : NULL);
@@ -1876,7 +1873,6 @@ void ED_view3d_draw_offscreen(
/* draw grease-pencil stuff */
ED_region_pixelspace(ar);
-
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
ED_gpencil_draw_view3d(NULL, scene, v3d, ar, false);
@@ -1891,6 +1887,9 @@ void ED_view3d_draw_offscreen(
ar->winy = bwiny;
ar->winrct = brect;
+ glMatrixMode(GL_PROJECTION);
+ gpuPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
gpuPopMatrix();
UI_Theme_Restore(&theme_state);
@@ -2529,6 +2528,13 @@ void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar)
bool render_border = ED_view3d_calc_render_border(scene, v3d, ar, &border_rect);
bool clip_border = (render_border && !BLI_rcti_compare(&ar->drawrct, &border_rect));
+ glMatrixMode(GL_PROJECTION);
+ gpuPushMatrix();
+ gpuLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ gpuPushMatrix();
+ gpuLoadIdentity();
+
/* draw viewport using opengl */
if (v3d->drawtype != OB_RENDER || !view3d_main_region_do_render_draw(scene) || clip_border) {
view3d_main_region_clear(scene, v3d, ar); /* background */
@@ -2547,6 +2553,11 @@ void view3d_main_region_draw_legacy(const bContext *C, ARegion *ar)
view3d_main_region_draw_info(C, scene, ar, v3d, grid_unit, render_border);
+ glMatrixMode(GL_PROJECTION);
+ gpuPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ gpuPopMatrix();
+
v3d->flag |= V3D_INVALID_BACKBUF;
BLI_assert(BLI_listbase_is_empty(&v3d->afterdraw_transp));