GLRefactor: partially remove gl calls from source/blender/editors.
authorRay Molenkamp <github@lazydodo.com>
Thu, 28 Jun 2018 01:07:23 +0000 (19:07 -0600)
committerRay Molenkamp <github@lazydodo.com>
Thu, 28 Jun 2018 01:07:23 +0000 (19:07 -0600)
This translates the gl calls to the new GPU_ wrappers from D3501.

Given it's tedious and repetitive work, this patch does as much as it can with search + replace, the remainder of the gl calls will need to be manually dealt with on a case by case basis.

This fixes 13 of the 28 failing editors when building without opengl.

For the list of substitutions see D3502

Reviewers: brecht

Differential Revision: https://developer.blender.org/D3502

82 files changed:
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_draw.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/animation/keyframes_draw.c
source/blender/editors/curve/editcurve_paint.c
source/blender/editors/gpencil/drawgpencil.c
source/blender/editors/gpencil/gpencil_brush.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_region_hud.c
source/blender/editors/interface/interface_region_search.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/resources.c
source/blender/editors/interface/view2d.c
source/blender/editors/manipulator_library/manipulator_draw_utils.c
source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c
source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c
source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c
source/blender/editors/mask/mask_draw.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/render/render_opengl.c
source/blender/editors/screen/area.c
source/blender/editors/screen/glutil.c
source/blender/editors/screen/screen_draw.c
source/blender/editors/screen/screendump.c
source/blender/editors/sculpt_paint/paint_cursor.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/sculpt_paint/sculpt_uv.c
source/blender/editors/space_action/action_draw.c
source/blender/editors/space_action/space_action.c
source/blender/editors/space_clip/clip_dopesheet_draw.c
source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_clip/clip_graph_draw.c
source/blender/editors/space_clip/clip_utils.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_console/space_console.c
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/space_file.c
source/blender/editors/space_graph/graph_draw.c
source/blender/editors/space_graph/space_graph.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_info/info_draw.c
source/blender/editors/space_info/space_info.c
source/blender/editors/space_info/textview.c
source/blender/editors/space_nla/nla_draw.c
source/blender/editors/space_nla/space_nla.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_ops.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_script/space_script.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_text/space_text.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/drawvolume.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_draw_legacy.c
source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
source/blender/editors/space_view3d/view3d_manipulator_ruler.c
source/blender/editors/space_view3d/view3d_ruler.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_constraints.c
source/blender/editors/transform/transform_snap.c
source/blender/editors/util/ed_util.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/editors/uvedit/uvedit_smart_stitch.c

index e4213a8d907c78bee60c2f19f6abdbe63c4e2c88..f0bde9dcdfbe17b5d9568893766190348b2268a0 100644 (file)
@@ -70,6 +70,7 @@
 #include "BKE_context.h"
 
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "DEG_depsgraph.h"
 
@@ -3832,8 +3833,8 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
                selected = 0;
 
        /* set blending again, as may not be set in previous step */
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-       glEnable(GL_BLEND);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
 
        /* step 1) draw backdrop ...........................................  */
        if (acf->draw_backdrop)
@@ -3852,7 +3853,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
        }
 
        /* turn off blending, since not needed anymore... */
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* step 4) draw special toggles  .................................
         *      - in Graph Editor, checkboxes for visibility in curves area
@@ -3930,7 +3931,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
                        /* FIXME: replace hardcoded color here, and check on extents! */
                        immUniformColor3f(1.0f, 0.0f, 0.0f);
 
-                       glLineWidth(2.0f);
+                       GPU_line_width(2.0f);
 
                        immBegin(GWN_PRIM_LINES, 2);
                        immVertex2f(pos, (float)offset, yminc);
index c2cfb877745db0b919587a99e02c6df4a1b72b87..953898a05869e501530650b35cd9871b6c768f2b 100644 (file)
@@ -64,6 +64,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 /* *************************************************** */
 /* CURRENT FRAME DRAWING */
@@ -138,7 +139,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
        const float time = scene->r.cfra + scene->r.subframe;
        const float x = (float)(time * scene->r.framelen);
 
