diff options
author | Alexander Romanov <a.romanov@blend4web.com> | 2015-12-26 00:57:50 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2015-12-27 00:15:23 +0300 |
commit | 700c40e2f9b59b7e780429fdc10fb0d2d5d117a1 (patch) | |
tree | 8a6ed722fba1e652fe9756276c83da3467f396aa /source/blender/editors | |
parent | 58cf3327e481cea3dbd2c1c0b89b02d4d2ca7be4 (diff) |
OpenGL: stipple support added to basic GLSL shader
The is intended to replace the deprecated glPolygonStipple() calls with a shader
based alternative, once we switch over to GLSL shaders.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D1688
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 9 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 8 | ||||
-rw-r--r-- | source/blender/editors/screen/glutil.c | 95 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_draw.c | 26 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 14 |
5 files changed, 35 insertions, 117 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index ae2e6744160..a3adf65cd84 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1133,14 +1133,17 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti sizey_solid = sizey / 4; y1 = rect->ymin; + /* Drawing the checkerboard. + * This could be optimized with a single checkerboard shader, + * instead of drawing twice and using stippling the second time. */ /* layer: background, to show tranparency */ glColor4ub(UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, 255); glRectf(x1, y1, x1 + sizex, rect->ymax); - glEnable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); glColor4ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, 255); - glPolygonStipple(stipple_checker_8px); + GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_CHECKER_8PX); glRectf(x1, y1, x1 + sizex, rect->ymax); - glDisable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); /* layer: color ramp */ glShadeModel(GL_FLAT); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index da348c88650..279572f82d1 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -57,6 +57,8 @@ #include "interface_intern.h" +#include "GPU_basic_shader.h" + #ifdef WITH_INPUT_IME # include "WM_types.h" #endif @@ -660,14 +662,14 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glDrawArrays(GL_POLYGON, 0, wtb->totvert); /* light checkers */ - glEnable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); glColor4ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, 255); - glPolygonStipple(stipple_checker_8px); + GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_CHECKER_8PX); glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v); glDrawArrays(GL_POLYGON, 0, wtb->totvert); - glDisable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); /* alpha fill */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 91eea6f8248..cbb6b7685af 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -56,95 +56,6 @@ #define GL_CLAMP_TO_EDGE 0x812F #endif - -/* ******************************************** */ - -/* defined in BIF_gl.h */ -const GLubyte stipple_halftone[128] = { - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, - 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55}; - - -/* repeat this pattern - * - * X000X000 - * 00000000 - * 00X000X0 - * 00000000 */ - - -const GLubyte stipple_quarttone[128] = { - 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, - 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, - 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, - 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, - 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, - 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, - 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0, - 136, 136, 136, 136, 0, 0, 0, 0, 34, 34, 34, 34, 0, 0, 0, 0}; - - -const GLubyte stipple_diag_stripes_pos[128] = { - 0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe, - 0x03, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x07, 0xf8, - 0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0, - 0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80, - 0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01, - 0xfc, 0x03, 0xfc, 0x03, 0xf8, 0x07, 0xf8, 0x07, - 0xf0, 0x0f, 0xf0, 0x0f, 0xe0, 0x1f, 0xe0, 0x1f, - 0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f, - 0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe, - 0x03, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x07, 0xf8, - 0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0, - 0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80, - 0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01, - 0xfc, 0x03, 0xfc, 0x03, 0xf8, 0x07, 0xf8, 0x07, - 0xf0, 0x0f, 0xf0, 0x0f, 0xe0, 0x1f, 0xe0, 0x1f, - 0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f}; - - -const GLubyte stipple_diag_stripes_neg[128] = { - 0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01, - 0xfc, 0x03, 0xfc, 0x03, 0xf8, 0x07, 0xf8, 0x07, - 0xf0, 0x0f, 0xf0, 0x0f, 0xe0, 0x1f, 0xe0, 0x1f, - 0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f, - 0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe, - 0x03, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x07, 0xf8, - 0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0, - 0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80, - 0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01, - 0xfc, 0x03, 0xfc, 0x03, 0xf8, 0x07, 0xf8, 0x07, - 0xf0, 0x0f, 0xf0, 0x0f, 0xe0, 0x1f, 0xe0, 0x1f, - 0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f, - 0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe, - 0x03, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x07, 0xf8, - 0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0, - 0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80}; - -const GLubyte stipple_checker_8px[128] = { - 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, - 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, - 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, - 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, - 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, - 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, - 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, - 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255}; - /* UNUSED */ #if 0 void fdrawbezier(float vec[4][3]) @@ -206,10 +117,10 @@ void fdrawcheckerboard(float x1, float y1, float x2, float y2) glRectf(x1, y1, x2, y2); glColor3ubv(col2); - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(stipple_checker_8px); + GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); + GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_CHECKER_8PX); glRectf(x1, y1, x2, y2); - glDisable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); } void sdrawline(int x1, int y1, int x2, int y2) diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index deb0a3f6d03..393e7292d64 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -281,14 +281,14 @@ static void drawseqwave(const bContext *C, SpaceSeq *sseq, Scene *scene, Sequenc static void drawmeta_stipple(int value) { if (value) { - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(stipple_halftone); + GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); + GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_HALFTONE); glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x8888); } else { - glDisable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); glDisable(GL_LINE_STIPPLE); } } @@ -586,8 +586,8 @@ void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, f float ymid1, ymid2; if (seq->flag & SEQ_MUTE) { - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(stipple_halftone); + GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); + GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_HALFTONE); } ymid1 = (y2 - y1) * 0.25f + y1; @@ -634,7 +634,7 @@ void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, f glEnd(); if (seq->flag & SEQ_MUTE) { - glDisable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); } } @@ -801,32 +801,32 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg /* draw lock */ if (seq->flag & SEQ_LOCK) { - glEnable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); glEnable(GL_BLEND); /* light stripes */ glColor4ub(255, 255, 255, 32); - glPolygonStipple(stipple_diag_stripes_pos); + GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_DIAG_STRIPES); glRectf(x1, y1, x2, y2); /* dark stripes */ glColor4ub(0, 0, 0, 32); - glPolygonStipple(stipple_diag_stripes_neg); + GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_DIAG_STRIPES_SWAP); glRectf(x1, y1, x2, y2); - glDisable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); glDisable(GL_BLEND); } if (!BKE_sequence_is_valid_check(seq)) { - glEnable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); /* panic! */ glColor4ub(255, 0, 0, 255); - glPolygonStipple(stipple_diag_stripes_pos); + GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_DIAG_STRIPES); glRectf(x1, y1, x2, y2); - glDisable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); } color3ubv_from_seq(scene, seq, col); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index f4eed3e1fda..34f59b56fff 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -65,6 +65,8 @@ #include "uvedit_intern.h" +#include "GPU_basic_shader.h" + /* use editmesh tessface */ #define USE_EDBM_LOOPTRIS @@ -637,8 +639,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) if (tf == activetf) { /* only once */ - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(stipple_quarttone); + GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); + GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE); UI_ThemeColor4(TH_EDITMESH_ACTIVE); } else { @@ -650,7 +652,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glEnd(); if (tf == activetf) { - glDisable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); } } else { @@ -713,8 +715,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); UI_ThemeColor4(TH_EDITMESH_ACTIVE); - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(stipple_quarttone); + GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); + GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_QUARTTONE); glBegin(GL_POLYGON); BM_ITER_ELEM (l, &liter, activef, BM_LOOPS_OF_FACE) { @@ -723,7 +725,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } glEnd(); - glDisable(GL_POLYGON_STIPPLE); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); glDisable(GL_BLEND); } } |