option to use offscreen opengl drawing with the sequencer scene strips.

warning, uses bad level call, will need to resolve very very soon!
This commit is contained in:
2010-03-08 21:33:51 +00:00
parent 8d2e51f559
commit 754b22bd51
10 changed files with 104 additions and 38 deletions

View File

@@ -617,6 +617,7 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel):
strip = act_strip(context)
layout.template_ID(strip, "scene")
layout.prop(strip, "use_opengl")
class SEQUENCER_PT_filter(SequencerButtonsPanel):

View File

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

View File

@@ -351,4 +351,3 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type)
}
return NULL;
}

View File

@@ -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)) {
}
else if (se->ibuf==NULL && sce_valid) {
int frame= seq->sfra + se->nr + seq->anim_startofs;
int oldcfra = seq->scene->r.cfra;
/* 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;
/* prevent eternal loop */
doseq= scene->r.scemode & R_DOSEQ;
scene->r.scemode &= ~R_DOSEQ;
seq->scene->r.cfra= frame;
if(G.background==0 && (seq->flag & SEQ_USE_SCENE_OPENGL) && have_seq==0) {
/* opengl offscreen render */
/* sequencer_view3d_cb */
// void (*seq_view3d_cb)(Scene *, int, int, int, int)= sequencer_view3d_cb;
// seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty);
#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;
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;
oldcfra = seq->scene->r.cfra;
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);

View File

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

View File

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

View File

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

View File

@@ -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.
*/

View File

@@ -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*/

View File

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