-       glLineWidth((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);
+       GPU_line_width((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);
 
        Gwn_VertFormat *format = immVertexFormat();
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -166,8 +167,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
 
        /* only draw this if preview range is set */
        if (PRVRANGEON) {
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-               glEnable(GL_BLEND);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
 
                Gwn_VertFormat *format = immVertexFormat();
                unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -187,7 +188,7 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
 
                immUnbindProgram();
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 }
 
@@ -199,8 +200,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
 void ANIM_draw_framerange(Scene *scene, View2D *v2d)
 {
        /* draw darkened area outside of active timeline frame range */
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-       glEnable(GL_BLEND);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
 
        Gwn_VertFormat *format = immVertexFormat();
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -216,7 +217,7 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
                immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* thin lines where the actual frames are */
        immUniformThemeColorShade(TH_BACK, -60);
index c4fbc86a38979c6127547e734497e453fdce5a45..2815bc58d7a01144ff7e6450faa07d7fd12268f8 100644 (file)
@@ -61,6 +61,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "UI_interface.h"
 #include "UI_interface_icons.h"
@@ -389,8 +390,8 @@ static void draw_marker(
 #endif
        int icon_id;
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        /* vertical line - dotted */
 #ifdef DURIAN_CAMERA_SWITCH
@@ -405,7 +406,7 @@ static void draw_marker(
                immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
                float viewport_size[4];
-               glGetFloatv(GL_VIEWPORT, viewport_size);
+               GPU_viewport_size_getf(viewport_size);
                immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
                if (marker->flag & SELECT) {
@@ -444,7 +445,7 @@ static void draw_marker(
 
        UI_icon_draw(xpos - 0.45f * UI_DPI_ICON_SIZE, yoffs + UI_DPI_ICON_SIZE, icon_id);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* and the marker name too, shifted slightly to the top-right */
 #ifdef DURIAN_CAMERA_SWITCH
@@ -491,12 +492,12 @@ void ED_markers_draw(const bContext *C, int flag)
                const unsigned char shade[4] = {0, 0, 0, 16};
                immUniformColor4ubv(shade);
 
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                immRectf(pos, v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y);
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
 
                immUnbindProgram();
        }
index d137770394903649d4781944b3bfdbf0f9cf58d9..859eb05e7b9204491f7fa15eaceab8345841349d 100644 (file)
@@ -54,6 +54,7 @@
 
 #include "GPU_draw.h"
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "UI_resources.h"
 #include "UI_view2d.h"
@@ -561,7 +562,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
        const float icon_sz = U.widget_unit * 0.5f * yscale_fac;
        const float half_icon_sz = 0.5f * icon_sz;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        /* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */
        /* TODO: allow this opacity factor to be themed? */
@@ -654,7 +655,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
                }
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 /* *************************** Channel Drawing Funcs *************************** */
index 887f3dd13da78bbd68420bfd54d5fcb7a80a7c34..e679b04f25d02bf60217c2177fd0612415716b2b 100644 (file)
@@ -53,6 +53,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "curve_intern.h"
 
@@ -433,15 +434,15 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
                        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
                        immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
 
-                       glEnable(GL_BLEND);
-                       glEnable(GL_LINE_SMOOTH);
+                       GPU_blend(true);
+                       GPU_line_smooth(true);
 
                        imm_cpack(0x0);
                        immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
-                       glLineWidth(3.0f);
+                       GPU_line_width(3.0f);
 
                        if (v3d->zbuf) {
-                               glDisable(GL_DEPTH_TEST);
+                               GPU_depth_test(false);
                        }
 
                        for (int i = 0; i < stroke_len; i++) {
@@ -452,7 +453,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
 
                        imm_cpack(0xffffffff);
                        immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
-                       glLineWidth(1.0f);
+                       GPU_line_width(1.0f);
 
                        for (int i = 0; i < stroke_len; i++) {
                                immVertex3fv(pos, coord_array[i]);
@@ -461,11 +462,11 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
                        immEnd();
 
                        if (v3d->zbuf) {
-                               glEnable(GL_DEPTH_TEST);
+                               GPU_depth_test(true);
                        }
 
-                       glDisable(GL_BLEND);
-                       glDisable(GL_LINE_SMOOTH);
+                       GPU_blend(false);
+                       GPU_line_smooth(false);
 
                        immUnbindProgram();
                }
index a30cb5780463e7ab869507ea998140d3184e8431..a79a5052eb8e416c3732e27c1e7bdd5dfa179737 100644 (file)
@@ -64,6 +64,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_draw.h"
+#include "GPU_state.h"
 
 #include "ED_gpencil.h"
 #include "ED_screen.h"
@@ -215,7 +216,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
 
        if (totpoints == 1) {
                /* if drawing a single point, draw it larger */
-               glPointSize((float)(thickness + 2) * points->pressure);
+               GPU_point_size((float)(thickness + 2) * points->pressure);
                immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
                immBegin(GWN_PRIM_POINTS, 1);
                gp_set_tpoint_varying_color(pt, ink, color);
@@ -225,7 +226,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
                float oldpressure = points[0].pressure;
 
                /* draw stroke curve */
-               glLineWidth(max_ff(oldpressure * thickness, 1.0));
+               GPU_line_width(max_ff(oldpressure * thickness, 1.0));
                immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
                immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints);
 
@@ -245,7 +246,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
                                immEnd();
                                draw_points = 0;
 
-                               glLineWidth(max_ff(pt->pressure * thickness, 1.0f));
+                               GPU_line_width(max_ff(pt->pressure * thickness, 1.0f));
                                immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1);
 
                                /* need to roll-back one point to ensure that there are no gaps in the stroke */
@@ -625,7 +626,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
        /* TODO: implement this with a geometry shader to draw one continuous tapered stroke */
 
        /* draw stroke curve */
-       glLineWidth(max_ff(curpressure * thickness, 1.0f));
+       GPU_line_width(max_ff(curpressure * thickness, 1.0f));
        immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints + cyclic_add);
        const bGPDspoint *pt = points;
        for (int i = 0; i < totpoints; i++, pt++) {
@@ -646,7 +647,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi
                        draw_points = 0;
 
                        curpressure = pt->pressure;
-                       glLineWidth(max_ff(curpressure * thickness, 1.0f));
+                       GPU_line_width(max_ff(curpressure * thickness, 1.0f));
                        immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
 
                        /* need to roll-back one point to ensure that there are no gaps in the stroke */
@@ -941,7 +942,7 @@ static void gp_draw_strokes(
                        if (no_xray) {
                                glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
                                glDepthMask(0);
-                               glEnable(GL_DEPTH_TEST);
+                               GPU_depth_test(true);
 
                                /* first arg is normally rv3d->dist, but this isn't
                                 * available here and seems to work quite well without */
@@ -1005,7 +1006,7 @@ static void gp_draw_strokes(
                        }
                        if (no_xray) {
                                glDepthMask(mask_orig);
-                               glDisable(GL_DEPTH_TEST);
+                               GPU_depth_test(false);
 
                                bglPolygonOffset(0.0, 0.0);
                        }
@@ -1090,7 +1091,7 @@ static void gp_draw_strokes_edit(
                if (no_xray) {
                        glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
                        glDepthMask(0);
-                       glEnable(GL_DEPTH_TEST);
+                       GPU_depth_test(true);
 
                        /* first arg is normally rv3d->dist, but this isn't
                         * available here and seems to work quite well without */
@@ -1215,7 +1216,7 @@ static void gp_draw_strokes_edit(
        if (dflag & GP_DRAWDATA_ONLY3D) {
                if (no_xray) {
                        glDepthMask(mask_orig);
-                       glDisable(GL_DEPTH_TEST);
+                       GPU_depth_test(false);
 
                        bglPolygonOffset(0.0, 0.0);
 #if 0
@@ -1329,7 +1330,7 @@ void ED_gp_draw_interpolation(tGPDinterpolate *tgpi, const int type)
        }
 
        /* turn on alpha-blending */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) {
                /* calculate parent position */
                ED_gpencil_parent_location(tgpil->gpl, diff_mat);
@@ -1338,7 +1339,7 @@ void ED_gp_draw_interpolation(tGPDinterpolate *tgpi, const int type)
                                tgpil->gpl->thickness, 1.0f, color, true, true, diff_mat);
                }
        }
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 /* loop over gpencil data layers, drawing them */
@@ -1365,7 +1366,7 @@ static void gp_draw_data_layers(
                        continue;
 
                /* set basic stroke thickness */
-               glLineWidth(lthick);
+               GPU_line_width(lthick);
 
                /* Add layer drawing settings to the set of "draw flags"
                 * NOTE: If the setting doesn't apply, it *must* be cleared,
@@ -1479,15 +1480,15 @@ static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar)
 
                /* grease pencil icon... */
                // XXX: is this too intrusive?
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-               glEnable(GL_BLEND);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
 
                xco -= U.widget_unit;
                yco -= (int)printable_size[1] / 2;
 
                UI_icon_draw(xco, yco, ICON_GREASEPENCIL);
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 }
 
@@ -1497,7 +1498,7 @@ static void gp_draw_data(
         int offsx, int offsy, int winx, int winy, int cfra, int dflag)
 {
        /* turn on smooth lines (i.e. anti-aliasing) */
-       glEnable(GL_LINE_SMOOTH);
+       GPU_line_smooth(true);
 
        /* XXX: turn on some way of ensuring that the polygon edges get smoothed
         *      GL_POLYGON_SMOOTH is nasty and shouldn't be used, as it ends up
@@ -1505,15 +1506,15 @@ static void gp_draw_data(
         */
 
        /* turn on alpha-blending */
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-       glEnable(GL_BLEND);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
 
        /* draw! */
        gp_draw_data_layers(brush, alpha, gpd, offsx, offsy, winx, winy, cfra, dflag);
 
        /* turn off alpha blending, then smooth lines */
-       glDisable(GL_BLEND); // alpha blending
-       glDisable(GL_LINE_SMOOTH); // smooth lines
+       GPU_blend(false); // alpha blending
+       GPU_line_smooth(false); // smooth lines
 }
 
 /* if we have strokes for scenes (3d view)/clips (movie clip editor)
index 5eb3321b414cd396a804bb985564a4b1d59da76e..d877ea03c5d446568ca7cdec7a0d346bf83116da 100644 (file)
@@ -78,6 +78,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
+#include "GPU_state.h"
 
 #include "gpencil_intern.h"
 
@@ -988,8 +989,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda
                unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-               glEnable(GL_LINE_SMOOTH);
-               glEnable(GL_BLEND);
+               GPU_line_smooth(true);
+               GPU_blend(true);
 
                /* Inner Ring: Light color for action of the brush */
                /* TODO: toggle between add and remove? */
@@ -1002,8 +1003,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda
 
                immUnbindProgram();
 
-               glDisable(GL_BLEND);
-               glDisable(GL_LINE_SMOOTH);
+               GPU_blend(false);
+               GPU_line_smooth(false);
        }
 }
 
index 800c899f9c2081209f0b7cfec4f3d60237df3c19..0ae45a9fde825e5d1c8522db4481f8fa44d652c2 100644 (file)
@@ -73,6 +73,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
+#include "GPU_state.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -1878,9 +1879,9 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
                const uint shdr_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-               glEnable(GL_LINE_SMOOTH);
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_line_smooth(true);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                immUniformColor4ub(255, 100, 100, 20);
                imm_draw_circle_fill_2d(shdr_pos, x, y, p->radius, 40);
@@ -1890,7 +1891,7 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
                immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
                float viewport_size[4];
-               glGetFloatv(GL_VIEWPORT, viewport_size);
+               GPU_viewport_size_getf(viewport_size);
                immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
 
                immUniformColor4f(1.0f, 0.39f, 0.39f, 0.78f);
@@ -1905,8 +1906,8 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
 
                immUnbindProgram();
 
-               glDisable(GL_BLEND);
-               glDisable(GL_LINE_SMOOTH);
+               GPU_blend(false);
+               GPU_line_smooth(false);
        }
 }
 
index a36f534807cd9d6d22778f6cce98e247ffd910d8..f4c4b8afc949f51eb9c5f5d8044446df86aa22a5 100644 (file)
@@ -61,6 +61,7 @@
 
 #include "GPU_glew.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "BLF_api.h"
 #include "BLT_translation.h"
@@ -1381,7 +1382,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
                UI_block_end(C, block);
 
        /* we set this only once */
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        /* scale fonts */
        ui_fontscale(&style.paneltitle.points, block->aspect);
index f093f47519c522cfc29e2862746fa5067dd075a0..ab85a3d5326c7956a82c9321651da11436d572ca 100644 (file)
@@ -58,6 +58,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "UI_interface.h"
 
@@ -119,7 +120,7 @@ void UI_draw_roundbox_aa(bool filled, float minx, float miny, float maxx, float
                .alpha_discard = 1.0f,
        };
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        if (filled) {
                /* plain antialiased filled box */
@@ -135,17 +136,17 @@ void UI_draw_roundbox_aa(bool filled, float minx, float miny, float maxx, float
        }
        else {
                /* plain antialiased unfilled box */
-               glEnable(GL_LINE_SMOOTH);
+               GPU_line_smooth(true);
 
                Gwn_Batch *batch = ui_batch_roundbox_get(filled, false);
                GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
                GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params);
                GWN_batch_draw(batch);
 
-               glDisable(GL_LINE_SMOOTH);
+               GPU_line_smooth(false);
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float maxy, float rad, const float col[4])
@@ -645,12 +646,12 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
        /* scissor doesn't seem to be doing the right thing...? */
 #if 0
        /* prevent drawing outside widget area */
-       GLint scissor[4];
-       glGetIntegerv(GL_SCISSOR_BOX, scissor);
-       glScissor(rect->xmin, rect->ymin, w, h);
+       int scissor[4];
+       GPU_scissor_geti(scissor);
+       GPU_scissor(rect->xmin, rect->ymin, w, h);
 #endif
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        if (w != ibuf->x || h != ibuf->y) {
                facx = (float)w / (float)ibuf->x;
@@ -661,11 +662,11 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
        immDrawPixelsTex(&state, (float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect,
                         facx, facy, NULL);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
 #if 0
        // restore scissortest
-       glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+       GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
 #endif
 
 #endif
@@ -710,9 +711,9 @@ void UI_draw_safe_areas(
 static void draw_scope_end(const rctf *rect, GLint *scissor)
 {
        /* restore scissortest */
-       glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+       GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
 
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        /* outline */
        UI_draw_roundbox_corner_set(UI_CNR_ALL);
@@ -731,14 +732,14 @@ static void histogram_draw_one(
        if (res == 0)
                return;
 
-       glEnable(GL_LINE_SMOOTH);
+       GPU_line_smooth(true);
        glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE);
 
        immUniformColor4fv(color);
 
        if (is_line) {
                /* curve outline */
-               glLineWidth(1.5);
+               GPU_line_width(1.5);
 
                immBegin(GWN_PRIM_LINE_STRIP, res);
                for (int i = 0; i < res; i++) {
@@ -762,7 +763,7 @@ static void histogram_draw_one(
                /* curve outline */
                immUniformColor4f(0.0f, 0.0f, 0.0f, 0.25f);
 
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
                immBegin(GWN_PRIM_LINE_STRIP, res);
                for (int i = 0; i < res; i++) {
                        float x2 = x + i * (w / (float)res);
@@ -771,7 +772,7 @@ static void histogram_draw_one(
                immEnd();
        }
 
-       glDisable(GL_LINE_SMOOTH);
+       GPU_line_smooth(false);
 }
 
 #define HISTOGRAM_TOT_GRID_LINES 4
@@ -792,8 +793,8 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS
        float w = BLI_rctf_size_x(&rect);
        float h = BLI_rctf_size_y(&rect) * hist->ymax;
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        float color[4];
        UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
@@ -801,9 +802,9 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS
        UI_draw_roundbox_4fv(true, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
 
        /* need scissor test, histogram can draw outside of boundary */
-       GLint scissor[4];
-       glGetIntegerv(GL_SCISSOR_BOX, scissor);
-       glScissor((rect.xmin - 1),
+       int scissor[4];
+       GPU_scissor_geti(scissor);
+       GPU_scissor((rect.xmin - 1),
                  (rect.ymin - 1),
                  (rect.xmax + 1) - (rect.xmin - 1),
                  (rect.ymax + 1) - (rect.ymin - 1));
@@ -879,7 +880,7 @@ static void waveform_draw_one(float *waveform, int nbr, const float col[3])
 void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti)
 {
        Scopes *scopes = (Scopes *)but->poin;
-       GLint scissor[4];
+       int scissor[4];
        float colors[3][3];
        float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}};
        float colors_alpha[3][3], colorsycc_alpha[3][3]; /* colors  pre multiplied by alpha for speed up */
@@ -916,8 +917,8 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
        /* Flush text cache before changing scissors. */
        BLF_batch_draw_flush();
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        float color[4];
        UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
@@ -925,8 +926,8 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
        UI_draw_roundbox_4fv(true, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
 
        /* need scissor test, waveform can draw outside of boundary */
-       glGetIntegerv(GL_SCISSOR_BOX, scissor);
-       glScissor((rect.xmin - 1),
+       GPU_scissor_geti(scissor);
+       GPU_scissor((rect.xmin - 1),
                  (rect.ymin - 1),
                  (rect.xmax + 1) - (rect.xmin - 1),
                  (rect.ymax + 1) - (rect.ymin - 1));
@@ -943,8 +944,8 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
        /* Flush text cache before drawing things on top. */
        BLF_batch_draw_flush();
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        Gwn_VertFormat *format = immVertexFormat();
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -1010,7 +1011,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
 
        if (scopes->ok && scopes->waveform_1 != NULL) {
                glBlendFunc(GL_ONE, GL_ONE);
-               glPointSize(1.0);
+               GPU_point_size(1.0);
 
                /* LUMA (1 channel) */
                if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
@@ -1098,7 +1099,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE
        /* outline */
        draw_scope_end(&rect, scissor);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static float polar_to_x(float center, float diam, float ampli, float angle)
@@ -1187,8 +1188,8 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
 
        float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha;
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        float color[4];
        UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
@@ -1196,9 +1197,9 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
        UI_draw_roundbox_4fv(true, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
 
        /* need scissor test, hvectorscope can draw outside of boundary */
-       GLint scissor[4];
-       glGetIntegerv(GL_SCISSOR_BOX, scissor);
-       glScissor((rect.xmin - 1),
+       int scissor[4];
+       GPU_scissor_geti(scissor);
+       GPU_scissor((rect.xmin - 1),
                  (rect.ymin - 1),
                  (rect.xmax + 1) - (rect.xmin - 1),
                  (rect.ymax + 1) - (rect.ymin - 1));
@@ -1249,7 +1250,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
                float col[3] = {alpha, alpha, alpha};
 
                glBlendFunc(GL_ONE, GL_ONE);
-               glPointSize(1.0);
+               GPU_point_size(1.0);
 
                gpuPushMatrix();
                gpuTranslate2f(centerx, centery);
@@ -1265,12 +1266,12 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN
        /* outline */
        draw_scope_end(&rect, scissor);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void ui_draw_colorband_handle_tri_hlight(unsigned int pos, float x1, float y1, float halfwidth, float height)
 {
-       glEnable(GL_LINE_SMOOTH);
+       GPU_line_smooth(true);
 
        immBegin(GWN_PRIM_LINE_STRIP, 3);
        immVertex2f(pos, x1 + halfwidth, y1);
@@ -1278,7 +1279,7 @@ static void ui_draw_colorband_handle_tri_hlight(unsigned int pos, float x1, floa
        immVertex2f(pos, x1 - halfwidth, y1);
        immEnd();
 
-       glDisable(GL_LINE_SMOOTH);
+       GPU_line_smooth(false);
 }
 
 static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, float halfwidth, float height, bool fill)
@@ -1329,7 +1330,7 @@ static void ui_draw_colorband_handle(
                immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
                float viewport_size[4];
-               glGetFloatv(GL_VIEWPORT, viewport_size);
+               GPU_viewport_size_getf(viewport_size);
                immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
                immUniform1i("num_colors", 2);  /* "advanced" mode */
@@ -1358,7 +1359,7 @@ static void ui_draw_colorband_handle(
        ui_draw_colorband_handle_box(shdr_pos, x - half_width, y1 - 1, x + half_width, y1 + height, false);
 
        /* draw all triangles blended */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        ui_draw_colorband_handle_tri(shdr_pos, x, y1 + height, half_width, half_width, true);
 
@@ -1377,7 +1378,7 @@ static void ui_draw_colorband_handle(
        immUniformColor3ub(0, 0, 0);
        ui_draw_colorband_handle_tri_hlight(shdr_pos, x, y1 + height, half_width, half_width);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        immUniformColor3ub(128, 128, 128);
        ui_draw_colorband_handle_box(shdr_pos, x - (half_width - 1), y1, x + (half_width - 1), y1 + height, true);
@@ -1425,7 +1426,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
        immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
 
        /* layer: color ramp */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        CBData *cbd = coba->data;
 
@@ -1471,7 +1472,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
 
        immUnbindProgram();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* New format */
        format = immVertexFormat();
@@ -1483,7 +1484,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
        imm_draw_box_wire_2d(position, x1, y1, x1 + sizex, rect->ymax);
 
        /* layer: box outline */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
 
        immBegin(GWN_PRIM_LINES, 2);
@@ -1498,7 +1499,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
        immVertex2f(position, x1 + sizex, y1 - 1);
        immEnd();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* layer: draw handles */
        for (int a = 0; a < coba->tot; a++, cbd++) {
@@ -1561,11 +1562,11 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
        immUniformColor3ubv((unsigned char *)wcol->inner);
 
-       glEnable(GL_BLEND);
-       glEnable(GL_LINE_SMOOTH);
+       GPU_blend(true);
+       GPU_line_smooth(true);
        imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, 1.0f, 32);
-       glDisable(GL_BLEND);
-       glDisable(GL_LINE_SMOOTH);
+       GPU_blend(false);
+       GPU_line_smooth(false);
 
        /* matrix after circle */
        gpuPopMatrix();
@@ -1622,8 +1623,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
        CurveMap *cuma = &cumap->cm[cumap->cur];
 
        /* need scissor test, curve can draw outside of boundary */
-       GLint scissor[4];
-       glGetIntegerv(GL_SCISSOR_BOX, scissor);
+       int scissor[4];
+       GPU_scissor_geti(scissor);
        rcti scissor_new = {
                .xmin = rect->xmin,
                .ymin = rect->ymin,
@@ -1632,7 +1633,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
        };
        rcti scissor_region = {0, ar->winx, 0, ar->winy};
        BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
-       glScissor(scissor_new.xmin,
+       GPU_scissor(scissor_new.xmin,
                  scissor_new.ymin,
                  BLI_rcti_size_x(&scissor_new),
                  BLI_rcti_size_y(&scissor_new));
@@ -1658,7 +1659,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
                ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f);
        }
 
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        Gwn_VertFormat *format = immVertexFormat();
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -1667,11 +1668,11 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
        /* backdrop */
        if (but->a1 == UI_GRAD_H) {
                /* grid, hsv uses different grid */
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
                immUniformColor4ub(0, 0, 0, 48);
                ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 0.1666666f);
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
        else {
                if (cumap->flag & CUMA_DO_CLIP) {
@@ -1752,8 +1753,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
 
        /* the curve */
        immUniformColor3ubv((unsigned char *)wcol->item);
-       glEnable(GL_LINE_SMOOTH);
-       glEnable(GL_BLEND);
+       GPU_line_smooth(true);
+       GPU_blend(true);
        immBegin(GWN_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2);
 
        if (cuma->table == NULL)
@@ -1785,8 +1786,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
                immVertex2f(pos, fx, fy);
        }
        immEnd();
-       glDisable(GL_LINE_SMOOTH);
-       glDisable(GL_BLEND);
+       GPU_line_smooth(false);
+       GPU_blend(false);
        immUnbindProgram();
 
        /* the points, use aspect to make them visible on edges */
@@ -1796,7 +1797,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
        immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
 
        cmp = cuma->curve;
-       glPointSize(3.0f);
+       GPU_point_size(3.0f);
        immBegin(GWN_PRIM_POINTS, cuma->totpoint);
        for (int a = 0; a < cuma->totpoint; a++) {
                float color[4];
@@ -1813,7 +1814,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
        immUnbindProgram();
 
        /* restore scissortest */
-       glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+       GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
 
        /* outline */
        format = immVertexFormat();
@@ -1841,13 +1842,13 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
        int width  = BLI_rctf_size_x(&rect) + 1;
        int height = BLI_rctf_size_y(&rect);
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        /* need scissor test, preview image can draw outside of boundary */
-       GLint scissor[4];
-       glGetIntegerv(GL_SCISSOR_BOX, scissor);
-       glScissor((rect.xmin - 1),
+       int scissor[4];
+       GPU_scissor_geti(scissor);
+       GPU_scissor((rect.xmin - 1),
                  (rect.ymin - 1),
                  (rect.xmax + 1) - (rect.xmin - 1),
                  (rect.ymax + 1) - (rect.ymin - 1));
@@ -1885,7 +1886,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
                gpuPushMatrix();
 
                /* draw content of pattern area */
-               glScissor(rect.xmin, rect.ymin, scissor[2], scissor[3]);
+               GPU_scissor(rect.xmin, rect.ymin, scissor[2], scissor[3]);
 
                if (width > 0 && height > 0) {
                        ImBuf *drawibuf = scopes->track_preview;
@@ -1902,7 +1903,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
 
                        /* draw cross for pixel position */
                        gpuTranslate2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]);
-                       glScissor(rect.xmin,
+                       GPU_scissor(rect.xmin,
                                  rect.ymin,
                                  BLI_rctf_size_x(&rect),
                                  BLI_rctf_size_y(&rect));
@@ -1953,7 +1954,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U
        /* outline */
        draw_scope_end(&rect, scissor);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti)
@@ -1975,10 +1976,10 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
            0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f,
        };
 
-       GLint scissor[4];
+       int scissor[4];
 
        /* need scissor test, can draw outside of boundary */
-       glGetIntegerv(GL_SCISSOR_BOX, scissor);
+       GPU_scissor_geti(scissor);
 
        rcti scissor_new = {
                .xmin = recti->xmin,
@@ -1990,7 +1991,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
        rcti scissor_region = {0, ar->winx, 0, ar->winy};
 
        BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
-       glScissor(scissor_new.xmin,
+       GPU_scissor(scissor_new.xmin,
                  scissor_new.ymin,
                  BLI_rcti_size_x(&scissor_new),
                  BLI_rcti_size_y(&scissor_new));
@@ -2003,26 +2004,26 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
        immUniformColor4ubv(but->col);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        immBegin(GWN_PRIM_TRI_FAN, 16);
        for (int a = 0; a < 16; a++)
                immVertex2f(pos, x + size * si[a], y + size * co[a]);
        immEnd();
 
        immUniformColor4ub(0, 0, 0, 150);
-       glLineWidth(1);
-       glEnable(GL_LINE_SMOOTH);
+       GPU_line_width(1);
+       GPU_line_smooth(true);
        immBegin(GWN_PRIM_LINE_LOOP, 16);
        for (int a = 0; a < 16; a++)
                immVertex2f(pos, x + size * si[a], y + size * co[a]);
        immEnd();
-       glDisable(GL_LINE_SMOOTH);
-       glDisable(GL_BLEND);
+       GPU_line_smooth(false);
+       GPU_blend(false);
 
        immUnbindProgram();
 
        /* restore scissortest */
-       glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+       GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
 }
 
 /* ****************************************************** */
@@ -2093,7 +2094,7 @@ static void ui_shadowbox(unsigned pos, unsigned color, float minx, float miny, f
 
 void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy)
 {
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        Gwn_VertFormat *format = immVertexFormat();
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -2112,7 +2113,7 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
 
        immUnbindProgram();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 
@@ -2136,7 +2137,7 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha
                a = i * aspect;
        }
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        const float dalpha = alpha * 2.0f / 255.0f;
        float calpha = dalpha;
        float visibility = 1.0f;
@@ -2173,10 +2174,10 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha
        GWN_batch_draw(batch);
 
        /* outline emphasis */
-       glEnable(GL_LINE_SMOOTH);
+       GPU_line_smooth(true);
        float color[4] = {0.0f, 0.0f, 0.0f, 0.4f};
        UI_draw_roundbox_4fv(false, rct->xmin - 0.5f, rct->ymin - 0.5f, rct->xmax + 0.5f, rct->ymax + 0.5f, radius + 0.5f, color);
-       glDisable(GL_LINE_SMOOTH);
+       GPU_line_smooth(false);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
index a8feaedf7170e84ad8f07eb85c637d89b7aa769b..083f94a41b2e5f586b1c38ca1f016ef9a67ed4d7 100644 (file)
@@ -37,6 +37,7 @@
 #include "GPU_matrix.h"
 #include "GPU_batch.h"
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
@@ -1106,10 +1107,10 @@ static void icon_draw_cache_flush_ex(void)
                return;
 
        /* We need to flush widget base first to ensure correct ordering. */
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
        UI_widgetbase_draw_cache_flush();
 
-       glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, icongltex.id);
@@ -1139,12 +1140,12 @@ void UI_icon_draw_cache_end(void)
        if (g_icon_draw_cache.calls == 0)
                return;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        icon_draw_cache_flush_ex();
 
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-       glDisable(GL_BLEND);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(false);
 }
 
 static void icon_draw_texture_cached(
@@ -1187,7 +1188,7 @@ static void icon_draw_texture(
        }
 
        /* We need to flush widget base first to ensure correct ordering. */
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
        UI_widgetbase_draw_cache_flush();
 
        float x1, x2, y1, y2;
@@ -1291,14 +1292,14 @@ static void icon_draw_size(
                }
                glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
                icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, rgb, desaturate);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
        }
        else if (di->type == ICON_TYPE_TEXTURE) {
                /* texture image use premul alpha for correct scaling */
-               glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
                icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y,
                                  di->data.texture.w, di->data.texture.h, alpha, rgb);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
        }
        else if (di->type == ICON_TYPE_BUFFER) {
                /* it is a builtin icon */
@@ -1308,9 +1309,9 @@ static void icon_draw_size(
 #endif
                if (!iimg->rect) return;  /* something has gone wrong! */
 
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
                icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, desaturate);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
        }
        else if (di->type == ICON_TYPE_PREVIEW) {
                PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : icon->obj;
@@ -1320,10 +1321,10 @@ static void icon_draw_size(
                        if (!pi->rect[size]) return;  /* something has gone wrong! */
 
                        /* preview images use premul alpha ... */
-                       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+                       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                        icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, rgb, desaturate);
-                       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+                       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
                }
        }
 }
index 5d02968581002a3ec0f23ec3d41ec0099a30292f..1e3a080c097072286dadbdf1b7ea94e6997c7e0f 100644 (file)
@@ -63,6 +63,7 @@
 #include "UI_resources.h"
 
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "interface_intern.h"
 
@@ -486,10 +487,10 @@ static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float
 {
 
        /* set antialias line */
-       glEnable(GL_LINE_SMOOTH);
-       glEnable(GL_BLEND);
+       GPU_line_smooth(true);
+       GPU_blend(true);
 
-       glLineWidth(2.0);
+       GPU_line_width(2.0);
 
        immBegin(GWN_PRIM_LINES, 4);
 
@@ -501,8 +502,8 @@ static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float
 
        immEnd();
 
-       glDisable(GL_LINE_SMOOTH);
-       glDisable(GL_BLEND);
+       GPU_line_smooth(false);
+       GPU_blend(false);
 
 }
 
@@ -529,7 +530,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect)
        dx = 0.5f * (xmax - xmin);
        dy = 0.5f * (ymax - ymin);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        immUniformColor4ub(255, 255, 255, 50);
 
        immBegin(GWN_PRIM_LINES, 4);
@@ -554,7 +555,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect)
 
        immEnd();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void immRectf_tris_color_ex(unsigned int pos, float x1, float y1, float x2, float y2,
@@ -696,7 +697,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
                float maxx = is_closed_x ? (minx + PNL_HEADER / block->aspect) : rect->xmax;
                float y = headrect.ymax;
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                if (UI_GetThemeValue(TH_PANEL_SHOW_HEADER)) {
                        /* draw with background color */
@@ -736,7 +737,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
                        immEnd();
                }
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        immUnbindProgram();
@@ -749,11 +750,11 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
        if (show_pin)
 #endif
        {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                UI_icon_draw_aspect(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect), headrect.ymin + (5.0f / block->aspect),
                                    (panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED,
                                    (block->aspect / UI_DPI_FAC), 1.0f);
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
 
@@ -809,12 +810,12 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
 
                /* panel backdrop */
                if (is_subpanel) {
-                       glEnable(GL_BLEND);
+                       GPU_blend(true);
                        immUniformThemeColor(TH_PANEL_SUB_BACK);
                        immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
                }
                else if (UI_GetThemeValue(TH_PANEL_SHOW_BACK)) {
-                       glEnable(GL_BLEND);
+                       GPU_blend(true);
                        immUniformThemeColor(TH_PANEL_BACK);
                        immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
                }
@@ -1959,14 +1960,14 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
 
 
        /* begin drawing */
-       glEnable(GL_LINE_SMOOTH);
+       GPU_line_smooth(true);
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
        /* draw the background */
        if (is_alpha) {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                immUniformColor4ubv(theme_col_tab_bg);
        }
        else {
@@ -1976,7 +1977,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
        immRecti(pos, v2d->mask.xmin, v2d->mask.ymin, v2d->mask.xmin + category_tabs_width, v2d->mask.ymax);
 
        if (is_alpha) {
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        immUnbindProgram();
@@ -1997,7 +1998,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
                }
 #endif
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
 #ifdef USE_FLAT_INACTIVE
                if (is_active)
@@ -2047,7 +2048,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
                /* main tab title */
                BLF_draw(fontid, category_id_draw, category_draw_len);
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
 
                /* tab blackline remaining (last tab) */
                pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
@@ -2085,7 +2086,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
                pc_dyn->rect.xmin = v2d->mask.xmin;
        }
 
-       glDisable(GL_LINE_SMOOTH);
+       GPU_line_smooth(false);
 
        BLF_disable(fontid, BLF_ROTATION);
 
index 1a49010ad9d23f7f89f657878bae15387acd897f..3ac9932fdc9cc8d4ac7f2d00e3427473aee8a4bf 100644 (file)
@@ -60,6 +60,7 @@
 #include "ED_undo.h"
 
 #include "interface_intern.h"
+#include "GPU_framebuffer.h"
 
 
 /* -------------------------------------------------------------------- */
@@ -194,8 +195,8 @@ static void hud_region_draw(const bContext *C, ARegion *ar)
 {
        UI_view2d_view_ortho(&ar->v2d);
        wmOrtho2_region_pixelspace(ar);
-       glClearColor(0, 0, 0, 0.0f);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear_color(0, 0, 0, 0.0f);
+       GPU_clear(GPU_COLOR_BIT);
 
        if ((ar->flag & RGN_FLAG_HIDDEN) == 0) {
                float color[4];
index e0dc149be17b3d281e710731e0f55748b4e07967..257455be27ed92493dd43ad747411ed817872198 100644 (file)
@@ -64,6 +64,7 @@
 
 #include "interface_intern.h"
 #include "interface_regions_intern.h"
+#include "GPU_state.h"
 
 #define MENU_BORDER                    (int)(0.3f * U.widget_unit)
 
@@ -429,15 +430,15 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *ar)
                        /* indicate more */
                        if (data->items.more) {
                                ui_searchbox_butrect(&rect, data, data->items.maxitem - 1);
-                               glEnable(GL_BLEND);
+                               GPU_blend(true);
                                UI_icon_draw(rect.xmax - 18, rect.ymin - 7, ICON_TRIA_DOWN);
-                               glDisable(GL_BLEND);
+                               GPU_blend(false);
                        }
                        if (data->items.offset) {
                                ui_searchbox_butrect(&rect, data, 0);
-                               glEnable(GL_BLEND);
+                               GPU_blend(true);
                                UI_icon_draw(rect.xmin, rect.ymax - 9, ICON_TRIA_UP);
-                               glDisable(GL_BLEND);
+                               GPU_blend(false);
                        }
 
                }
@@ -454,15 +455,15 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *ar)
                        /* indicate more */
                        if (data->items.more) {
                                ui_searchbox_butrect(&rect, data, data->items.maxitem - 1);
-                               glEnable(GL_BLEND);
+                               GPU_blend(true);
                                UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN);
-                               glDisable(GL_BLEND);
+                               GPU_blend(false);
                        }
                        if (data->items.offset) {
                                ui_searchbox_butrect(&rect, data, 0);
-                               glEnable(GL_BLEND);
+                               GPU_blend(true);
                                UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP);
-                               glDisable(GL_BLEND);
+                               GPU_blend(false);
                        }
                }
        }
@@ -732,15 +733,15 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe
                /* indicate more */
                if (data->items.more) {
                        ui_searchbox_butrect(&rect, data, data->items.maxitem - 1);
-                       glEnable(GL_BLEND);
+                       GPU_blend(true);
                        UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN);
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
                }
                if (data->items.offset) {
                        ui_searchbox_butrect(&rect, data, 0);
-                       glEnable(GL_BLEND);
+                       GPU_blend(true);
                        UI_icon_draw((BLI_rcti_size_x(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP);
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
                }
        }
 }
index 4eb3724e2422ed5b68f24f173a49d2b6b74e0709..3a96d22ffb947a4668d184f87dda5c330f6f97e0 100644 (file)
@@ -58,6 +58,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #ifdef WITH_INPUT_IME
 #  include "WM_types.h"
@@ -509,7 +510,7 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
        /* Note: This won't give back the original color. */
        draw_color[3] *= 1.0f / WIDGET_AA_JITTER;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -528,7 +529,7 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
 
        immUnbindProgram();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float color[4])
@@ -538,7 +539,7 @@ void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float col
        copy_v4_v4(draw_color, color);
        draw_color[3] *= 2.0f / WIDGET_AA_JITTER;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -562,7 +563,7 @@ void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float col
 
        immUnbindProgram();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void widget_init(uiWidgetBase *wtb)
@@ -1109,11 +1110,11 @@ void UI_widgetbase_draw_cache_end(void)
        BLI_assert(g_widget_base_batch.enabled == true);
        g_widget_base_batch.enabled = false;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        UI_widgetbase_draw_cache_flush();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb)
@@ -1169,7 +1170,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, const uiWidgetColors *wcol)
        /* For color widget. */
        bool alpha_check = (wcol->alpha_check && (wcol->shaded == 0));
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        /* backdrop non AA */
        if (wtb->draw_inner) {
@@ -1213,7 +1214,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, const uiWidgetColors *wcol)
                draw_widgetbase_batch(roundbox_batch, wtb);
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 /* *********************** text/icon ************************************** */
@@ -1258,9 +1259,9 @@ static void widget_draw_icon_ex(
        float aspect, height;
 
        if (but->flag & UI_BUT_ICON_PREVIEW) {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                widget_draw_preview(icon, alpha, rect);
-               glDisable(GL_BLEND);
+               GPU_blend(false);
                return;
        }
 
@@ -1288,7 +1289,7 @@ static void widget_draw_icon_ex(
                }
        }
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        if (icon && icon != ICON_BLANK1) {
                float ofs = 1.0f / aspect;
@@ -1334,7 +1335,7 @@ static void widget_draw_icon_ex(
                UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, aspect, alpha);
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void widget_draw_icon(
@@ -1785,9 +1786,9 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
 
                        if (drawstr[0] != 0) {
                                /* We are drawing on top of widget bases. Flush cache. */
-                               glEnable(GL_BLEND);
+                               GPU_blend(true);
                                UI_widgetbase_draw_cache_flush();
-                               glDisable(GL_BLEND);
+                               GPU_blend(false);
 
                                if (but->selsta >= but->ofs) {
                                        selsta_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selsta - but->ofs);
@@ -1830,9 +1831,9 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
                                t = 0;
                        }
                        /* We are drawing on top of widget bases. Flush cache. */
-                       glEnable(GL_BLEND);
+                       GPU_blend(true);
                        UI_widgetbase_draw_cache_flush();
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
 
                        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
                        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1995,9 +1996,9 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
 
                /* draw icon in rect above the space reserved for the label */
                rect->ymin += text_size;
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                widget_draw_preview(icon, alpha, rect);
-               glDisable(GL_BLEND);
+               GPU_blend(false);
 
                /* offset rect to draw label in */
                rect->ymin -= text_size;
@@ -2413,14 +2414,14 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
                rect->ymax += 0.1f * U.widget_unit;
        }
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        widget_softshadow(rect, roundboxalign, wcol->roundness * U.widget_unit);
 
        round_box_edges(&wtb, roundboxalign, rect, wcol->roundness * U.widget_unit);
        wtb.draw_emboss = false;
        widgetbase_draw(&wtb, wcol);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void ui_hsv_cursor(float x, float y)
@@ -2432,12 +2433,12 @@ static void ui_hsv_cursor(float x, float y)
        immUniformColor3f(1.0f, 1.0f, 1.0f);
        imm_draw_circle_fill_2d(pos, x, y, 3.0f * U.pixelsize, 8);
 
-       glEnable(GL_BLEND);
-       glEnable(GL_LINE_SMOOTH);
+       GPU_blend(true);
+       GPU_line_smooth(true);
        immUniformColor3f(0.0f, 0.0f, 0.0f);
        imm_draw_circle_wire_2d(pos, x, y, 3.0f * U.pixelsize, 12);
-       glDisable(GL_BLEND);
-       glDisable(GL_LINE_SMOOTH);
+       GPU_blend(false);
+       GPU_line_smooth(false);
 
        immUnbindProgram();
 }
@@ -2551,16 +2552,16 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
 
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-       glEnable(GL_BLEND);
-       glEnable(GL_LINE_SMOOTH);
+       GPU_blend(true);
+       GPU_line_smooth(true);
 
        immUniformColor3ubv((unsigned char *)wcol->outline);
        imm_draw_circle_wire_2d(pos, centx, centy, radius, tot);
 
        immUnbindProgram();
 
-       glDisable(GL_BLEND);
-       glDisable(GL_LINE_SMOOTH);
+       GPU_blend(false);
+       GPU_line_smooth(false);
 
        /* cursor */
        float xpos, ypos;
@@ -2851,9 +2852,9 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
        );
 
        /* We are drawing on top of widget bases. Flush cache. */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        UI_widgetbase_draw_cache_flush();
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* cursor */
        x = rect->xmin + 0.5f * BLI_rcti_size_x(rect);
@@ -2872,9 +2873,9 @@ static void ui_draw_roundbox(const rcti *rect, const float rad, const uiWidgetCo
        widgetbase_draw(&wtb, wcol);
 
        /* We are drawing on top of widget bases. Flush cache. */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        UI_widgetbase_draw_cache_flush();
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 
@@ -2892,16 +2893,16 @@ static void ui_draw_separator(const rcti *rect,  uiWidgetColors *wcol)
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        immUniformColor4ubv(col);
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        immBegin(GWN_PRIM_LINES, 2);
        immVertex2f(pos, rect->xmin, y);
        immVertex2f(pos, rect->xmax, y);
        immEnd();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        immUnbindProgram();
 }
@@ -3347,9 +3348,9 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
                bw += (bw < 0.5f) ? 0.5f : -0.5f;
 
                /* We are drawing on top of widget bases. Flush cache. */
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                UI_widgetbase_draw_cache_flush();
-               glDisable(GL_BLEND);
+               GPU_blend(false);
 
                unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -3720,9 +3721,9 @@ static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundbox
        widgetbase_draw(&wtb, wcol);
 
        /* We are drawing on top of widget bases. Flush cache. */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        UI_widgetbase_draw_cache_flush();
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
 #ifdef USE_TAB_SHADED_HIGHLIGHT
        /* draw outline (3d look) */
@@ -4301,7 +4302,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
                        wt->draw(&wt->wcol, rect, state, roundboxalign);
 
                if (disabled)
-                       glEnable(GL_BLEND);
+                       GPU_blend(true);
 
 #ifdef USE_UI_POPOVER_ONCE
                if (but->block->flag & UI_BLOCK_POPOVER_ONCE) {
@@ -4323,7 +4324,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
 
                wt->text(fstyle, &wt->wcol, but, rect);
                if (disabled)
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
 
 //             if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
 //                     if (but->dt != UI_EMBOSS_PULLDOWN)
@@ -4380,7 +4381,7 @@ static void ui_draw_popover_back_impl(
        rect->ymax -= unit_half;
        rect->ymin += unit_half;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        /* Extracted from 'widget_menu_back', keep separate to avoid menu changes breaking popovers */
        {
@@ -4400,7 +4401,7 @@ static void ui_draw_popover_back_impl(
                unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
                immUniformColor4ubv((unsigned char *)wcol->inner);
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                immBegin(GWN_PRIM_TRIS, 3);
                if (direction == UI_DIR_DOWN) {
                        const float y = rect->ymax;
@@ -4418,7 +4419,7 @@ static void ui_draw_popover_back_impl(
                immUnbindProgram();
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 void ui_draw_popover_back(ARegion *ar, uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
@@ -4512,7 +4513,7 @@ void ui_draw_pie_center(uiBlock *block)
        gpuPushMatrix();
        gpuTranslate2f(cx, cy);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        if (btheme->tui.wcol_pie_menu.shaded) {
                char col1[4], col2[4];
                shadecolors4(col1, col2, btheme->tui.wcol_pie_menu.inner, btheme->tui.wcol_pie_menu.shadetop, btheme->tui.wcol_pie_menu.shadedown);
@@ -4555,7 +4556,7 @@ void ui_draw_pie_center(uiBlock *block)
                draw_disk_shaded(angle - range / 2.0f, range, pie_confirm_radius, pie_confirm_external, subd, col, NULL, false);
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
        gpuPopMatrix();
 }
 
@@ -4576,9 +4577,9 @@ void ui_draw_widget_back_color(
        uiWidgetType *wt = widget_type(type);
 
        if (use_shadow) {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit);
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        rcti rect_copy = *rect;
@@ -4675,9 +4676,9 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
                height = ICON_SIZE_FROM_BUTRECT(rect);
                aspect = ICON_DEFAULT_HEIGHT / height;
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                UI_icon_draw_aspect(xs, ys, iconid, aspect, 1.0f); /* XXX scale weak get from fstyle? */
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 }
 
@@ -4694,9 +4695,9 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
 
        /* draw icon in rect above the space reserved for the label */
        rect->ymin += text_size;
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        widget_draw_preview(iconid, 1.0f, rect);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        BLF_width_and_height(fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]);
 
index b5036f1967140dee48fc3bf2aaf1f0ebda0ab02f..df5f5cbfeb71d4116bdda35ee8f3c75e5ae9f9ba 100644 (file)
@@ -62,6 +62,7 @@
 #include "UI_interface_icons.h"
 
 #include "interface_intern.h"
+#include "GPU_framebuffer.h"
 
 
 extern const bTheme U_theme_default;
@@ -1274,14 +1275,14 @@ void UI_ThemeClearColor(int colorid)
        float col[3];
 
        UI_GetThemeColor3fv(colorid, col);
-       glClearColor(col[0], col[1], col[2], 0.0f);
+       GPU_clear_color(col[0], col[1], col[2], 0.0f);
 }
 
 void UI_ThemeClearColorAlpha(int colorid, float alpha)
 {
        float col[3];
        UI_GetThemeColor3fv(colorid, col);
-       glClearColor(col[0], col[1], col[2], alpha);
+       GPU_clear_color(col[0], col[1], col[2], alpha);
 }
 
 
index 530a6e28860c1f4f9de932100fc153a7ca72264f..b538842ffa00a8e3aa5f60f5afa081dd45b58af9 100644 (file)
@@ -51,6 +51,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "WM_api.h"
 
@@ -1535,7 +1536,7 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s
        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, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
 
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
        immBeginAtMost(GWN_PRIM_LINES, vertex_count);
index 430841311aa744d29b7d006ea03a3716946f23fb..a0b226b7502d7e7b5134b9c0ba5eddc7a85f2977 100644 (file)
@@ -41,6 +41,7 @@
 #include "GPU_batch.h"
 #include "GPU_glew.h"
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -104,13 +105,13 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo
         * since it causes issues leaving the GL state modified. */
 #if 0
        glEnable(GL_CULL_FACE);
-       glEnable(GL_DEPTH_TEST);
+       GPU_depth_test(true);
 #endif
 
        GWN_batch_draw(batch);
 
 #if 0
-       glDisable(GL_DEPTH_TEST);
+       GPU_depth_test(false);
        glDisable(GL_CULL_FACE);
 #endif
 
index 749e92e25fb6be046ec7ed152a5f944a80c37f0b..5acf1ab2d647a9845cfe84a63bacc22a0a1338db 100644 (file)
@@ -44,6 +44,7 @@
 #include "GPU_draw.h"
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -103,20 +104,20 @@ static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *m
 
        manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, color);
 
-       glLineWidth(mpr->line_width);
+       GPU_line_width(mpr->line_width);
 
        WM_manipulator_calc_matrix_final(mpr, matrix_final);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        arrow2d_draw_geom(mpr, matrix_final, color);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        if (mpr->interaction_data) {
                ManipulatorInteraction *inter = mpr->interaction_data;
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                arrow2d_draw_geom(mpr, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f});
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 }
 
index 8516b9d8244f1c5d3c85642b1923fb8ae21e8c72..a5bcef7ed5e3805b5b3853cea20ee10b5cd2313a 100644 (file)
@@ -51,6 +51,7 @@
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
 #include "GPU_select.h"
+#include "GPU_state.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -118,7 +119,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
                        {-unitx,  unity, 0},
                };
 
-               glLineWidth(arrow->manipulator.line_width);
+               GPU_line_width(arrow->manipulator.line_width);
                wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP);
        }
        else {
@@ -133,7 +134,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
                };
 
                if (draw_options & ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM) {
-                       glLineWidth(arrow->manipulator.line_width);
+                       GPU_line_width(arrow->manipulator.line_width);
                        wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP);
                }
                else {
@@ -197,9 +198,9 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons
 
        gpuPushMatrix();
        gpuMultMatrix(matrix_final);
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        arrow_draw_geom(arrow, select, color);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        gpuPopMatrix();
 
@@ -210,9 +211,9 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons
                gpuMultMatrix(inter->init_matrix_final);
 
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f});
-               glDisable(GL_BLEND);
+               GPU_blend(false);
 
                gpuPopMatrix();
        }
index 86c3b4a09de26841924025bf5a12c9dcf3fb5bbe..db33f45705615e26261effe341a2fd9c0f608103 100644 (file)
@@ -45,6 +45,7 @@
 #include "GPU_matrix.h"
 #include "GPU_select.h"
 #include "GPU_batch.h"
+#include "GPU_state.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -80,7 +81,7 @@ typedef struct ButtonManipulator2D {
 static void button2d_geom_draw_backdrop(
         const wmManipulator *mpr, const float color[4], const bool select)
 {
-       glLineWidth(mpr->line_width);
+       GPU_line_width(mpr->line_width);
 
        Gwn_VertFormat *format = immVertexFormat();
        uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -138,7 +139,7 @@ static void button2d_draw_intern(
                uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
                immUniformColor4fv(color);
-               glLineWidth(mpr->line_width);
+               GPU_line_width(mpr->line_width);
                immUniformColor4fv(color);
                immBegin(GWN_PRIM_LINE_STRIP, 2);
                immVertex3fv(pos, matrix_final[3]);
@@ -168,11 +169,11 @@ static void button2d_draw_intern(
        }
        else {
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                if (button->shape_batch[0] != NULL) {
-                       glEnable(GL_LINE_SMOOTH);
-                       glDisable(GL_POLYGON_SMOOTH);
-                       glLineWidth(1.0f);
+                       GPU_line_smooth(true);
+                       GPU_polygon_smooth(false);
+                       GPU_line_width(1.0f);
                        for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) {
                                /* Invert line color for wire. */
                                GWN_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR);
@@ -185,8 +186,8 @@ static void button2d_draw_intern(
                                        color[2] = 1.0f - color[2];
                                }
                        }
-                       glDisable(GL_LINE_SMOOTH);
-                       glEnable(GL_POLYGON_SMOOTH);
+                       GPU_line_smooth(false);
+                       GPU_polygon_smooth(true);
                }
                else if (button->icon != ICON_NONE) {
                        button2d_geom_draw_backdrop(mpr, color, select);
@@ -206,7 +207,7 @@ static void button2d_draw_intern(
                        }
                        UI_icon_draw(size[0], size[1], button->icon);
                }
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        if (need_to_pop) {
@@ -224,9 +225,9 @@ static void manipulator_button2d_draw(const bContext *C, wmManipulator *mpr)
 {
        const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        button2d_draw_intern(C, mpr, false, is_highlight);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static int manipulator_button2d_test_select(
index fe748f33d351f8f0525c2acf55d5ab6d5e908f8b..b7b19ccd634fe9fa9b7c17ca2aad72aeaec037a1 100644 (file)
@@ -49,6 +49,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_select.h"
+#include "GPU_state.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -420,7 +421,7 @@ static void cage2d_draw_box_interaction(
                }
                else {
                        BLI_assert(ELEM(prim_type, GWN_PRIM_LINE_STRIP, GWN_PRIM_LINES));
-                       glLineWidth(line_width + 3.0f);
+                       GPU_line_width(line_width + 3.0f);
 
                        immBegin(prim_type, verts_len);
                        immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f);
@@ -429,7 +430,7 @@ static void cage2d_draw_box_interaction(
                        }
                        immEnd();
 
-                       glLineWidth(line_width);
+                       GPU_line_width(line_width);
 
                        immBegin(prim_type, verts_len);
                        immAttrib3fv(attr_id.col, color);
@@ -558,14 +559,14 @@ static void manipulator_cage2d_draw_intern(
 
        /* Handy for quick testing draw (if it's outside bounds). */
        if (false) {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
                immUniformColor4fv((const float[4]){1, 1, 1, 0.5f});
                float s = 0.5f;
                immRectf(pos, -s, -s, s, s);
                immUnbindProgram();
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        if (select) {
@@ -610,13 +611,13 @@ static void manipulator_cage2d_draw_intern(
                };
                if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) {
                        /* corner manipulators */
-                       glLineWidth(mpr->line_width + 3.0f);
+                       GPU_line_width(mpr->line_width + 3.0f);
                        cage2d_draw_box_corners(&r, margin, (const float[3]){0, 0, 0});
 
                        /* corner manipulators */
                        float color[4];
                        manipulator_color_get(mpr, highlight, color);
-                       glLineWidth(mpr->line_width);
+                       GPU_line_width(mpr->line_width);
                        cage2d_draw_box_corners(&r, margin, color);
 
                        bool show = false;
@@ -645,12 +646,12 @@ static void manipulator_cage2d_draw_intern(
                        float color[4];
                        manipulator_color_get(mpr, highlight, color);
 
-                       glEnable(GL_LINE_SMOOTH);
-                       glEnable(GL_BLEND);
+                       GPU_line_smooth(true);
+                       GPU_blend(true);
 
-                       glLineWidth(mpr->line_width + 3.0f);
+                       GPU_line_width(mpr->line_width + 3.0f);
                        cage2d_draw_circle_wire(&r, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options);
-                       glLineWidth(mpr->line_width);
+                       GPU_line_width(mpr->line_width);
                        cage2d_draw_circle_wire(&r, margin, color, transform_flag, draw_options);
 
 
@@ -658,15 +659,15 @@ static void manipulator_cage2d_draw_intern(
                        cage2d_draw_circle_handles(&r, margin, color, transform_flag, true);
                        cage2d_draw_circle_handles(&r, margin, (const float[3]){0, 0, 0}, transform_flag, false);
 
-                       glDisable(GL_BLEND);
-                       glDisable(GL_LINE_SMOOTH);
+                       GPU_blend(false);
+                       GPU_line_smooth(false);
                }
                else {
                        BLI_assert(0);
                }
        }
 
-       glLineWidth(1.0);
+       GPU_line_width(1.0);
        gpuPopMatrix();
 }
 
index 6c2e2bd564d3d942f88874ea08eb14a6bd664950..a907816b08f5d2f27aa94e21760a6a6aa8b6950d 100644 (file)
@@ -48,6 +48,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_select.h"
+#include "GPU_state.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -303,14 +304,14 @@ static void manipulator_cage3d_draw_intern(
 
        /* Handy for quick testing draw (if it's outside bounds). */
        if (false) {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
                immUniformColor4fv((const float[4]){1, 1, 1, 0.5f});
                float s = 0.5f;
                immRectf(pos, -s, -s, s, s);
                immUnbindProgram();
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        if (select) {
@@ -358,13 +359,13 @@ static void manipulator_cage3d_draw_intern(
 #endif
                if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) {
                        /* corner manipulators */
-                       glLineWidth(mpr->line_width + 3.0f);
+                       GPU_line_width(mpr->line_width + 3.0f);
                        cage3d_draw_box_corners(size_real, margin, (const float[3]){0, 0, 0});
 
                        /* corner manipulators */
                        float color[4];
                        manipulator_color_get(mpr, highlight, color);
-                       glLineWidth(mpr->line_width);
+                       GPU_line_width(mpr->line_width);
                        cage3d_draw_box_corners(size_real, margin, color);
 
                        bool show = false;
@@ -388,29 +389,29 @@ static void manipulator_cage3d_draw_intern(
                        float color[4];
                        manipulator_color_get(mpr, highlight, color);
 
-                       glEnable(GL_LINE_SMOOTH);
-                       glEnable(GL_POLYGON_SMOOTH);
-                       glEnable(GL_BLEND);
+                       GPU_line_smooth(true);
+                       GPU_polygon_smooth(true);
+                       GPU_blend(true);
 
-                       glLineWidth(mpr->line_width + 3.0f);
+                       GPU_line_width(mpr->line_width + 3.0f);
                        cage3d_draw_circle_wire(size_real, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options);
-                       glLineWidth(mpr->line_width);
+                       GPU_line_width(mpr->line_width);
                        cage3d_draw_circle_wire(size_real, margin, color, transform_flag, draw_options);
 
                        /* corner manipulators */
                        cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, (const float[3]){0, 0, 0}, true, 60);
                        cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 40);
 
-                       glDisable(GL_BLEND);
-                       glDisable(GL_POLYGON_SMOOTH);
-                       glDisable(GL_LINE_SMOOTH);
+                       GPU_blend(false);
+                       GPU_polygon_smooth(false);
+                       GPU_line_smooth(false);
                }
                else {
                        BLI_assert(0);
                }
        }
 
-       glLineWidth(1.0);
+       GPU_line_width(1.0);
        gpuPopMatrix();
 }
 
index 643a379cbb0cc10a234fd7c83da091284119b040..74ba8bd77a9b4a62e6e8789c06cfb9cb980b06f0 100644 (file)
@@ -51,6 +51,7 @@
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
 #include "GPU_select.h"
+#include "GPU_state.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -123,7 +124,7 @@ static void dial_geom_draw(
        const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
        const bool filled = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL) != 0;
 
-       glLineWidth(mpr->line_width);
+       GPU_line_width(mpr->line_width);
 
        Gwn_VertFormat *format = immVertexFormat();
        uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -158,7 +159,7 @@ static void dial_geom_draw(
  */
 static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[3], const float color[4])
 {
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        gpuPushMatrix();
        gpuRotate3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f);
@@ -313,9 +314,9 @@ static void dial_draw_intern(
 
                /* draw! */
                for (int i = 0; i < 2; i++) {
-                       glDisable(GL_POLYGON_SMOOTH);
+                       GPU_polygon_smooth(false);
                        dial_ghostarc_draw(mpr, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f});
-                       glEnable(GL_POLYGON_SMOOTH);
+                       GPU_polygon_smooth(true);
 
                        dial_ghostarc_draw_helpline(angle_ofs, co_outer, color); /* starting position */
                        dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color); /* starting position + current value */
@@ -382,9 +383,9 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
                glEnable(GL_CLIP_DISTANCE0);
        }
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        dial_draw_intern(C, mpr, false, is_highlight, clip_plane);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        if (clip_plane) {
                glDisable(GL_CLIP_DISTANCE0);
index e2d1979b7a69e662bd6a89ef64d532cba844fa4a..458dc2fd1c8306969d68ced317c9fbf8b3afd34d 100644 (file)
@@ -46,6 +46,7 @@
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
 #include "GPU_select.h"
+#include "GPU_state.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -102,7 +103,7 @@ static void grab_geom_draw(
        const int draw_style = RNA_enum_get(mpr->ptr, "draw_style");
        const bool filled = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL) != 0;
 
-       glLineWidth(mpr->line_width);
+       GPU_line_width(mpr->line_width);
 
        Gwn_VertFormat *format = immVertexFormat();
        uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -188,9 +189,9 @@ static void grab3d_draw_intern(
                gpuMultMatrix(matrix_align);
        }
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        grab_geom_draw(mpr, color, select, draw_options);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
        gpuPopMatrix();
 
        if (mpr->interaction_data) {
@@ -201,9 +202,9 @@ static void grab3d_draw_intern(
                        gpuMultMatrix(matrix_align);
                }
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                grab_geom_draw(mpr, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options);
-               glDisable(GL_BLEND);
+               GPU_blend(false);
                gpuPopMatrix();
        }
 }
@@ -221,9 +222,9 @@ static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr)
 
        (void)is_modal;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        grab3d_draw_intern(C, mpr, false, is_highlight);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static int manipulator_grab_modal(
index 531cf742e6fff61056cda33b3036e584972de8f9..419873ccffffe9f460c985c2dd38ce2109959bfb 100644 (file)
@@ -42,6 +42,7 @@
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
 #include "GPU_select.h"
+#include "GPU_state.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -101,9 +102,9 @@ static void manipulator_primitive_draw_intern(
        gpuPushMatrix();
        gpuMultMatrix(matrix_final);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        manipulator_primitive_draw_geom(color_inner, color_outer, draw_style);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        gpuPopMatrix();
 
@@ -117,9 +118,9 @@ static void manipulator_primitive_draw_intern(
                gpuPushMatrix();
                gpuMultMatrix(inter->init_matrix_final);
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                manipulator_primitive_draw_geom(color_inner, color_outer, draw_style);
-               glDisable(GL_BLEND);
+               GPU_blend(false);
 
                gpuPopMatrix();
        }
index 689a96a3decbf7e029dc0f948629f47458849cc3..6b5fce26debf931e2c2ecde5b8cbce6d839e7f71 100644 (file)
@@ -56,6 +56,7 @@
 #include "GPU_draw.h"
 #include "GPU_shader.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "UI_resources.h"
 #include "UI_view2d.h"
@@ -132,7 +133,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
 
        /* this could be split into its own loop */
        if (draw_type == MASK_DT_OUTLINE) {
-               glLineWidth(3.0f);
+               GPU_line_width(3.0f);
                immBegin(GWN_PRIM_LINES, 2);
                immVertex2fv(pos, point_pos);
                immVertex2fv(pos, handle_pos);
@@ -152,7 +153,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin
                        break;
        }
 
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
        immBegin(GWN_PRIM_LINES, 2);
        immVertex2fv(pos, point_pos);
        immVertex2fv(pos, handle_pos);
@@ -262,7 +263,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
        immUnbindProgram();
 
        if (is_smooth) {
-               glEnable(GL_LINE_SMOOTH);
+               GPU_line_smooth(true);
        }
 
        /* control points */
@@ -329,7 +330,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
        }
 
        if (is_smooth) {
-               glDisable(GL_LINE_SMOOTH);
+               GPU_line_smooth(false);
        }
 
        if (is_spline_sel) {
@@ -412,13 +413,13 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
                         */
                        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-                       glLineWidth(3.0f);
+                       GPU_line_width(3.0f);
 
                        mask_color_active_tint(rgb_tmp, rgb_black, is_active);
                        immUniformColor4ubv(rgb_tmp);
                        mask_draw_array(pos, draw_method, points, tot_point);
 
-                       glLineWidth(1.0f);
+                       GPU_line_width(1.0f);
 
                        mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
                        immUniformColor4ubv(rgb_tmp);
@@ -430,7 +431,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
                case MASK_DT_BLACK:
                case MASK_DT_WHITE:
                        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-                       glLineWidth(1.0f);
+                       GPU_line_width(1.0f);
 
                        if (draw_type == MASK_DT_BLACK) { rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 0;   }
                        else                            { rgb_tmp[0] = rgb_tmp[1] = rgb_tmp[2] = 255; }
@@ -456,7 +457,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
                         * probably better with geometry shader (after core profile switch)
                         */
 #if 0
-                       glLineWidth(1.0f);
+                       GPU_line_width(1.0f);
 
                        GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
                        GPU_basic_shader_line_stipple(3, 0xAAAA);
@@ -508,7 +509,7 @@ static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline
                return;
 
        if (is_smooth) {
-               glEnable(GL_LINE_SMOOTH);
+               GPU_line_smooth(true);
        }
 
        feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, &tot_feather_point, resol, (is_fill != false));
@@ -547,15 +548,15 @@ static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline
        MEM_freeN(diff_points);
 
        if (is_smooth) {
-               glDisable(GL_LINE_SMOOTH);
+               GPU_line_smooth(false);
        }
 }
 
 static void draw_masklays(const bContext *C, Mask *mask, const char draw_flag, const char draw_type,
                           const int width, const int height)
 {
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
        GPU_enable_program_point_size();
 
        MaskLayer *masklay;
@@ -592,7 +593,7 @@ static void draw_masklays(const bContext *C, Mask *mask, const char draw_flag, c
        }
 
        GPU_disable_program_point_size();
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 void ED_mask_draw(const bContext *C,
@@ -690,8 +691,8 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
 
                if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
                        /* More blending types could be supported in the future. */
-                       glEnable(GL_BLEND);
-                       glBlendFunc(GL_DST_COLOR, GL_ZERO);
+                       GPU_blend(true);
+                       GPU_blend_set_func(GPU_DST_COLOR, GPU_ZERO);
                }
 
                gpuPushMatrix();
@@ -707,7 +708,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
                gpuPopMatrix();
 
                if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
                }
 
                MEM_freeN(buffer);
