Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra vertex attribute, which means dashed shader no longer requires fiddling with those vertex attributes definition, and, most importantly, does not require anymore special drawing code! As you can see, this makes code much simpler, and much less verbose, especially in complex cases. In addition, changed how dashes are handled, to have two 'modes', a simple one with single color (using default "color" uniform name), and a more advanced one allowing more complex and multi-color patterns. Note that since GLSL 1.2 does not support geometry shaders, a hack was added for now (which gives solid lines, but at least does not make Blender crash).
This commit is contained in:
@@ -90,6 +90,7 @@ void immUniform3fv(const char* name, const float data[3]);
|
||||
void immUniformArray3fv(const char* name, const float *data, int count);
|
||||
void immUniform4f(const char* name, float x, float y, float z, float w);
|
||||
void immUniform4fv(const char* name, const float data[4]);
|
||||
void immUniformArray4fv(const char* bare_name, const float *data, int count);
|
||||
void immUniformMatrix4fv(const char* name, const float data[4][4]);
|
||||
|
||||
|
||||
|
||||
@@ -807,6 +807,24 @@ void immUniform4fv(const char* name, const float data[4])
|
||||
glUniform4fv(uniform->location, 1, data);
|
||||
}
|
||||
|
||||
void immUniformArray4fv(const char* bare_name, const float *data, int count)
|
||||
{
|
||||
// look up "name[0]" when given "name"
|
||||
const size_t len = strlen(bare_name);
|
||||
#if TRUST_NO_ONE
|
||||
assert(len <= MAX_UNIFORM_NAME_LEN);
|
||||
#endif
|
||||
char name[MAX_UNIFORM_NAME_LEN];
|
||||
strcpy(name, bare_name);
|
||||
name[len + 0] = '[';
|
||||
name[len + 1] = '0';
|
||||
name[len + 2] = ']';
|
||||
name[len + 3] = '\0';
|
||||
|
||||
GET_UNIFORM
|
||||
glUniform4fv(uniform->location, count, data);
|
||||
}
|
||||
|
||||
void immUniformMatrix4fv(const char* name, const float data[4][4])
|
||||
{
|
||||
GET_UNIFORM
|
||||
|
||||
@@ -353,7 +353,6 @@ static void draw_marker(
|
||||
{
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -362,17 +361,15 @@ static void draw_marker(
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
if (marker->flag & SELECT) {
|
||||
immUniform4f("color1", 1.0f, 1.0f, 1.0f, 0.38f);
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.38f);
|
||||
}
|
||||
else {
|
||||
immUniform4f("color1", 0.0f, 0.0f, 0.0f, 0.38f);
|
||||
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.38f);
|
||||
}
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib2f(line_origin, xpos + 0.5f, 12.0f);
|
||||
immVertex2f(pos, xpos + 0.5f, 12.0f);
|
||||
immVertex2f(pos, xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale);
|
||||
immEnd();
|
||||
|
||||
@@ -1862,25 +1862,21 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
format = immVertexFormat();
|
||||
const uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 1.0f, 0.39f, 0.39f, 0.78f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniformColor4f(1.0f, 0.39f, 0.39f, 0.78f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniform1f("dash_width", 12.0f);
|
||||
immUniform1f("dash_width_on", 6.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
imm_draw_circle_wire_dashed(shdr_dashed_pos, shdr_dashed_origin, x, y, p->radius,
|
||||
/* XXX Dashed shader gives bad results with sets of small segments currently,
|
||||
* temp hack around the issue. :( */
|
||||
max_ii(8, p->radius / 2)); /* was fixed 40 */
|
||||
imm_draw_circle_wire(shdr_pos, x, y, p->radius,
|
||||
/* XXX Dashed shader gives bad results with sets of small segments currently,
|
||||
* temp hack around the issue. :( */
|
||||
max_ii(8, p->radius / 2)); /* was fixed 40 */
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
|
||||
@@ -323,8 +323,7 @@ void UI_draw_roundbox_shade_y(bool filled, float minx, float miny, float maxx, f
|
||||
void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
|
||||
void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4]);
|
||||
|
||||
void UI_draw_safe_areas(
|
||||
uint pos, uint line_origin, float x1, float x2, float y1, float y2,
|
||||
void UI_draw_safe_areas(uint pos, float x1, float x2, float y1, float y2,
|
||||
const float title_aspect[2], const float action_aspect[2]);
|
||||
|
||||
/* state for scrolldrawing */
|
||||
|
||||
@@ -585,7 +585,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
|
||||
* The next 4 parameters are the offsets for the view, not the zones.
|
||||
*/
|
||||
void UI_draw_safe_areas(
|
||||
uint pos, uint line_origin, float x1, float x2, float y1, float y2,
|
||||
uint pos, float x1, float x2, float y1, float y2,
|
||||
const float title_aspect[2], const float action_aspect[2])
|
||||
{
|
||||
const float size_x_half = (x2 - x1) * 0.5f;
|
||||
@@ -604,7 +604,7 @@ void UI_draw_safe_areas(
|
||||
float maxx = x2 - margin_x;
|
||||
float maxy = y2 - margin_y;
|
||||
|
||||
imm_draw_line_box_dashed(pos, line_origin, minx, miny, maxx, maxy);
|
||||
imm_draw_line_box(pos, minx, miny, maxx, maxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1223,33 +1223,23 @@ static void ui_draw_colorband_handle(
|
||||
if (active || half_width < min_width) {
|
||||
immUnbindProgram();
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
const uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform4f("color1", 0.8f, 0.8f, 0.8f, 1.0f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.8f, 0.8f, 0.8f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", active ? 4.0f : 2.0f);
|
||||
immUniform1f("dash_width_on", active ? 2.0f : 1.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib2f(shdr_dashed_origin, x, y1);
|
||||
immVertex2f(shdr_dashed_pos, x, y1);
|
||||
immVertex2f(shdr_dashed_pos, x, y2);
|
||||
immVertex2f(shdr_pos, x, y1);
|
||||
immVertex2f(shdr_pos, x, y2);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
const uint pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
BLI_assert(pos == shdr_pos);
|
||||
UNUSED_VARS_NDEBUG(pos);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* hide handles when zoomed out too far */
|
||||
|
||||
@@ -169,9 +169,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -179,23 +177,20 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
const float alpha = (float)paint->paint_cursor_col[3] / 255.0f;
|
||||
immUniform4f("color1", 0.0f, 0.0f, 0.0f, alpha);
|
||||
immUniform4f("color2", 1.0f, 1.0f, 1.0f, alpha);
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.0f, 0.0f, 0.0f, alpha}, {1.0f, 1.0f, 1.0f, alpha}}, 2);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
|
||||
if (stroke->constrain_line) {
|
||||
immAttrib2f(line_origin, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
|
||||
immVertex2f(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
|
||||
immVertex2f(pos, stroke->constrained_pos[0], stroke->constrained_pos[1]);
|
||||
immVertex2f(shdr_pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
|
||||
immVertex2f(shdr_pos, stroke->constrained_pos[0], stroke->constrained_pos[1]);
|
||||
}
|
||||
else {
|
||||
immAttrib2f(line_origin, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
|
||||
immVertex2f(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
|
||||
immVertex2f(pos, x, y);
|
||||
immVertex2f(shdr_pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
|
||||
immVertex2f(shdr_pos, x, y);
|
||||
}
|
||||
|
||||
immEnd();
|
||||
|
||||
@@ -348,9 +348,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
|
||||
|
||||
/* draw boundary border for frame if stabilization is enabled */
|
||||
if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
const uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
/* Exclusive OR allows to get orig value when second operand is 0,
|
||||
* and negative of orig value when second operand is 1. */
|
||||
@@ -369,12 +367,12 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform4f("color1", 1.0f, 1.0f, 1.0f, 0.0f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
imm_draw_line_box_dashed(shdr_dashed_pos, shdr_dashed_origin, 0.0f, 0.0f, width, height);
|
||||
imm_draw_line_box(shdr_pos, 0.0f, 0.0f, width, height);
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
@@ -640,12 +638,8 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
{
|
||||
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
|
||||
bool show_search = false;
|
||||
float *curr_col, other_col[3], col[3], scol[3];
|
||||
float col[3], scol[3];
|
||||
float px[2];
|
||||
bool is_dashed_shader = false;
|
||||
|
||||
/* Vertex attributes ids for dashed shader... */
|
||||
uint shdr_dashed_pos, shdr_dashed_origin;
|
||||
|
||||
track_colors(track, act, col, scol);
|
||||
|
||||
@@ -654,26 +648,35 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
|
||||
glLineWidth(1.0f);
|
||||
|
||||
/* Since we are switching solid and dashed lines in rather complex logic here, just always go with dashed shader. */
|
||||
immUnbindProgram();
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
|
||||
/* marker position and offset position */
|
||||
if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) {
|
||||
float pos[2], p[2];
|
||||
|
||||
if (track->flag & TRACK_LOCKED) {
|
||||
if (act) {
|
||||
UI_GetThemeColor3fv(TH_ACT_MARKER, other_col);
|
||||
immUniformThemeColor(TH_ACT_MARKER);
|
||||
}
|
||||
else if (track->flag & SELECT) {
|
||||
UI_GetThemeColorShade3fv(TH_LOCK_MARKER, 64, other_col);
|
||||
immUniformThemeColorShade(TH_LOCK_MARKER, 64);
|
||||
}
|
||||
else {
|
||||
UI_GetThemeColor3fv(TH_LOCK_MARKER, other_col);
|
||||
immUniformThemeColor(TH_LOCK_MARKER);
|
||||
}
|
||||
curr_col = other_col;
|
||||
}
|
||||
else {
|
||||
curr_col = (track->flag & SELECT) ? scol : col;
|
||||
immUniformColor3fv((track->flag & SELECT) ? scol : col);
|
||||
}
|
||||
immUniformColor3fv(curr_col);
|
||||
|
||||
add_v2_v2v2(pos, marker->pos, track->offset);
|
||||
ED_clip_point_undistorted_pos(sc, pos, pos);
|
||||
@@ -685,11 +688,15 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
{
|
||||
glPointSize(tiny ? 1.0f : 2.0f);
|
||||
|
||||
immUniform1f("dash_factor", 2.0f); /* Solid "line" */
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immVertex2f(shdr_pos, pos[0], pos[1]);
|
||||
immEnd();
|
||||
}
|
||||
else {
|
||||
immUniform1f("dash_factor", 2.0f); /* Solid line */
|
||||
|
||||
immBegin(PRIM_LINES, 8);
|
||||
|
||||
immVertex2f(shdr_pos, pos[0] + px[0] * 3, pos[1]);
|
||||
@@ -706,31 +713,16 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
is_dashed_shader = true;
|
||||
VertexFormat *format = immVertexFormat();
|
||||
shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform4f("color1", 1.0f, 1.0f, 1.0f, 0.0f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.0f);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
glEnable(GL_COLOR_LOGIC_OP);
|
||||
glLogicOp(GL_XOR);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib2fv(shdr_dashed_origin, pos);
|
||||
immVertex2fv(shdr_dashed_pos, pos);
|
||||
immVertex2fv(shdr_dashed_pos, marker_pos);
|
||||
immVertex2fv(shdr_pos, pos);
|
||||
immVertex2fv(shdr_pos, marker_pos);
|
||||
immEnd();
|
||||
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
@@ -743,124 +735,66 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
|
||||
if (track->flag & TRACK_LOCKED) {
|
||||
if (act) {
|
||||
UI_GetThemeColor3fv(TH_ACT_MARKER, other_col);
|
||||
immUniformThemeColor(TH_ACT_MARKER);
|
||||
}
|
||||
else if (track->pat_flag & SELECT) {
|
||||
UI_GetThemeColorShade3fv(TH_LOCK_MARKER, 64, other_col);
|
||||
immUniformThemeColorShade(TH_LOCK_MARKER, 64);
|
||||
}
|
||||
else {
|
||||
UI_GetThemeColor3fv(TH_LOCK_MARKER, other_col);
|
||||
immUniformThemeColor(TH_LOCK_MARKER);
|
||||
}
|
||||
curr_col = other_col;
|
||||
}
|
||||
else if (marker->flag & MARKER_DISABLED) {
|
||||
if (act) {
|
||||
UI_GetThemeColor3fv(TH_ACT_MARKER, other_col);
|
||||
immUniformThemeColor(TH_ACT_MARKER);
|
||||
}
|
||||
else if (track->pat_flag & SELECT) {
|
||||
UI_GetThemeColorShade3fv(TH_DIS_MARKER, 128, other_col);
|
||||
immUniformThemeColorShade(TH_DIS_MARKER, 128);
|
||||
}
|
||||
else {
|
||||
UI_GetThemeColor3fv(TH_DIS_MARKER, other_col);
|
||||
immUniformThemeColor(TH_DIS_MARKER);
|
||||
}
|
||||
curr_col = other_col;
|
||||
}
|
||||
else {
|
||||
curr_col = (track->pat_flag & SELECT) ? scol : col;
|
||||
immUniformColor3fv((track->pat_flag & SELECT) ? scol : col);
|
||||
}
|
||||
|
||||
if (tiny) {
|
||||
if (!is_dashed_shader) {
|
||||
immUnbindProgram();
|
||||
|
||||
is_dashed_shader = true;
|
||||
VertexFormat *format = immVertexFormat();
|
||||
shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
}
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform4f("color1", curr_col[0], curr_col[1], curr_col[2], 1.0f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
|
||||
if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
|
||||
immBegin(PRIM_LINES, 8);
|
||||
immAttrib2fv(shdr_dashed_origin, marker->pattern_corners[0]);
|
||||
immVertex2fv(shdr_dashed_pos, marker->pattern_corners[0]);
|
||||
immVertex2fv(shdr_dashed_pos, marker->pattern_corners[1]);
|
||||
|
||||
immAttrib2fv(shdr_dashed_origin, marker->pattern_corners[1]);
|
||||
immVertex2fv(shdr_dashed_pos, marker->pattern_corners[1]);
|
||||
immVertex2fv(shdr_dashed_pos, marker->pattern_corners[2]);
|
||||
|
||||
immAttrib2fv(shdr_dashed_origin, marker->pattern_corners[3]);
|
||||
immVertex2fv(shdr_dashed_pos, marker->pattern_corners[2]);
|
||||
immVertex2fv(shdr_dashed_pos, marker->pattern_corners[3]);
|
||||
|
||||
immAttrib2fv(shdr_dashed_origin, marker->pattern_corners[0]);
|
||||
immVertex2fv(shdr_dashed_pos, marker->pattern_corners[3]);
|
||||
immVertex2fv(shdr_dashed_pos, marker->pattern_corners[0]);
|
||||
immEnd();
|
||||
}
|
||||
|
||||
/* search */
|
||||
show_search = (TRACK_VIEW_SELECTED(sc, track) &&
|
||||
((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) != 0;
|
||||
|
||||
if ((track->search_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_SEARCH) && show_search) {
|
||||
imm_draw_line_box_dashed(shdr_dashed_pos, shdr_dashed_origin, marker->search_min[0], marker->search_min[1],
|
||||
marker->search_max[0], marker->search_max[1]);
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
}
|
||||
else {
|
||||
immUniform1f("dash_factor", 2.0f); /* Solid line */
|
||||
}
|
||||
|
||||
if (is_dashed_shader) {
|
||||
immUnbindProgram();
|
||||
|
||||
uint pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
BLI_assert(pos == shdr_pos);
|
||||
UNUSED_VARS_NDEBUG(pos);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
is_dashed_shader = false;
|
||||
if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
|
||||
immBegin(PRIM_LINE_LOOP, 4);
|
||||
immVertex2fv(shdr_pos, marker->pattern_corners[0]);
|
||||
immVertex2fv(shdr_pos, marker->pattern_corners[1]);
|
||||
immVertex2fv(shdr_pos, marker->pattern_corners[2]);
|
||||
immVertex2fv(shdr_pos, marker->pattern_corners[3]);
|
||||
immEnd();
|
||||
}
|
||||
|
||||
if (!tiny) {
|
||||
immUniformColor3fv(curr_col);
|
||||
/* search */
|
||||
show_search = (TRACK_VIEW_SELECTED(sc, track) &&
|
||||
((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) != 0;
|
||||
|
||||
if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
|
||||
immBegin(PRIM_LINE_LOOP, 4);
|
||||
immVertex2fv(shdr_pos, marker->pattern_corners[0]);
|
||||
immVertex2fv(shdr_pos, marker->pattern_corners[1]);
|
||||
immVertex2fv(shdr_pos, marker->pattern_corners[2]);
|
||||
immVertex2fv(shdr_pos, marker->pattern_corners[3]);
|
||||
immEnd();
|
||||
}
|
||||
|
||||
/* search */
|
||||
show_search = (TRACK_VIEW_SELECTED(sc, track) &&
|
||||
((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0)) != 0;
|
||||
|
||||
if ((track->search_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_SEARCH) && show_search) {
|
||||
imm_draw_line_box(shdr_pos, marker->search_min[0],
|
||||
marker->search_min[1],
|
||||
marker->search_max[0],
|
||||
marker->search_max[1]);
|
||||
}
|
||||
if ((track->search_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_SEARCH) && show_search) {
|
||||
imm_draw_line_box(shdr_pos, marker->search_min[0], marker->search_min[1],
|
||||
marker->search_max[0], marker->search_max[1]);
|
||||
}
|
||||
|
||||
gpuPopMatrix();
|
||||
|
||||
/* Restore default shader */
|
||||
immUnbindProgram();
|
||||
|
||||
const uint pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
BLI_assert(pos == shdr_pos);
|
||||
UNUSED_VARS_NDEBUG(pos);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
}
|
||||
|
||||
static float get_shortest_pattern_side(MovieTrackingMarker *marker)
|
||||
@@ -1245,7 +1179,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
|
||||
BKE_image_has_ibuf(plane_track->image, NULL);
|
||||
const bool draw_plane_quad = !has_image || plane_track->image_opacity == 0.0f;
|
||||
float px[2];
|
||||
float *curr_color, other_color[3], color[3], selected_color[3];
|
||||
float color[3], selected_color[3];
|
||||
|
||||
px[0] = 1.0f / width / sc->zoom;
|
||||
px[1] = 1.0f / height / sc->zoom;
|
||||
@@ -1256,8 +1190,15 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
|
||||
}
|
||||
|
||||
if (draw_plane_quad || is_selected_track) {
|
||||
uint shdr_pos;
|
||||
bool is_uniform_shader_defined = false;
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
|
||||
if (draw_plane_quad) {
|
||||
const bool stipple = !draw_outline && tiny;
|
||||
@@ -1265,137 +1206,60 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
|
||||
|
||||
glLineWidth(thick ? 3.0f : 1.0f);
|
||||
|
||||
if (stipple) {
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
}
|
||||
else {
|
||||
immUniform1f("dash_factor", 2.0f); /* Solid line */
|
||||
}
|
||||
|
||||
if (draw_outline) {
|
||||
UI_GetThemeColor3fv(TH_MARKER_OUTLINE, other_color);
|
||||
curr_color = other_color;
|
||||
immUniformThemeColor(TH_MARKER_OUTLINE);
|
||||
}
|
||||
else {
|
||||
plane_track_colors(is_active_track, color, selected_color);
|
||||
curr_color = is_selected_track ? selected_color : color;
|
||||
immUniformColor3fv(is_selected_track ? selected_color : color);
|
||||
}
|
||||
|
||||
if (stipple) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
/* Draw rectangle itself. */
|
||||
immBegin(PRIM_LINE_LOOP, 4);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[1]);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[2]);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[3]);
|
||||
immEnd();
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
/* Draw axis. */
|
||||
if (!draw_outline) {
|
||||
float end_point[2];
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
immUniformColor3f(1.0f, 0.0f, 0.0f);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
immBegin(PRIM_LINES, 2);
|
||||
|
||||
immUniform4f("color1", curr_color[0], curr_color[1], curr_color[2], 1.0f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
|
||||
/* Draw rectangle itself. */
|
||||
immBegin(PRIM_LINES, 8);
|
||||
immAttrib2fv(shdr_dashed_origin, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_dashed_pos, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_dashed_pos, plane_marker->corners[1]);
|
||||
|
||||
immAttrib2fv(shdr_dashed_origin, plane_marker->corners[1]);
|
||||
immVertex2fv(shdr_dashed_pos, plane_marker->corners[1]);
|
||||
immVertex2fv(shdr_dashed_pos, plane_marker->corners[2]);
|
||||
|
||||
immAttrib2fv(shdr_dashed_origin, plane_marker->corners[3]);
|
||||
immVertex2fv(shdr_dashed_pos, plane_marker->corners[2]);
|
||||
immVertex2fv(shdr_dashed_pos, plane_marker->corners[3]);
|
||||
|
||||
immAttrib2fv(shdr_dashed_origin, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_dashed_pos, plane_marker->corners[3]);
|
||||
immVertex2fv(shdr_dashed_pos, plane_marker->corners[0]);
|
||||
immEnd();
|
||||
|
||||
/* Draw axis. */
|
||||
if (!draw_outline) {
|
||||
float end_point[2];
|
||||
|
||||
immUniform4f("color1", 1.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
|
||||
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[1], end_point);
|
||||
immAttrib2fv(shdr_dashed_origin, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_dashed_pos, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_dashed_pos, end_point);
|
||||
|
||||
immEnd();
|
||||
|
||||
immUniform4f("color1", 0.0f, 1.0f, 0.0f, 1.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
|
||||
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[3], end_point);
|
||||
immAttrib2fv(shdr_dashed_origin, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_dashed_pos, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_dashed_pos, end_point);
|
||||
|
||||
immEnd();
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
is_uniform_shader_defined = true;
|
||||
|
||||
immUniformColor3fv(curr_color);
|
||||
|
||||
if (!stipple) {
|
||||
/* Draw rectangle itself. */
|
||||
immBegin(PRIM_LINE_LOOP, 4);
|
||||
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[1], end_point);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[1]);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[2]);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[3]);
|
||||
immVertex2fv(shdr_pos, end_point);
|
||||
|
||||
immEnd();
|
||||
|
||||
/* Draw axis. */
|
||||
if (!draw_outline) {
|
||||
float end_point[2];
|
||||
immUniformColor3f(0.0f, 1.0f, 0.0f);
|
||||
|
||||
immUniformColor3f(1.0f, 0.0f, 0.0f);
|
||||
immBegin(PRIM_LINES, 2);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[3], end_point);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_pos, end_point);
|
||||
|
||||
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[1], end_point);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_pos, end_point);
|
||||
|
||||
immEnd();
|
||||
|
||||
immUniformColor3f(0.0f, 1.0f, 0.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
|
||||
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[3], end_point);
|
||||
immVertex2fv(shdr_pos, plane_marker->corners[0]);
|
||||
immVertex2fv(shdr_pos, end_point);
|
||||
|
||||
immEnd();
|
||||
}
|
||||
immEnd();
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_uniform_shader_defined) {
|
||||
shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
is_uniform_shader_defined = true;
|
||||
}
|
||||
|
||||
/* Draw sliders. */
|
||||
if (is_selected_track) {
|
||||
immUniform1f("dash_factor", 2.0f); /* Solid line */
|
||||
|
||||
if (draw_outline) {
|
||||
immUniformThemeColor(TH_MARKER_OUTLINE);
|
||||
}
|
||||
|
||||
@@ -688,7 +688,6 @@ void draw_image_sample_line(SpaceImage *sima)
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -696,13 +695,11 @@ void draw_image_sample_line(SpaceImage *sima)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform4f("color1", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
immUniform1i("num_colors", 2); /* Advanced dashes. */
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", 2.0f);
|
||||
immUniform1f("dash_width_on", 1.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib2fv(shdr_dashed_origin, hist->co[0]);
|
||||
immVertex2fv(shdr_dashed_pos, hist->co[0]);
|
||||
immVertex2fv(shdr_dashed_pos, hist->co[1]);
|
||||
immEnd();
|
||||
|
||||
@@ -121,6 +121,8 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos_id = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4fv(color);
|
||||
|
||||
/* - draw a rect from the first to the last frame (no extra overlaps for now)
|
||||
@@ -175,67 +177,37 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax
|
||||
if (!(act && act->markers.first))
|
||||
return;
|
||||
|
||||
float color[4];
|
||||
UI_GetThemeColorShade4fv(TH_STRIP_SELECT, shade, color);
|
||||
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
if (dashed) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
const uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform4fv("color1", color);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
|
||||
immBeginAtMost(PRIM_LINES, BLI_listbase_count(&act->markers) * 2);
|
||||
for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
|
||||
if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) {
|
||||
float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP);
|
||||
|
||||
/* just a simple line for now */
|
||||
/* XXX: draw a triangle instead... */
|
||||
immAttrib2f(shdr_dashed_origin, frame, yminc + 1);
|
||||
immVertex2f(shdr_dashed_pos, frame, yminc + 1);
|
||||
immVertex2f(shdr_dashed_pos, frame, ymaxc - 1);
|
||||
}
|
||||
}
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
}
|
||||
else {
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4fv(color);
|
||||
|
||||
immBeginAtMost(PRIM_LINES, BLI_listbase_count(&act->markers) * 2);
|
||||
for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
|
||||
if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) {
|
||||
float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP);
|
||||
|
||||
/* just a simple line for now */
|
||||
/* XXX: draw a triangle instead... */
|
||||
immVertex2f(shdr_pos, frame, yminc + 1);
|
||||
immVertex2f(shdr_pos, frame, ymaxc - 1);
|
||||
}
|
||||
}
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
immUniformThemeColorShade(TH_STRIP_SELECT, shade);
|
||||
|
||||
immBeginAtMost(PRIM_LINES, BLI_listbase_count(&act->markers) * 2);
|
||||
for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
|
||||
if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) {
|
||||
float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP);
|
||||
|
||||
/* just a simple line for now */
|
||||
/* XXX: draw a triangle instead... */
|
||||
immVertex2f(shdr_pos, frame, yminc + 1);
|
||||
immVertex2f(shdr_pos, frame, ymaxc - 1);
|
||||
}
|
||||
}
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
/* Markers inside a NLA-Strip */
|
||||
|
||||
@@ -1033,13 +1033,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
|
||||
glLineWidth(1.0f);
|
||||
|
||||
/* border */
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
float color1[4];
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -1047,36 +1041,31 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
UI_GetThemeColor4fv(TH_BACK, color1);
|
||||
immUniform4fv("color1", color1);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniformThemeColor(TH_BACK);
|
||||
immUniform1i("num_colors", 0); /* Simple dashes. */
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
imm_draw_line_box_dashed(pos, line_origin, x1 - 0.5f, y1 - 0.5f, x2 + 0.5f, y2 + 0.5f);
|
||||
imm_draw_line_box(shdr_pos, x1 - 0.5f, y1 - 0.5f, x2 + 0.5f, y2 + 0.5f);
|
||||
|
||||
/* safety border */
|
||||
if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) {
|
||||
UI_GetThemeColorBlend3f(TH_VIEW_OVERLAY, TH_BACK, 0.25f, color1);
|
||||
color1[3] = 1.0f;
|
||||
immUniform4fv("color1", color1);
|
||||
immUniformThemeColorBlend(TH_VIEW_OVERLAY, TH_BACK, 0.25f);
|
||||
|
||||
UI_draw_safe_areas(
|
||||
pos, line_origin, x1, x2, y1, y2,
|
||||
shdr_pos, x1, x2, y1, y2,
|
||||
scene->safe_areas.title,
|
||||
scene->safe_areas.action);
|
||||
|
||||
if (sseq->flag & SEQ_SHOW_SAFE_CENTER) {
|
||||
UI_draw_safe_areas(
|
||||
pos, line_origin, x1, x2, y1, y2,
|
||||
shdr_pos, x1, x2, y1, y2,
|
||||
scene->safe_areas.title_center,
|
||||
scene->safe_areas.action_center);
|
||||
}
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
/* draws checkerboard background for transparent content */
|
||||
|
||||
@@ -1501,12 +1501,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
|
||||
margin_column_x = x + st->cwidth * (st->margin_column - st->left);
|
||||
|
||||
if (margin_column_x >= x) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -1514,21 +1509,16 @@ void draw_text_main(SpaceText *st, ARegion *ar)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
float color1[4];
|
||||
UI_GetThemeColor4fv(TH_GRID, color1); /* same color as line number background */
|
||||
immUniform4fv("color1", color1);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniformThemeColor(TH_GRID); /* same color as line number background */
|
||||
immUniform1f("dash_width", 2.0f);
|
||||
immUniform1f("dash_width_on", 1.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib2i(shdr_dashed_origin, margin_column_x, 0);
|
||||
immVertex2i(shdr_dashed_pos, margin_column_x, 0);
|
||||
immVertex2i(shdr_dashed_pos, margin_column_x, ar->winy - 2);
|
||||
immVertex2i(shdr_pos, margin_column_x, 0);
|
||||
immVertex2i(shdr_pos, margin_column_x, ar->winy - 2);
|
||||
immEnd();
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1632,12 +1632,7 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
|
||||
bConstraint *con;
|
||||
bPoseChannel *parchan;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -1645,10 +1640,10 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4fv("color1", fcolor);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniformColor4fv(fcolor);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
for (con = pchan->constraints.first; con; con = con->next) {
|
||||
if (con->enforce == 0.0f)
|
||||
@@ -1683,9 +1678,8 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
|
||||
|
||||
if (parchan) {
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib3fv(line_origin, ik_tip);
|
||||
immVertex3fv(pos, ik_tip);
|
||||
immVertex3fv(pos, parchan->pose_head);
|
||||
immVertex3fv(shdr_pos, ik_tip);
|
||||
immVertex3fv(shdr_pos, parchan->pose_head);
|
||||
immEnd();
|
||||
}
|
||||
|
||||
@@ -1710,9 +1704,8 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
|
||||
/* Only draw line in case our chain is more than one bone long! */
|
||||
if (parchan != pchan) { /* XXX revise the breaking conditions to only stop at the tail? */
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib3fv(line_origin, ik_tip);
|
||||
immVertex3fv(pos, ik_tip);
|
||||
immVertex3fv(pos, parchan->pose_head);
|
||||
immVertex3fv(shdr_pos, ik_tip);
|
||||
immVertex3fv(shdr_pos, parchan->pose_head);
|
||||
immEnd();
|
||||
}
|
||||
break;
|
||||
@@ -1721,8 +1714,6 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp)
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
static void imm_sphere_project(unsigned int pos, float ax, float az)
|
||||
@@ -2216,12 +2207,7 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
|
||||
* - only if V3D_HIDE_HELPLINES is enabled...
|
||||
*/
|
||||
if ((do_dashed & DASH_HELP_LINES) && ((bone->flag & BONE_CONNECTED) == 0)) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -2229,26 +2215,22 @@ static void draw_pose_bones(Scene *scene, SceneLayer *sl, View3D *v3d, ARegion *
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4fv("color1", fcolor);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniformColor4fv(fcolor);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
if (arm->flag & ARM_POSEMODE) {
|
||||
GPU_select_load_id(index & 0xFFFF); /* object tag, for bordersel optim */
|
||||
UI_GetThemeColor4fv(TH_WIRE, fcolor);
|
||||
immUniform4fv("color1", fcolor);
|
||||
immUniformThemeColor(TH_WIRE);
|
||||
}
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib3fv(line_origin, pchan->parent->pose_tail);
|
||||
immVertex3fv(pos, pchan->parent->pose_tail);
|
||||
immVertex3fv(pos, pchan->pose_head);
|
||||
immVertex3fv(shdr_pos, pchan->parent->pose_tail);
|
||||
immVertex3fv(shdr_pos, pchan->pose_head);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
/* Draw a line to IK root bone
|
||||
@@ -2530,12 +2512,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
|
||||
|
||||
/* offset to parent */
|
||||
if (eBone->parent) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
||||
GPU_select_load_id(-1); /* -1 here is OK! */
|
||||
|
||||
@@ -2545,21 +2522,17 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
UI_GetThemeColor4fv(TH_WIRE_EDIT, fcolor);
|
||||
immUniform4fv("color1", fcolor);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniformThemeColor(TH_WIRE_EDIT);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib3fv(line_origin, eBone->parent->tail);
|
||||
immVertex3fv(pos, eBone->parent->tail);
|
||||
immVertex3fv(pos, eBone->head);
|
||||
immVertex3fv(shdr_pos, eBone->parent->tail);
|
||||
immVertex3fv(shdr_pos, eBone->head);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ void ED_view3d_calc_camera_border(
|
||||
view3d_camera_border(scene, ar, v3d, rv3d, r_viewborder, no_shift, false);
|
||||
}
|
||||
|
||||
static void drawviewborder_grid3(uint pos, uint line_origin, float x1, float x2, float y1, float y2, float fac)
|
||||
static void drawviewborder_grid3(uint shdr_pos, float x1, float x2, float y1, float y2, float fac)
|
||||
{
|
||||
float x3, y3, x4, y4;
|
||||
|
||||
@@ -428,28 +428,24 @@ static void drawviewborder_grid3(uint pos, uint line_origin, float x1, float x2,
|
||||
|
||||
immBegin(PRIM_LINES, 8);
|
||||
|
||||
immAttrib2f(line_origin, x1, y3);
|
||||
immVertex2f(pos, x1, y3);
|
||||
immVertex2f(pos, x2, y3);
|
||||
immVertex2f(shdr_pos, x1, y3);
|
||||
immVertex2f(shdr_pos, x2, y3);
|
||||
|
||||
immAttrib2f(line_origin, x1, y4);
|
||||
immVertex2f(pos, x1, y4);
|
||||
immVertex2f(pos, x2, y4);
|
||||
immVertex2f(shdr_pos, x1, y4);
|
||||
immVertex2f(shdr_pos, x2, y4);
|
||||
|
||||
immAttrib2f(line_origin, x3, y1);
|
||||
immVertex2f(pos, x3, y1);
|
||||
immVertex2f(pos, x3, y2);
|
||||
immVertex2f(shdr_pos, x3, y1);
|
||||
immVertex2f(shdr_pos, x3, y2);
|
||||
|
||||
immAttrib2f(line_origin, x4, y1);
|
||||
immVertex2f(pos, x4, y1);
|
||||
immVertex2f(pos, x4, y2);
|
||||
immVertex2f(shdr_pos, x4, y1);
|
||||
immVertex2f(shdr_pos, x4, y2);
|
||||
|
||||
immEnd();
|
||||
}
|
||||
|
||||
/* harmonious triangle */
|
||||
static void drawviewborder_triangle(
|
||||
uint pos, uint line_origin, float x1, float x2, float y1, float y2, const char golden, const char dir)
|
||||
uint shdr_pos, float x1, float x2, float y1, float y2, const char golden, const char dir)
|
||||
{
|
||||
float ofs;
|
||||
float w = x2 - x1;
|
||||
@@ -466,17 +462,14 @@ static void drawviewborder_triangle(
|
||||
}
|
||||
if (dir == 'B') SWAP(float, y1, y2);
|
||||
|
||||
immAttrib2f(line_origin, x1, y1);
|
||||
immVertex2f(pos, x1, y1);
|
||||
immVertex2f(pos, x2, y2);
|
||||
immVertex2f(shdr_pos, x1, y1);
|
||||
immVertex2f(shdr_pos, x2, y2);
|
||||
|
||||
immAttrib2f(line_origin, x2, y1);
|
||||
immVertex2f(pos, x2, y1);
|
||||
immVertex2f(pos, x1 + (w - ofs), y2);
|
||||
immVertex2f(shdr_pos, x2, y1);
|
||||
immVertex2f(shdr_pos, x1 + (w - ofs), y2);
|
||||
|
||||
immAttrib2f(line_origin, x1, y2);
|
||||
immVertex2f(pos, x1, y2);
|
||||
immVertex2f(pos, x1 + ofs, y1);
|
||||
immVertex2f(shdr_pos, x1, y2);
|
||||
immVertex2f(shdr_pos, x1 + ofs, y1);
|
||||
}
|
||||
else {
|
||||
if (golden) {
|
||||
@@ -487,17 +480,14 @@ static void drawviewborder_triangle(
|
||||
}
|
||||
if (dir == 'B') SWAP(float, x1, x2);
|
||||
|
||||
immAttrib2f(line_origin, x1, y1);
|
||||
immVertex2f(pos, x1, y1);
|
||||
immVertex2f(pos, x2, y2);
|
||||
immVertex2f(shdr_pos, x1, y1);
|
||||
immVertex2f(shdr_pos, x2, y2);
|
||||
|
||||
immAttrib2f(line_origin, x2, y1);
|
||||
immVertex2f(pos, x2, y1);
|
||||
immVertex2f(pos, x1, y1 + ofs);
|
||||
immVertex2f(shdr_pos, x2, y1);
|
||||
immVertex2f(shdr_pos, x1, y1 + ofs);
|
||||
|
||||
immAttrib2f(line_origin, x1, y2);
|
||||
immVertex2f(pos, x1, y2);
|
||||
immVertex2f(pos, x2, y1 + (h - ofs));
|
||||
immVertex2f(shdr_pos, x1, y2);
|
||||
immVertex2f(shdr_pos, x2, y1 + (h - ofs));
|
||||
}
|
||||
|
||||
immEnd();
|
||||
@@ -538,9 +528,10 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
x2i = (int)(x2 + (1.0f - 0.0001f));
|
||||
y2i = (int)(y2 + (1.0f - 0.0001f));
|
||||
|
||||
uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
/* First, solid lines. */
|
||||
{
|
||||
unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* passepartout, specified in camera edit buttons */
|
||||
@@ -559,24 +550,24 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
immUniformColor4f(0.0f, 0.0f, 0.0f, alpha);
|
||||
|
||||
if (x1i > 0.0f)
|
||||
immRectf(pos, 0.0f, winy, x1i, 0.0f);
|
||||
immRectf(shdr_pos, 0.0f, winy, x1i, 0.0f);
|
||||
if (x2i < winx)
|
||||
immRectf(pos, x2i, winy, winx, 0.0f);
|
||||
immRectf(shdr_pos, x2i, winy, winx, 0.0f);
|
||||
if (y2i < winy)
|
||||
immRectf(pos, x1i, winy, x2i, y2i);
|
||||
immRectf(shdr_pos, x1i, winy, x2i, y2i);
|
||||
if (y2i > 0.0f)
|
||||
immRectf(pos, x1i, y1i, x2i, 0.0f);
|
||||
immRectf(shdr_pos, x1i, y1i, x2i, 0.0f);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
immUniformThemeColor(TH_BACK);
|
||||
imm_draw_line_box(pos, x1i, y1i, x2i, y2i);
|
||||
imm_draw_line_box(shdr_pos, x1i, y1i, x2i, y2i);
|
||||
|
||||
#ifdef VIEW3D_CAMERA_BORDER_HACK
|
||||
if (view3d_camera_border_hack_test == true) {
|
||||
immUniformColor3ubv(view3d_camera_border_hack_col);
|
||||
imm_draw_line_box(pos, x1i + 1, y1i + 1, x2i - 1, y2i - 1);
|
||||
imm_draw_line_box(shdr_pos, x1i + 1, y1i + 1, x2i - 1, y2i - 1);
|
||||
view3d_camera_border_hack_test = false;
|
||||
}
|
||||
#endif
|
||||
@@ -586,34 +577,24 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
|
||||
/* And now, the dashed lines! */
|
||||
{
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
float color1[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
/* outer line not to confuse with object selection */
|
||||
if (v3d->flag2 & V3D_LOCK_CAMERA) {
|
||||
UI_GetThemeColor4fv(TH_REDALERT, color1);
|
||||
immUniform4fv("color1", color1);
|
||||
imm_draw_line_box_dashed(pos, line_origin, x1i - 1, y1i - 1, x2i + 1, y2i + 1);
|
||||
immUniformThemeColor(TH_REDALERT);
|
||||
imm_draw_line_box(shdr_pos, x1i - 1, y1i - 1, x2i + 1, y2i + 1);
|
||||
}
|
||||
|
||||
UI_GetThemeColor4fv(TH_VIEW_OVERLAY, color1);
|
||||
immUniform4fv("color1", color1);
|
||||
imm_draw_line_box_dashed(pos, line_origin, x1i, y1i, x2i, y2i);
|
||||
immUniformThemeColor(TH_VIEW_OVERLAY);
|
||||
imm_draw_line_box(shdr_pos, x1i, y1i, x2i, y2i);
|
||||
|
||||
/* border */
|
||||
if (scene->r.mode & R_BORDER) {
|
||||
@@ -624,15 +605,13 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
x4 = floorf(x1 + (scene->r.border.xmax * (x2 - x1))) + (U.pixelsize - 1);
|
||||
y4 = floorf(y1 + (scene->r.border.ymax * (y2 - y1))) + (U.pixelsize - 1);
|
||||
|
||||
immUniform4f("color1", 1.0f, 0.25f, 0.25f, 1.0f);
|
||||
imm_draw_line_box_dashed(pos, line_origin, x3, y3, x4, y4);
|
||||
immUniformColor3f(1.0f, 0.25f, 0.25f);
|
||||
imm_draw_line_box(shdr_pos, x3, y3, x4, y4);
|
||||
}
|
||||
|
||||
/* safety border */
|
||||
if (ca) {
|
||||
UI_GetThemeColorBlend3f(TH_VIEW_OVERLAY, TH_BACK, 0.25f, color1);
|
||||
color1[3] = 1.0f;
|
||||
immUniform4fv("color1", color1);
|
||||
immUniformThemeColorBlend(TH_VIEW_OVERLAY, TH_BACK, 0.25f);
|
||||
|
||||
if (ca->dtx & CAM_DTX_CENTER) {
|
||||
float x3, y3;
|
||||
@@ -642,13 +621,11 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
|
||||
immBegin(PRIM_LINES, 4);
|
||||
|
||||
immAttrib2f(line_origin, x1, y3);
|
||||
immVertex2f(pos, x1, y3);
|
||||
immVertex2f(pos, x2, y3);
|
||||
immVertex2f(shdr_pos, x1, y3);
|
||||
immVertex2f(shdr_pos, x2, y3);
|
||||
|
||||
immAttrib2f(line_origin, x3, y1);
|
||||
immVertex2f(pos, x3, y1);
|
||||
immVertex2f(pos, x3, y2);
|
||||
immVertex2f(shdr_pos, x3, y1);
|
||||
immVertex2f(shdr_pos, x3, y2);
|
||||
|
||||
immEnd();
|
||||
}
|
||||
@@ -656,52 +633,46 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
if (ca->dtx & CAM_DTX_CENTER_DIAG) {
|
||||
immBegin(PRIM_LINES, 4);
|
||||
|
||||
immAttrib2f(line_origin, x1, y1);
|
||||
immVertex2f(pos, x1, y1);
|
||||
immVertex2f(pos, x2, y2);
|
||||
immVertex2f(shdr_pos, x1, y1);
|
||||
immVertex2f(shdr_pos, x2, y2);
|
||||
|
||||
immAttrib2f(line_origin, x1, y2);
|
||||
immVertex2f(pos, x1, y2);
|
||||
immVertex2f(pos, x2, y1);
|
||||
immVertex2f(shdr_pos, x1, y2);
|
||||
immVertex2f(shdr_pos, x2, y1);
|
||||
|
||||
immEnd();
|
||||
}
|
||||
|
||||
if (ca->dtx & CAM_DTX_THIRDS) {
|
||||
drawviewborder_grid3(pos, line_origin, x1, x2, y1, y2, 1.0f / 3.0f);
|
||||
drawviewborder_grid3(shdr_pos, x1, x2, y1, y2, 1.0f / 3.0f);
|
||||
}
|
||||
|
||||
if (ca->dtx & CAM_DTX_GOLDEN) {
|
||||
drawviewborder_grid3(pos, line_origin, x1, x2, y1, y2, 1.0f - (1.0f / 1.61803399f));
|
||||
drawviewborder_grid3(shdr_pos, x1, x2, y1, y2, 1.0f - (1.0f / 1.61803399f));
|
||||
}
|
||||
|
||||
if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) {
|
||||
drawviewborder_triangle(pos, line_origin, x1, x2, y1, y2, 0, 'A');
|
||||
drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 0, 'A');
|
||||
}
|
||||
|
||||
if (ca->dtx & CAM_DTX_GOLDEN_TRI_B) {
|
||||
drawviewborder_triangle(pos, line_origin, x1, x2, y1, y2, 0, 'B');
|
||||
drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 0, 'B');
|
||||
}
|
||||
|
||||
if (ca->dtx & CAM_DTX_HARMONY_TRI_A) {
|
||||
drawviewborder_triangle(pos, line_origin, x1, x2, y1, y2, 1, 'A');
|
||||
drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 1, 'A');
|
||||
}
|
||||
|
||||
if (ca->dtx & CAM_DTX_HARMONY_TRI_B) {
|
||||
drawviewborder_triangle(pos, line_origin, x1, x2, y1, y2, 1, 'B');
|
||||
drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 1, 'B');
|
||||
}
|
||||
|
||||
if (ca->flag & CAM_SHOW_SAFE_MARGINS) {
|
||||
UI_draw_safe_areas(
|
||||
pos, line_origin, x1, x2, y1, y2,
|
||||
scene->safe_areas.title,
|
||||
scene->safe_areas.action);
|
||||
UI_draw_safe_areas(shdr_pos, x1, x2, y1, y2,
|
||||
scene->safe_areas.title, scene->safe_areas.action);
|
||||
|
||||
if (ca->flag & CAM_SHOW_SAFE_CENTER) {
|
||||
UI_draw_safe_areas(
|
||||
pos, line_origin, x1, x2, y1, y2,
|
||||
scene->safe_areas.title_center,
|
||||
scene->safe_areas.action_center);
|
||||
UI_draw_safe_areas(shdr_pos, x1, x2, y1, y2,
|
||||
scene->safe_areas.title_center, scene->safe_areas.action_center);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -738,18 +709,15 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
}
|
||||
|
||||
/* draw */
|
||||
UI_GetThemeColorShade4fv(TH_VIEW_OVERLAY, 100, color1);
|
||||
immUniform4fv("color1", color1);
|
||||
immUniformThemeColorShade(TH_VIEW_OVERLAY, 100);
|
||||
|
||||
/* TODO Was using UI_draw_roundbox_4fv(false, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f, color).
|
||||
* We'll probably need a new imm_draw_line_roundbox_dashed dor that - though in practice the
|
||||
* 2.0f round corner effect was nearly not visible anyway... */
|
||||
imm_draw_line_box_dashed(pos, line_origin, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
||||
imm_draw_line_box(shdr_pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
/* camera name - draw in highlighted text color */
|
||||
@@ -763,13 +731,9 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
||||
static void drawrenderborder(ARegion *ar, View3D *v3d)
|
||||
{
|
||||
/* use the same program for everything */
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
glLineWidth(1.0f);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -777,14 +741,14 @@ static void drawrenderborder(ARegion *ar, View3D *v3d)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 1.0f, 0.25f, 0.25f, 1.0f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniform4f("color", 1.0f, 0.25f, 0.25f, 1.0f);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
imm_draw_line_box_dashed(pos, line_origin,
|
||||
v3d->render_border.xmin * ar->winx, v3d->render_border.ymin * ar->winy,
|
||||
v3d->render_border.xmax * ar->winx, v3d->render_border.ymax * ar->winy);
|
||||
imm_draw_line_box(shdr_pos,
|
||||
v3d->render_border.xmin * ar->winx, v3d->render_border.ymin * ar->winy,
|
||||
v3d->render_border.xmax * ar->winx, v3d->render_border.ymax * ar->winy);
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
@@ -458,38 +458,30 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
if (ruler_item->flag & RULERITEM_USE_ANGLE) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
if (ruler_item->flag & RULERITEM_USE_ANGLE) {
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 0.67f, 0.67f, 0.67f, 1.0f);
|
||||
immUniform4fv("color2", is_act ? color_act : color_base);
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
const float *col = is_act ? color_act : color_base;
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 4);
|
||||
immBegin(PRIM_LINE_STRIP, 3);
|
||||
|
||||
immAttrib2fv(line_origin, co_ss[0]);
|
||||
immVertex2fv(pos, co_ss[0]);
|
||||
immVertex2fv(pos, co_ss[1]);
|
||||
|
||||
immAttrib2fv(line_origin, co_ss[1]);
|
||||
immVertex2fv(pos, co_ss[1]);
|
||||
immVertex2fv(pos, co_ss[2]);
|
||||
immVertex2fv(shdr_pos, co_ss[0]);
|
||||
immVertex2fv(shdr_pos, co_ss[1]);
|
||||
immVertex2fv(shdr_pos, co_ss[2]);
|
||||
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* arc */
|
||||
@@ -529,7 +521,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
|
||||
ED_view3d_project_float_global(ar, co_tmp, arc_ss_coord, V3D_PROJ_TEST_NOP);
|
||||
mul_qt_v3(quat, dir_tmp);
|
||||
|
||||
immVertex2fv(pos, arc_ss_coord);
|
||||
immVertex2fv(shdr_pos, arc_ss_coord);
|
||||
}
|
||||
|
||||
immEnd();
|
||||
@@ -558,20 +550,20 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
|
||||
immBegin(PRIM_LINES, 8);
|
||||
|
||||
madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size);
|
||||
immVertex2fv(pos, cap);
|
||||
immVertex2fv(shdr_pos, cap);
|
||||
madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, -cap_size);
|
||||
immVertex2fv(pos, cap);
|
||||
immVertex2fv(shdr_pos, cap);
|
||||
|
||||
madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, cap_size);
|
||||
immVertex2fv(pos, cap);
|
||||
immVertex2fv(shdr_pos, cap);
|
||||
madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec_b, -cap_size);
|
||||
immVertex2fv(pos, cap);
|
||||
immVertex2fv(shdr_pos, cap);
|
||||
|
||||
/* angle vertex */
|
||||
immVertex2f(pos, co_ss[1][0] - cap_size, co_ss[1][1] - cap_size);
|
||||
immVertex2f(pos, co_ss[1][0] + cap_size, co_ss[1][1] + cap_size);
|
||||
immVertex2f(pos, co_ss[1][0] - cap_size, co_ss[1][1] + cap_size);
|
||||
immVertex2f(pos, co_ss[1][0] + cap_size, co_ss[1][1] - cap_size);
|
||||
immVertex2f(shdr_pos, co_ss[1][0] - cap_size, co_ss[1][1] - cap_size);
|
||||
immVertex2f(shdr_pos, co_ss[1][0] + cap_size, co_ss[1][1] + cap_size);
|
||||
immVertex2f(shdr_pos, co_ss[1][0] - cap_size, co_ss[1][1] + cap_size);
|
||||
immVertex2f(shdr_pos, co_ss[1][0] + cap_size, co_ss[1][1] - cap_size);
|
||||
|
||||
immEnd();
|
||||
|
||||
@@ -608,33 +600,26 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
|
||||
}
|
||||
}
|
||||
else {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 0.67f, 0.67f, 0.67f, 1.0f);
|
||||
immUniform4fv("color2", is_act ? color_act : color_base);
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
const float *col = is_act ? color_act : color_base;
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
|
||||
immAttrib2fv(line_origin, co_ss[0]);
|
||||
immVertex2fv(pos, co_ss[0]);
|
||||
immVertex2fv(pos, co_ss[2]);
|
||||
immVertex2fv(shdr_pos, co_ss[0]);
|
||||
immVertex2fv(shdr_pos, co_ss[2]);
|
||||
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
sub_v2_v2v2(dir_ruler, co_ss[0], co_ss[2]);
|
||||
@@ -653,14 +638,14 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
|
||||
immBegin(PRIM_LINES, 4);
|
||||
|
||||
madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size);
|
||||
immVertex2fv(pos, cap);
|
||||
immVertex2fv(shdr_pos, cap);
|
||||
madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, -cap_size);
|
||||
immVertex2fv(pos, cap);
|
||||
immVertex2fv(shdr_pos, cap);
|
||||
|
||||
madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec, cap_size);
|
||||
immVertex2fv(pos, cap);
|
||||
immVertex2fv(shdr_pos, cap);
|
||||
madd_v2_v2v2fl(cap, co_ss[2], rot_90_vec, -cap_size);
|
||||
immVertex2fv(pos, cap);
|
||||
immVertex2fv(shdr_pos, cap);
|
||||
|
||||
immEnd();
|
||||
|
||||
|
||||
@@ -1722,15 +1722,11 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
||||
|
||||
/* Dashed lines first. */
|
||||
if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE)) {
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
UNUSED_VARS_NDEBUG(pos); /* silence warning */
|
||||
BLI_assert(pos == POS_INDEX);
|
||||
UNUSED_VARS_NDEBUG(shdr_pos); /* silence warning */
|
||||
BLI_assert(shdr_pos == POS_INDEX);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
glLineWidth(1.0f);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
@@ -1739,22 +1735,17 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
float color1[4];
|
||||
UI_GetThemeColor4fv(TH_VIEW_OVERLAY, color1);
|
||||
immUniform4fv("color1", color1);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniformThemeColor(TH_VIEW_OVERLAY);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib2fv(line_origin, cent);
|
||||
immVertex2fv(POS_INDEX, cent);
|
||||
immVertex2f(POS_INDEX, (float)t->mval[0], (float)t->mval[1]);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
/* And now, solid lines. */
|
||||
@@ -7495,7 +7486,7 @@ static void drawVertSlide(TransInfo *t)
|
||||
|
||||
glLineWidth(line_size);
|
||||
|
||||
uint pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
|
||||
@@ -7504,8 +7495,8 @@ static void drawVertSlide(TransInfo *t)
|
||||
if (is_clamp) {
|
||||
sv = sld->sv;
|
||||
for (i = 0; i < sld->totsv; i++, sv++) {
|
||||
immVertex3fv(pos, sv->co_orig_3d);
|
||||
immVertex3fv(pos, sv->co_link_orig_3d[sv->co_link_curr]);
|
||||
immVertex3fv(shdr_pos, sv->co_orig_3d);
|
||||
immVertex3fv(shdr_pos, sv->co_link_orig_3d[sv->co_link_curr]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -7518,8 +7509,8 @@ static void drawVertSlide(TransInfo *t)
|
||||
add_v3_v3(a, sv->co_orig_3d);
|
||||
add_v3_v3(b, sv->co_orig_3d);
|
||||
|
||||
immVertex3fv(pos, a);
|
||||
immVertex3fv(pos, b);
|
||||
immVertex3fv(shdr_pos, a);
|
||||
immVertex3fv(shdr_pos, b);
|
||||
}
|
||||
}
|
||||
immEnd();
|
||||
@@ -7527,7 +7518,7 @@ static void drawVertSlide(TransInfo *t)
|
||||
glPointSize(ctrl_size);
|
||||
|
||||
immBegin(PRIM_POINTS, 1);
|
||||
immVertex3fv(pos, (sld->flipped && sld->use_even) ?
|
||||
immVertex3fv(shdr_pos, (sld->flipped && sld->use_even) ?
|
||||
curr_sv->co_link_orig_3d[curr_sv->co_link_curr] :
|
||||
curr_sv->co_orig_3d);
|
||||
immEnd();
|
||||
@@ -7558,32 +7549,25 @@ static void drawVertSlide(TransInfo *t)
|
||||
|
||||
glLineWidth(1.0f);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
uint line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
|
||||
|
||||
float viewport_size[4];
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib3fv(line_origin, curr_sv->co_orig_3d);
|
||||
immVertex3fv(pos, curr_sv->co_orig_3d);
|
||||
immVertex3fv(pos, co_dest_3d);
|
||||
immVertex3fv(shdr_pos, curr_sv->co_orig_3d);
|
||||
immVertex3fv(shdr_pos, co_dest_3d);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
gpuPopMatrix();
|
||||
|
||||
if (v3d && v3d->zbuf)
|
||||
|
||||
@@ -728,12 +728,7 @@ void drawConstraint(TransInfo *t)
|
||||
if (depth_test_enabled)
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -741,21 +736,18 @@ void drawConstraint(TransInfo *t)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform1f("dash_width", 2.0f);
|
||||
immUniform1f("dash_width_on", 1.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib3fv(line_origin, t->center_global);
|
||||
immVertex3fv(pos, t->center_global);
|
||||
immVertex3fv(pos, vec);
|
||||
immVertex3fv(shdr_pos, t->center_global);
|
||||
immVertex3fv(shdr_pos, vec);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
if (depth_test_enabled)
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
@@ -318,13 +318,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
|
||||
const float mval_dst[2] = {win->eventstate->x - ar->winrct.xmin,
|
||||
win->eventstate->y - ar->winrct.ymin};
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
float color1[4];
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -332,21 +326,17 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
UI_GetThemeColor4fv(TH_VIEW_OVERLAY, color1);
|
||||
immUniform4fv("color1", color1);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
immUniform1i("num_colors", 0); /* "simple" mode */
|
||||
immUniformThemeColor(TH_VIEW_OVERLAY);
|
||||
immUniform1f("dash_width", 6.0f);
|
||||
immUniform1f("dash_width_on", 3.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
immAttrib2fv(shdr_dashed_origin, mval_src);
|
||||
immVertex2fv(shdr_dashed_pos, mval_src);
|
||||
immVertex2fv(shdr_dashed_pos, mval_dst);
|
||||
immVertex2fv(shdr_pos, mval_src);
|
||||
immVertex2fv(shdr_pos, mval_dst);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,8 +71,7 @@
|
||||
|
||||
#include "uvedit_intern.h"
|
||||
|
||||
static void draw_uvs_lineloop_bmface(
|
||||
BMFace *efa, const int cd_loop_uv_offset, uint shdr_pos, const bool use_dashed, uint shdr_dashed_origin);
|
||||
static void draw_uvs_lineloop_bmface(BMFace *efa, const int cd_loop_uv_offset, const uint shdr_pos);
|
||||
|
||||
void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
|
||||
{
|
||||
@@ -86,9 +85,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
|
||||
|
||||
gpuTranslate2fv(cursor);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -96,53 +93,42 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2])
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform4f("color1", 1.0f, 0.0f, 0.0f, 1.0f);
|
||||
immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 0.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", 8.0f);
|
||||
immUniform1f("dash_width_on", 4.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 8);
|
||||
|
||||
immAttrib2f(shdr_dashed_origin, -0.05f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_dashed_pos, -0.05f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_dashed_pos, 0.0f, 0.05f * y_fac);
|
||||
immVertex2f(shdr_pos, -0.05f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_pos, 0.0f, 0.05f * y_fac);
|
||||
|
||||
immAttrib2f(shdr_dashed_origin, 0.0f, 0.05f * y_fac);
|
||||
immVertex2f(shdr_dashed_pos, 0.0f, 0.05f * y_fac);
|
||||
immVertex2f(shdr_dashed_pos, 0.05f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_pos, 0.0f, 0.05f * y_fac);
|
||||
immVertex2f(shdr_pos, 0.05f * x_fac, 0.0f);
|
||||
|
||||
immAttrib2f(shdr_dashed_origin, 0.05f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_dashed_pos, 0.05f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_dashed_pos, 0.0f, -0.05f * y_fac);
|
||||
immVertex2f(shdr_pos, 0.05f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_pos, 0.0f, -0.05f * y_fac);
|
||||
|
||||
immAttrib2f(shdr_dashed_origin, 0.0f, -0.05f * y_fac);
|
||||
immVertex2f(shdr_dashed_pos, 0.0f, -0.05f * y_fac);
|
||||
immVertex2f(shdr_dashed_pos, -0.05f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_pos, 0.0f, -0.05f * y_fac);
|
||||
immVertex2f(shdr_pos, -0.05f * x_fac, 0.0f);
|
||||
|
||||
immEnd();
|
||||
|
||||
immUniform4f("color1", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform4f("color2", 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", 2.0f);
|
||||
immUniform1f("dash_width_on", 1.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 8);
|
||||
|
||||
immAttrib2f(shdr_dashed_origin, -0.020f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_dashed_pos, -0.020f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_dashed_pos, -0.1f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_pos, -0.020f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_pos, -0.1f * x_fac, 0.0f);
|
||||
|
||||
immAttrib2f(shdr_dashed_origin, 0.1f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_dashed_pos, 0.1f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_dashed_pos, 0.020f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_pos, 0.1f * x_fac, 0.0f);
|
||||
immVertex2f(shdr_pos, 0.020f * x_fac, 0.0f);
|
||||
|
||||
immAttrib2f(shdr_dashed_origin, 0.0f, -0.020f * y_fac);
|
||||
immVertex2f(shdr_dashed_pos, 0.0f, -0.020f * y_fac);
|
||||
immVertex2f(shdr_dashed_pos, 0.0f, -0.1f * y_fac);
|
||||
immVertex2f(shdr_pos, 0.0f, -0.020f * y_fac);
|
||||
immVertex2f(shdr_pos, 0.0f, -0.1f * y_fac);
|
||||
|
||||
immAttrib2f(shdr_dashed_origin, 0.0f, 0.1f * y_fac);
|
||||
immVertex2f(shdr_dashed_pos, 0.0f, 0.1f * y_fac);
|
||||
immVertex2f(shdr_dashed_pos, 0.0f, 0.020f * y_fac);
|
||||
immVertex2f(shdr_pos, 0.0f, 0.1f * y_fac);
|
||||
immVertex2f(shdr_pos, 0.0f, 0.020f * y_fac);
|
||||
|
||||
immEnd();
|
||||
|
||||
@@ -185,7 +171,7 @@ static void draw_uvs_shadow(Object *obedit)
|
||||
immUniformThemeColor(TH_UV_SHADOW);
|
||||
|
||||
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
|
||||
draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, pos, false, 0);
|
||||
draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, pos);
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
@@ -400,37 +386,17 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe
|
||||
BLI_buffer_free(&tf_uvorig_buf);
|
||||
}
|
||||
|
||||
static void draw_uvs_lineloop_bmface(
|
||||
BMFace *efa, const int cd_loop_uv_offset, uint shdr_pos, const bool use_dashed, uint shdr_dashed_origin)
|
||||
static void draw_uvs_lineloop_bmface(BMFace *efa, const int cd_loop_uv_offset, const uint shdr_pos)
|
||||
{
|
||||
BMIter liter;
|
||||
BMLoop *l;
|
||||
MLoopUV *luv;
|
||||
|
||||
if (use_dashed) {
|
||||
immBegin(PRIM_LINES, efa->len * 2);
|
||||
immBegin(PRIM_LINE_LOOP, efa->len);
|
||||
|
||||
const float *prev_uv = NULL;
|
||||
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
|
||||
if (prev_uv == NULL) {
|
||||
luv = BM_ELEM_CD_GET_VOID_P(l->prev, cd_loop_uv_offset);
|
||||
prev_uv = luv->uv;
|
||||
}
|
||||
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
|
||||
|
||||
immAttrib2fv(shdr_dashed_origin, prev_uv);
|
||||
immVertex2fv(shdr_pos, prev_uv);
|
||||
immVertex2fv(shdr_pos, luv->uv);
|
||||
prev_uv = luv->uv;
|
||||
}
|
||||
}
|
||||
else {
|
||||
immBegin(PRIM_LINE_LOOP, efa->len);
|
||||
|
||||
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
|
||||
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
|
||||
immVertex2fv(shdr_pos, luv->uv);
|
||||
}
|
||||
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
|
||||
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
|
||||
immVertex2fv(shdr_pos, luv->uv);
|
||||
}
|
||||
|
||||
immEnd();
|
||||
@@ -770,9 +736,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe
|
||||
switch (sima->dt_uv) {
|
||||
case SI_UVDT_DASH:
|
||||
{
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -780,10 +744,9 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform4f("color1", 0.56f, 0.56f, 0.56f, 1.0f);
|
||||
immUniform4f("color2", 0.07f, 0.07f, 0.07f, 1.0f);
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.56f, 0.56f, 0.56f, 1.0f}, {0.07f, 0.07f, 0.07f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", 4.0f);
|
||||
immUniform1f("dash_width_on", 2.0f);
|
||||
|
||||
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
|
||||
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
|
||||
@@ -791,7 +754,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe
|
||||
tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset);
|
||||
|
||||
if (tf) {
|
||||
draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, shdr_dashed_pos, true, shdr_dashed_origin);
|
||||
draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, shdr_pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,7 +779,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe
|
||||
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
|
||||
continue;
|
||||
|
||||
draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, pos, false, 0);
|
||||
draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, pos);
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
@@ -834,7 +797,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe
|
||||
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
|
||||
continue;
|
||||
|
||||
draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, pos, false, 0);
|
||||
draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, pos);
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
@@ -913,7 +876,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe
|
||||
if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
|
||||
continue;
|
||||
|
||||
draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, pos, false, 0);
|
||||
draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, pos);
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
@@ -133,8 +133,10 @@ data_to_c_simple(shaders/gpu_shader_flat_color_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_flat_color_alpha_test_0_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_flat_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_legacy_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_line_dashed_geom.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_smooth_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_smooth_color_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_2D_image_vert.glsl SRC)
|
||||
@@ -150,8 +152,8 @@ data_to_c_simple(shaders/gpu_shader_3D_image_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_normal_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_flat_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_line_dashed_legacy_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_line_dashed_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_line_dashed_frag.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_smooth_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_normal_smooth_color_vert.glsl SRC)
|
||||
data_to_c_simple(shaders/gpu_shader_3D_smooth_color_frag.glsl SRC)
|
||||
|
||||
@@ -107,10 +107,12 @@ extern char datatoc_gpu_shader_2D_point_uniform_size_aa_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_2D_point_uniform_size_outline_aa_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_2D_point_uniform_size_varying_color_outline_aa_vert_glsl[];
|
||||
|
||||
extern char datatoc_gpu_shader_2D_line_dashed_legacy_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_2D_line_dashed_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_2D_line_dashed_frag_glsl[];
|
||||
extern char datatoc_gpu_shader_2D_line_dashed_geom_glsl[];
|
||||
extern char datatoc_gpu_shader_3D_line_dashed_legacy_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_3D_line_dashed_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_3D_line_dashed_frag_glsl[];
|
||||
|
||||
extern char datatoc_gpu_shader_edges_front_back_persp_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_edges_front_back_persp_geom_glsl[];
|
||||
@@ -710,9 +712,11 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
|
||||
datatoc_gpu_shader_3D_groundline_geom_glsl },
|
||||
|
||||
[GPU_SHADER_2D_LINE_DASHED_COLOR] = { datatoc_gpu_shader_2D_line_dashed_vert_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_frag_glsl },
|
||||
[GPU_SHADER_3D_LINE_DASHED_COLOR] = { datatoc_gpu_shader_3D_line_dashed_vert_glsl,
|
||||
datatoc_gpu_shader_3D_line_dashed_frag_glsl },
|
||||
datatoc_gpu_shader_2D_line_dashed_frag_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_geom_glsl },
|
||||
[GPU_SHADER_3D_LINE_DASHED_COLOR] = { datatoc_gpu_shader_3D_line_dashed_vert_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_frag_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_geom_glsl },
|
||||
|
||||
[GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR] =
|
||||
{ datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl,
|
||||
@@ -790,6 +794,22 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
|
||||
stages = &legacy_fancy_edges;
|
||||
}
|
||||
|
||||
if (shader == GPU_SHADER_2D_LINE_DASHED_COLOR && !GLEW_VERSION_3_2) {
|
||||
/* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */
|
||||
/* TODO: remove after switch to core profile (maybe) */
|
||||
static const GPUShaderStages legacy_dashed_lines = { datatoc_gpu_shader_2D_line_dashed_legacy_vert_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_frag_glsl };
|
||||
stages = &legacy_dashed_lines;
|
||||
}
|
||||
|
||||
if (shader == GPU_SHADER_3D_LINE_DASHED_COLOR && !GLEW_VERSION_3_2) {
|
||||
/* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */
|
||||
/* TODO: remove after switch to core profile (maybe) */
|
||||
static const GPUShaderStages legacy_dashed_lines = { datatoc_gpu_shader_3D_line_dashed_legacy_vert_glsl,
|
||||
datatoc_gpu_shader_2D_line_dashed_frag_glsl };
|
||||
stages = &legacy_dashed_lines;
|
||||
}
|
||||
|
||||
/* common case */
|
||||
builtin_shaders[shader] = GPU_shader_create(stages->vert, stages->frag, stages->geom, NULL, defines);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
// Draw dashed lines, perforated in screen space.
|
||||
// Based on a (3D) version by Mike Erwin.
|
||||
|
||||
#if __VERSION__ == 120
|
||||
noperspective varying float distance_along_line;
|
||||
@@ -11,15 +10,38 @@
|
||||
#endif
|
||||
|
||||
uniform float dash_width;
|
||||
uniform float dash_width_on;
|
||||
uniform vec4 color1;
|
||||
uniform vec4 color2;
|
||||
|
||||
/* Simple mode, discarding non-dash parts (so no need for blending at all). */
|
||||
uniform float dash_factor; /* if > 1.0, solid line. */
|
||||
uniform vec4 color;
|
||||
|
||||
/* More advanced mode, allowing for complex, multi-colored patterns. Enabled when num_colors > 0. */
|
||||
/* Note: max number of steps/colors in pattern is 32! */
|
||||
uniform int num_colors; /* Enabled if > 0, 1 for solid line. */
|
||||
uniform vec4 colors[32];
|
||||
|
||||
void main()
|
||||
{
|
||||
if (mod(distance_along_line, dash_width) <= dash_width_on) {
|
||||
fragColor = color1;
|
||||
} else {
|
||||
fragColor = color2;
|
||||
/* Solid line cases, simple. */
|
||||
if (num_colors == 1) {
|
||||
fragColor = colors[0];
|
||||
}
|
||||
else if (dash_factor >= 1.0f) {
|
||||
fragColor = color;
|
||||
}
|
||||
else {
|
||||
/* Actually dashed line... */
|
||||
float normalized_distance = fract(distance_along_line / dash_width);
|
||||
if (num_colors > 0) {
|
||||
fragColor = colors[int(normalized_distance * num_colors)];
|
||||
}
|
||||
else {
|
||||
if (normalized_distance <= dash_factor) {
|
||||
fragColor = color;
|
||||
}
|
||||
else {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
// Draw dashed lines, perforated in screen space.
|
||||
|
||||
/* Make to be used with dynamic batching so no Model Matrix needed */
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform vec2 viewport_size;
|
||||
|
||||
/* Uniforms from fragment shader, used here to optimize out useless computation in case of solid line. */
|
||||
uniform float dash_factor; /* if > 1.0, solid line. */
|
||||
uniform int num_colors; /* Enabled if > 0, 1 for solid line. */
|
||||
|
||||
layout(lines) in;
|
||||
|
||||
layout(line_strip, max_vertices = 2) out;
|
||||
noperspective out float distance_along_line;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 v1 = gl_in[0].gl_Position;
|
||||
vec4 v2 = gl_in[1].gl_Position;
|
||||
|
||||
gl_Position = v1;
|
||||
distance_along_line = 0.0f;
|
||||
EmitVertex();
|
||||
|
||||
gl_Position = v2;
|
||||
if ((num_colors == 1) || (dash_factor >= 1.0f)) {
|
||||
/* Solid line, optimise out distance computation! */
|
||||
distance_along_line = 0.0f;
|
||||
}
|
||||
else {
|
||||
vec2 p1 = (v1.xy / v1.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
|
||||
p1 = p1 * viewport_size; // <- 'virtual' screen coordinates.
|
||||
|
||||
vec2 p2 = (v2.xy / v2.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
|
||||
p2 = p2 * viewport_size; // <- 'virtual' screen coordinates.
|
||||
|
||||
distance_along_line = distance(p1, p2);
|
||||
}
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
/* Note: we could also use similar approach as diag_stripes_frag, but this would give us dashed 'anchored'
|
||||
* to the screen, and not to one end of the line... */
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
// Draw dashed lines, perforated in screen space.
|
||||
// Based on a (3D) version by Mike Erwin.
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform vec2 viewport_size;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
attribute vec2 pos;
|
||||
noperspective varying float distance_along_line;
|
||||
#else
|
||||
in vec2 pos;
|
||||
noperspective out float distance_along_line;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
|
||||
|
||||
/* Hack - prevent stupid GLSL compiler to optimize out unused viewport_size uniform, which gives crash! */
|
||||
distance_along_line = viewport_size.x * 0.000001f - viewport_size.x * 0.0000009f;
|
||||
}
|
||||
@@ -1,33 +1,15 @@
|
||||
|
||||
// Draw dashed lines, perforated in screen space.
|
||||
// Based on a (3D) version by Mike Erwin.
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform vec2 viewport_size;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
attribute vec2 pos;
|
||||
attribute vec2 line_origin; // = pos for one vertex of the line
|
||||
noperspective varying float distance_along_line;
|
||||
#else
|
||||
in vec2 pos;
|
||||
in vec2 line_origin;
|
||||
noperspective out float distance_along_line;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
|
||||
|
||||
vec4 point = ModelViewProjectionMatrix * vec4(line_origin, 0.0, 1.0);
|
||||
vec2 ref_point = (point.xy / point.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
|
||||
ref_point = ref_point * viewport_size; // <- 'virtual' screen coordinates.
|
||||
|
||||
vec2 curr_point = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
|
||||
curr_point = curr_point * viewport_size; // <- 'virtual' screen coordinates.
|
||||
|
||||
distance_along_line = distance(ref_point, curr_point);
|
||||
|
||||
/* Note: we could also use similar approach as diag_stripes_frag, but this would give us dashed 'anchored'
|
||||
* to the screen, and not to one end of the line... */
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
/* Same code as 2D version actually, maybe we should deduplicate that? */
|
||||
|
||||
#if __VERSION__ == 120
|
||||
noperspective varying float distance_along_line;
|
||||
#define fragColor gl_FragColor
|
||||
#else
|
||||
noperspective in float distance_along_line;
|
||||
out vec4 fragColor;
|
||||
#endif
|
||||
|
||||
uniform float dash_width;
|
||||
uniform float dash_width_on;
|
||||
uniform vec4 color1;
|
||||
uniform vec4 color2;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (mod(distance_along_line, dash_width) <= dash_width_on) {
|
||||
fragColor = color1;
|
||||
} else {
|
||||
fragColor = color2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
/* Note: nearly the same code as for 2D version... Maybe we could deduplicate? */
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform vec2 viewport_size;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
attribute vec3 pos;
|
||||
noperspective varying float distance_along_line;
|
||||
#else
|
||||
in vec3 pos;
|
||||
noperspective out float distance_along_line;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
||||
|
||||
/* Hack - prevent stupid GLSL compiler to optimize out unused viewport_size uniform, which gives crash! */
|
||||
distance_along_line = viewport_size.x * 0.000001f - viewport_size.x * 0.0000009f;
|
||||
}
|
||||
@@ -1,32 +1,15 @@
|
||||
|
||||
/* Note: nearly the same code as for 2D version... Maybe we could deduplicate? */
|
||||
// Draw dashed lines, perforated in screen space.
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform vec2 viewport_size;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
attribute vec3 pos;
|
||||
attribute vec3 line_origin; // = pos for one vertex of the line
|
||||
noperspective varying float distance_along_line;
|
||||
#else
|
||||
in vec3 pos;
|
||||
in vec3 line_origin;
|
||||
noperspective out float distance_along_line;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
||||
|
||||
vec4 point = ModelViewProjectionMatrix * vec4(line_origin, 1.0);
|
||||
vec2 ref_point = (point.xy / point.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
|
||||
ref_point = ref_point * viewport_size; // <- fragment coordinates.
|
||||
|
||||
vec2 curr_point = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5; // <- device coordinates in [0..1] range.
|
||||
curr_point = curr_point * viewport_size; // <- fragment coordinates.
|
||||
|
||||
distance_along_line = distance(ref_point, curr_point);
|
||||
|
||||
/* Note: we could also use similar approach as diag_stripes_frag, but this would give us dashed 'anchored'
|
||||
* to the screen, and not to one end of the line... */
|
||||
}
|
||||
|
||||
@@ -171,10 +171,8 @@ int wm_gesture_evaluate(wmGesture *gesture)
|
||||
static void wm_gesture_draw_line(wmGesture *gt)
|
||||
{
|
||||
rcti *rect = (rcti *)gt->customdata;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -182,21 +180,16 @@ static void wm_gesture_draw_line(wmGesture *gt)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f);
|
||||
immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", 8.0f);
|
||||
immUniform1f("dash_width_on", 4.0f);
|
||||
|
||||
float xmin = (float)rect->xmin;
|
||||
float ymin = (float)rect->ymin;
|
||||
|
||||
immBegin(PRIM_LINES, 2);
|
||||
|
||||
immAttrib2f(line_origin, xmin, ymin);
|
||||
immVertex2f(pos, xmin, ymin);
|
||||
immAttrib2f(line_origin, xmin, ymin);
|
||||
immVertex2f(pos, (float)rect->xmax, (float)rect->ymax);
|
||||
|
||||
immVertex2f(shdr_pos, xmin, ymin);
|
||||
immVertex2f(shdr_pos, (float)rect->xmax, (float)rect->ymax);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
@@ -206,23 +199,20 @@ static void wm_gesture_draw_rect(wmGesture *gt)
|
||||
{
|
||||
rcti *rect = (rcti *)gt->customdata;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.05f);
|
||||
|
||||
immRecti(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
||||
immRecti(shdr_pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
format = immVertexFormat();
|
||||
pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -230,64 +220,33 @@ static void wm_gesture_draw_rect(wmGesture *gt)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f);
|
||||
immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", 8.0f);
|
||||
immUniform1f("dash_width_on", 4.0f);
|
||||
|
||||
imm_draw_line_box_dashed(pos, line_origin,
|
||||
(float)rect->xmin, (float)rect->ymin, (float)rect->xmax, (float)rect->ymax);
|
||||
|
||||
imm_draw_line_box(shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, (float)rect->ymax);
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
// wm_gesture_draw_line(gt); // draws a diagonal line in the lined box to test wm_gesture_draw_line
|
||||
}
|
||||
|
||||
static void imm_draw_lined_dashed_circle(unsigned pos, unsigned line_origin, float x, float y, float rad, int nsegments)
|
||||
{
|
||||
float xpos, ypos;
|
||||
|
||||
xpos = x + rad;
|
||||
ypos = y;
|
||||
|
||||
immBegin(PRIM_LINES, nsegments * 2);
|
||||
|
||||
for (int i = 1; i <= nsegments; ++i) {
|
||||
float angle = 2 * M_PI * ((float)i / (float)nsegments);
|
||||
|
||||
immAttrib2f(line_origin, xpos, ypos);
|
||||
immVertex2f(pos, xpos, ypos);
|
||||
|
||||
xpos = x + rad * cosf(angle);
|
||||
ypos = y + rad * sinf(angle);
|
||||
|
||||
immVertex2f(pos, xpos, ypos);
|
||||
}
|
||||
|
||||
immEnd();
|
||||
}
|
||||
|
||||
static void wm_gesture_draw_circle(wmGesture *gt)
|
||||
{
|
||||
rcti *rect = (rcti *)gt->customdata;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.05f);
|
||||
imm_draw_circle_fill(pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
|
||||
imm_draw_circle_fill(shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
format = immVertexFormat();
|
||||
pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -295,13 +254,11 @@ static void wm_gesture_draw_circle(wmGesture *gt)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f);
|
||||
immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", 4.0f);
|
||||
immUniform1f("dash_width_on", 2.0f);
|
||||
|
||||
imm_draw_lined_dashed_circle(pos, line_origin,
|
||||
(float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
|
||||
|
||||
imm_draw_circle_wire(shdr_pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
@@ -383,26 +340,20 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt)
|
||||
static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled)
|
||||
{
|
||||
const short *lasso = (short *)gt->customdata;
|
||||
int i, numverts;
|
||||
float x, y;
|
||||
int i;
|
||||
|
||||
if (filled) {
|
||||
draw_filled_lasso(win, gt);
|
||||
}
|
||||
|
||||
numverts = gt->points;
|
||||
if (gt->type == WM_GESTURE_LASSO) {
|
||||
numverts++;
|
||||
}
|
||||
const int numverts = gt->points;
|
||||
|
||||
/* Nothing to draw, do early output. */
|
||||
if (numverts < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -410,29 +361,14 @@ static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt, bool filled)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f);
|
||||
immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", 2.0f);
|
||||
immUniform1f("dash_width_on", 1.0f);
|
||||
|
||||
immBegin(PRIM_LINE_STRIP, numverts);
|
||||
immBegin((gt->type == WM_GESTURE_LASSO) ? PRIM_LINE_LOOP : PRIM_LINE_STRIP, numverts);
|
||||
|
||||
for (i = 0; i < gt->points; i++, lasso += 2) {
|
||||
|
||||
/* get line_origin coordinates only from the first vertex of each line */
|
||||
if (!(i % 2)) {
|
||||
x = (float)lasso[0];
|
||||
y = (float)lasso[1];
|
||||
}
|
||||
|
||||
immAttrib2f(line_origin, x, y);
|
||||
immVertex2f(pos, (float)lasso[0], (float)lasso[1]);
|
||||
}
|
||||
|
||||
if (gt->type == WM_GESTURE_LASSO) {
|
||||
immAttrib2f(line_origin, x, y);
|
||||
lasso = (short *)gt->customdata;
|
||||
immVertex2f(pos, (float)lasso[0], (float)lasso[1]);
|
||||
immVertex2f(shdr_pos, (float)lasso[0], (float)lasso[1]);
|
||||
}
|
||||
|
||||
immEnd();
|
||||
@@ -448,9 +384,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
|
||||
|
||||
float x1, x2, y1, y2;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
|
||||
const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
|
||||
|
||||
@@ -458,10 +392,9 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
|
||||
glGetFloatv(GL_VIEWPORT, viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
||||
|
||||
immUniform4f("color1", 0.4f, 0.4f, 0.4f, 1.0f);
|
||||
immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform1i("num_colors", 2); /* "advanced" mode */
|
||||
immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2);
|
||||
immUniform1f("dash_width", 8.0f);
|
||||
immUniform1f("dash_width_on", 4.0f);
|
||||
|
||||
immBegin(PRIM_LINES, 4);
|
||||
|
||||
@@ -470,20 +403,16 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
|
||||
x2 = (float)(rect->xmin + winsize_x);
|
||||
y2 = y1;
|
||||
|
||||
immAttrib2f(line_origin, x1, y1);
|
||||
immVertex2f(pos, x1, y1);
|
||||
immAttrib2f(line_origin, x1, y1);
|
||||
immVertex2f(pos, x2, y2);
|
||||
immVertex2f(shdr_pos, x1, y1);
|
||||
immVertex2f(shdr_pos, x2, y2);
|
||||
|
||||
x1 = (float)rect->xmin;
|
||||
y1 = (float)(rect->ymin - winsize_y);
|
||||
x2 = x1;
|
||||
y2 = (float)(rect->ymin + winsize_y);
|
||||
|
||||
immAttrib2f(line_origin, x1, y1);
|
||||
immVertex2f(pos, x1, y1);
|
||||
immAttrib2f(line_origin, x1, y1);
|
||||
immVertex2f(pos, x2, y2);
|
||||
immVertex2f(shdr_pos, x1, y1);
|
||||
immVertex2f(shdr_pos, x2, y2);
|
||||
|
||||
immEnd();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user