Cleanup: WM: Encapsulate stereo draw buffers binding
This commit is contained in:
parent
8dfc31f61f
commit
59975b0adf
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue