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:
authorCampbell Barton <ideasman42@gmail.com>2014-06-13 21:25:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-06-13 21:25:07 +0400
commit8957609f353f93475d79706cf2d6b306ed197beb (patch)
tree72d0711c98f6867f2d5c4dc86525708571de140b
parentf37c971878307d4f618bbbc50574293de9e09141 (diff)
Sequencer: add support for grease pencil rendering in previews
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c7
-rw-r--r--source/blender/editors/include/ED_gpencil.h1
-rw-r--r--source/blender/editors/render/render_opengl.c33
3 files changed, 40 insertions, 1 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index eb784abb34f..a69c020b076 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -799,4 +799,11 @@ void ED_gpencil_draw_view3d(Scene *scene, View3D *v3d, ARegion *ar, bool only3d)
gp_draw_data(gpd, offsx, offsy, winx, winy, CFRA, dflag);
}
+void ED_gpencil_draw_ex(bGPdata *gpd, int winx, int winy, const int cfra)
+{
+ int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D;
+
+ gp_draw_data(gpd, 0, 0, winx, winy, cfra, dflag);
+}
+
/* ************************************************** */
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 8c8178bbdfa..63ffa1bef0c 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -80,6 +80,7 @@ void ED_operatortypes_gpencil(void);
void ED_gpencil_draw_2dimage(const struct bContext *C);
void ED_gpencil_draw_view2d(const struct bContext *C, bool onlyv2d);
void ED_gpencil_draw_view3d(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, bool only3d);
+void ED_gpencil_draw_ex(struct bGPdata *gpd, int winx, int winy, const int cfra);
void ED_gpencil_panel_standard_header(const struct bContext *C, struct Panel *pa);
void ED_gpencil_panel_standard(const struct bContext *C, struct Panel *pa);
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 94dbf2eed8c..ecf5e962c80 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -36,6 +36,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
+#include "BLI_math_color_blend.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_jitter.h"
@@ -57,6 +58,7 @@
#include "ED_screen.h"
#include "ED_view3d.h"
+#include "ED_gpencil.h"
#include "RE_pipeline.h"
#include "IMB_imbuf_types.h"
@@ -139,7 +141,9 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
if (oglrender->is_sequencer) {
SeqRenderData context;
- int chanshown = oglrender->sseq ? oglrender->sseq->chanshown : 0;
+ SpaceSeq *sseq = oglrender->sseq;
+ int chanshown = sseq ? sseq->chanshown : 0;
+ struct bGPdata *gpd = (sseq && (sseq->flag & SEQ_SHOW_GPENCIL)) ? sseq->gpd : NULL;
context = BKE_sequencer_new_render_data(oglrender->bmain->eval_ctx, oglrender->bmain,
scene, oglrender->sizex, oglrender->sizey, 100.0f);
@@ -171,6 +175,33 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
IMB_freeImBuf(linear_ibuf);
}
+
+ if (gpd) {
+ int i;
+ unsigned char *gp_rect;
+
+ GPU_offscreen_bind(oglrender->ofs);
+
+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ wmOrtho2(0, sizex, 0, sizey);
+ glTranslatef(sizex / 2, sizey / 2, 0.0f);
+
+ ED_gpencil_draw_ex(gpd, sizex, sizey, scene->r.cfra);
+
+ gp_rect = MEM_mallocN(sizex * sizey * sizeof(unsigned char) * 4, "offscreen rect");
+ GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, gp_rect);
+
+ for (i = 0; i < sizex * sizey * 4; i += 4) {
+ float col_src[4];
+ rgba_uchar_to_float(col_src, &gp_rect[i]);
+ blend_color_mix_float(&rr->rectf[i], &rr->rectf[i], col_src);
+ }
+ GPU_offscreen_unbind(oglrender->ofs);
+
+ MEM_freeN(gp_rect);
+ }
}
else if (view_context) {
ED_view3d_draw_offscreen_init(scene, v3d);