First batch of PRIM_QUAD_XXX replacement by PRIM_TRIANGLES.

This commit is contained in:
Bastien Montagne 2017-04-10 15:16:59 +02:00
parent 2d158a425d
commit 9fd3435a93
Notes: blender-bot 2023-02-14 12:01:57 +01:00
Referenced by issue #51164, Deprecated OpenGL Migration, the home stretch!
3 changed files with 60 additions and 27 deletions

View File

@ -1922,29 +1922,62 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
static void ui_shadowbox(unsigned pos, unsigned color, float minx, float miny, float maxx, float maxy, float shadsize, unsigned char alpha)
{
/* v1-_
* | -_v2
* | |
* | |
* | |
* v7_______v3____v4
* \ | /
* \ | _v5
* v8______v6_-
*/
const float v1[2] = {maxx, maxy - 0.3f * shadsize};
const float v2[2] = {maxx + shadsize, maxy - 0.75f * shadsize};
const float v3[2] = {maxx, miny};
const float v4[2] = {maxx + shadsize, miny};
const float v5[2] = {maxx + 0.7f * shadsize, miny - 0.7f * shadsize};
const float v6[2] = {maxx, miny - shadsize};
const float v7[2] = {minx + 0.3f * shadsize, miny};
const float v8[2] = {minx + 0.5f * shadsize, miny - shadsize};
/* right quad */
immAttrib4ub(color, 0, 0, 0, alpha);
immVertex2f(pos, maxx, miny);
immVertex2f(pos, maxx, maxy - 0.3f * shadsize);
immVertex2fv(pos, v3);
immVertex2fv(pos, v1);
immAttrib4ub(color, 0, 0, 0, 0);
immVertex2f(pos, maxx + shadsize, maxy - 0.75f * shadsize);
immVertex2f(pos, maxx + shadsize, miny);
immVertex2fv(pos, v2);
immVertex2fv(pos, v2);
immVertex2fv(pos, v4);
immAttrib4ub(color, 0, 0, 0, alpha);
immVertex2fv(pos, v3);
/* corner shape */
immAttrib4ub(color, 0, 0, 0, alpha);
immVertex2f(pos, maxx, miny);
/* immAttrib4ub(color, 0, 0, 0, alpha); */ /* Not needed, done above in previous tri */
immVertex2fv(pos, v3);
immAttrib4ub(color, 0, 0, 0, 0);
immVertex2f(pos, maxx + shadsize, miny);
immVertex2f(pos, maxx + 0.7f * shadsize, miny - 0.7f * shadsize);
immVertex2f(pos, maxx, miny - shadsize);
immVertex2fv(pos, v4);
immVertex2fv(pos, v5);
immVertex2fv(pos, v5);
immVertex2fv(pos, v6);
immAttrib4ub(color, 0, 0, 0, alpha);
immVertex2fv(pos, v3);
/* bottom quad */
immAttrib4ub(color, 0, 0, 0, alpha);
immVertex2f(pos, minx + 0.3f * shadsize, miny);
immVertex2f(pos, maxx, miny);
/* immAttrib4ub(color, 0, 0, 0, alpha); */ /* Not needed, done above in previous tri */
immVertex2fv(pos, v3);
immAttrib4ub(color, 0, 0, 0, 0);
immVertex2f(pos, maxx, miny - shadsize);
immVertex2f(pos, minx + 0.5f * shadsize, miny - shadsize);
immVertex2fv(pos, v6);
immVertex2fv(pos, v8);
immVertex2fv(pos, v8);
immAttrib4ub(color, 0, 0, 0, alpha);
immVertex2fv(pos, v7);
immVertex2fv(pos, v3);
}
void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, float maxy)
@ -1957,8 +1990,7 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
#ifdef WITH_GL_PROFILE_COMPAT
immBegin(PRIM_QUADS_XXX, 36);
immBegin(PRIM_TRIANGLES, 54);
/* accumulated outline boxes to make shade not linear, is more pleasant */
ui_shadowbox(pos, color, minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8);
@ -1966,7 +1998,6 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
ui_shadowbox(pos, color, minx, miny, maxx, maxy, 5.0, (80 * alpha) >> 8);
immEnd();
#endif
immUnbindProgram();

View File

@ -1799,18 +1799,19 @@ static void outliner_back(ARegion *ar)
int tot = (int)floor(ystart - ar->v2d.cur.ymin + 2 * UI_UNIT_Y) / (2 * UI_UNIT_Y);
if (tot > 0) {
#ifdef WITH_GL_PROFILE_COMPAT
immBegin(PRIM_QUADS_XXX, 4 * tot);
immBegin(PRIM_TRIANGLES, 6 * tot);
while (tot--) {
y1 -= 2 * UI_UNIT_Y;
y2 = y1 + UI_UNIT_Y;
immVertex2f(pos, x1, y1);
immVertex2f(pos, x2, y1);
immVertex2f(pos, x2, y2);
immVertex2f(pos, x1, y1);
immVertex2f(pos, x2, y2);
immVertex2f(pos, x1, y2);
}
immEnd();
#endif
}
immUnbindProgram();
}

View File

@ -196,8 +196,8 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
break;
}
int sta = pid->cache->startframe, end = pid->cache->endframe;
int len = (end - sta + 1) * 4;
const int sta = pid->cache->startframe, end = pid->cache->endframe;
const int len = (end - sta + 1) * 6;
glEnable(GL_BLEND);
@ -214,9 +214,8 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
immUniformColor4fv(col);
#ifdef WITH_GL_PROFILE_COMPAT
if (len > 0) {
immBeginAtMost(PRIM_QUADS_XXX, len);
immBeginAtMost(PRIM_TRIANGLES, len);
/* draw a quad for each cached frame */
for (int i = sta; i <= end; i++) {
@ -224,13 +223,15 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
immVertex2f(pos, (float)i - 0.5f, 0.0f);
immVertex2f(pos, (float)i - 0.5f, 1.0f);
immVertex2f(pos, (float)i + 0.5f, 1.0f);
immVertex2f(pos, (float)i - 0.5f, 0.0f);
immVertex2f(pos, (float)i + 0.5f, 1.0f);
immVertex2f(pos, (float)i + 0.5f, 0.0f);
}
}
immEnd();
}
#endif
glDisable(GL_BLEND);