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/editors/space_view3d
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/editors/space_view3d')
-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
8 files changed, 98 insertions, 88 deletions
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)