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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface/interface_draw.c')
-rw-r--r--source/blender/editors/interface/interface_draw.c173
1 files changed, 87 insertions, 86 deletions
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);
}