Fix crash in debug drawing of fullscreen exit icon
authorJulian Eisel <eiseljulian@gmail.com>
Mon, 7 May 2018 11:46:00 +0000 (13:46 +0200)
committerJulian Eisel <eiseljulian@gmail.com>
Mon, 7 May 2018 11:49:52 +0000 (13:49 +0200)
Steps to recreate were:
* Go into fullscreen mode (Alt+F10)
* Open debug menu (Ctrl+Alt+D)
* Set value to 1
* Confirming should crash (at least in debug builds)

source/blender/editors/screen/area.c

index 10be667f261eccfd1a5c0dafffccc4188f38f939..d0d19398f5b44b28e6386c676030546548865c21 100644 (file)
@@ -256,19 +256,18 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f
        if (G.debug_value == 1) {
                rcti click_rect;
                float icon_size = UI_DPI_ICON_SIZE + 7 * UI_DPI_FAC;
-               unsigned char alpha_debug = 255 * alpha;
 
                BLI_rcti_init(&click_rect, x, x + icon_size, y, y + icon_size);
 
                Gwn_VertFormat *format = immVertexFormat();
                unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-               unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
 
-               immAttrib4ub(color, 255, 0, 0, alpha_debug);
-               immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+               immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+               immUniformColor4f(1.0f, 0.0f, 0.0f, alpha);
                imm_draw_box_wire_2d(pos, click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax);
 
-               immAttrib4ub(color, 0, 255, 255, alpha_debug);
+               immUniformColor4f(0.0f, 1.0f, 1.0f, alpha);
                immBegin(GWN_PRIM_LINES, 4);
                immVertex2f(pos, click_rect.xmin, click_rect.ymin);
                immVertex2f(pos, click_rect.xmax, click_rect.ymax);