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:
authorJulian Eisel <eiseljulian@gmail.com>2019-11-05 17:33:16 +0300
committerJulian Eisel <eiseljulian@gmail.com>2019-11-05 17:33:48 +0300
commit7f1fadba67718434efecb7aa2c0aaf8dbea6f042 (patch)
tree554a3d257f69173b5e094f6985efeae2bb911fca /source/blender/gpu/intern/gpu_viewport.c
parent8537cdc71d8145572a06eabc7ec39030b3c99118 (diff)
Core XR Support [part 4]: Blender-side changes (+ the remaining bits)
Changes for the higher level, more Blender specific side of the implementation. Main additions: * WM-XR: Layer tying Ghost-XR to the Blender specific APIs/data * wmSurface API: drawable, non-window container (manages Ghost-OpenGL and GPU context) * DNA/RNA for initial management of VR session settings * Utility batch & config file for using the Oculus runtime (Windows only) Differential Revision: https://developer.blender.org/D6193
Diffstat (limited to 'source/blender/gpu/intern/gpu_viewport.c')
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index 615af57c1bd..73f588ba3d1 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -505,34 +505,21 @@ void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect)
}
}
-void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect)
+void GPU_viewport_draw_to_screen_ex(
+ GPUViewport *viewport, float x1, float x2, float y1, float y2, bool to_srgb)
{
- DefaultFramebufferList *dfbl = viewport->fbl;
+ GPUTexture *color = GPU_viewport_color_texture(viewport);
- if (dfbl->default_fb == NULL) {
+ if (!color) {
return;
}
- DefaultTextureList *dtxl = viewport->txl;
-
- GPUTexture *color = dtxl->color;
-
- const float w = (float)GPU_texture_width(color);
- const float h = (float)GPU_texture_height(color);
-
- BLI_assert(w == BLI_rcti_size_x(rect) + 1);
- BLI_assert(h == BLI_rcti_size_y(rect) + 1);
-
/* wmOrtho for the screen has this same offset */
- const float halfx = GLA_PIXEL_OFS / w;
- const float halfy = GLA_PIXEL_OFS / h;
-
- float x1 = rect->xmin;
- float x2 = rect->xmin + w;
- float y1 = rect->ymin;
- float y2 = rect->ymin + h;
+ const float halfx = GLA_PIXEL_OFS / ABS(x2 - x1);
+ const float halfy = GLA_PIXEL_OFS / ABS(y2 - y1);
- GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
+ GPUShader *shader = GPU_shader_get_builtin_shader(
+ to_srgb ? GPU_SHADER_2D_IMAGE_RECT_LINEAR_TO_SRGB : GPU_SHADER_2D_IMAGE_RECT_COLOR);
GPU_shader_bind(shader);
GPU_texture_bind(color, 0);
@@ -550,6 +537,22 @@ void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect)
GPU_texture_unbind(color);
}
+void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect)
+{
+ GPUTexture *color = GPU_viewport_color_texture(viewport);
+
+ if (color) {
+ const float w = (float)GPU_texture_width(color);
+ const float h = (float)GPU_texture_height(color);
+
+ BLI_assert(w == BLI_rcti_size_x(rect) + 1);
+ BLI_assert(h == BLI_rcti_size_y(rect) + 1);
+
+ GPU_viewport_draw_to_screen_ex(
+ viewport, rect->xmin, rect->xmin + w, rect->ymin, rect->ymin + h, false);
+ }
+}
+
void GPU_viewport_unbind(GPUViewport *UNUSED(viewport))
{
GPU_framebuffer_restore();