index 84da02b3b419c2342fa5fe37e8e0afb82688d6b2..2ee8918c5da2d9ff287fe87d47b852a9b48315dd 100644 (file)
@@ -58,6 +58,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "ED_screen.h"
 #include "ED_space_api.h"
@@ -1010,7 +1011,7 @@ static void knifetool_draw_angle_snapping(const KnifeTool_OpData *kcd)
 
        immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
        immUniformThemeColor(TH_TRANSFORM);
-       glLineWidth(2.0);
+       GPU_line_width(2.0);
 
        immBegin(GWN_PRIM_LINES, 2);
        immVertex3fv(pos, v1);
@@ -1041,7 +1042,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
        View3D *v3d = CTX_wm_view3d(C);
        const KnifeTool_OpData *kcd = arg;
 
-       if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
+       if (v3d->zbuf) GPU_depth_test(false);
 
        glPolygonOffset(1.0f, 1.0f);
 
@@ -1057,7 +1058,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
                        knifetool_draw_angle_snapping(kcd);
 
                immUniformColor3ubv(kcd->colors.line);
-               glLineWidth(2.0);
+               GPU_line_width(2.0);
 
                immBegin(GWN_PRIM_LINES, 2);
                immVertex3fv(pos, kcd->prev.cage);
@@ -1067,7 +1068,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
        if (kcd->prev.vert) {
                immUniformColor3ubv(kcd->colors.point);
-               glPointSize(11);
+               GPU_point_size(11);
 
                immBegin(GWN_PRIM_POINTS, 1);
                immVertex3fv(pos, kcd->prev.cage);
@@ -1076,7 +1077,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
        if (kcd->prev.bmface) {
                immUniformColor3ubv(kcd->colors.curpoint);
-               glPointSize(9);
+               GPU_point_size(9);
 
                immBegin(GWN_PRIM_POINTS, 1);
                immVertex3fv(pos, kcd->prev.cage);
@@ -1085,7 +1086,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
        if (kcd->curr.edge) {
                immUniformColor3ubv(kcd->colors.edge);
-               glLineWidth(2.0);
+               GPU_line_width(2.0);
 
                immBegin(GWN_PRIM_LINES, 2);
                immVertex3fv(pos, kcd->curr.edge->v1->cageco);
@@ -1094,7 +1095,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
        }
        else if (kcd->curr.vert) {
                immUniformColor3ubv(kcd->colors.point);
-               glPointSize(11);
+               GPU_point_size(11);
 
                immBegin(GWN_PRIM_POINTS, 1);
                immVertex3fv(pos, kcd->curr.cage);
@@ -1103,7 +1104,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
        if (kcd->curr.bmface) {
                immUniformColor3ubv(kcd->colors.curpoint);
-               glPointSize(9);
+               GPU_point_size(9);
 
                immBegin(GWN_PRIM_POINTS, 1);
                immVertex3fv(pos, kcd->curr.cage);
@@ -1114,12 +1115,12 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
                KnifeLineHit *lh;
                int i;
 
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                /* draw any snapped verts first */
                immUniformColor4ubv(kcd->colors.point_a);
-               glPointSize(11);
+               GPU_point_size(11);
 
                immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit);
 
@@ -1134,7 +1135,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
                /* now draw the rest */
                immUniformColor4ubv(kcd->colors.curpoint_a);
-               glPointSize(7);
+               GPU_point_size(7);
 
                immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit);
 
@@ -1147,7 +1148,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
                immEnd();
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        if (kcd->totkedge > 0) {
@@ -1155,7 +1156,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
                KnifeEdge *kfe;
 
                immUniformColor3ubv(kcd->colors.line);
-               glLineWidth(1.0);
+               GPU_line_width(1.0);
 
                immBeginAtMost(GWN_PRIM_LINES, BLI_mempool_len(kcd->kedges) * 2);
 
@@ -1176,7 +1177,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
                KnifeVert *kfv;
 
                immUniformColor3ubv(kcd->colors.point);
-               glPointSize(5.0);
+               GPU_point_size(5.0);
 
                immBeginAtMost(GWN_PRIM_POINTS, BLI_mempool_len(kcd->kverts));
 
@@ -1195,7 +1196,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
        gpuPopMatrix();
 
-       if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
+       if (v3d->zbuf) GPU_depth_test(true);
 }
 
 /**
index cf806b0b10478fe95b1560002e6421b5b7ffc6d2..78d980254763640a6c8fe2c70be210c6ed06072f 100644 (file)
@@ -48,6 +48,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "UI_interface.h"
 
@@ -112,7 +113,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 
        if ((lcd->totedge > 0) || (lcd->totpoint > 0)) {
                if (v3d && v3d->zbuf)
-                       glDisable(GL_DEPTH_TEST);
+                       GPU_depth_test(false);
 
                gpuPushMatrix();
                gpuMultMatrix(lcd->ob->obmat);
@@ -134,7 +135,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
                }
 
                if (lcd->totpoint > 0) {
-                       glPointSize(3.0f);
+                       GPU_point_size(3.0f);
 
                        immBegin(GWN_PRIM_POINTS, lcd->totpoint);
 
@@ -150,7 +151,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
                gpuPopMatrix();
 
                if (v3d && v3d->zbuf)
-                       glEnable(GL_DEPTH_TEST);
+                       GPU_depth_test(true);
        }
 }
 
index cfdeeffc4347dee48c8e82300de63a8eaaa04468..d2ca8471d82fcc2c27b327d2454b0c84d3d3ba92 100644 (file)
@@ -80,6 +80,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
+#include "GPU_state.h"
 
 #include "UI_resources.h"
 
@@ -2897,13 +2898,13 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)
 
                immUniformColor4ub(255, 255, 255, 128);
 
-               glEnable(GL_LINE_SMOOTH);
-               glEnable(GL_BLEND);
+               GPU_line_smooth(true);
+               GPU_blend(true);
 
                imm_draw_circle_wire_2d(pos, (float)x, (float)y, pe_brush_size_get(scene, brush), 40);
 
-               glDisable(GL_BLEND);
-               glDisable(GL_LINE_SMOOTH);
+               GPU_blend(false);
+               GPU_line_smooth(false);
 
                immUnbindProgram();
        }
index fb007accaeb78c3ba89713b0efb14ac4526d9d23..b5c1ffc64dd3741ee2acae7185f0079534bc3543 100644 (file)
@@ -322,8 +322,8 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
                        DRW_opengl_context_enable();
                        GPU_offscreen_bind(oglrender->ofs, true);
 
-                       glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-                       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+                       GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
+                       GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT);
 
                        wmOrtho2(0, sizex, 0, sizey);
                        gpuTranslate2f(sizex / 2, sizey / 2);
index 986a2a030e2cc03142112d86afc0c87056f9050c..9bf15a292ea75bb818fa3cee0721813e12546ec8 100644 (file)
@@ -62,6 +62,8 @@
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
 #include "GPU_draw.h"
+#include "GPU_state.h"
+#include "GPU_framebuffer.h"
 
 #include "BLF_api.h"
 
@@ -97,8 +99,8 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides)
        rect.ymax = scirct->ymax - ar->winrct.ymin;
 
        /* set transp line */
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        float color[4] = {0.0f, 0.0f, 0.0f, 0.25f};
        UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color);
@@ -137,7 +139,7 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides)
        immEnd();
        immUnbindProgram();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 }
 
