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/screen
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/screen')
-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
4 files changed, 45 insertions, 40 deletions
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 */