diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-03-09 00:33:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-03-09 00:33:51 +0300 |
commit | 754b22bd515790cd31b8e40f188b2e07196d76a8 (patch) | |
tree | dc3e931573e036627292ce1ee84a79a7cb7c2b42 /source | |
parent | 8d2e51f559917499c6d6359d5e2fa1b023a44718 (diff) |
option to use offscreen opengl drawing with the sequencer scene strips.
warning, uses bad level call, will need to resolve very very soon!
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/screen.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 79 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_draw.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 43 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_sequence_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sequencer.c | 6 |
9 files changed, 103 insertions, 38 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ac107212e30..a0337704c2d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -587,9 +587,11 @@ Image *BKE_add_image_size(int width, int height, char *name, int floatbuf, short Image *BKE_add_image_imbuf(ImBuf *ibuf) { /* on save, type is changed to FILE in editsima.c */ + Image *ima; char filename[sizeof(ibuf->name)]; + BLI_split_dirfile(ibuf->name, NULL, filename); - Image *ima= image_alloc(filename, IMA_SRC_FILE, IMA_TYPE_IMAGE); + ima= image_alloc(filename, IMA_SRC_FILE, IMA_TYPE_IMAGE); if (ima) { BLI_strncpy(ima->name, ibuf->name, FILE_MAX); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 6d0057ca298..59a8bd74910 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -351,4 +351,3 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type) } return NULL; } - diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d3b05cf802c..994bbc3e70e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -39,6 +39,7 @@ #include "DNA_sequence_types.h" #include "DNA_scene_types.h" #include "DNA_anim_types.h" +#include "DNA_object_types.h" #include "BKE_global.h" #include "BKE_image.h" @@ -46,6 +47,7 @@ #include "BKE_sequencer.h" #include "BKE_fcurve.h" #include "BKE_utildefines.h" +#include "BKE_scene.h" #include "RNA_access.h" #include "RE_pipeline.h" @@ -1938,6 +1940,8 @@ static void check_limiter_refcount_comp(const char * func, TStripElem *se) static TStripElem* do_build_seq_array_recursively(Scene *scene, ListBase *seqbasep, int cfra, int chanshown, int render_size); +extern ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height); + static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, int build_proxy_run, int render_size) { @@ -2130,47 +2134,52 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int if (!sce_valid) { se->ok = STRIPELEM_FAILED; - } else if (se->ibuf==NULL && sce_valid) { - int do_opengl= 0; - if(do_opengl && have_seq==0 && (sequencer_view3d_cb!=NULL)) { - /* opengl offscreen render */ + } + else if (se->ibuf==NULL && sce_valid) { + int frame= seq->sfra + se->nr + seq->anim_startofs; + int oldcfra = seq->scene->r.cfra; - /* sequencer_view3d_cb */ - // void (*seq_view3d_cb)(Scene *, int, int, int, int)= sequencer_view3d_cb; + /* Hack! This function can be called from do_render_seq(), in that case + the seq->scene can already have a Render initialized with same name, + so we have to use a default name. (compositor uses scene name to + find render). + However, when called from within the UI (image preview in sequencer) + we do want to use scene Render, that way the render result is defined + for display in render/imagewindow - // seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty); - } - else { - RenderResult rres; - int oldcfra; - /* Hack! This function can be called from do_render_seq(), in that case - the seq->scene can already have a Render initialized with same name, - so we have to use a default name. (compositor uses scene name to - find render). - However, when called from within the UI (image preview in sequencer) - we do want to use scene Render, that way the render result is defined - for display in render/imagewindow + Hmm, don't see, why we can't do that all the time, + and since G.rendering is uhm, gone... (Peter) + */ + + int rendering = 1; + int doseq; - Hmm, don't see, why we can't do that all the time, - and since G.rendering is uhm, gone... (Peter) - */ + /* prevent eternal loop */ + doseq= scene->r.scemode & R_DOSEQ; + scene->r.scemode &= ~R_DOSEQ; - int rendering = 1; - int doseq; + seq->scene->r.cfra= frame; + + if(G.background==0 && (seq->flag & SEQ_USE_SCENE_OPENGL) && have_seq==0) { + /* opengl offscreen render */ - oldcfra = seq->scene->r.cfra; +#ifdef DURIAN_CAMERA_SWITCH + Object *camera= scene_find_camera_switch(seq->scene); + if(camera) + seq->scene->camera= camera; +#endif + scene_update_for_newframe(seq->scene, seq->scene->lay); + se->ibuf= ED_view3d_draw_offscreen_imbuf_simple(seq->scene, seqrectx, seqrecty); // BAD LEVEL CALL! DONT ALLOW THIS FOR MORE THEN A FEW DAYS, USE A CALLBACK!!! - campell + } + else { + RenderResult rres; if(rendering) re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT); else re= RE_NewRender(sce->id.name, RE_SLOT_VIEW); - /* prevent eternal loop */ - doseq= scene->r.scemode & R_DOSEQ; - scene->r.scemode &= ~R_DOSEQ; - - RE_BlenderFrame(re, sce, NULL, - seq->sfra+se->nr+seq->anim_startofs); + RE_BlenderFrame(re, sce, NULL, frame); RE_AcquireResultImage(re, &rres); @@ -2189,12 +2198,12 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int RE_ReleaseResultImage(re); // BIF_end_render_callbacks(); - - /* restore */ - scene->r.scemode |= doseq; - - seq->scene->r.cfra = oldcfra; } + + /* restore */ + scene->r.scemode |= doseq; + + seq->scene->r.cfra = oldcfra; copy_to_ibuf_still(seq, se); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 303748c79fd..a4035cef880 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -159,6 +159,7 @@ void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct AR int winx, int winy, float viewmat[][4], float winmat[][4]); struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey); +struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height); void view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 4a98f524bc4..a6df4243f60 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5515,7 +5515,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) memcpy(array, rv3d->winmat, sizeof(rv3d->winmat)); array += sizeof(rv3d->winmat)/sizeof(float); memcpy(array, rv3d->viewmat, sizeof(rv3d->viewmat)); array += sizeof(rv3d->viewmat)/sizeof(float); orth= project_paint_view_clip(v3d, rv3d, &array[0], &array[1]); - array[2]= orth ? 1.0f : 0.0f; + array[2]= orth ? 1.0f : 0.0f; /* using float for a bool is dodgy but since its an extra member in the array... easier then adding a single bool prop */ IDP_AddToGroup(idgroup, view_data); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 41e2fe2b124..13e2a9e6962 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -687,6 +687,9 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); + /* without this colors can flicker from previous opengl state */ + glColor4ub(255, 255, 255, 255); + UI_view2d_totRect_set(v2d, viewrectx + 0.5f, viewrecty + 0.5f); UI_view2d_curRect_validate(v2d); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 35818a4e3e0..42416c2d8eb 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2031,6 +2031,8 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, ar->winy= bwiny; glPopMatrix(); + + glColor4ub(255, 255, 255, 255); // XXX, without this the sequencer flickers with opengl draw enabled, need to find out why - campbell } /* utility func for ED_view3d_draw_offscreen */ @@ -2075,6 +2077,47 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in return ibuf; } +/* creates own 3d views, used by the sequencer */ +ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height) +{ + View3D v3d; + ARegion ar; + RegionView3D rv3d; + + memset(&v3d, 0, sizeof(v3d)); + memset(&ar, 0, sizeof(ar)); + memset(&rv3d, 0, sizeof(rv3d)); + + /* connect data */ + v3d.regionbase.first= v3d.regionbase.last= &ar; + ar.regiondata= &rv3d; + ar.regiontype= RGN_TYPE_WINDOW; + + v3d.camera= scene->camera; + v3d.lay= scene->lay; + v3d.drawtype = OB_SOLID; /* should be able to configure */ + + rv3d.persp= RV3D_CAMOB; + + copy_m4_m4(rv3d.viewinv, v3d.camera->obmat); + normalize_m4(rv3d.viewinv); + invert_m4_m4(rv3d.viewmat, rv3d.viewinv); + + { + float _yco, _dx, _dy; + rctf _viewplane; + object_camera_matrix(&scene->r, v3d.camera, width, height, 0, rv3d.winmat, &_viewplane, &v3d.near, &v3d.far, &v3d.lens, &_yco, &_dx, &_dy); + } + + mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat); + invert_m4_m4(rv3d.persinv, rv3d.viewinv); + + return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height); + + // seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty); +} + + /* NOTE: the info that this uses is updated in ED_refresh_viewport_fps(), * which currently gets called during SCREEN_OT_animation_step. */ diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 329e9ce771a..14b121a4281 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -273,6 +273,8 @@ typedef struct SpeedControlVars { #define SEQ_USE_PROXY_CUSTOM_FILE 2097152 #define SEQ_USE_EFFECT_DEFAULT_FADE 4194304 +#define SEQ_USE_SCENE_OPENGL 8388608 + /* deprecated, dont use a flag anymore*/ /*#define SEQ_ACTIVE 1048576*/ diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 8f80ae8a301..14ccd79a28b 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -920,6 +920,12 @@ static void rna_def_scene(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Scene", "Scene that this sequence uses"); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + + + prop= RNA_def_property(srna, "use_opengl", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_SCENE_OPENGL); + RNA_def_property_ui_text(prop, "Use OpenGL", "Use OpenGL preview rather then rendering the scene"); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); rna_def_filter_video(srna); rna_def_proxy(srna); |