@@ -296,7 +298,7 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2)
        Gwn_VertFormat *format = immVertexFormat();
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
        immUniformColor4f(0.8f, 0.8f, 0.8f, 0.4f);
 
@@ -305,12 +307,12 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2)
        immRectf(pos, (x1 + x2 + width) * 0.5f, (y1 + y2 - width) * 0.5f, x2 - pad, (y1 + y2 + width) * 0.5f);
 
        immUnbindProgram();
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void region_draw_azone_tab_plus(AZone *az)
 {
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        /* add code to draw region hidden as 'too small' */
        switch (az->edge) {
@@ -346,9 +348,9 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
        if (!sa)
                return;
 
-       glLineWidth(1.0f);
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_line_width(1.0f);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        gpuPushMatrix();
        gpuTranslate2f(-ar->winrct.xmin, -ar->winrct.ymin);
@@ -388,7 +390,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
 
        gpuPopMatrix();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 /* Follow wmMsgNotifyFn spec */
@@ -473,7 +475,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
 
        /* for debugging unneeded area redraws and partial redraw */
 #if 0
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        Gwn_VertFormat *format = immVertexFormat();
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -481,7 +483,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
        immRectf(pos, ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin,
                ar->drawrct.xmax - ar->winrct.xmin, ar->drawrct.ymax - ar->winrct.ymin);
        immUnbindProgram();
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 #endif
 
        memset(&ar->drawrct, 0, sizeof(ar->drawrct));
@@ -1817,12 +1819,12 @@ static void region_clear_color(const bContext *C, const ARegion *ar, ThemeColorI
 
                float back[4];
                UI_GetThemeColor4fv(colorid, back);
-               glClearColor(back[3] * back[0], back[3] * back[1], back[3] * back[2], back[3]);
-               glClear(GL_COLOR_BUFFER_BIT);
+               GPU_clear_color(back[3] * back[0], back[3] * back[1], back[3] * back[2], back[3]);
+               GPU_clear(GPU_COLOR_BIT);
        }
        else {
                UI_ThemeClearColor(colorid);
-               glClear(GL_COLOR_BUFFER_BIT);
+               GPU_clear(GPU_COLOR_BIT);
        }
 }
 
@@ -2148,7 +2150,7 @@ void ED_region_panels_draw(const bContext *C, ARegion *ar)
        }
 
        /* reset line width for drawing tabs */
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        /* set the view */
        UI_view2d_view_ortho(v2d);
