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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-13 20:18:04 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-13 22:02:31 +0300
commit6e040b045ab1d94a877ab6f72f431c9b64e1121c (patch)
tree0c2ac27d592da617eccb911d32d65c565c7186ca /source/blender/gpu/intern/gpu_viewport.c
parente9b1163162d78324c118d3649451e81644b1af03 (diff)
GPU: add offscreen buffer drawing utility functions.
Diffstat (limited to 'source/blender/gpu/intern/gpu_viewport.c')
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index 3ef53b3a6c3..fc045805874 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -474,7 +474,7 @@ cleanup:
GPU_framebuffer_slots_bind(dfbl->default_fb, 0);
}
-static void draw_ofs_to_screen(GPUViewport *viewport)
+static void draw_ofs_to_screen(GPUViewport *viewport, const rcti *rect)
{
DefaultTextureList *dtxl = viewport->txl;
@@ -483,6 +483,9 @@ static void draw_ofs_to_screen(GPUViewport *viewport)
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);
+
Gwn_VertFormat *format = immVertexFormat();
unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -495,16 +498,16 @@ static void draw_ofs_to_screen(GPUViewport *viewport)
immBegin(GWN_PRIM_TRI_STRIP, 4);
immAttrib2f(texcoord, 0.0f, 0.0f);
- immVertex2f(pos, 0.0f, 0.0f);
+ immVertex2f(pos, rect->xmin, rect->ymin);
immAttrib2f(texcoord, 1.0f, 0.0f);
- immVertex2f(pos, w, 0.0f);
+ immVertex2f(pos, rect->xmin + w, rect->ymin);
immAttrib2f(texcoord, 0.0f, 1.0f);
- immVertex2f(pos, 0.0f, h);
+ immVertex2f(pos, rect->xmin, rect->ymin + h);
immAttrib2f(texcoord, 1.0f, 1.0f);
- immVertex2f(pos, w, h);
+ immVertex2f(pos, rect->xmin + w, rect->ymin + h);
immEnd();
@@ -523,9 +526,16 @@ void GPU_viewport_unbind(GPUViewport *viewport)
glEnable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_TEST);
+ }
+}
+void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect)
+{
+ DefaultFramebufferList *dfbl = viewport->fbl;
+
+ if (dfbl->default_fb) {
/* This might be bandwidth limiting */
- draw_ofs_to_screen(viewport);
+ draw_ofs_to_screen(viewport, rect);
}
}