diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-27 03:30:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-27 03:30:15 +0400 |
commit | ea3be03743c8e066b2ef2ffff8f38371ea553fd3 (patch) | |
tree | 7d42e9f75540165ffdda9e5857ebb163f7178d5d /source/blender/editors | |
parent | 50bce31dbbf727cef0746a16bb5a669c30b21628 (diff) |
ED_view3d_draw_offscreen_imbuf_simple and ED_view3d_draw_offscreen_imbuf now accept the imbuf flag so they can get the float buffer from opengl directly.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 4 | ||||
-rw-r--r-- | source/blender/editors/render/render_opengl.c | 6 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 17 |
4 files changed, 16 insertions, 13 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 5d33816bf02..f5a84aa4c19 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -160,8 +160,8 @@ int ED_view3d_context_activate(struct bContext *C); void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct ARegion *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, int drawtype); +struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag); +struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, unsigned int flag, int drawtype); void view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index de32efde452..7833f93b3b5 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -144,12 +144,8 @@ static void screen_opengl_render_apply(OGLRender *oglrender) GPU_offscreen_unbind(oglrender->ofs); /* unbind */ } else { - ImBuf *ibuf_view= ED_view3d_draw_offscreen_imbuf_simple(scene, oglrender->sizex, oglrender->sizey, OB_SOLID); - ibuf_view->profile = IB_PROFILE_NONE; /* ensures no conversion!, see note above */ - IMB_float_from_rect(ibuf_view); - + ImBuf *ibuf_view= ED_view3d_draw_offscreen_imbuf_simple(scene, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID); memcpy(rr->rectf, ibuf_view->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey); - IMB_freeImBuf(ibuf_view); } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 77b6d88fdf5..418bac69974 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5514,7 +5514,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) if(w > maxsize) w= maxsize; if(h > maxsize) h= maxsize; - ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h); + ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect); image= BKE_add_image_imbuf(ibuf); if(image) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 5f88a1b8b62..f0aa54248da 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2115,7 +2115,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, } /* utility func for ED_view3d_draw_offscreen */ -ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey) +ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey, unsigned int flag) { RegionView3D *rv3d= ar->regiondata; ImBuf *ibuf; @@ -2143,9 +2143,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in } /* read in pixels & stamp */ - ibuf= IMB_allocImBuf(sizex, sizey, 24, IB_rect, 0); - glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + ibuf= IMB_allocImBuf(sizex, sizey, 32, flag, 0); + if(ibuf->rect_float) + glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_FLOAT, ibuf->rect_float); + else if(ibuf->rect) + glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + //if((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW)) // BKE_stamp_buf(scene, NULL, rr->rectf, rr->rectx, rr->recty, 4); @@ -2153,11 +2157,14 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in GPU_offscreen_unbind(ofs); GPU_offscreen_free(ofs); + if(ibuf->rect_float && ibuf->rect) + IMB_rect_from_float(ibuf); + return ibuf; } /* creates own 3d views, used by the sequencer */ -ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, int drawtype) +ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, unsigned int flag, int drawtype) { View3D v3d; ARegion ar; @@ -2192,7 +2199,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height 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); + return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag); // seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty); } |