@@ -2378,7 +2380,7 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float
        const int header_height = UI_UNIT_Y;
        uiStyle *style = UI_style_get_dpi();
        int fontid = style->widget.uifont_id;
-       GLint scissor[4];
+       int scissor[4];
        rcti rect;
        int num_lines = 0;
 
@@ -2406,19 +2408,19 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float
        rect.ymin = rect.ymax - header_height * num_lines;
 
        /* setup scissor */
-       glGetIntegerv(GL_SCISSOR_BOX, scissor);
-       glScissor(rect.xmin, rect.ymin,
+       GPU_scissor_geti(scissor);
+       GPU_scissor(rect.xmin, rect.ymin,
                  BLI_rcti_size_x(&rect) + 1, BLI_rcti_size_y(&rect) + 1);
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
        Gwn_VertFormat *format = immVertexFormat();
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
        immUniformColor4fv(fill_color);
        immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1);
        immUnbindProgram();
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* text */
        UI_FontThemeColor(fontid, TH_TEXT_HI);
@@ -2438,7 +2440,7 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float
        BLF_disable(fontid, BLF_CLIPPING);
 
        /* restore scissor as it was before */
-       glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
+       GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
 }
 
 void ED_region_info_draw(ARegion *ar, const char *text, float fill_color[4], const bool full_redraw)
index 1d73566e5a8e6772a605c7fa3008221b31f7f815..6cff82295f0afa651cceecfa3383cd8f64cb3891 100644 (file)
@@ -51,6 +51,7 @@
 #include "GPU_basic_shader.h"
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "UI_interface.h"
 
 void setlinestyle(int nr)
 {
        if (nr == 0) {
-               glDisable(GL_LINE_STIPPLE);
+               GPU_line_stipple(false);
        }
        else {
 
-               glEnable(GL_LINE_STIPPLE);
+               GPU_line_stipple(true);
                if (U.pixelsize > 1.0f)
                        glLineStipple(nr, 0xCCCC);
                else
index fec39ade1106279428de942b81c74ebc429d15c7..b81c1e489ea2a863b8cd5ff761ff273546b3ff01 100644 (file)
@@ -27,6 +27,7 @@
 #include "GPU_framebuffer.h"
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "BLI_math.h"
 
@@ -353,7 +354,7 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey)
  */
 static void scrarea_draw_shape_dark(ScrArea *sa, char dir, unsigned int pos)
 {
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
        immUniformColor4ub(0, 0, 0, 50);
 
        draw_join_shape(sa, dir, pos);
@@ -364,7 +365,7 @@ static void scrarea_draw_shape_dark(ScrArea *sa, char dir, unsigned int pos)
  */
 static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir), unsigned int pos)
 {
-       glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA);
+       GPU_blend_set_func(GPU_DST_COLOR, GPU_SRC_ALPHA);
        /* value 181 was hardly computed: 181~105 */
        immUniformColor4ub(255, 255, 255, 50);
        /* draw_join_shape(sa, dir); */
@@ -444,7 +445,7 @@ void ED_screen_draw_edges(wmWindow *win)
        /* Note: first loop only draws if U.pixelsize > 1, skip otherwise */
        if (U.pixelsize > 1.0f) {
                /* FIXME: doesn't our glLineWidth already scale by U.pixelsize? */
-               glLineWidth((2.0f * U.pixelsize) - 1);
+               GPU_line_width((2.0f * U.pixelsize) - 1);
                immUniformThemeColor(TH_EDITOR_OUTLINE);
 
                for (sa = screen->areabase.first; sa; sa = sa->next) {
@@ -452,7 +453,7 @@ void ED_screen_draw_edges(wmWindow *win)
                }
        }
 
-       glLineWidth(1);
+       GPU_line_width(1);
        immUniformThemeColor(TH_EDITOR_OUTLINE);
 
        for (sa = screen->areabase.first; sa; sa = sa->next) {
@@ -479,7 +480,7 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2)
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-       glLineWidth(1);
+       GPU_line_width(1);
 
        /* blended join arrow */
        int dir = area_getorientation(sa1, sa2);
@@ -504,12 +505,12 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2)
                                break;
                }
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                scrarea_draw_shape_dark(sa2, dir, pos);
                scrarea_draw_shape_light(sa1, dira, pos);
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        immUnbindProgram();
@@ -521,7 +522,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
        /* splitpoint */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        immUniformColor4ub(255, 255, 255, 100);
 
        immBegin(GWN_PRIM_LINES, 2);
@@ -562,7 +563,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
                immEnd();
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        immUnbindProgram();
 }
@@ -645,8 +646,8 @@ void ED_screen_preview_render(const bScreen *screen, int size_x, int size_y, uns
        GPUOffScreen *offscreen = GPU_offscreen_create(size_x, size_y, 0, true, false, err_out);
 
        GPU_offscreen_bind(offscreen, true);
-       glClearColor(0.0, 0.0, 0.0, 0.0);
-       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+       GPU_clear_color(0.0, 0.0, 0.0, 0.0);
+       GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT);
 
        screen_preview_draw(screen, size_x, size_y);
 
index e7b075dd5d06b888088dc30197235ed1134d8ef0..fbe0b8dc40ec7a804f883aff3dd104dd2bd336b2 100644 (file)
@@ -57,6 +57,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
+#include "GPU_state.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -453,8 +454,8 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
 /* Helper callback for drawing the cursor itself */
 static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUSED(p_ptr))
 {
-       glEnable(GL_LINE_SMOOTH);
-       glEnable(GL_BLEND);
+       GPU_line_smooth(true);
+       GPU_blend(true);
 
        Gwn_VertFormat *format = immVertexFormat();
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -469,8 +470,8 @@ static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUS
 
        immUnbindProgram();
 
-       glDisable(GL_BLEND);
-       glDisable(GL_LINE_SMOOTH);
+       GPU_blend(false);
+       GPU_line_smooth(false);
 }
 
 /* Turn brush cursor in 3D view on/off */
index 848d12bcfaa420b60d0679ff16e313f3f61f2d07..50d178bc757001347c2f5e2275a821114edae9d8 100644 (file)
@@ -62,6 +62,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "UI_resources.h"
 
@@ -607,7 +608,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
        }
 
        if (load_tex(brush, vc, zoom, col, primary)) {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
                glDepthMask(GL_FALSE);
@@ -726,7 +727,7 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush,
        if (load_tex_cursor(brush, vc, zoom)) {
                bool do_pop = false;
                float center[2];
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
                glDepthMask(GL_FALSE);
@@ -829,7 +830,7 @@ BLI_INLINE void draw_tri_point(
 {
        immUniformColor4fv(selected ? sel_col : pivot_col);
 
-       glLineWidth(3.0f);
+       GPU_line_width(3.0f);
 
        float w = width / 2.0f;
        float tri[3][2] = {
@@ -845,7 +846,7 @@ BLI_INLINE void draw_tri_point(
        immEnd();
 
        immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        immBegin(GWN_PRIM_LINE_LOOP, 3);
        immVertex2fv(pos, tri[0]);
@@ -860,7 +861,7 @@ BLI_INLINE void draw_rect_point(
 {
        immUniformColor4fv(selected ? sel_col : handle_col);
 
-       glLineWidth(3.0f);
+       GPU_line_width(3.0f);
 
        float w = width / 2.0f;
        float minx = co[0] - w;
@@ -871,7 +872,7 @@ BLI_INLINE void draw_rect_point(
        imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
 
        immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
 }
@@ -880,7 +881,7 @@ BLI_INLINE void draw_rect_point(
 BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], BezTriple *bez)
 {
        immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
-       glLineWidth(3.0f);
+       GPU_line_width(3.0f);
 
        immBegin(GWN_PRIM_LINE_STRIP, 3);
        immVertex2fv(pos, bez->vec[0]);
@@ -888,7 +889,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez
        immVertex2fv(pos, bez->vec[2]);
        immEnd();
 
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        if (bez->f1 || bez->f2) {
                immUniformColor4fv(sel_col);
@@ -920,8 +921,8 @@ static void paint_draw_curve_cursor(Brush *brush)
                PaintCurve *pc = brush->paint_curve;
                PaintCurvePoint *cp = pc->points;
 
-               glEnable(GL_LINE_SMOOTH);
-               glEnable(GL_BLEND);
+               GPU_line_smooth(true);
+               GPU_blend(true);
 
                /* draw the bezier handles and the curve segment between the current and next point */
                unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -954,7 +955,7 @@ static void paint_draw_curve_cursor(Brush *brush)
                        float (*v)[2] = (float(*)[2])data;
 
                        immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
-                       glLineWidth(3.0f);
+                       GPU_line_width(3.0f);
                        immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1);
                        for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) {
                                immVertex2fv(pos, v[j]);
@@ -962,7 +963,7 @@ static void paint_draw_curve_cursor(Brush *brush)
                        immEnd();
 
                        immUniformColor4f(0.9f, 0.9f, 1.0f, 0.5f);
-                       glLineWidth(1.0f);
+                       GPU_line_width(1.0f);
                        immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1);
                        for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) {
                                immVertex2fv(pos, v[j]);
@@ -976,8 +977,8 @@ static void paint_draw_curve_cursor(Brush *brush)
                draw_rect_point(pos, selec_col, handle_col, &cp->bez.vec[0][0], 8.0f, cp->bez.f1 || cp->bez.f2);
                draw_rect_point(pos, selec_col, handle_col, &cp->bez.vec[2][0], 8.0f, cp->bez.f3 || cp->bez.f2);
 
-               glDisable(GL_BLEND);
-               glDisable(GL_LINE_SMOOTH);
+               GPU_blend(false);
+               GPU_line_smooth(false);
 
                immUnbindProgram();
        }
@@ -1107,9 +1108,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
        }
 
        /* make lines pretty */
-       glLineWidth(1.0f);
-       glEnable(GL_BLEND); /* TODO: also set blend mode? */
-       glEnable(GL_LINE_SMOOTH);
+       GPU_line_width(1.0f);
+       GPU_blend(true); /* TODO: also set blend mode? */
+       GPU_line_smooth(true);
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1129,8 +1130,8 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
        immUnbindProgram();
 
        /* restore GL state */
-       glDisable(GL_BLEND);
-       glDisable(GL_LINE_SMOOTH);
+       GPU_blend(false);
+       GPU_line_smooth(false);
 }
 
 /* Public API */
index c3a0ca4299f402bd10750223f435bb10c52da46b..b5da9a5d68cfe3b6cc1034f93626061484cbf95c 100644 (file)
@@ -82,6 +82,7 @@
 
 #include "GPU_draw.h"
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "BIF_gl.h"
 
@@ -413,15 +414,15 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda
        PaintOperation *pop = (PaintOperation *)customdata;
 
        if (pop) {
-               glEnable(GL_LINE_SMOOTH);
-               glEnable(GL_BLEND);
+               GPU_line_smooth(true);
+               GPU_blend(true);
 
                Gwn_VertFormat *format = immVertexFormat();
                unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
 
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-               glLineWidth(4.0);
+               GPU_line_width(4.0);
                immUniformColor4ub(0, 0, 0, 255);
 
                immBegin(GWN_PRIM_LINES, 2);
@@ -429,7 +430,7 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda
                immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]);
                immEnd();
 
-               glLineWidth(2.0);
+               GPU_line_width(2.0);
                immUniformColor4ub(255, 255, 255, 255);
 
                immBegin(GWN_PRIM_LINES, 2);
@@ -439,8 +440,8 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda
 
                immUnbindProgram();
 
-               glDisable(GL_BLEND);
-               glDisable(GL_LINE_SMOOTH);
+               GPU_blend(false);
+               GPU_line_smooth(false);
        }
 }
 
index a7aa19807ddfe8f03125421aad3a4296233fe9d9..ee888c71659d6eb1fd60fc3e7a7b3a567dfb9e06 100644 (file)
@@ -62,6 +62,7 @@
 #include "BIF_glutil.h"
 
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "ED_screen.h"
 #include "ED_view3d.h"
@@ -149,8 +150,8 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata
        PaintStroke *stroke = customdata;
 
        if (stroke && brush) {
-               glEnable(GL_LINE_SMOOTH);
-               glEnable(GL_BLEND);
+               GPU_line_smooth(true);
+               GPU_blend(true);
 
                ARegion *ar = stroke->vc.ar;
 
@@ -168,8 +169,8 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata
 
                immUnbindProgram();
 
-               glDisable(GL_BLEND);
-               glDisable(GL_LINE_SMOOTH);
+               GPU_blend(false);
+               GPU_line_smooth(false);
        }
 }
 
@@ -178,14 +179,14 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
        Paint *paint = BKE_paint_get_active_from_context(C);
        PaintStroke *stroke = customdata;
 
-       glEnable(GL_LINE_SMOOTH);
+       GPU_line_smooth(true);
 
        uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 
        immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
        float viewport_size[4];
-       glGetFloatv(GL_VIEWPORT, viewport_size);
+       GPU_viewport_size_getf(viewport_size);
        immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
 
        immUniform1i("num_colors", 2);  /* "advanced" mode */
@@ -218,7 +219,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
 
        immUnbindProgram();
 
-       glDisable(GL_LINE_SMOOTH);
+       GPU_line_smooth(false);
 }
 
 static bool paint_tool_require_location(Brush *brush, ePaintMode mode)
index 80c4d4099a2ee53e328b79b4a4a4c763827f20e2..d6de9c235f106a2ea6ac1c5d9eeb5808d0feb7ea 100644 (file)
@@ -65,6 +65,7 @@
 
 #include "GPU_glew.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "IMB_colormanagement.h"
 #include "IMB_imbuf_types.h"
