From ac21e7b182d08cdbdcb5f4e0f2fd44a23e7e8d93 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 17 Apr 2009 15:10:55 +0100 Subject: [PATCH] [cogl debug] --cogl-debug=rectangles now outlines all cogl rectangles This makes the #if 0'd debug code that was in _cogl_journal_flush_quad_batch - which we have repeatedly found usefull for debugging various geometry issues in Clutter apps - a runtime debug option. The outline colors rotate in order from red to green to blue which can also help confirm the order that your geometry really drawn. The outlines are not affected by the current material state, so if you e.g. have a blending bug where geometry mysteriously disappears this can confirm if the underlying rectangles are actually being emitted but blending is causing them to be invisible. --- clutter/cogl/cogl-debug.h | 15 ++++++++------- clutter/cogl/common/cogl-debug.c | 3 ++- clutter/cogl/common/cogl-primitives.c | 7 +++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/clutter/cogl/cogl-debug.h b/clutter/cogl/cogl-debug.h index 44711c172..7440831b9 100644 --- a/clutter/cogl/cogl-debug.h +++ b/clutter/cogl/cogl-debug.h @@ -6,13 +6,14 @@ G_BEGIN_DECLS typedef enum { - COGL_DEBUG_MISC = 1 << 0, - COGL_DEBUG_TEXTURE = 1 << 1, - COGL_DEBUG_MATERIAL = 1 << 2, - COGL_DEBUG_SHADER = 1 << 3, - COGL_DEBUG_OFFSCREEN = 1 << 4, - COGL_DEBUG_DRAW = 1 << 5, - COGL_DEBUG_PANGO = 1 << 6 + COGL_DEBUG_MISC = 1 << 0, + COGL_DEBUG_TEXTURE = 1 << 1, + COGL_DEBUG_MATERIAL = 1 << 2, + COGL_DEBUG_SHADER = 1 << 3, + COGL_DEBUG_OFFSCREEN = 1 << 4, + COGL_DEBUG_DRAW = 1 << 5, + COGL_DEBUG_PANGO = 1 << 6, + COGL_DEBUG_RECTANGLES = 1 << 7 } CoglDebugFlags; #ifdef COGL_ENABLE_DEBUG diff --git a/clutter/cogl/common/cogl-debug.c b/clutter/cogl/common/cogl-debug.c index 0497d744f..2200b1f19 100644 --- a/clutter/cogl/common/cogl-debug.c +++ b/clutter/cogl/common/cogl-debug.c @@ -14,7 +14,8 @@ static const GDebugKey cogl_debug_keys[] = { { "shader", COGL_DEBUG_SHADER }, { "offscreen", COGL_DEBUG_OFFSCREEN }, { "draw", COGL_DEBUG_DRAW }, - { "pango", COGL_DEBUG_PANGO } + { "pango", COGL_DEBUG_PANGO }, + { "rectangles", COGL_DEBUG_RECTANGLES } }; static const gint n_cogl_debug_keys = G_N_ELEMENTS (cogl_debug_keys); diff --git a/clutter/cogl/common/cogl-primitives.c b/clutter/cogl/common/cogl-primitives.c index 881e6cef4..a1b0e2bc2 100644 --- a/clutter/cogl/common/cogl-primitives.c +++ b/clutter/cogl/common/cogl-primitives.c @@ -160,11 +160,11 @@ _cogl_journal_flush_quad_batch (CoglJournalEntry *batch_start, /* DEBUGGING CODE XXX: - * Uncommenting this will cause all rectangles to be drawn with a red, green + * This path will cause all rectangles to be drawn with a red, green * or blue outline with no blending. This may e.g. help with debugging * texture slicing issues or blending issues, plus it looks quite cool. */ -#if 0 + if (cogl_debug_flags & COGL_DEBUG_RECTANGLES) { static CoglHandle outline = COGL_INVALID_HANDLE; static int color = 0; @@ -172,7 +172,7 @@ _cogl_journal_flush_quad_batch (CoglJournalEntry *batch_start, outline = cogl_material_new (); cogl_enable (COGL_ENABLE_VERTEX_ARRAY); - for (i = 0; i < batch_len; i++, color = (++color) % 3) + for (i = 0; i < batch_len; i++, color = (color + 1) % 3) { cogl_material_set_color4ub (outline, color == 0 ? 0xff : 0x00, @@ -184,7 +184,6 @@ _cogl_journal_flush_quad_batch (CoglJournalEntry *batch_start, GE( glDrawArrays (GL_LINE_LOOP, 4 * i, 4) ); } } -#endif } void