Immediate Mode: animation markers

This commit is contained in:
Dalai Felinto 2017-02-14 11:10:51 +01:00
parent 1089294439
commit 9151f12dad
1 changed files with 24 additions and 12 deletions

View File

@ -59,6 +59,8 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "GPU_immediate.h"
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "UI_view2d.h"
@ -348,19 +350,24 @@ static void draw_marker(
if (flag & DRAW_MARKERS_LINES)
#endif
{
unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
setlinestyle(3);
if (marker->flag & SELECT)
glColor4ub(255, 255, 255, 96);
else
glColor4ub(0, 0, 0, 96);
glBegin(GL_LINES);
glVertex2f(xpos + 0.5f, 12.0f);
glVertex2f(xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale);
glEnd();
if (marker->flag & SELECT) {
immUniformColor4ub(255, 255, 255, 96);
}
else {
immUniformColor4ub(0, 0, 0, 96);
}
immBegin(GL_LINES, 2);
immVertex2f(pos, xpos + 0.5f, 12.0f);
immVertex2f(pos, xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale);
immEnd();
setlinestyle(0);
immUnbindProgram();
}
/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
@ -438,15 +445,20 @@ void ED_markers_draw(const bContext *C, int flag)
v2d = UI_view2d_fromcontext(C);
if (flag & DRAW_MARKERS_MARGIN) {
unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
const unsigned char shade[4] = {0, 0, 0, 16};
glColor4ubv(shade);
immUniformColor4ubv(shade);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glRectf(v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y);
immRectf(pos, v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y);
glDisable(GL_BLEND);
immUnbindProgram();
}
/* no time correction for framelen! space is drawn with old values */