@@ -291,7 +292,7 @@ static void imapaint_pick_uv(Mesh *me_eval, Scene *scene, Object *ob_eval, unsig
        const int *index_mp_to_orig  = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
 
        /* get the needed opengl matrices */
-       glGetIntegerv(GL_VIEWPORT, view);
+       GPU_viewport_size_geti(view);
        gpuGetModelViewMatrix(matrix);
        gpuGetProjectionMatrix(proj);
        view[0] = view[1] = 0;
index cf9feae62b5a35996504f0f452c82d324ff8dc4e..1405de8cfa95758fa5d798e58ae8e7d0dec77e49 100644 (file)
@@ -59,6 +59,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
+#include "GPU_state.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -218,11 +219,11 @@ static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(cu
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
                immUniformColor3fvAlpha(brush->add_col, alpha);
 
-               glEnable(GL_LINE_SMOOTH);
-               glEnable(GL_BLEND);
+               GPU_line_smooth(true);
+               GPU_blend(true);
                imm_draw_circle_wire_2d(pos, (float)x, (float)y, size, 40);
-               glDisable(GL_BLEND);
-               glDisable(GL_LINE_SMOOTH);
+               GPU_blend(false);
+               GPU_line_smooth(false);
 
                immUnbindProgram();
        }
index 35ebb62a7cc6e87616245bbeda45a10e05541fd0..6105652a4c71e3b3e0fd15982f6ada8aa0ff0ab5 100644 (file)
@@ -59,6 +59,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "UI_interface.h"
 #include "UI_resources.h"
@@ -215,7 +216,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
 
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        for (ale = anim_data.first; ale; ale = ale->next) {
                const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
@@ -319,7 +320,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                /*      Increment the step */
                y -= ACHANNEL_STEP(ac);
        }
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* black line marking 'current frame' for Time-Slide transform mode */
        if (saction->flag & SACTION_MOVING) {
@@ -475,7 +476,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
                const int sta = pid->cache->startframe, end = pid->cache->endframe;
                const int len = (end - sta + 1) * 6;
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                immUniformColor4fv(col);
                immRectf(pos, (float)sta, 0.0, (float)end, 1.0);
@@ -509,7 +510,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
                        immEnd();
                }
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
 
                gpuPopMatrix();
 
index 537f184c71cb6016df463f7f18f5df17023afa37..876b73a4a762b72524c012005cf70c145b08030b 100644 (file)
@@ -65,6 +65,7 @@
 #include "ED_markers.h"
 
 #include "action_intern.h"  /* own include */
+#include "GPU_framebuffer.h"
 
 /* ******************** manage regions ********************* */
 
@@ -226,7 +227,7 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
@@ -312,7 +313,7 @@ static void action_channel_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
index bc2aa3ae67fe00fd45faffa626fb8394e865395d..d50d10d5cc307b41c59d7dd994cb52b2233cf3a7 100644 (file)
@@ -54,6 +54,7 @@
 
 #include "GPU_draw.h"
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "clip_intern.h"  /* own include */
 
@@ -147,7 +148,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
                strip[3] = 0.5f;
                selected_strip[3] = 1.0f;
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                clip_draw_dopesheet_background(ar, clip, pos_id);
 
@@ -279,7 +280,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
                        immUnbindProgram();
                }
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 }
 
@@ -378,7 +379,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
        PropertyRNA *chan_prop_lock = RNA_struct_type_find_property(&RNA_MovieTrackingTrack, "lock");
        BLI_assert(chan_prop_lock);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        for (channel = dopesheet->channels.first; channel; channel = channel->next) {
                float yminc = (float)(y - CHANNEL_HEIGHT_HALF);
                float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF);
@@ -403,7 +404,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
                /* adjust y-position for next one */
                y -= CHANNEL_STEP;
        }
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        UI_block_end(C, block);
        UI_block_draw(C, block);
index 5962bfe33f3da8233d0a25f59566f532088ecd95..d91e039ecb6c7f2f2f818c86b6c4ccacf8ed9d18 100644 (file)
@@ -60,6 +60,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "WM_types.h"
 
@@ -156,8 +157,8 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
        MovieTrackingPlaneTrack *act_plane_track = BKE_tracking_plane_track_get_active(&clip->tracking);
        MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking);
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        /* cache background */
        ED_region_cache_draw_background(ar);
@@ -235,7 +236,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
                }
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* current frame */
        x = (sc->user.framenr - sfra) / (efra - sfra + 1) * ar->winx;
@@ -313,8 +314,8 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
 
        /* checkerboard for case alpha */
        if (ibuf->planes == 32) {
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                imm_draw_box_checker_2d(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
        }
@@ -335,7 +336,7 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
        }
 
        if (ibuf->planes == 32)
-               glDisable(GL_BLEND);
+               GPU_blend(false);
 }
 
 static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int height, float zoomx, float zoomy)
@@ -364,7 +365,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
                immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
                float viewport_size[4];
-               glGetFloatv(GL_VIEWPORT, viewport_size);
+               GPU_viewport_size_getf(viewport_size);
                immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
                immUniform1i("num_colors", 0);  /* "simple" mode */
@@ -460,7 +461,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
 
                if (TRACK_VIEW_SELECTED(sc, track)) {
                        if ((b - a - 1) >= 1) {
-                               glPointSize(5.0f);
+                               GPU_point_size(5.0f);
 
                                immBegin(GWN_PRIM_POINTS, b - a - 1);
 
@@ -475,7 +476,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
                }
 
                if ((b - a) >= 2) {
-                       glLineWidth(3.0f);
+                       GPU_line_width(3.0f);
 
                        immBegin(GWN_PRIM_LINE_STRIP, b - a);
 
@@ -488,7 +489,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
        }
 
        if (TRACK_VIEW_SELECTED(sc, track)) {
-               glPointSize(3.0f);
+               GPU_point_size(3.0f);
 
                if ((curindex - a) >= 1) {
                        immUniformThemeColor(TH_PATH_BEFORE);
@@ -515,7 +516,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
                }
        }
 
-       glLineWidth(1);
+       GPU_line_width(1);
 
        if ((curindex - a + 1) >= 2) {
                immUniformThemeColor(TH_PATH_BEFORE);
@@ -559,7 +560,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
        px[0] = 1.0f / width / sc->zoom;
        px[1] = 1.0f / height / sc->zoom;
 
-       glLineWidth(tiny ? 1.0f : 3.0f);
+       GPU_line_width(tiny ? 1.0f : 3.0f);
 
        immUniformThemeColor(TH_MARKER_OUTLINE);
 
@@ -576,7 +577,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
                if (isect_point_quad_v2(p, marker->pattern_corners[0], marker->pattern_corners[1],
                                        marker->pattern_corners[2], marker->pattern_corners[3]))
                {
-                       glPointSize(tiny ? 3.0f : 4.0f);
+                       GPU_point_size(tiny ? 3.0f : 4.0f);
 
                        immBegin(GWN_PRIM_POINTS, 1);
                        immVertex2f(position, pos[0], pos[1]);
@@ -660,7 +661,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
        px[0] = 1.0f / width / sc->zoom;
        px[1] = 1.0f / height / sc->zoom;
 
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        /* Since we are switching solid and dashed lines in rather complex logic here, just always go with dashed shader. */
        immUnbindProgram();
@@ -668,7 +669,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
        immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
        float viewport_size[4];
-       glGetFloatv(GL_VIEWPORT, viewport_size);
+       GPU_viewport_size_getf(viewport_size);
        immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
        immUniform1i("num_colors", 0);  /* "simple" mode */
@@ -700,7 +701,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
                if (isect_point_quad_v2(p, marker->pattern_corners[0], marker->pattern_corners[1],
                                        marker->pattern_corners[2], marker->pattern_corners[3]))
                {
-                       glPointSize(tiny ? 1.0f : 2.0f);
+                       GPU_point_size(tiny ? 1.0f : 2.0f);
 
                        immUniform1f("dash_factor", 2.0f);  /* Solid "line" */
 
@@ -932,7 +933,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
 
                BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
 
-               glLineWidth(outline ? 3.0f : 1.0f);
+               GPU_line_width(outline ? 3.0f : 1.0f);
 
                immBegin(GWN_PRIM_LINES, 2);
                immVertex2f(pos, 0.0f, 0.0f);
@@ -1125,8 +1126,8 @@ static void draw_plane_marker_image(Scene *scene,
 
                        if (plane_track->image_opacity != 1.0f || ibuf->planes == 32) {
                                transparent = true;
-                               glEnable(GL_BLEND);
-                               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+                               GPU_blend(true);
+                               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
                        }
 
                        glGenTextures(1, (GLuint *)&texid);
@@ -1174,7 +1175,7 @@ static void draw_plane_marker_image(Scene *scene,
                        glBindTexture(GL_TEXTURE_2D, 0);
 
                        if (transparent) {
-                               glDisable(GL_BLEND);
+                               GPU_blend(false);
                        }
                }
 
@@ -1210,7 +1211,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
                immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
                float viewport_size[4];
-               glGetFloatv(GL_VIEWPORT, viewport_size);
+               GPU_viewport_size_getf(viewport_size);
                immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
                immUniform1i("num_colors", 0);  /* "simple" mode */
@@ -1219,7 +1220,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
                        const bool stipple = !draw_outline && tiny;
                        const bool thick = draw_outline && !tiny;
 
-                       glLineWidth(thick ? 3.0f : 1.0f);
+                       GPU_line_width(thick ? 3.0f : 1.0f);
 
                        if (stipple) {
                                immUniform1f("dash_width", 6.0f);
@@ -1483,7 +1484,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
                MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
                float pos[4], vec[4], mat[4][4], aspy;
 
-               glPointSize(3.0f);
+               GPU_point_size(3.0f);
 
                aspy = 1.0f / clip->tracking.camera.pixel_aspect;
                BKE_tracking_get_projection_matrix(tracking, object, framenr, width, height, mat);
@@ -1711,8 +1712,8 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
 
                        immUniformColor4fv(layer->color);
 
-                       glLineWidth(layer->thickness);
-                       glPointSize((float)(layer->thickness + 2));
+                       GPU_line_width(layer->thickness);
+                       GPU_point_size((float)(layer->thickness + 2));
 
                        while (frame) {
                                bGPDstroke *stroke = frame->strokes.first;
index 8d29cb73a68186b20555f281673364d2dcb5dc51..d463f585470d82e79afd5636c69f252203b1901e 100644 (file)
@@ -45,6 +45,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "WM_types.h"
 
@@ -80,11 +81,11 @@ static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track,
 
        if (track == data->act_track) {
                col[3] = 1.0f;
-               glLineWidth(2.0f);
+               GPU_line_width(2.0f);
        }
        else {
                col[3] = 0.5f;
-               glLineWidth(1.0f);
+               GPU_line_width(1.0f);
        }
 
        immUniformColor4fv(col);
@@ -152,13 +153,13 @@ static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc, unsigned int p
                                           (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
                                           &userdata, tracking_segment_knot_cb, NULL, NULL);
        /* draw graph lines */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        clip_graph_tracking_values_iterate(sc,
                                           (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
                                           (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
                                           &userdata, tracking_segment_point_cb, tracking_segment_start_cb,
                                           tracking_segment_end_cb);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* selected knot handles on top of curves */
        userdata.sel = true;
@@ -226,11 +227,11 @@ static void tracking_error_segment_start_cb(void *userdata, MovieTrackingTrack *
 
                if (track == data->active_track) {
                        col[3] = 1.0f;
-                       glLineWidth(2.0f);
+                       GPU_line_width(2.0f);
                }
                else {
                        col[3] = 0.5f;
-                       glLineWidth(1.0f);
+                       GPU_line_width(1.0f);
                }
 
                immUniformColor4fv(col);
@@ -330,7 +331,7 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
                unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-               glPointSize(3.0f);
+               GPU_point_size(3.0f);
 
                if (sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) {
                        draw_tracks_motion_curves(v2d, sc, pos);
index a666b20dfa479947a728f362f11a55c90ca7453b..c3208260b3b19317604a1eb50e113ec6a629a719 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -269,8 +270,8 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
        UI_view2d_view_ortho(v2d);
 
        /* currently clip editor supposes that editing clip length is equal to scene frame range */
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-       glEnable(GL_BLEND);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -279,12 +280,12 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
        immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
        immRectf(pos, (float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        immUniformThemeColorShade(TH_BACK, -60);
 
        /* thin lines where the actual frames are */
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        immBegin(GWN_PRIM_LINES, 4);
        immVertex2f(pos, (float)SFRA, v2d->cur.ymin);
index b050e9911405f9a5f3d30644af26bce43e0acb52..2e98e3cec5c8538cf46c3b2dbaa3ccbd2b1ebc0d 100644 (file)
@@ -63,6 +63,7 @@
 
 #include "GPU_glew.h"
 #include "GPU_matrix.h"
+#include "GPU_framebuffer.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -1146,7 +1147,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        /* data... */
        movieclip_main_area_set_view2d(C, ar);
@@ -1253,7 +1254,7 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
@@ -1295,7 +1296,7 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
@@ -1368,7 +1369,7 @@ static void clip_channels_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
index c65c9a175a0974e5e7f346b7b56ead35f17ea41c..74bc7e956433e4150b9d76a5d842bd2155c7d6e8 100644 (file)
@@ -49,6 +49,7 @@
 #include "UI_view2d.h"
 
 #include "console_intern.h" // own include
+#include "GPU_framebuffer.h"
 
 /* ******************** default callbacks for console space ***************** */
 
@@ -227,7 +228,7 @@ static void console_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        /* worlks best with no view2d matrix set */
        UI_view2d_view_ortho(v2d);
index 360009d3ea499c4ead9f35370ac84d6458af9db7..4d4845c41b96ba10da5c4c932c768e18046d77fb 100644 (file)
@@ -74,6 +74,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
+#include "GPU_state.h"
 
 #include "filelist.h"
 
@@ -377,14 +378,14 @@ static void file_draw_preview(
        xco = sx + (int)dx;
        yco = sy - layout->prv_h + (int)dy;
 
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        /* shadow */
        if (use_dropshadow) {
                UI_draw_box_shadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
        }
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        /* the image */
        if (!is_icon && typeflags & FILE_TYPE_FTFONT) {
@@ -419,7 +420,7 @@ static void file_draw_preview(
                UI_but_drag_set_image(but, BLI_strdup(path), icon, imb, scale, true);
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
index 7b045a42595fe57e9ae9cdbcee76ca3f8960f135..8798c7b01c014e6a57b1fe02e4b2fb40f3e2ca6d 100644 (file)
@@ -65,6 +65,7 @@
 #include "file_intern.h"    // own include
 #include "fsmenu.h"
 #include "filelist.h"
+#include "GPU_framebuffer.h"
 
 /* ******************** default callbacks for file space ***************** */
 
@@ -408,8 +409,8 @@ static void file_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_GetThemeColor3fv(TH_BACK, col);
-       glClearColor(col[0], col[1], col[2], 0.0);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear_color(col[0], col[1], col[2], 0.0);
+       GPU_clear(GPU_COLOR_BIT);
 
        /* Allow dynamically sliders to be set, saves notifiers etc. */
 
@@ -687,8 +688,8 @@ static void file_ui_region_draw(const bContext *C, ARegion *ar)
        float col[3];
        /* clear */
        UI_GetThemeColor3fv(TH_BACK, col);
-       glClearColor(col[0], col[1], col[2], 0.0);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear_color(col[0], col[1], col[2], 0.0);
+       GPU_clear(GPU_COLOR_BIT);
 
        /* scrolling here is just annoying, disable it */
        ar->v2d.cur.ymax = BLI_rctf_size_y(&ar->v2d.cur);
index 7c6af0b4c620ff8fd2b55354ab589b54f1679aaf..87fe4a6234328b64caf0681d46c4803f3dd12a1e 100644 (file)
@@ -51,6 +51,7 @@
 #include "GPU_draw.h"
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "ED_anim_api.h"
 
@@ -87,12 +88,12 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
 
        const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
        float viewport_size[4];
-       glGetFloatv(GL_VIEWPORT, viewport_size);
+       GPU_viewport_size_getf(viewport_size);
        immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
        immUniform1i("num_colors", 0);  /* Simple dashes. */
@@ -114,7 +115,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
 
        if (env->totvert > 0) {
                /* set size of vertices (non-adjustable for now) */
-               glPointSize(2.0f);
+               GPU_point_size(2.0f);
 
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
@@ -281,7 +282,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        GPU_enable_program_point_size();
 
        /* draw the two handles first (if they're shown, the curve doesn't have just a single keyframe, and the curve is being edited) */
@@ -293,7 +294,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool
        draw_fcurve_keyframe_vertices(fcu, v2d, !(fcu->flag & FCURVE_PROTECTED), pos);
 
        GPU_disable_program_point_size();
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 /* Handles ---------------- */
@@ -449,8 +450,8 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
        /* draw */
        if (first && last) {
                /* anti-aliased lines for more consistent appearance */
-               if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
-               glEnable(GL_BLEND);
+               if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) GPU_line_smooth(true);
+               GPU_blend(true);
 
                unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -462,8 +463,8 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
 
                immUnbindProgram();
 
-               glDisable(GL_BLEND);
-               if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
+               GPU_blend(false);
+               if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) GPU_line_smooth(false);
        }
 }
 
@@ -846,7 +847,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
        immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
        float viewport_size[4];
-       glGetFloatv(GL_VIEWPORT, viewport_size);
+       GPU_viewport_size_getf(viewport_size);
        immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
        immUniform1i("num_colors", 0);  /* Simple dashes. */
@@ -862,7 +863,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
 
                immUniform1f("dash_width", 40.0f);
                immUniform1f("dash_factor", 0.5f);
-               glLineWidth(2.0f);
+               GPU_line_width(2.0f);
 
                /* draw 1-1 line, stretching just past the screen limits
                 * NOTE: we need to scale the y-values to be valid for the units
@@ -925,7 +926,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
                        /* x marks the spot .................................................... */
                        /* -> outer frame */
                        immUniformColor3f(0.9f, 0.9f, 0.9f);
-                       glPointSize(7.0);
+                       GPU_point_size(7.0);
 
                        immBegin(GWN_PRIM_POINTS, 1);
                        immVertex2f(shdr_pos, x, y);
@@ -933,7 +934,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
 
                        /* inner frame */
                        immUniformColor3f(0.9f, 0.0f, 0.0f);
-                       glPointSize(3.0);
+                       GPU_point_size(3.0);
 
                        immBegin(GWN_PRIM_POINTS, 1);
                        immVertex2f(shdr_pos, x, y);
@@ -954,20 +955,20 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
        FCurve *fcu;
 
        /* draw with thick dotted lines */
-       glLineWidth(3.0f);
+       GPU_line_width(3.0f);
 
        /* anti-aliased lines for less jagged appearance */
        if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
-               glEnable(GL_LINE_SMOOTH);
+               GPU_line_smooth(true);
        }
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 
        immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
        float viewport_size[4];
-       glGetFloatv(GL_VIEWPORT, viewport_size);
+       GPU_viewport_size_getf(viewport_size);
        immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
        immUniform1i("num_colors", 0);  /* Simple dashes. */
@@ -989,9 +990,9 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
        immUnbindProgram();
 
        if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
-               glDisable(GL_LINE_SMOOTH);
+               GPU_line_smooth(false);
        }
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 /* This is called twice from space_graph.c -> graph_main_region_draw()
@@ -1036,24 +1037,24 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
                        /* set color/drawing style for curve itself */
                        /* draw active F-Curve thicker than the rest to make it stand out */
                        if (fcu->flag & FCURVE_ACTIVE) {
-                               glLineWidth(2.5);
+                               GPU_line_width(2.5);
                        }
                        else {
-                               glLineWidth(1.0);
+                               GPU_line_width(1.0);
                        }
 
                        /* anti-aliased lines for less jagged appearance */
                        if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
-                               glEnable(GL_LINE_SMOOTH);
+                               GPU_line_smooth(true);
                        }
-                       glEnable(GL_BLEND);
+                       GPU_blend(true);
 
                        const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 
                        immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
                        float viewport_size[4];
-                       glGetFloatv(GL_VIEWPORT, viewport_size);
+                       GPU_viewport_size_getf(viewport_size);
                        immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
                        immUniform1i("num_colors", 0);  /* Simple dashes. */
@@ -1104,9 +1105,9 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
                        immUnbindProgram();
 
                        if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
-                               glDisable(GL_LINE_SMOOTH);
+                               GPU_line_smooth(false);
                        }
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
                }
 
                /* 2) draw handles and vertices as appropriate based on active
@@ -1134,16 +1135,16 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
                                gpuTranslate2f(0.0f, offset);
 
                                /* set this once and for all - all handles and handle-verts should use the same thickness */
-                               glLineWidth(1.0);
+                               GPU_line_width(1.0);
 
                                if (fcu->bezt) {
                                        bool do_handles = draw_fcurve_handles_check(sipo, fcu);
 
                                        if (do_handles) {
                                                /* only draw handles/vertices on keyframes */
-                                               glEnable(GL_BLEND);
+                                               GPU_blend(true);
                                                draw_fcurve_handles(sipo, fcu);
-                                               glDisable(GL_BLEND);
+                                               GPU_blend(false);
                                        }
 
                                        draw_fcurve_vertices(ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY));
@@ -1229,8 +1230,8 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
                y = (float)ACHANNEL_FIRST(ac);
 
                /* set blending again, as may not be set in previous step */
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-               glEnable(GL_BLEND);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
 
                for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
                        const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac));
@@ -1252,7 +1253,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
                UI_block_end(C, block);
                UI_block_draw(C, block);
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        /* free tempolary channels */
index 7c3105843c539c89be102fbc8c10427825345ede..878c4815f73bd19009aca983870e27c5d58646e3 100644 (file)
@@ -54,6 +54,8 @@
 #include "ED_markers.h"
 
 #include "GPU_immediate.h"
+#include "GPU_state.h"
+#include "GPU_framebuffer.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -240,8 +242,8 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_GetThemeColor3fv(TH_BACK, col);
-       glClearColor(col[0], col[1], col[2], 0.0);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear_color(col[0], col[1], col[2], 0.0);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
@@ -287,15 +289,15 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
 
                        /* Draw a green line to indicate the cursor value */
                        immUniformThemeColorShadeAlpha(TH_CFRAME, -10, -50);
-                       glEnable(GL_BLEND);
-                       glLineWidth(2.0);
+                       GPU_blend(true);
+                       GPU_line_width(2.0);
 
                        immBegin(GWN_PRIM_LINES, 2);
                        immVertex2f(pos, v2d->cur.xmin, y);
                        immVertex2f(pos, v2d->cur.xmax, y);
                        immEnd();
 
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
                }
 
                /* current frame or vertical component of vertical component of the cursor */
@@ -305,15 +307,15 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
 
                        /* to help differentiate this from the current frame, draw slightly darker like the horizontal one */
                        immUniformThemeColorShadeAlpha(TH_CFRAME, -40, -50);
-                       glEnable(GL_BLEND);
-                       glLineWidth(2.0);
+                       GPU_blend(true);
+                       GPU_line_width(2.0);
 
                        immBegin(GWN_PRIM_LINES, 2);
                        immVertex2f(pos, x, v2d->cur.ymin);
                        immVertex2f(pos, x, v2d->cur.ymax);
                        immEnd();
 
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
                }
 
                immUnbindProgram();
@@ -381,8 +383,8 @@ static void graph_channel_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_GetThemeColor3fv(TH_BACK, col);
-       glClearColor(col[0], col[1], col[2], 0.0);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear_color(col[0], col[1], col[2], 0.0);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
index 1e2d668018f9b0b24bfa96612ac645daa22e716f..11e06c168b4471e3fcfb325389a4d72111d060f5 100644 (file)
@@ -65,6 +65,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "BLF_api.h"
 
@@ -130,7 +131,7 @@ static void draw_render_info(const bContext *C,
                        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
                        immUniformThemeColor(TH_FACE_SELECT);
 
-                       glLineWidth(1.0f);
+                       GPU_line_width(1.0f);
 
                        rcti *tile = tiles;
                        for (int i = 0; i < total_tiles; i++, tile++) {
@@ -170,8 +171,8 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
        float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0;
        float col[4], finalcol[4];
 
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-       glEnable(GL_BLEND);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -182,7 +183,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
 
        immUnbindProgram();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        BLF_size(blf_mono_font, 11 * U.pixelsize, U.dpi);
 
@@ -323,7 +324,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
                copy_v4_v4(finalcol, col);
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
        dx += 0.25f * UI_UNIT_X;
 
        BLI_rcti_init(&color_rect, dx, dx + (1.5f * UI_UNIT_X), 0.15f * UI_UNIT_Y, 0.85f * UI_UNIT_Y);
@@ -354,10 +355,10 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d
                immRecti(pos, color_quater_x, color_quater_y, color_rect_half.xmax, color_rect_half.ymax);
                immRecti(pos, color_rect_half.xmin, color_rect_half.ymin, color_quater_x, color_quater_y);
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                immUniformColor3fvAlpha(finalcol, fp ? fp[3] : (cp[3] / 255.0f));
                immRecti(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
        else {
                immUniformColor3fv(finalcol);
@@ -503,8 +504,8 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
                if (sima->flag & SI_USE_ALPHA) {
                        imm_draw_box_checker_2d(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
 
-                       glEnable(GL_BLEND);
-                       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+                       GPU_blend(true);
+                       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
                }
 
                /* If RGBA display with color management */
@@ -544,7 +545,7 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
                }
 
                if (sima->flag & SI_USE_ALPHA)
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
        }
 }
 
@@ -578,7 +579,7 @@ void draw_image_sample_line(SpaceImage *sima)
                immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
                float viewport_size[4];
-               glGetFloatv(GL_VIEWPORT, viewport_size);
+               GPU_viewport_size_getf(viewport_size);
                immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
                immUniform1i("num_colors", 2);  /* Advanced dashes. */
@@ -618,13 +619,13 @@ static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scen
                                return;
                        }
 
-                       glEnable(GL_BLEND);
-                       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+                       GPU_blend(true);
+                       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                        IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
                        immDrawPixelsTex(&state, x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer, zoomx, zoomy, col);
 
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
 
                        BKE_image_release_ibuf(brush->clone.image, ibuf, NULL);
                        IMB_display_buffer_release(cache_handle);
@@ -758,8 +759,8 @@ void draw_image_cache(const bContext *C, ARegion *ar)
                mask = ED_space_image_get_mask(sima);
        }
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        /* Draw cache background. */
        ED_region_cache_draw_background(ar);
@@ -773,7 +774,7 @@ void draw_image_cache(const bContext *C, ARegion *ar)
                ED_region_cache_draw_cached_segments(ar, num_segments, points, sfra + sima->iuser.offset, efra + sima->iuser.offset);
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* Draw current frame. */
        x = (cfra - sfra) / (efra - sfra + 1) * ar->winx;
index 827c39b8033c1eccb2f7e8bab849d2244abdcc02..792dc25981e66299efca6fd5c2465116a816f94b 100644 (file)
@@ -79,6 +79,7 @@
 #include "UI_view2d.h"
 
 #include "image_intern.h"
+#include "GPU_framebuffer.h"
 
 /**************************** common state *****************************/
 
@@ -722,8 +723,8 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_GetThemeColor3fv(TH_BACK, col);
-       glClearColor(col[0], col[1], col[2], 0.0);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear_color(col[0], col[1], col[2], 0.0);
+       GPU_clear(GPU_COLOR_BIT);
 
        image_user_refresh_scene(C, sima);
 
index 9421567b6ba082f199b1ba7034ec29ee216a88ec..ecd0b082df607441429aa3ae5d72d17ebb342555 100644 (file)
@@ -51,6 +51,7 @@
 
 #include "info_intern.h"
 #include "textview.h"
+#include "GPU_framebuffer.h"
 
 /* complicates things a bit, so leaving in old simple code */
 #define USE_INFO_NEWLINE
@@ -130,7 +131,7 @@ static int report_textview_begin(TextViewContext *tvc)
        tvc->iter = reports->list.last;
 
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
 #ifdef USE_INFO_NEWLINE
        tvc->iter_tmp = 0;
index 65b3c7bb9fd84cc958bfa1248d0e1fc3c4094fb4..4273404ac90d57932412371d7f3db0bc5120a86f 100644 (file)
@@ -60,6 +60,7 @@
 
 #include "info_intern.h"  /* own include */
 #include "BLO_readfile.h"
+#include "GPU_framebuffer.h"
 
 /* ******************** default callbacks for info space ***************** */
 
@@ -157,7 +158,7 @@ static void info_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        /* quick way to avoid drawing if not bug enough */
        if (ar->winy < 16)
index 85de70c020f1aa273edbd327760c0b3038305d5a..a1e3842f887272efa1790628b30b6cc7a0081372 100644 (file)
@@ -40,6 +40,7 @@
 #include "BLI_string_utf8.h"
 
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "BIF_gl.h"
 
@@ -81,8 +82,8 @@ static void console_draw_sel(const char *str, const int sel[2], const int xy[2],
                const int sta = txt_utf8_offset_to_column(str, max_ii(sel[0], 0));
                const int end = txt_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw));
 
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                Gwn_VertFormat *format = immVertexFormat();
                unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
@@ -93,7 +94,7 @@ static void console_draw_sel(const char *str, const int sel[2], const int xy[2],
 
                immUnbindProgram();
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 }
 
index 3f1ab059a913aff40f12a4c2606c4feb8431099c..16fb3576ae8dfe8a5959e85cf3cfaff4f78703c4 100644 (file)
@@ -58,6 +58,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_draw.h"
+#include "GPU_state.h"
 
 #include "WM_types.h"
 
@@ -181,7 +182,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax
                immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
                float viewport_size[4];
-               glGetFloatv(GL_VIEWPORT, viewport_size);
+               GPU_viewport_size_getf(viewport_size);
                immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
                immUniform1i("num_colors", 0);  /* "simple" mode */
@@ -212,7 +213,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax
 /* Markers inside a NLA-Strip */
 static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
 {
-       glLineWidth(2.0f);
+       GPU_line_width(2.0f);
 
        if (strip->type == NLASTRIP_TYPE_CLIP) {
                /* try not to be too conspicuous, while being visible enough when transforming */
@@ -232,7 +233,7 @@ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
                }
        }
 
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 }
 
 /* Strips (Proper) ---------------------- */
@@ -307,8 +308,8 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns
        immUniformColor3f(0.7f, 0.7f, 0.7f);
 
        /* draw with AA'd line */
-       glEnable(GL_LINE_SMOOTH);
-       glEnable(GL_BLEND);
+       GPU_line_smooth(true);
+       GPU_blend(true);
 
        /* influence -------------------------- */
        if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) {
@@ -357,8 +358,8 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns
        }
 
        /* turn off AA'd lines */
-       glDisable(GL_LINE_SMOOTH);
-       glDisable(GL_BLEND);
+       GPU_line_smooth(false);
+       GPU_blend(false);
 }
 
 /* helper call to setup dashed-lines for strip outlines */
@@ -369,7 +370,7 @@ static uint nla_draw_use_dashed_outlines(float color[4], bool muted)
        immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
        float viewport_size[4];
-       glGetFloatv(GL_VIEWPORT, viewport_size);
+       GPU_viewport_size_getf(viewport_size);
        immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
        immUniform1i("num_colors", 0);  /* Simple dashes. */
@@ -380,12 +381,12 @@ static uint nla_draw_use_dashed_outlines(float color[4], bool muted)
                /* dotted - and slightly thicker for readability of the dashes */
                immUniform1f("dash_width", 5.0f);
                immUniform1f("dash_factor", 0.4f);
-               glLineWidth(1.5f);
+               GPU_line_width(1.5f);
        }
        else {
                /* solid line */
                immUniform1f("dash_factor", 2.0f);
-               glLineWidth(1.0f);
+               GPU_line_width(1.0f);
        }
 
        return shdr_pos;
