Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Molenkamp <github@lazydodo.com>2018-06-28 04:07:23 +0300
committerRay Molenkamp <github@lazydodo.com>2018-06-28 04:07:23 +0300
commit8e02106d0ddc7b31844d26037a824d56d3c65663 (patch)
treebfa1898220d74ac9610b8a1363a4087a44f7b41d /source/blender
parentfe258fd4451a7fb1ccdd85d1607b6dbd30442f28 (diff)
GLRefactor: partially remove gl calls from source/blender/editors.
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
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c9
-rw-r--r--source/blender/editors/animation/anim_draw.c15
-rw-r--r--source/blender/editors/animation/anim_markers.c15
-rw-r--r--source/blender/editors/animation/keyframes_draw.c5
-rw-r--r--source/blender/editors/curve/editcurve_paint.c17
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c41
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c9
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c13
-rw-r--r--source/blender/editors/interface/interface.c3
-rw-r--r--source/blender/editors/interface/interface_draw.c173
-rw-r--r--source/blender/editors/interface/interface_icons.c27
-rw-r--r--source/blender/editors/interface/interface_panel.c39
-rw-r--r--source/blender/editors/interface/interface_region_hud.c5
-rw-r--r--source/blender/editors/interface/interface_region_search.c25
-rw-r--r--source/blender/editors/interface/interface_widgets.c105
-rw-r--r--source/blender/editors/interface/resources.c5
-rw-r--r--source/blender/editors/interface/view2d.c3
-rw-r--r--source/blender/editors/manipulator_library/manipulator_draw_utils.c5
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c11
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c13
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c23
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c27
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c27
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c13
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c15
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c9
-rw-r--r--source/blender/editors/mask/mask_draw.c33
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c33
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c7
-rw-r--r--source/blender/editors/physics/particle_edit.c9
-rw-r--r--source/blender/editors/render/render_opengl.c4
-rw-r--r--source/blender/editors/screen/area.c48
-rw-r--r--source/blender/editors/screen/glutil.c5
-rw-r--r--source/blender/editors/screen/screen_draw.c23
-rw-r--r--source/blender/editors/screen/screendump.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c39
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c13
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c15
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c3
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c9
-rw-r--r--source/blender/editors/space_action/action_draw.c9
-rw-r--r--source/blender/editors/space_action/space_action.c5
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c9
-rw-r--r--source/blender/editors/space_clip/clip_draw.c51
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c15
-rw-r--r--source/blender/editors/space_clip/clip_utils.c9
-rw-r--r--source/blender/editors/space_clip/space_clip.c9
-rw-r--r--source/blender/editors/space_console/space_console.c3
-rw-r--r--source/blender/editors/space_file/file_draw.c7
-rw-r--r--source/blender/editors/space_file/space_file.c9
-rw-r--r--source/blender/editors/space_graph/graph_draw.c65
-rw-r--r--source/blender/editors/space_graph/space_graph.c22
-rw-r--r--source/blender/editors/space_image/image_draw.c35
-rw-r--r--source/blender/editors/space_image/space_image.c5
-rw-r--r--source/blender/editors/space_info/info_draw.c3
-rw-r--r--source/blender/editors/space_info/space_info.c3
-rw-r--r--source/blender/editors/space_info/textview.c7
-rw-r--r--source/blender/editors/space_nla/nla_draw.c47
-rw-r--r--source/blender/editors/space_nla/space_nla.c5
-rw-r--r--source/blender/editors/space_node/drawnode.c19
-rw-r--r--source/blender/editors/space_node/node_draw.c46
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c47
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c5
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c3
-rw-r--r--source/blender/editors/space_script/space_script.c3
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c76
-rw-r--r--source/blender/editors/space_text/space_text.c3
-rw-r--r--source/blender/editors/space_text/text_draw.c9
-rw-r--r--source/blender/editors/space_view3d/drawobject.c26
-rw-r--r--source/blender/editors/space_view3d/drawvolume.c15
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c42
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c31
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c29
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_ruler.c19
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c19
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c5
-rw-r--r--source/blender/editors/transform/transform.c57
-rw-r--r--source/blender/editors/transform/transform_constraints.c15
-rw-r--r--source/blender/editors/transform/transform_snap.c9
-rw-r--r--source/blender/editors/util/ed_util.c3
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c39
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c7
82 files changed, 917 insertions, 830 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index e4213a8d907..f0bde9dcdfb 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -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);
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index c2cfb877745..953898a0586 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -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);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index c4fbc86a389..2815bc58d7a 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -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();
}
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index d1377703949..859eb05e7b9 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -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 *************************** */
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 887f3dd13da..e679b04f25d 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -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();
}
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index a30cb578046..a79a5052eb8 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -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)
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 5eb3321b414..d877ea03c5d 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -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);
}
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 800c899f9c2..0ae45a9fde8 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -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);
}
}
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index a36f534807c..f4c4b8afc94 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -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);
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index f093f47519c..ab85a3d5326 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -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);
}
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index a8feaedf717..083f94a41b2 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -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);
}
}
}
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 5d029685810..1e3a080c097 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -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);
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c
index 1a49010ad9d..3ac9932fdc9 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -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];
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.c
index e0dc149be17..257455be27e 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.c
@@ -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);
}
}
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 4eb3724e242..3a96d22ffb9 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -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]);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index b5036f19671..df5f5cbfeb7 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -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);
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 530a6e28860..b538842ffa0 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -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);
diff --git a/source/blender/editors/manipulator_library/manipulator_draw_utils.c b/source/blender/editors/manipulator_library/manipulator_draw_utils.c
index 430841311aa..a0b226b7502 100644
--- a/source/blender/editors/manipulator_library/manipulator_draw_utils.c
+++ b/source/blender/editors/manipulator_library/manipulator_draw_utils.c
@@ -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
diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c
index 749e92e25fb..5acf1ab2d64 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c
@@ -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);
}
}
diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
index 8516b9d8244..a5bcef7ed5e 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
@@ -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();
}
diff --git a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
index 86c3b4a09de..db33f457056 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
@@ -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(
diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
index fe748f33d35..b7b19ccd634 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
@@ -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();
}
diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c
index 6c2e2bd564d..a907816b08f 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c
@@ -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();
}
diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
index 643a379cbb0..74ba8bd77a9 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
@@ -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);
diff --git a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
index e2d1979b7a6..458dc2fd1c8 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
@@ -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(
diff --git a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c
index 531cf742e6f..419873ccfff 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c
@@ -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();
}
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 689a96a3dec..6b5fce26deb 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -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);
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 84da02b3b41..2ee8918c5da 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -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);
}
/**
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index cf806b0b104..78d98025476 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -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);
}
}
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index cfdeeffc434..d2ca8471d82 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -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();
}
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index fb007accaeb..b5c1ffc64dd 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -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);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 986a2a030e2..9bf15a292ea 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -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)
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 1d73566e5a8..6cff82295f0 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -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"
@@ -59,11 +60,11 @@
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
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index fec39ade110..b81c1e489ea 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -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);
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index e7b075dd5d0..fbe0b8dc40e 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -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 */
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 848d12bcfaa..50d178bc757 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -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 */
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index c3a0ca4299f..b5da9a5d68c 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -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);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index a7aa19807dd..ee888c71659 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -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)
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 80c4d4099a2..d6de9c235f1 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -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;
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index cf9feae62b5..1405de8cfa9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -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();
}
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 35ebb62a7cc..6105652a4c7 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -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();
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 537f184c71c..876b73a4a76 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -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);
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index bc2aa3ae67f..d50d10d5cc3 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -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);
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 5962bfe33f3..d91e039ecb6 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -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;
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 8d29cb73a68..d463f585470 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -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);
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index a666b20dfa4..c3208260b3b 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -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);
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index b050e991140..2e98e3cec5c 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -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);
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index c65c9a175a0..74bc7e95643 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -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);
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 360009d3ea4..4d4845c41b9 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -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)
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 7b045a42595..8798c7b01c0 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -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);
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 7c6af0b4c62..87fe4a62343 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -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 */
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 7c3105843c5..878c4815f73 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -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);
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 1e2d668018f..11e06c168b4 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -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;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 827c39b8033..792dc25981e 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -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);
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index 9421567b6ba..ecd0b082df6 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -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;
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 65b3c7bb9fd..4273404ac90 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -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)
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index 85de70c020f..a1e3842f887 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -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);
}
}
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 3f1ab059a91..16fb3576ae8 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -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 */
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 745cea37ea3..62144db0577 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -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);
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index a162a863038..12da5086c52 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -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))
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 8089f47bce4..01e22ec5245 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -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) */
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index e617bb40837..19e5217cdd2 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -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);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 316caf0e239..786172ca18e 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -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)
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 71ae7eeeb3d..f1431647754 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -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);
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index c8e5a4bdf87..fcda16b846b 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -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);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index ffcb4329726..1ac628a8b54 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -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);
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index e827f4f0149..f57a1c0eb89 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -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);
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index c1b49fbd32a..99305b143c6 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -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 */
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 1224c284d5f..5ecef03e475 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -100,6 +100,8 @@
#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;
Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset);
@@ -384,7 +386,7 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset)
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
- glLineWidth(1.0f);
+ GPU_line_width(1.0f);
immBeginAtMost(GWN_PRIM_LINES, imm_len);
dm->foreachMappedEdge(dm, bbs_mesh_wire__mapFunc, &data);
@@ -395,7 +397,7 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset)
#else
static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset)
{
- glLineWidth(1.0f);
+ GPU_line_width(1.0f);
Mesh *me = em->ob->data;
Gwn_Batch *batch = DRW_mesh_batch_cache_get_edges_with_select_id(me, offset);
@@ -503,7 +505,7 @@ static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *dm)
immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
- glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE));
+ GPU_point_size(UI_GetThemeValuef(TH_FACEDOT_SIZE));
immBeginAtMost(GWN_PRIM_POINTS, em->bm->totface);
dm->foreachMappedFaceCenter(dm, bbs_mesh_solid__drawCenter, &data, DM_FOREACH_NOP);
@@ -621,8 +623,8 @@ void draw_object_backbufsel(
gpuMultMatrix(ob->obmat);
- glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT);
- glEnable(GL_DEPTH_TEST);
+ glClearDepth(1.0); GPU_clear(GPU_DEPTH_BIT);
+ GPU_depth_test(true);
switch (ob->type) {
case OB_MESH:
@@ -722,7 +724,7 @@ void ED_draw_object_facemap(
glColor4fv(col);
gpuPushAttrib(GL_ENABLE_BIT);
- glEnable(GL_BLEND);
+ GPU_blend(true);
glDisable(GL_LIGHTING);
/* always draw using backface culling */
@@ -752,8 +754,8 @@ void ED_draw_object_facemap(
immUniformColor4fv(col);
/* XXX, alpha isn't working yet, not sure why. */
- 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);
MVert *mvert;
@@ -810,7 +812,7 @@ void ED_draw_object_facemap(
immUnbindProgram();
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
#endif
diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c
index 3b648e3b13a..d90f1b16d29 100644
--- a/source/blender/editors/space_view3d/drawvolume.c
+++ b/source/blender/editors/space_view3d/drawvolume.c
@@ -1,4 +1,4 @@
-/*
+/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -50,6 +50,7 @@
#include "GPU_shader.h"
#include "GPU_texture.h"
+#include "GPU_state.h"
#include "view3d_intern.h" // own include
@@ -632,11 +633,11 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
glGetBooleanv(GL_DEPTH_TEST, (GLboolean *)&gl_depth);
glGetBooleanv(GL_DEPTH_WRITEMASK, (GLboolean *)&gl_depth_write);
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
glDepthMask(GL_FALSE);
- glEnable(GL_BLEND);
+ GPU_blend(true);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
draw_buffer(sds, shader, &slicer, ob_sizei, invsize, num_points, false);
/* Draw fire separately (T47639). */
@@ -655,11 +656,11 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
glDepthMask(gl_depth_write);
if (!gl_blend) {
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
if (gl_depth) {
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
}
}
@@ -831,7 +832,7 @@ void draw_smoke_velocity(SmokeDomainSettings *domain, float viewnormal[3])
}
}
- glLineWidth(1.0f);
+ GPU_line_width(1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, verts);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 74554e8d62b..e9c2ddbab76 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -80,6 +80,8 @@
#include "GPU_immediate_util.h"
#include "GPU_material.h"
#include "GPU_viewport.h"
+#include "GPU_state.h"
+#include "GPU_framebuffer.h"
#include "MEM_guardedalloc.h"
@@ -450,7 +452,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
x2 = viewborder.xmax;
y2 = viewborder.ymax;
- glLineWidth(1.0f);
+ GPU_line_width(1.0f);
/* apply offsets so the real 3D camera shows through */
@@ -478,8 +480,8 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
float alpha = 1.0f;
if (ca->passepartalpha != 1.0f) {
- 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);
alpha = ca->passepartalpha;
}
@@ -494,7 +496,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
if (y2i > 0.0f)
immRectf(shdr_pos, x1i, y1i, x2i, 0.0f);
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
immUniformThemeColor(TH_BACK);
@@ -516,7 +518,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View
{
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", 0); /* "simple" mode */
@@ -673,12 +675,12 @@ static void drawrenderborder(ARegion *ar, View3D *v3d)
/* use the same program for everything */
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], viewport_size[3]);
immUniform1i("num_colors", 0); /* "simple" mode */
@@ -717,7 +719,7 @@ void ED_view3d_draw_depth(
ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL);
- glClear(GL_DEPTH_BUFFER_BIT);
+ GPU_clear(GPU_DEPTH_BIT);
if (rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_set(rv3d);
@@ -726,7 +728,7 @@ void ED_view3d_draw_depth(
rv3d->rflag |= RV3D_ZOFFSET_DISABLED;
v3d->zbuf = true;
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
DRW_draw_depth_loop(depsgraph, ar, v3d);
@@ -736,7 +738,7 @@ void ED_view3d_draw_depth(
rv3d->rflag &= ~RV3D_ZOFFSET_DISABLED;
v3d->zbuf = zbuf;
- if (!v3d->zbuf) glDisable(GL_DEPTH_TEST);
+ if (!v3d->zbuf) GPU_depth_test(false);
U.glalphaclip = glalphaclip;
v3d->flag = flag;
@@ -808,10 +810,10 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect)
}
/* draw axis lines */
- glLineWidth(2.0f);
- 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_width(2.0f);
+ 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);
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -831,7 +833,7 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect)
immEnd();
immUnbindProgram();
- glDisable(GL_LINE_SMOOTH);
+ GPU_line_smooth(false);
/* draw axis names */
for (int axis_i = 0; axis_i < 3; axis_i++) {
@@ -854,8 +856,8 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d)
negate_v3_v3(o, rv3d->ofs);
- 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);
glDepthMask(GL_FALSE); /* don't overwrite zbuf */
Gwn_VertFormat *format = immVertexFormat();
@@ -938,7 +940,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d)
/* -- draw rotation center -- */
immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
- glPointSize(5.0f);
+ GPU_point_size(5.0f);
immBegin(GWN_PRIM_POINTS, 1);
immAttrib4ubv(col, color);
immVertex3fv(pos, o);
@@ -952,7 +954,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d)
/* ^^ just playing around, does not work */
#endif
- glDisable(GL_BLEND);
+ GPU_blend(false);
glDepthMask(GL_TRUE);
}
#endif /* WITH_INPUT_NDOF */
@@ -1283,7 +1285,7 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar)
gpu_batch_presets_reset();
/* No depth test for drawing action zones afterwards. */
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
v3d->flag |= V3D_INVALID_BACKBUF;
}
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index b19001ab834..6acec568bf4 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -105,6 +105,7 @@
#include "GPU_immediate_util.h"
#include "GPU_select.h"
#include "GPU_matrix.h"
+#include "GPU_state.h"
#include "RE_engine.h"
@@ -246,16 +247,16 @@ static void backdrawview3d(
if (rv3d->gpuoffscreen)
GPU_offscreen_bind(rv3d->gpuoffscreen, true);
else
- glScissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct));
+ GPU_scissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct));
- glClearColor(0.0, 0.0, 0.0, 0.0);
+ GPU_clear_color(0.0, 0.0, 0.0, 0.0);
if (v3d->zbuf) {
- glEnable(GL_DEPTH_TEST);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ GPU_depth_test(true);
+ GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT);
}
else {
- glClear(GL_COLOR_BUFFER_BIT);
- glDisable(GL_DEPTH_TEST);
+ GPU_clear(GPU_COLOR_BIT);
+ GPU_depth_test(false);
}
if (rv3d->rflag & RV3D_CLIPPING)
@@ -274,7 +275,7 @@ static void backdrawview3d(
G.f &= ~G_BACKBUFSEL;
v3d->zbuf = false;
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
glEnable(GL_DITHER);
if (rv3d->rflag & RV3D_CLIPPING)
@@ -684,11 +685,11 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
ibuf = ibuf->mipmap[mip - 1];
}
- if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
+ if (v3d->zbuf) GPU_depth_test(false);
glDepthMask(GL_FALSE);
- 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);
gpuPushProjectionMatrix();
gpuPushMatrix();
@@ -715,10 +716,10 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph,
gpuPopProjectionMatrix();
gpuPopMatrix();
- glDisable(GL_BLEND);
+ GPU_blend(false);
glDepthMask(GL_TRUE);
- if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
+ if (v3d->zbuf) GPU_depth_test(true);
if (freeibuf)
IMB_freeImBuf(freeibuf);
@@ -883,17 +884,17 @@ void ED_view3d_draw_depth_gpencil(
/* Setup view matrix. */
ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL);
- glClear(GL_DEPTH_BUFFER_BIT);
+ GPU_clear(GPU_DEPTH_BIT);
v3d->zbuf = true;
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
ED_gpencil_draw_view3d(NULL, scene, view_layer, depsgraph, v3d, ar, true);
}
v3d->zbuf = zbuf;
- if (!zbuf) glDisable(GL_DEPTH_TEST);
+ if (!zbuf) GPU_depth_test(false);
}
/* *********************** customdata **************** */
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
index b232be35462..996da2a1475 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
@@ -43,6 +43,7 @@
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
+#include "GPU_state.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -64,7 +65,7 @@
static void axis_geom_draw(
const wmManipulator *mpr, const float color[4], const bool UNUSED(select))
{
- glLineWidth(mpr->line_width);
+ GPU_line_width(mpr->line_width);
Gwn_VertFormat *format = immVertexFormat();
const uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
@@ -128,15 +129,15 @@ static void axis_geom_draw(
zero_v3(center);
copy_v3_fl(size, HANDLE_SIZE);
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);
- glBlendFunc(GL_ONE, GL_ZERO);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ GPU_blend_set_func(GPU_ONE, GPU_ZERO);
+ GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
- glLineWidth(1.0f);
+ GPU_line_smooth(true);
+ GPU_blend(true);
+ GPU_line_width(1.0f);
/* Just draw depth values. */
immUniformColor4fv(axis_nop);
imm_draw_cube_fill_3d(pos_id, center, size);
@@ -150,9 +151,9 @@ static void axis_geom_draw(
},
0.08f);
imm_draw_cube_wire_3d(pos_id, center, size);
- glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH);
- glDisable(GL_DEPTH_TEST);
+ GPU_blend(false);
+ GPU_line_smooth(false);
+ GPU_depth_test(false);
}
draw_center_done = true;
@@ -216,9 +217,9 @@ static void axis3d_draw_intern(
gpuPushMatrix();
gpuMultMatrix(matrix_final);
- glEnable(GL_BLEND);
+ GPU_blend(true);
axis_geom_draw(mpr, color, select);
- glDisable(GL_BLEND);
+ GPU_blend(false);
gpuPopMatrix();
}
@@ -229,9 +230,9 @@ static void manipulator_axis_draw(const bContext *C, wmManipulator *mpr)
(void)is_modal;
- glEnable(GL_BLEND);
+ GPU_blend(true);
axis3d_draw_intern(C, mpr, false, is_highlight);
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
static int manipulator_axis_test_select(
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
index 8178c2f5be9..4a9f07c34e8 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_ruler.c
@@ -63,6 +63,7 @@
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_select.h"
+#include "GPU_state.h"
#include "BLF_api.h"
@@ -526,7 +527,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
float color_back[4] = {1.0f, 1.0f, 1.0f, 0.5f};
/* anti-aliased lines for more consistent appearance */
- glEnable(GL_LINE_SMOOTH);
+ GPU_line_smooth(true);
BLF_enable(blf_mono_font, BLF_ROTATION);
BLF_size(blf_mono_font, 14 * U.pixelsize, U.dpi);
@@ -545,7 +546,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP);
}
- glEnable(GL_BLEND);
+ GPU_blend(true);
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -553,7 +554,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
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 */
@@ -632,7 +633,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
rot_90_vec_b[1] = dir_ruler[0];
normalize_v2(rot_90_vec_b);
- glEnable(GL_BLEND);
+ GPU_blend(true);
immUniformColor3ubv(color_wire);
@@ -656,7 +657,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
immEnd();
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
immUnbindProgram();
@@ -693,7 +694,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
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 */
@@ -721,7 +722,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
normalize_v2(rot_90_vec);
- glEnable(GL_BLEND);
+ GPU_blend(true);
immUniformColor3ubv(color_wire);
@@ -739,7 +740,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
immEnd();
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
immUnbindProgram();
@@ -775,7 +776,7 @@ static void manipulator_ruler_draw(const bContext *C, wmManipulator *mpr)
}
}
- glDisable(GL_LINE_SMOOTH);
+ GPU_line_smooth(false);
BLF_disable(blf_mono_font, BLF_ROTATION);
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index cc951805289..3a86f70febb 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -46,6 +46,7 @@
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
+#include "GPU_state.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -438,7 +439,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
float color_back[4] = {1.0f, 1.0f, 1.0f, 0.5f};
/* anti-aliased lines for more consistent appearance */
- glEnable(GL_LINE_SMOOTH);
+ GPU_line_smooth(true);
BLF_enable(blf_mono_font, BLF_ROTATION);
BLF_size(blf_mono_font, 14 * U.pixelsize, U.dpi);
@@ -458,7 +459,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
ED_view3d_project_float_global(ar, ruler_item->co[j], co_ss[j], V3D_PROJ_TEST_NOP);
}
- glEnable(GL_BLEND);
+ GPU_blend(true);
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -466,7 +467,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
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 */
@@ -545,7 +546,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
rot_90_vec_b[1] = dir_ruler[0];
normalize_v2(rot_90_vec_b);
- glEnable(GL_BLEND);
+ GPU_blend(true);
immUniformColor3ubv(color_wire);
@@ -569,7 +570,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
immEnd();
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
immUnbindProgram();
@@ -605,7 +606,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
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 */
@@ -633,7 +634,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
normalize_v2(rot_90_vec);
- glEnable(GL_BLEND);
+ GPU_blend(true);
immUniformColor3ubv(color_wire);
@@ -651,7 +652,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
immEnd();
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
immUnbindProgram();
@@ -687,7 +688,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
}
}
- glDisable(GL_LINE_SMOOTH);
+ GPU_line_smooth(false);
BLF_disable(blf_mono_font, BLF_ROTATION);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 8b9ad387065..53e3fbb87b0 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -55,6 +55,7 @@
#include "GPU_glew.h"
#include "GPU_select.h"
#include "GPU_matrix.h"
+#include "GPU_state.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -1004,7 +1005,7 @@ int view3d_opengl_select(
if (v3d->drawtype > OB_WIRE) {
v3d->zbuf = true;
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
}
if (vc->rv3d->rflag & RV3D_CLIPPING)
@@ -1050,7 +1051,7 @@ int view3d_opengl_select(
if (v3d->drawtype > OB_WIRE) {
v3d->zbuf = 0;
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
}
if (vc->rv3d->rflag & RV3D_CLIPPING)
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index bb51678080f..1b861c5749d 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -74,6 +74,7 @@
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
+#include "GPU_state.h"
#include "ED_image.h"
#include "ED_keyframing.h"
@@ -1751,12 +1752,12 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
UNUSED_VARS_NDEBUG(shdr_pos); /* silence warning */
BLI_assert(shdr_pos == POS_INDEX);
- 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], viewport_size[3]);
immUniform1i("num_colors", 0); /* "simple" mode */
@@ -1785,7 +1786,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
gpuTranslate3fv(mval);
gpuRotateAxis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z');
- glLineWidth(3.0f);
+ GPU_line_width(3.0f);
drawArrow(UP, 5, 10, 5);
drawArrow(DOWN, 5, 10, 5);
break;
@@ -1793,7 +1794,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
immUniformThemeColor(TH_VIEW_OVERLAY);
gpuTranslate3fv(mval);
- glLineWidth(3.0f);
+ GPU_line_width(3.0f);
drawArrow(RIGHT, 5, 10, 5);
drawArrow(LEFT, 5, 10, 5);
break;
@@ -1802,7 +1803,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
gpuTranslate3fv(mval);
- glLineWidth(3.0f);
+ GPU_line_width(3.0f);
drawArrow(UP, 5, 10, 5);
drawArrow(DOWN, 5, 10, 5);
break;
@@ -1818,7 +1819,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
gpuTranslate3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0);
- glLineWidth(3.0f);
+ GPU_line_width(3.0f);
drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
@@ -1844,7 +1845,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
gpuTranslate3fv(mval);
- glLineWidth(3.0f);
+ GPU_line_width(3.0f);
UI_make_axis_color(col, col2, 'X');
immUniformColor3ubv((GLubyte *)col2);
@@ -1870,7 +1871,7 @@ static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), voi
{
TransInfo *t = arg;
- glLineWidth(1.0f);
+ GPU_line_width(1.0f);
drawConstraint(t);
drawPropCircle(C, t);
@@ -1910,15 +1911,15 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar)
#endif
/* autokey recording icon... */
- 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_REC);
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, void *arg)
@@ -6975,10 +6976,10 @@ static void drawEdgeSlide(TransInfo *t)
const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
if (v3d && v3d->zbuf)
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
- 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);
gpuPushMatrix();
gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
@@ -6998,7 +6999,7 @@ static void drawEdgeSlide(TransInfo *t)
add_v3_v3v3(co_a, curr_sv->v_co_orig, curr_sv->dir_side[0]);
add_v3_v3v3(co_b, curr_sv->v_co_orig, curr_sv->dir_side[1]);
- glLineWidth(line_size);
+ GPU_line_width(line_size);
immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
immBeginAtMost(GWN_PRIM_LINES, 4);
if (curr_sv->v_side[0]) {
@@ -7012,7 +7013,7 @@ static void drawEdgeSlide(TransInfo *t)
immEnd();
immUniformThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade);
- glPointSize(ctrl_size);
+ GPU_point_size(ctrl_size);
immBegin(GWN_PRIM_POINTS, 1);
if (slp->flipped) {
if (curr_sv->v_side[1]) immVertex3fv(pos, curr_sv->v_side[1]->co);
@@ -7023,7 +7024,7 @@ static void drawEdgeSlide(TransInfo *t)
immEnd();
immUniformThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade);
- glPointSize(guide_size);
+ GPU_point_size(guide_size);
immBegin(GWN_PRIM_POINTS, 1);
interp_line_v3_v3v3v3(co_mark, co_b, curr_sv->v_co_orig, co_a, fac);
immVertex3fv(pos, co_mark);
@@ -7036,7 +7037,7 @@ static void drawEdgeSlide(TransInfo *t)
int i;
const int alpha_shade = -160;
- glLineWidth(line_size);
+ GPU_line_width(line_size);
immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
immBegin(GWN_PRIM_LINES, sld->totsv * 2);
@@ -7071,10 +7072,10 @@ static void drawEdgeSlide(TransInfo *t)
gpuPopMatrix();
- glDisable(GL_BLEND);
+ GPU_blend(false);
if (v3d && v3d->zbuf)
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
}
}
}
@@ -7611,15 +7612,15 @@ static void drawVertSlide(TransInfo *t)
int i;
if (v3d && v3d->zbuf)
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
- 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);
gpuPushMatrix();
gpuMultMatrix(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);
- glLineWidth(line_size);
+ GPU_line_width(line_size);
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
@@ -7650,7 +7651,7 @@ static void drawVertSlide(TransInfo *t)
}
immEnd();
- glPointSize(ctrl_size);
+ GPU_point_size(ctrl_size);
immBegin(GWN_PRIM_POINTS, 1);
immVertex3fv(shdr_pos, (slp->flipped && slp->use_even) ?
@@ -7682,12 +7683,12 @@ static void drawVertSlide(TransInfo *t)
add_v3_v3(co_dest_3d, curr_sv->co_orig_3d);
- glLineWidth(1.0f);
+ GPU_line_width(1.0f);
immBindBuiltinProgram(GPU_SHADER_3D_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", 0); /* "simple" mode */
@@ -7706,7 +7707,7 @@ static void drawVertSlide(TransInfo *t)
gpuPopMatrix();
if (v3d && v3d->zbuf)
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
}
}
}
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 93e644b9706..7aa1419b0dc 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -44,6 +44,7 @@
#include "GPU_immediate.h"
#include "GPU_matrix.h"
+#include "GPU_state.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -742,16 +743,16 @@ void drawConstraint(TransInfo *t)
drawLine(t, t->center_global, tc->mtx[1], 'Y', 0);
drawLine(t, t->center_global, tc->mtx[2], 'Z', 0);
- depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
+ depth_test_enabled = GPU_depth_test_enabled();
if (depth_test_enabled)
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_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", 0); /* "simple" mode */
@@ -767,7 +768,7 @@ void drawConstraint(TransInfo *t)
immUnbindProgram();
if (depth_test_enabled)
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
}
if (tc->mode & CON_AXIS0) {
@@ -818,9 +819,9 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
gpuScale2f(1.0f, (ysize / xsize) * (xmask / ymask));
}
- depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
+ depth_test_enabled = GPU_depth_test_enabled();
if (depth_test_enabled)
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
@@ -834,7 +835,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
immUnbindProgram();
if (depth_test_enabled)
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
gpuPopMatrix();
}
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 02855e0a809..48ec664d634 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -50,6 +50,7 @@
#include "BLI_utildefines.h"
#include "GPU_immediate.h"
+#include "GPU_state.h"
#include "BKE_global.h"
#include "BKE_object.h"
@@ -159,7 +160,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
float imat[4][4];
float size;
- glDisable(GL_DEPTH_TEST);
+ GPU_depth_test(false);
size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
@@ -201,7 +202,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
immUnbindProgram();
if (v3d->zbuf)
- glEnable(GL_DEPTH_TEST);
+ GPU_depth_test(true);
}
}
else if (t->spacetype == SPACE_IMAGE) {
@@ -218,7 +219,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
- glEnable(GL_BLEND);
+ GPU_blend(true);
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -243,7 +244,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
immUnbindProgram();
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
}
}
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 549b9b7de77..10c2f735e0e 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -76,6 +76,7 @@
#include "ED_util.h"
#include "GPU_immediate.h"
+#include "GPU_state.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -346,7 +347,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
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 */
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index b3f3d188851..da50fe51d27 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -64,6 +64,7 @@
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
+#include "GPU_state.h"
#include "ED_image.h"
#include "ED_mesh.h"
@@ -87,7 +88,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
x_fac = zoom[0];
y_fac = zoom[1];
- glLineWidth(1.0f);
+ GPU_line_width(1.0f);
gpuTranslate2fv(cursor);
@@ -96,7 +97,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
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 */
@@ -654,8 +655,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
/* draw transparent faces */
UI_GetThemeColor4fv(TH_FACE, col1);
UI_GetThemeColor4fv(TH_FACE_SELECT, col2);
- 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();
pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -691,7 +692,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
immUnbindProgram();
- glDisable(GL_BLEND);
+ GPU_blend(false);
}
else {
if (efa_act && !uvedit_face_visible_test(scene, obedit, ima, efa_act)) {
@@ -706,9 +707,9 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
/* 4. draw edges */
if (sima->flag & SI_SMOOTH_UV) {
- 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);
}
pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -719,13 +720,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
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 */
immUniformArray4fv("colors", (float *)(float[][4]){{0.56f, 0.56f, 0.56f, 1.0f}, {0.07f, 0.07f, 0.07f, 1.0f}}, 2);
immUniform1f("dash_width", 4.0f);
- glLineWidth(1.0f);
+ GPU_line_width(1.0f);
break;
}
@@ -738,13 +739,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
else {
immUniformColor3f(0.0f, 0.0f, 0.0f);
}
- glLineWidth(1.0f);
+ GPU_line_width(1.0f);
break;
case SI_UVDT_OUTLINE:
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
imm_cpack(0x0);
- glLineWidth(3.0f);
+ GPU_line_width(3.0f);
break;
}
@@ -780,7 +781,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
if (sima->dt_uv == SI_UVDT_OUTLINE) {
- glLineWidth(1.0f);
+ GPU_line_width(1.0f);
UI_GetThemeColor4fv(TH_WIRE_EDIT, col2);
if (me->drawflag & ME_DRAWEDGES) {
@@ -883,8 +884,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
GWN_batch_discard(loop_batch);
if (sima->flag & SI_SMOOTH_UV) {
- glDisable(GL_LINE_SMOOTH);
- glDisable(GL_BLEND);
+ GPU_line_smooth(false);
+ GPU_blend(false);
}
/* 5. draw face centers */
@@ -900,7 +901,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE);
- glPointSize(pointsize);
+ GPU_point_size(pointsize);
immBeginAtMost(GWN_PRIM_POINTS, bm->totface);
@@ -961,7 +962,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
/* unselected uvs */
immUniformThemeColor(TH_VERTEX);
pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
- glPointSize(pointsize);
+ GPU_point_size(pointsize);
immBeginAtMost(GWN_PRIM_POINTS, bm->totloop);
@@ -980,7 +981,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
/* pinned uvs */
/* give odd pointsizes odd pin pointsizes */
- glPointSize(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0));
+ GPU_point_size(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0));
imm_cpack(0xFF);
immBeginAtMost(GWN_PRIM_POINTS, bm->totloop);
@@ -1001,7 +1002,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje
/* selected uvs */
immUniformThemeColor(TH_VERTEX_SELECT);
- glPointSize(pointsize);
+ GPU_point_size(pointsize);
immBeginAtMost(GWN_PRIM_POINTS, bm->totloop);
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index bac30830516..9091f3eff0b 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -65,6 +65,7 @@
#include "ED_space_api.h"
#include "GPU_batch.h"
+#include "GPU_state.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -1570,7 +1571,7 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
}
- glEnable(GL_BLEND);
+ GPU_blend(true);
/* Static Tris */
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_ACTIVE, col);
@@ -1623,12 +1624,12 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_EDGE, col);
stitch_draw_vbo(vbo_line, GWN_PRIM_LINES, col);
- glDisable(GL_BLEND);
+ GPU_blend(false);
/* draw stitch vert/lines preview */
if (state->mode == STITCH_VERT) {
- glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) * 2.0f);
+ GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE) * 2.0f);
UI_GetThemeColor4fv(TH_STITCH_PREVIEW_STITCHABLE, col);
vbo = GWN_vertbuf_create_with_format(&format);