[Bf-blender-cvs] [59975b0adf4] master: Cleanup: WM: Encapsulate stereo draw buffers binding

Clément Foucault noreply at git.blender.org
Sat Jul 18 03:08:18 CEST 2020


Commit: 59975b0adf42cfbc51a90c02caaed49085abafa2
Author: Clément Foucault
Date:   Fri Jul 17 21:22:39 2020 +0200
Branches: master
https://developer.blender.org/rB59975b0adf42cfbc51a90c02caaed49085abafa2

Cleanup: WM: Encapsulate stereo draw buffers binding

===================================================================

M	source/blender/gpu/GPU_framebuffer.h
M	source/blender/gpu/intern/gpu_framebuffer.c
M	source/blender/windowmanager/intern/wm_draw.c

===================================================================

diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h
index 6925839256b..1a9fb1bad7a 100644
--- a/source/blender/gpu/GPU_framebuffer.h
+++ b/source/blender/gpu/GPU_framebuffer.h
@@ -41,6 +41,12 @@ typedef enum eGPUFrameBufferBits {
   GPU_STENCIL_BIT = (1 << 2),
 } eGPUFrameBufferBits;
 
+typedef enum eGPUBackBuffer {
+  GPU_BACKBUFFER = 0,
+  GPU_BACKBUFFER_RIGHT,
+  GPU_BACKBUFFER_LEFT,
+} eGPUBackBuffer;
+
 typedef struct GPUFrameBuffer GPUFrameBuffer;
 typedef struct GPUOffScreen GPUOffScreen;
 
@@ -224,6 +230,8 @@ void GPU_clear(eGPUFrameBufferBits flags);
 void GPU_frontbuffer_read_pixels(
     int x, int y, int w, int h, int channels, eGPUDataFormat format, void *data);
 
+void GPU_backbuffer_bind(eGPUBackBuffer buffer);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index c079864126e..77abb786117 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -1080,3 +1080,17 @@ void GPU_frontbuffer_read_pixels(
   glReadBuffer(GL_FRONT);
   gpu_framebuffer_read_color_ex(x, y, w, h, channels, GL_FRONT, format, data);
 }
+
+/* For stereo rendering. */
+void GPU_backbuffer_bind(eGPUBackBuffer buffer)
+{
+  if (buffer == GPU_BACKBUFFER) {
+    glDrawBuffer(GL_BACK);
+  }
+  else if (buffer == GPU_BACKBUFFER_LEFT) {
+    glDrawBuffer(GL_BACK_LEFT);
+  }
+  else if (buffer == GPU_BACKBUFFER_RIGHT) {
+    glDrawBuffer(GL_BACK_RIGHT);
+  }
+}
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index f6fc97f602b..d2e45d92df8 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -831,11 +831,13 @@ static void wm_draw_window(bContext *C, wmWindow *win)
   }
   else if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP) {
     /* For pageflip we simply draw to both back buffers. */
-    glDrawBuffer(GL_BACK_LEFT);
+    GPU_backbuffer_bind(GPU_BACKBUFFER_LEFT);
     wm_draw_window_onscreen(C, win, 0);
-    glDrawBuffer(GL_BACK_RIGHT);
+
+    GPU_backbuffer_bind(GPU_BACKBUFFER_RIGHT);
     wm_draw_window_onscreen(C, win, 1);
-    glDrawBuffer(GL_BACK);
+
+    GPU_backbuffer_bind(GPU_BACKBUFFER);
   }
   else if (ELEM(win->stereo3d_format->display_mode, S3D_DISPLAY_ANAGLYPH, S3D_DISPLAY_INTERLACE)) {
     /* For anaglyph and interlace, we draw individual regions with



More information about the Bf-blender-cvs mailing list