@@ -410,8 +411,8 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
         */
        if ((strip->extendmode != NLASTRIP_EXTEND_NOTHING) && (non_solo == 0)) {
                /* enable transparency... */
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-               glEnable(GL_BLEND);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
 
                switch (strip->extendmode) {
                        /* since this does both sides, only do the 'before' side, and leave the rest to the next case */
@@ -442,7 +443,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
                                break;
                }
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
 
@@ -462,9 +463,9 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri
                /* strip is in disabled track - make less visible */
                immUniformColor3fvAlpha(color, 0.1f);
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                immRectf(shdr_pos, strip->start, yminc, strip->end, ymaxc);
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
 
@@ -711,8 +712,8 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
                                        /* just draw a semi-shaded rect spanning the width of the viewable area if there's data,
                                         * and a second darker rect within which we draw keyframe indicator dots if there's data
                                         */
-                                       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-                                       glEnable(GL_BLEND);
+                                       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+                                       GPU_blend(true);
 
                                        /* get colors for drawing */
                                        float color[4];
@@ -726,7 +727,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
 
                                        /* draw 'embossed' lines above and below the strip for effect */
                                        /* white base-lines */
-                                       glLineWidth(2.0f);
+                                       GPU_line_width(2.0f);
                                        immUniformColor4f(1.0f, 1.0f, 1.0f, 0.3f);
                                        immBegin(GWN_PRIM_LINES, 4);
                                        immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP);
@@ -736,7 +737,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
                                        immEnd();
 
                                        /* black top-lines */
-                                       glLineWidth(1.0f);
+                                       GPU_line_width(1.0f);
                                        immUniformColor3f(0.0f, 0.0f, 0.0f);
                                        immBegin(GWN_PRIM_LINES, 4);
                                        immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP);
@@ -752,7 +753,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
                                        /* draw keyframes in the action */
                                        nla_action_draw_keyframes(adt, ale->data, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP);
 
-                                       glDisable(GL_BLEND);
+                                       GPU_blend(false);
                                        break;
                                }
                        }
@@ -828,8 +829,8 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
                y = (float)(-NLACHANNEL_HEIGHT(snla));
 
                /* set blending again, as may not be set in previous step */
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-               glEnable(GL_BLEND);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
 
                /* loop through channels, and set up drawing depending on their type  */
                for (ale = anim_data.first; ale; ale = ale->next) {
@@ -852,7 +853,7 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar)
                UI_block_end(C, block);
                UI_block_draw(C, block);
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        /* free temporary channels */
index 745cea37ea301cb0b2271c47d97990de3aaa366f..62144db0577a10761e6832402aea6411c7468280 100644 (file)
@@ -63,6 +63,7 @@
 #include "UI_view2d.h"
 
 #include "nla_intern.h" /* own include */
+#include "GPU_framebuffer.h"
 
 /* ******************** manage regions ********************* */
 
@@ -232,7 +233,7 @@ static void nla_channel_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
@@ -278,7 +279,7 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
index a162a8630388ae1550c2aad7ae87997d243d1d9b..12da5086c52e819fafd0ded21784ef61d7f62850 100644 (file)
@@ -56,6 +56,7 @@
 #include "GPU_batch.h"
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -562,8 +563,8 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(
 
        /* outline active and selected emphasis */
        if (node->flag & SELECT) {
-               glEnable(GL_BLEND);
-               glEnable(GL_LINE_SMOOTH);
+               GPU_blend(true);
+               GPU_line_smooth(true);
                /* using different shades of TH_TEXT_HI for the empasis, like triangle */
                if (node->flag & NODE_ACTIVE) {
                        UI_GetThemeColorShadeAlpha4fv(TH_TEXT_HI, 0, -40, debug_color);
@@ -573,8 +574,8 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(
                }
                UI_draw_roundbox_4fv(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size, debug_color);
 
-               glDisable(GL_LINE_SMOOTH);
-               glDisable(GL_BLEND);
+               GPU_line_smooth(false);
+               GPU_blend(false);
        }
 #endif
 
@@ -3214,12 +3215,12 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
                                GPU_shader_unbind();
                        }
                        else if (snode->flag & SNODE_USE_ALPHA) {
-                               glEnable(GL_BLEND);
-                               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+                               GPU_blend(true);
+                               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                                glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
 
-                               glDisable(GL_BLEND);
+                               GPU_blend(false);
                        }
                        else {
                                glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
@@ -3503,7 +3504,7 @@ static void nodelink_batch_draw(SpaceNode *snode)
        if (g_batch_link.count == 0)
                return;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        float colors[6][4] = {{0.0f}};
        UI_GetThemeColor4fv(TH_WIRE_INNER,  colors[nodelink_get_color_id(TH_WIRE_INNER)]);
@@ -3523,7 +3524,7 @@ static void nodelink_batch_draw(SpaceNode *snode)
 
        nodelink_batch_reset();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 void nodelink_batch_start(SpaceNode *UNUSED(snode))
index 8089f47bce48d84a503046512846add86c3064b7..01e22ec5245d556257c96af57d29d82781f01d0b 100644 (file)
@@ -58,6 +58,8 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
+#include "GPU_framebuffer.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -620,12 +622,12 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node)
 {
        bNodeLink *link;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        for (link = node->internal_links.first; link; link = link->next)
                node_draw_link_bezier(v2d, snode, link, TH_REDALERT, TH_REDALERT, -1);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void node_socket_circle_draw(const bContext *C, bNodeTree *ntree, PointerRNA node_ptr, bNodeSocket *sock, unsigned pos, unsigned col)
@@ -710,14 +712,14 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
 
        node_draw_preview_background(BLI_rctf_size_x(prv) / 10.0f, &draw_rect);
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);  /* premul graphics */
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);  /* premul graphics */
 
        IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
        immDrawPixelsTex(&state, draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect,
                         scale, scale, NULL);
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -773,7 +775,7 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        unsigned int col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        GPU_enable_program_point_size();
 
        immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA);
