diff options
Diffstat (limited to 'source/blender/windowmanager/intern/wm_draw.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 73 |
1 files changed, 32 insertions, 41 deletions
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 5289b747f05..38cd667c422 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -235,7 +235,7 @@ static void wm_region_test_render_do_draw(const Scene *scene, if (sa->spacetype == SPACE_VIEW3D && region->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = region->regiondata; RenderEngine *engine = rv3d->render_engine; - GPUViewport *viewport = WM_draw_region_get_viewport(region, 0); + GPUViewport *viewport = WM_draw_region_get_viewport(region); if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) { View3D *v3d = sa->spacedata.first; @@ -332,10 +332,8 @@ static void wm_draw_callbacks(wmWindow *win) static void wm_draw_region_buffer_free(ARegion *region) { if (region->draw_buffer) { - for (int view = 0; view < 2; view++) { - if (region->draw_buffer->viewport[view]) { - GPU_viewport_free(region->draw_buffer->viewport[view]); - } + if (region->draw_buffer->viewport) { + GPU_viewport_free(region->draw_buffer->viewport); } if (region->draw_buffer->offscreen) { GPU_offscreen_free(region->draw_buffer->offscreen); @@ -361,7 +359,6 @@ static void wm_draw_offscreen_texture_parameters(GPUOffScreen *offscreen) /* GL_TEXTURE_BASE_LEVEL = 0 by default */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glBindTexture(GL_TEXTURE_2D, 0); } @@ -387,8 +384,8 @@ static void wm_draw_region_buffer_create(ARegion *region, bool stereo, bool use_ /* Allocate viewport which includes an offscreen buffer with depth * multisample, etc. */ region->draw_buffer = MEM_callocN(sizeof(wmDrawBuffer), "wmDrawBuffer"); - region->draw_buffer->viewport[0] = GPU_viewport_create(); - region->draw_buffer->viewport[1] = (stereo) ? GPU_viewport_create() : NULL; + region->draw_buffer->viewport = stereo ? GPU_viewport_stereo_create() : + GPU_viewport_create(); } else { /* Allocate offscreen buffer if it does not exist. This one has no @@ -417,8 +414,8 @@ static void wm_draw_region_bind(ARegion *region, int view) return; } - if (region->draw_buffer->viewport[view]) { - GPU_viewport_bind(region->draw_buffer->viewport[view], ®ion->winrct); + if (region->draw_buffer->viewport) { + GPU_viewport_bind(region->draw_buffer->viewport, view, ®ion->winrct); } else { GPU_offscreen_bind(region->draw_buffer->offscreen, false); @@ -432,7 +429,7 @@ static void wm_draw_region_bind(ARegion *region, int view) region->draw_buffer->bound_view = view; } -static void wm_draw_region_unbind(ARegion *region, int view) +static void wm_draw_region_unbind(ARegion *region) { if (!region->draw_buffer) { return; @@ -440,8 +437,8 @@ static void wm_draw_region_unbind(ARegion *region, int view) region->draw_buffer->bound_view = -1; - if (region->draw_buffer->viewport[view]) { - GPU_viewport_unbind(region->draw_buffer->viewport[view]); + if (region->draw_buffer->viewport) { + GPU_viewport_unbind(region->draw_buffer->viewport); } else { glDisable(GL_SCISSOR_TEST); @@ -460,14 +457,14 @@ static void wm_draw_region_blit(ARegion *region, int view) view = 0; } else if (view > 0) { - if (region->draw_buffer->viewport[view] == NULL) { + if (region->draw_buffer->viewport == NULL) { /* Region does not need stereo or failed to allocate stereo buffers. */ view = 0; } } - if (region->draw_buffer->viewport[view]) { - GPU_viewport_draw_to_screen(region->draw_buffer->viewport[view], ®ion->winrct); + if (region->draw_buffer->viewport) { + GPU_viewport_draw_to_screen(region->draw_buffer->viewport, view, ®ion->winrct); } else { GPU_offscreen_draw_to_screen( @@ -481,8 +478,9 @@ GPUTexture *wm_draw_region_texture(ARegion *region, int view) return NULL; } - if (region->draw_buffer->viewport[view]) { - return GPU_viewport_color_texture(region->draw_buffer->viewport[view]); + GPUViewport *viewport = region->draw_buffer->viewport; + if (viewport) { + return GPU_viewport_color_texture(viewport, view); } else { return GPU_offscreen_color_texture(region->draw_buffer->offscreen); @@ -573,13 +571,14 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend) } } -GPUViewport *WM_draw_region_get_viewport(ARegion *region, int view) +GPUViewport *WM_draw_region_get_viewport(ARegion *region) { if (!region->draw_buffer) { return NULL; } - return region->draw_buffer->viewport[view]; + GPUViewport *viewport = region->draw_buffer->viewport; + return viewport; } GPUViewport *WM_draw_region_get_bound_viewport(ARegion *region) @@ -588,8 +587,8 @@ GPUViewport *WM_draw_region_get_bound_viewport(ARegion *region) return NULL; } - int view = region->draw_buffer->bound_view; - return region->draw_buffer->viewport[view]; + GPUViewport *viewport = region->draw_buffer->viewport; + return viewport; } static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) @@ -650,14 +649,18 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) wm_draw_region_bind(region, view); ED_region_do_draw(C, region); - wm_draw_region_unbind(region, view); + wm_draw_region_unbind(region); + } + if (use_viewport) { + GPUViewport *viewport = region->draw_buffer->viewport; + GPU_viewport_stereo_composite(viewport, win->stereo3d_format); } } else { wm_draw_region_buffer_create(region, false, use_viewport); wm_draw_region_bind(region, 0); ED_region_do_draw(C, region); - wm_draw_region_unbind(region, 0); + wm_draw_region_unbind(region); } region->do_draw = false; @@ -686,7 +689,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); ED_region_do_draw(C, region); - wm_draw_region_unbind(region, 0); + wm_draw_region_unbind(region); region->do_draw = false; CTX_wm_menu_set(C, NULL); @@ -715,19 +718,8 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) { for (ARegion *region = sa->regionbase.first; region; region = region->next) { if (region->visible && region->overlap == false) { - if (view == -1 && region->draw_buffer && region->draw_buffer->stereo) { - /* Stereo drawing from textures. */ - if (win->stereo3d_format->display_mode == S3D_DISPLAY_ANAGLYPH) { - wm_stereo3d_draw_anaglyph(win, region); - } - else { - wm_stereo3d_draw_interlace(win, region); - } - } - else { - /* Blit from offscreen buffer. */ - wm_draw_region_blit(region, view); - } + /* Blit from offscreen buffer. */ + wm_draw_region_blit(region, view); } } } @@ -789,7 +781,6 @@ static void wm_draw_window(bContext *C, wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); bool stereo = WM_stereo3d_enabled(win, false); - /* Draw area regions into their own framebuffer. This way we can redraw * the areas that need it, and blit the rest from existing framebuffers. */ wm_draw_window_offscreen(C, win, stereo); @@ -1028,7 +1019,7 @@ void wm_draw_region_test(bContext *C, ScrArea *sa, ARegion *region) wm_draw_region_buffer_create(region, false, use_viewport); wm_draw_region_bind(region, 0); ED_region_do_draw(C, region); - wm_draw_region_unbind(region, 0); + wm_draw_region_unbind(region); region->do_draw = false; } @@ -1068,7 +1059,7 @@ void WM_draw_region_viewport_bind(ARegion *region) void WM_draw_region_viewport_unbind(ARegion *region) { - wm_draw_region_unbind(region, 0); + wm_draw_region_unbind(region); } /** \} */ |