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:
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_draw.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c90
1 files changed, 80 insertions, 10 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 2c85dc62edb..10480a3872a 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -97,6 +97,16 @@
#include "view3d_intern.h" /* own include */
+/* handy utility for drawing shapes in the viewport for arbitrary code.
+ * could add lines and points too */
+// #define DEBUG_DRAW
+#ifdef DEBUG_DRAW
+static void bl_debug_draw(void);
+/* add these locally when using these functions for testing */
+extern void bl_debug_draw_quad_clear(void);
+extern void bl_debug_draw_quad_add(const float v0[3], const float v1[3], const float v2[3], const float v3[3]);
+extern void bl_debug_draw_edge_add(const float v0[3], const float v1[3]);
+#endif
static void star_stuff_init_func(void)
{
@@ -1271,7 +1281,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
hmargin = 0.035f * (x2 - x1);
vmargin = 0.035f * (y2 - y1);
- uiDrawBox(GL_LINE_LOOP, x1 + hmargin, y1+vmargin, x2 - hmargin, y2 - vmargin, 2.0f);
+ uiDrawBox(GL_LINE_LOOP, x1 + hmargin, y1 + vmargin, x2 - hmargin, y2 - vmargin, 2.0f);
}
if (ca && (ca->flag & CAM_SHOWSENSOR)) {
/* determine sensor fit, and get sensor x/y, for auto fit we
@@ -1464,8 +1474,8 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax,
ibuf = IMB_allocImBuf((xmaxc - xminc + 1), (ymaxc - yminc + 1), 32, IB_rect);
- view3d_validate_backbuf(vc);
-
+ view3d_validate_backbuf(vc);
+
glReadPixels(vc->ar->winrct.xmin + xminc,
vc->ar->winrct.ymin + yminc,
(xmaxc - xminc + 1),
@@ -1613,7 +1623,8 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d,
ibuf = NULL; /* frame is out of range, dont show */
}
else {
- ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser);
+ ibuf = BKE_image_acquire_ibuf(ima, &bgpic->iuser, NULL);
+ freeibuf = ibuf;
}
image_aspect[0] = ima->aspx;
@@ -3036,9 +3047,10 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
v3d->zbuf = FALSE;
/* enables anti-aliasing for 3D view drawing */
- if (U.ogl_multisamples)
- if (!(U.gameflags & USER_DISABLE_AA))
- glEnable(GL_MULTISAMPLE_ARB);
+ if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) {
+ // if (!(U.gameflags & USER_DISABLE_AA))
+ glEnable(GL_MULTISAMPLE_ARB);
+ }
/* needs to be done always, gridview is adjusted in drawgrid() now */
@@ -3153,9 +3165,10 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
BIF_draw_manipulator(C);
/* Disable back anti-aliasing */
- if (U.ogl_multisamples)
- if (!(U.gameflags & USER_DISABLE_AA))
- glDisable(GL_MULTISAMPLE_ARB);
+ if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) {
+ // if (!(U.gameflags & USER_DISABLE_AA))
+ glDisable(GL_MULTISAMPLE_ARB);
+ }
if (v3d->zbuf) {
@@ -3257,6 +3270,9 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
/* draw viewport using opengl */
if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(C) || draw_border) {
view3d_main_area_draw_objects(C, ar, &grid_unit);
+#ifdef DEBUG_DRAW
+ bl_debug_draw();
+#endif
ED_region_pixelspace(ar);
}
@@ -3269,3 +3285,57 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
v3d->flag |= V3D_INVALID_BACKBUF;
}
+#ifdef DEBUG_DRAW
+/* debug drawing */
+#define _DEBUG_DRAW_QUAD_TOT 1024
+static float _bl_debug_draw_quads[_DEBUG_DRAW_QUAD_TOT][4][3];
+static int _bl_debug_draw_quads_tot = 0;
+
+void bl_debug_draw_quad_clear(void)
+{
+ _bl_debug_draw_quads_tot = 0;
+}
+void bl_debug_draw_quad_add(const float v0[3], const float v1[3], const float v2[3], const float v3[3])
+{
+ if (_bl_debug_draw_quads_tot >= _DEBUG_DRAW_QUAD_TOT) {
+ printf("%s: max quad count hit %d!", __func__, _bl_debug_draw_quads_tot);
+ }
+ else {
+ float *pt = &_bl_debug_draw_quads[_bl_debug_draw_quads_tot][0][0];
+ copy_v3_v3(pt, v0); pt += 3;
+ copy_v3_v3(pt, v1); pt += 3;
+ copy_v3_v3(pt, v2); pt += 3;
+ copy_v3_v3(pt, v3); pt += 3;
+ _bl_debug_draw_quads_tot++;
+ }
+}
+void bl_debug_draw_edge_add(const float v0[3], const float v1[3])
+{
+ if (_bl_debug_draw_quads_tot >= _DEBUG_DRAW_QUAD_TOT) {
+ printf("%s: max edge count hit %d!", __func__, _bl_debug_draw_quads_tot);
+ }
+ else {
+ float *pt = &_bl_debug_draw_quads[_bl_debug_draw_quads_tot][0][0];
+ copy_v3_v3(pt, v0); pt += 3;
+ copy_v3_v3(pt, v1); pt += 3;
+ copy_v3_v3(pt, v0); pt += 3;
+ copy_v3_v3(pt, v1); pt += 3;
+ _bl_debug_draw_quads_tot++;
+ }
+}
+static void bl_debug_draw(void)
+{
+ if (_bl_debug_draw_quads_tot) {
+ int i;
+ cpack(0x00FF0000);
+ glBegin(GL_LINE_LOOP);
+ for (i = 0; i < _bl_debug_draw_quads_tot; i ++) {
+ glVertex3fv(_bl_debug_draw_quads[i][0]);
+ glVertex3fv(_bl_debug_draw_quads[i][1]);
+ glVertex3fv(_bl_debug_draw_quads[i][2]);
+ glVertex3fv(_bl_debug_draw_quads[i][3]);
+ }
+ glEnd();
+ }
+}
+#endif