Sequencer: add support for grease pencil rendering in previews

This commit is contained in:
Campbell Barton 2014-06-14 03:25:07 +10:00
parent f37c971878
commit 8957609f35
3 changed files with 40 additions and 1 deletions

View File

@ -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);
}
/* ************************************************** */

View File

@ -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);

View File

@ -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);