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_graph
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_graph')
-rw-r--r--source/blender/editors/space_graph/graph_draw.c65
-rw-r--r--source/blender/editors/space_graph/space_graph.c22
2 files changed, 45 insertions, 42 deletions
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);