diff options
author | Mike Erwin <significant.bit@gmail.com> | 2017-02-11 08:59:43 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2017-02-11 08:59:43 +0300 |
commit | e008ca13f13856ed5e76b98de0b8410b90016d18 (patch) | |
tree | 6b83bd2a0b78ab832e7698d572aa5a3679db421a /source/blender/editors/space_clip | |
parent | 768e4e991cc62129af4513a39c6ec9a75bd21f13 (diff) |
OpenGL: updated clip_utils.c to new immediate mode
D2391 by @darwin, part of T49043
Reviewed by @merwin who made some small changes before committing.
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/clip_utils.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 547c2fba66f..6026036c05d 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -43,8 +43,7 @@ #include "BKE_tracking.h" #include "BKE_depsgraph.h" -#include "BIF_gl.h" -#include "BIF_glutil.h" +#include "GPU_immediate.h" #include "WM_api.h" #include "WM_types.h" @@ -52,7 +51,6 @@ #include "ED_screen.h" #include "ED_clip.h" - #include "UI_interface.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -237,31 +235,35 @@ void clip_view_center_to_point(SpaceClip *sc, float x, float y) void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) { + /* Draw a light green line to indicate current frame */ View2D *v2d = &ar->v2d; - float xscale, yscale; + float x = (float)(sc->user.framenr * scene->r.framelen); - /* Draw a light green line to indicate current frame */ - UI_ThemeColor(TH_CFRAME); + unsigned pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT); - float x = (float)(sc->user.framenr * scene->r.framelen); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformThemeColor(TH_CFRAME); + glLineWidth(2.0f); - glLineWidth(2.0); + immBegin(GL_LINES, 2); + immVertex2f(pos, x, v2d->cur.ymin); + immVertex2f(pos, x, v2d->cur.ymax); + immEnd(); - glBegin(GL_LINES); - glVertex2f(x, v2d->cur.ymin); - glVertex2f(x, v2d->cur.ymax); - glEnd(); + immUnbindProgram(); UI_view2d_view_orthoSpecial(ar, v2d, 1); /* because the frame number text is subject to the same scaling as the contents of the view */ + float xscale, yscale; UI_view2d_scale_get(v2d, &xscale, &yscale); + glPushMatrix(); glScalef(1.0f / xscale, 1.0f, 1.0f); ED_region_cache_draw_curfra_label(sc->user.framenr, (float)sc->user.framenr * xscale, 18); /* restore view transform */ - glScalef(xscale, 1.0, 1.0); + glPopMatrix(); } void clip_draw_sfra_efra(View2D *v2d, Scene *scene) @@ -271,15 +273,27 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene) /* currently clip editor supposes that editing clip length is equal to scene frame range */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - glColor4f(0.0f, 0.0f, 0.0f, 0.4f); - glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); - glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + unsigned pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + + immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f); + immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); + immRectf(pos, (float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + glDisable(GL_BLEND); - UI_ThemeColorShade(TH_BACK, -60); + immUniformThemeColorShade(TH_BACK, -60); /* thin lines where the actual frames are */ - fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); - fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax); + glLineWidth(1.0f); + + immBegin(GL_LINES, 4); + immVertex2f(pos, (float)SFRA, v2d->cur.ymin); + immVertex2f(pos, (float)SFRA, v2d->cur.ymax); + immVertex2f(pos, (float)EFRA, v2d->cur.ymin); + immVertex2f(pos, (float)EFRA, v2d->cur.ymax); + immEnd(); + + immUnbindProgram(); } |