@@ -864,7 +866,7 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *
        immUnbindProgram();
 
        GPU_disable_program_point_size();
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key)
@@ -903,7 +905,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
                }
        }
 
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
        UI_draw_roundbox_aa(true, rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD, color);
@@ -1048,13 +1050,13 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
 
        /* custom color inline */
        if (node->flag & NODE_CUSTOM_COLOR) {
-               glEnable(GL_BLEND);
-               glEnable(GL_LINE_SMOOTH);
+               GPU_blend(true);
+               GPU_line_smooth(true);
 
                UI_draw_roundbox_3fvAlpha(false, rct->xmin + 1, rct->ymin + 1, rct->xmax -1, rct->ymax - 1, hiddenrad, node->color, 1.0f);
 
-               glDisable(GL_LINE_SMOOTH);
-               glDisable(GL_BLEND);
+               GPU_line_smooth(false);
+               GPU_blend(false);
        }
 
        /* title */
@@ -1239,14 +1241,14 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT
        }
 
        /* node lines */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        nodelink_batch_start(snode);
        for (link = ntree->links.first; link; link = link->next) {
                if (!nodeLinkIsHidden(link))
                        node_draw_link(&ar->v2d, snode, link);
        }
        nodelink_batch_end(snode);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* draw foreground nodes, last nodes in front */
        for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) {
@@ -1303,12 +1305,12 @@ static void draw_group_overlay(const bContext *C, ARegion *ar)
        float color[4];
 
        /* shade node groups to separate them visually */
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        UI_GetThemeColorShadeAlpha4fv(TH_NODE_GROUP, 0, -70, color);
        UI_draw_roundbox_corner_set(UI_CNR_NONE);
        UI_draw_roundbox_4fv(true, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0, color);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        /* set the block bounds to clip mouse events from underlying nodes */
        block = UI_block_begin(C, ar, "node tree bounds block", UI_EMBOSS);
@@ -1325,7 +1327,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
        View2D *v2d = &ar->v2d;
 
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
@@ -1338,7 +1340,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
        ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
 
        /* only set once */
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        /* nodes */
        snode_set_context(C);
@@ -1418,14 +1420,14 @@ void drawnodespace(const bContext *C, ARegion *ar)
                }
 
                /* temporary links */
-               glEnable(GL_BLEND);
-               glEnable(GL_LINE_SMOOTH);
+               GPU_blend(true);
+               GPU_line_smooth(true);
                for (nldrag = snode->linkdrag.first; nldrag; nldrag = nldrag->next) {
                        for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next)
                                node_draw_link(v2d, snode, (bNodeLink *)linkdata->data);
                }
-               glDisable(GL_LINE_SMOOTH);
-               glDisable(GL_BLEND);
+               GPU_line_smooth(false);
+               GPU_blend(false);
 
                if (snode->flag & SNODE_SHOW_GPENCIL) {
                        /* draw grease-pencil ('canvas' strokes) */
index e617bb408370d5c6050d78421bc9ea7b5ab18f58..19e5217cdd2ca5f2ad7f0f0b166fa7c855cb525a 100644 (file)
@@ -72,6 +72,7 @@
 #include "WM_types.h"
 
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "UI_interface.h"
 #include "UI_interface_icons.h"
@@ -739,7 +740,7 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex)
        float miny = v2d->cur.ymin;
        if (miny < v2d->tot.ymin) miny = v2d->tot.ymin;
 
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -855,9 +856,9 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon)
 {
        /* restrict column clip... it has been coded by simply overdrawing, doesnt work for buttons */
        if (arg->x >= arg->xmax) {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
                UI_icon_draw_alpha(arg->x, arg->y, icon, arg->alpha);
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
        else {
                uiBut *but = uiDefIconBut(
@@ -1383,7 +1384,7 @@ static void outliner_draw_iconrow_number(
                                 (float)ys - UI_UNIT_Y * 0.095f + ufac,
                                 number_text, text_col);
        UI_fontstyle_set(fstyle);
-       glEnable(GL_BLEND); /* Roundbox and text drawing disables. */
+       GPU_blend(true); /* Roundbox and text drawing disables. */
 }
 
 static void outliner_draw_iconrow_doit(
@@ -1409,7 +1410,7 @@ static void outliner_draw_iconrow_doit(
                                    (float)ys + UI_UNIT_Y - ufac,
                                    (float)UI_UNIT_Y / 2.0f - ufac,
                                    color);
-               glEnable(GL_BLEND); /* Roundbox disables. */
+               GPU_blend(true); /* Roundbox disables. */
        }
 
        /* No inlined icon should be clickable. */
@@ -1579,7 +1580,7 @@ static void outliner_draw_tree_element(
                if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0)
                        xmax -= OL_TOGW + UI_UNIT_X;
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                /* colors for active/selected data */
                if (tselem->type == 0) {
@@ -1642,7 +1643,7 @@ static void outliner_draw_tree_element(
                                (float)startx + 2.0f * UI_UNIT_X - 1.0f * ufac,
                                (float)*starty + UI_UNIT_Y - 1.0f * ufac,
                                UI_UNIT_Y / 2.0f - 1.0f * ufac, color);
-                       glEnable(GL_BLEND); /* roundbox disables it */
+                       GPU_blend(true); /* roundbox disables it */
 
                        te->flag |= TE_ACTIVE; // for lookup in display hierarchies
                }
@@ -1701,7 +1702,7 @@ static void outliner_draw_tree_element(
                                alpha_fac);
                        offsx += UI_UNIT_X + 2 * ufac;
                }
-               glDisable(GL_BLEND);
+               GPU_blend(false);
 
                /* name */
                if ((tselem->flag & TSE_TEXTBUT) == 0) {
@@ -1734,7 +1735,7 @@ static void outliner_draw_tree_element(
                                else if (tselem->type != TSE_R_LAYER) {
                                        int tempx = startx + offsx;
 
-                                       glEnable(GL_BLEND);
+                                       GPU_blend(true);
 
                                        /* divider */
                                        {
@@ -1758,7 +1759,7 @@ static void outliner_draw_tree_element(
                                                C, block, fstyle, scene, view_layer, soops, &te->subtree, 0, xmax, &tempx,
                                                *starty, alpha_fac);
 
-                                       glDisable(GL_BLEND);
+                                       GPU_blend(false);
                                }
                        }
                }
@@ -1808,14 +1809,14 @@ static void outliner_draw_tree_element_floating(
 
        UI_GetThemeColorShade4fv(TH_BACK, -40, col);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        if (ELEM(te_floating->drag_data->insert_type, TE_INSERT_BEFORE, TE_INSERT_AFTER)) {
                if (te_floating->drag_data->insert_type == TE_INSERT_BEFORE) {
                        coord_y += UI_UNIT_Y;
                }
                immUniformColor4fv(col);
-               glLineWidth(line_width);
+               GPU_line_width(line_width);
 
                immBegin(GWN_PRIM_LINE_STRIP, 2);
                immVertex2f(pos, coord_x, coord_y);
@@ -1834,7 +1835,7 @@ static void outliner_draw_tree_element_floating(
                immEnd();
        }
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
        immUnbindProgram();
 }
 
@@ -1908,9 +1909,9 @@ static void outliner_draw_hierarchy_lines(SpaceOops *soops, ListBase *lb, int st
        UI_GetThemeColorBlend3ubv(TH_BACK, TH_TEXT, 0.4f, col);
        col[3] = 255;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        outliner_draw_hierarchy_lines_recursive(pos, soops, lb, startx, col, false, starty);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 
        immUnbindProgram();
 }
@@ -2005,7 +2006,7 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx,
        UI_GetThemeColor4fv(TH_MATCH, col_searchmatch);
        col_searchmatch[3] = 0.5f;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        Gwn_VertFormat *format = immVertexFormat();
        unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -2013,7 +2014,7 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx,
                pos, ar, soops, &soops->tree, col_selection, col_highlight, col_searchmatch,
                startx, starty);
        immUnbindProgram();
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static void outliner_draw_tree(
@@ -2025,7 +2026,7 @@ static void outliner_draw_tree(
        TreeElement *te_floating = NULL;
        int starty, startx;
 
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // only once
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); // only once
 
        if (soops->outlinevis == SO_DATA_API) {
                /* struct marks */
@@ -2039,13 +2040,13 @@ static void outliner_draw_tree(
        outliner_draw_highlights(ar, soops, startx, &starty);
 
        /* set scissor so tree elements or lines can't overlap restriction icons */
-       GLfloat scissor[4] = {0};
+       float scissor[4] = {0};
        if (has_restrict_icons) {
                int mask_x = BLI_rcti_size_x(&ar->v2d.mask) - (int)OL_TOGW + 1;
                CLAMP_MIN(mask_x, 0);
 
-               glGetFloatv(GL_SCISSOR_BOX, scissor);
-               glScissor(0, 0, mask_x, ar->winy);
+               GPU_scissor_getf(scissor);
+               GPU_scissor(0, 0, mask_x, ar->winy);
        }
 
        // gray hierarchy lines
@@ -2069,7 +2070,7 @@ static void outliner_draw_tree(
 
        if (has_restrict_icons) {
                /* reset scissor */
-               glScissor(UNPACK4(scissor));
+               GPU_scissor(UNPACK4(scissor));
        }
 }
 
@@ -2111,7 +2112,7 @@ static void outliner_back(ARegion *ar)
 
 static void outliner_draw_restrictcols(ARegion *ar)
 {
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
index 316caf0e23900921aecda59092abeb8afc853f56..786172ca18e15c267eae5fc1bf7c76d924f3ed3c 100644 (file)
@@ -41,6 +41,7 @@
 #include "BKE_main.h"
 
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "RNA_access.h"
 
@@ -346,9 +347,9 @@ static void outliner_drag_drop_tooltip_cb(const wmWindow *win, void *vdata)
        const float col_fg[4] = {1.0f, 1.0f, 1.0f, 1.0f};
        const float col_bg[4] = {0.0f, 0.0f, 0.0f, 0.2f};
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
        UI_fontstyle_draw_simple_backdrop(fstyle, x, y, tooltip, col_fg, col_bg);
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 static int outliner_item_drag_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
index 71ae7eeeb3d45ea5d2022ee7a51aea03b0090b1a..f1431647754e40c13165a67e69f26242be806841 100644 (file)
@@ -63,6 +63,7 @@
 
 
 #include "outliner_intern.h"
+#include "GPU_framebuffer.h"
 
 static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar)
 {
@@ -289,7 +290,7 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        draw_outliner(C);
 
index c8e5a4bdf8742a9bff0db4c0a9631c33890d61f4..fcda16b846bb0c553e225473f22c62f92624b186 100644 (file)
@@ -55,6 +55,7 @@
 #endif
 
 #include "script_intern.h"  // own include
+#include "GPU_framebuffer.h"
 
 
 //static script_run_python(char *funcname, )
@@ -144,7 +145,7 @@ static void script_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
index ffcb43297265d2a38b64933ff8430db03c0f75d0..1ac628a8b54ed8bce112fbdf73003d78e15c2924 100644 (file)
@@ -61,6 +61,8 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
+#include "GPU_framebuffer.h"
 
 #include "ED_anim_api.h"
 #include "ED_gpencil.h"
@@ -263,7 +265,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
 
                immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
 
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                immBegin(GWN_PRIM_TRI_STRIP, length * 2);
 
@@ -296,7 +298,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
 
                immEnd();
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 }
 static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2)
@@ -328,8 +330,8 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
                offset = 0;
        }
 
-       glEnable(GL_BLEND);
-       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+       GPU_blend(true);
+       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
        for (seq = seqbase->first; seq; seq = seq->next) {
                chan_min = min_ii(chan_min, seq->machine);
@@ -379,7 +381,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
 
        immUnbindProgram();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 /* clamp handles to defined size in pixel space */
@@ -432,9 +434,9 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
        if (!(seq->type & SEQ_TYPE_EFFECT) ||
            BKE_sequence_effect_get_num_inputs(seq->type) == 0)
        {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                if (seq->flag & whichsel) {
                        immUniformColor4ub(0, 0, 0, 80);
@@ -461,7 +463,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
                immVertex2fv(pos, v3);
                immEnd();
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        if ((G.moving & G_TRANSFORM_SEQ) || (seq->flag & whichsel)) {
@@ -618,8 +620,8 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u
        blendcol[0] = blendcol[1] = blendcol[2] = 120;
 
        if (seq->startofs || seq->endofs) {
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                color3ubv_from_seq(scene, seq, col);
 
@@ -658,12 +660,12 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u
        }
 
        if (seq->startofs || seq->endofs) {
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        if (seq->startstill || seq->endstill) {
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                color3ubv_from_seq(scene, seq, col);
                UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5f, 60);
@@ -691,7 +693,7 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u
        }
 
        if (seq->startstill || seq->endstill) {
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 }
 
@@ -728,8 +730,8 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
        if (seq->flag & SEQ_MUTE) {
                background_col[3] = 128;
 
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
        }
        else {
                background_col[3] = 255;
@@ -751,7 +753,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
        }
 
        if (seq->flag & SEQ_MUTE) {
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        if (!is_single_image) {
@@ -777,7 +779,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
 
        /* draw lock */
        if (seq->flag & SEQ_LOCK) {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES);
@@ -791,11 +793,11 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
 
                immUnbindProgram();
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        if (!BKE_sequence_is_valid_check(seq)) {
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES);
@@ -809,7 +811,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
 
                immUnbindProgram();
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        color3ubv_from_seq(scene, seq, col);
@@ -840,8 +842,8 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg
        if (seq->flag & SEQ_MUTE) {
                col[3] = 96;
 
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
                immUniformColor4ubv(col);
        }
@@ -1035,7 +1037,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
        float x2 = v2d->tot.xmax;
        float y2 = v2d->tot.ymax;
 
-       glLineWidth(1.0f);
+       GPU_line_width(1.0f);
 
        /* border */
        const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -1043,7 +1045,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
        immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
        float viewport_size[4];
-       glGetFloatv(GL_VIEWPORT, viewport_size);
+       GPU_viewport_size_getf(viewport_size);
        immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
        immUniformThemeColor(TH_BACK);
@@ -1124,8 +1126,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 
        if ((!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) && !draw_backdrop) {
                UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col);
-               glClearColor(col[0], col[1], col[2], 0.0);
-               glClear(GL_COLOR_BUFFER_BIT);
+               GPU_clear_color(col[0], col[1], col[2], 0.0);
+               GPU_clear(GPU_COLOR_BIT);
        }
 
        /* only initialize the preview if a render is in progress */
@@ -1221,8 +1223,8 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
        }
 
        if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) {
-               glEnable(GL_BLEND);
-               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+               GPU_blend(true);
+               GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
        }
 
        /* Format needs to be created prior to any immBindProgram call.
@@ -1418,7 +1420,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
        }
 
        if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) {
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 
        glDeleteTextures(1, &texid);
@@ -1589,7 +1591,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
        /* draw highlight when previewing a single strip */
        if (special_seq_update) {
                const Sequence *seq = special_seq_update;
-               glEnable(GL_BLEND);
+               GPU_blend(true);
 
                unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
                immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1599,7 +1601,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
 
                immUnbindProgram();
 
-               glDisable(GL_BLEND);
+               GPU_blend(false);
        }
 }
 
@@ -1609,7 +1611,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
        const int frame_sta = PSFRA;
        const int frame_end = PEFRA + 1;
 
-       glEnable(GL_BLEND);
+       GPU_blend(true);
 
        unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
@@ -1660,7 +1662,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d)
 
        immUnbindProgram();
 
-       glDisable(GL_BLEND);
+       GPU_blend(false);
 }
 
 /* Draw Timeline/Strip Editor Mode for Sequencer */
@@ -1677,10 +1679,10 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
        /* clear and setup matrix */
        UI_GetThemeColor3fv(TH_BACK, col);
        if (ed && ed->metastack.first)
-               glClearColor(col[0], col[1], col[2] - 0.1f, 0.0f);
+               GPU_clear_color(col[0], col[1], col[2] - 0.1f, 0.0f);
        else
-               glClearColor(col[0], col[1], col[2], 0.0f);
-       glClear(GL_COLOR_BUFFER_BIT);
+               GPU_clear_color(col[0], col[1], col[2], 0.0f);
+       GPU_clear(GPU_COLOR_BIT);
 
        UI_view2d_view_ortho(v2d);
 
index e827f4f01492af0105d2c8fec7ae156b93318561..f57a1c0eb89cd531b518813a0326ffdb87315716 100644 (file)
@@ -59,6 +59,7 @@
 
 #include "text_format.h"
 #include "text_intern.h"  /* own include */
+#include "GPU_framebuffer.h"
 
 /* ******************** default callbacks for text space ***************** */
 
@@ -441,7 +442,7 @@ static void text_main_region_draw(const bContext *C, ARegion *ar)
 
        /* clear and setup matrix */
        UI_ThemeClearColor(TH_BACK);
-       glClear(GL_COLOR_BUFFER_BIT);
+       GPU_clear(GPU_COLOR_BIT);
 
        // UI_view2d_view_ortho(v2d);
 
index c1b49fbd32a3d1cded6a1792ec87f81d64eddcb8..99305b143c607eeec554483ce91ac548e0823216 100644 (file)
@@ -50,6 +50,7 @@
 #include "BIF_glutil.h"
 
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "UI_interface.h"
 #include "UI_resources.h"
@@ -1207,10 +1208,10 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
 
                        immUniformColor4ub(255, 255, 255, 32);
 
-                       glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-                       glEnable(GL_BLEND);
+                       GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+                       GPU_blend(true);
                        immRecti(pos, x1 - 4, y1, x2, y2);
-                       glDisable(GL_BLEND);
+                       GPU_blend(false);
                }
        }
 
@@ -1506,7 +1507,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
                        immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
                        float viewport_size[4];
-                       glGetFloatv(GL_VIEWPORT, viewport_size);
+                       GPU_viewport_size_getf(viewport_size);
                        immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
                        immUniform1i("num_colors", 0);  /* "simple" mode */
index 1224c284d5f7a0cb2a7a45af709824e5544ce59a..5ecef03e475836dba477fcd3ad15bc8a382f0a36 100644 (file)
 #include "GPU_immediate_util.h"
 #include "GPU_batch.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
+#include "GPU_framebuffer.h"
 
 #include "ED_mesh.h"
 #include "ED_particle.h"
@@ -289,7 +291,7 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset)
 
        immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
 
-       glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
+       GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE));
 
        immBeginAtMost(GWN_PRIM_POINTS, imm_len);
        dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, &data, DM_FOREACH_NOP);
@@ -332,7 +334,7 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset)
 
        immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
 
-       glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
+       GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE));
 
        immBeginAtMost(GWN_PRIM_POINTS, em->bm->totvert);
        dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, &data, DM_FOREACH_NOP);
@@ -343,7 +345,7 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset)
 #else
 static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset)
 {
-       glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
+       GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE));
 
        Mesh *me = em->ob->data;