OpenGL: transition away from GL_QUADS
Single quads are drawn as a TRIANGLE_FAN, with 4 verts in the same order. Multiple quads now use PRIM_QUADS_XXX and will need further work. Only 8 places still use this. Part of T49043
This commit is contained in:
parent
d6ae3789a1
commit
7a75581d92
|
@ -206,7 +206,7 @@ static void blf_font_draw_ex(
|
|||
|
||||
blf_font_ensure_ascii_table(font);
|
||||
|
||||
immBeginAtMost(GL_QUADS, verts_needed(font, str, len));
|
||||
immBeginAtMost(PRIM_QUADS_XXX, verts_needed(font, str, len));
|
||||
/* at most because some glyphs might be clipped & not drawn */
|
||||
|
||||
while ((i < len) && str[i]) {
|
||||
|
@ -253,7 +253,7 @@ static void blf_font_draw_ascii_ex(
|
|||
|
||||
blf_font_ensure_ascii_table(font);
|
||||
|
||||
immBeginAtMost(GL_QUADS, verts_needed(font, str, len));
|
||||
immBeginAtMost(PRIM_QUADS_XXX, verts_needed(font, str, len));
|
||||
|
||||
while ((c = *(str++)) && len--) {
|
||||
BLI_assert(c < 128);
|
||||
|
@ -293,7 +293,7 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
|
|||
|
||||
blf_font_ensure_ascii_table(font);
|
||||
|
||||
immBeginAtMost(GL_QUADS, verts_needed(font, str, len));
|
||||
immBeginAtMost(PRIM_QUADS_XXX, verts_needed(font, str, len));
|
||||
|
||||
while ((i < len) && str[i]) {
|
||||
BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
|
||||
|
|
|
@ -568,7 +568,7 @@ void DRW_draw_background(void)
|
|||
UI_GetThemeColor3ubv(TH_LOW_GRAD, col_lo);
|
||||
UI_GetThemeColor3ubv(TH_HIGH_GRAD, col_hi);
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
immAttrib3ubv(color, col_lo);
|
||||
immVertex2f(pos, -1.0f, -1.0f);
|
||||
immVertex2f(pos, 1.0f, -1.0f);
|
||||
|
|
|
@ -740,7 +740,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, int totpoints, short thi
|
|||
unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
||||
immBegin(GL_QUADS, (totpoints - 2) * 4 + 12);
|
||||
immBegin(PRIM_QUADS_XXX, (totpoints - 2) * 4 + 12);
|
||||
|
||||
for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) {
|
||||
float s0[2], s1[2]; /* segment 'center' points */
|
||||
|
|
|
@ -1195,7 +1195,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f
|
|||
|
||||
static void ui_draw_colorband_handle_box(unsigned int pos, float x1, float y1, float x2, float y2, bool fill)
|
||||
{
|
||||
immBegin(fill ? GL_QUADS : GL_LINE_LOOP, 4);
|
||||
immBegin(fill ? PRIM_TRIANGLE_FAN : PRIM_LINE_LOOP, 4);
|
||||
immVertex2f(pos, x1, y1);
|
||||
immVertex2f(pos, x1, y2);
|
||||
immVertex2f(pos, x2, y2);
|
||||
|
@ -1916,6 +1916,9 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
|
|||
|
||||
/* ****************************************************** */
|
||||
|
||||
/* TODO: high quality UI drop shadows using GLSL shader and single draw call
|
||||
* would replace / modify the following 3 functions - merwin
|
||||
*/
|
||||
|
||||
static void ui_shadowbox(unsigned pos, unsigned color, float minx, float miny, float maxx, float maxy, float shadsize, unsigned char alpha)
|
||||
{
|
||||
|
@ -1954,7 +1957,7 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
|
|||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||
|
||||
immBegin(GL_QUADS, 36);
|
||||
immBegin(PRIM_QUADS_XXX, 36);
|
||||
|
||||
/* accumulated outline boxes to make shade not linear, is more pleasant */
|
||||
ui_shadowbox(pos, color, minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8);
|
||||
|
|
|
@ -684,7 +684,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
|
|||
/* draw textured quad */
|
||||
immUniform1i("image", GL_TEXTURE0);
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
immAttrib2f(texCoord, 0.0f, 0.0f);
|
||||
immVertex2f(pos, quad.xmin, quad.ymin);
|
||||
immAttrib2f(texCoord, 1.0f, 0.0f);
|
||||
|
@ -773,7 +773,7 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush,
|
|||
/* draw textured quad */
|
||||
immUniform1i("image", GL_TEXTURE0);
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
immAttrib2f(texCoord, 0.0f, 0.0f);
|
||||
immVertex2f(pos, quad.xmin, quad.ymin);
|
||||
immAttrib2f(texCoord, 1.0f, 0.0f);
|
||||
|
|
|
@ -1108,7 +1108,7 @@ static void draw_plane_marker_image(Scene *scene,
|
|||
immUniform4f("color", 1.0f, 1.0f, 1.0f, plane_track->image_opacity);
|
||||
immUniform1i("image", GL_TEXTURE0);
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
|
||||
immAttrib2f(texCoord, 0.0f, 0.0f);
|
||||
immVertex2f(pos, 0.0f, 0.0f);
|
||||
|
|
|
@ -1799,7 +1799,7 @@ 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) {
|
||||
immBegin(GL_QUADS, 4 * tot);
|
||||
immBegin(PRIM_QUADS_XXX, 4 * tot);
|
||||
while (tot--) {
|
||||
y1 -= 2 * UI_UNIT_Y;
|
||||
y2 = y1 + UI_UNIT_Y;
|
||||
|
|
|
@ -1313,7 +1313,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
|
|||
immUniform4f("color", 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
immUniform1i("image", GL_TEXTURE0);
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
|
||||
if (draw_overlay) {
|
||||
if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
|
||||
|
|
|
@ -215,7 +215,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
|
|||
immUniformColor4fv(col);
|
||||
|
||||
if (len > 0) {
|
||||
immBeginAtMost(GL_QUADS, len);
|
||||
immBeginAtMost(PRIM_QUADS_XXX, len);
|
||||
|
||||
/* draw a quad for each cached frame */
|
||||
for (int i = sta; i <= end; i++) {
|
||||
|
|
|
@ -1876,7 +1876,7 @@ static void draw_viewport_reconstruction(
|
|||
/* camera frame */
|
||||
static void drawcamera_frame(float vec[4][3], bool filled, unsigned pos)
|
||||
{
|
||||
immBegin(filled ? GL_QUADS : GL_LINE_LOOP, 4);
|
||||
immBegin(filled ? PRIM_TRIANGLE_FAN : PRIM_LINE_LOOP, 4);
|
||||
immVertex3fv(pos, vec[0]);
|
||||
immVertex3fv(pos, vec[1]);
|
||||
immVertex3fv(pos, vec[2]);
|
||||
|
@ -1905,7 +1905,7 @@ static void drawcamera_volume(float near_plane[4][3], float far_plane[4][3], boo
|
|||
drawcamera_frame(far_plane, filled, pos);
|
||||
|
||||
if (filled) {
|
||||
immBegin(GL_QUADS, 16); /* TODO(merwin): use GL_TRIANGLE_STRIP here */
|
||||
immBegin(PRIM_QUADS_XXX, 16); /* TODO(merwin): use PRIM_TRIANGLE_STRIP here */
|
||||
immVertex3fv(pos, near_plane[0]);
|
||||
immVertex3fv(pos, far_plane[0]);
|
||||
immVertex3fv(pos, far_plane[1]);
|
||||
|
@ -5582,7 +5582,7 @@ static bool drawDispList(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D
|
|||
/* *********** drawing for particles ************* */
|
||||
/* stride : offset size in bytes
|
||||
* col[4] : the color to use when *color is NULL, can be also NULL */
|
||||
static void draw_vertex_array(int dt, const float *vert, const float *nor, const float *color, int stride, int vert_ct, float col[4])
|
||||
static void draw_vertex_array(PrimitiveType prim_type, const float *vert, const float *nor, const float *color, int stride, int vert_ct, float col[4])
|
||||
{
|
||||
VertexFormat format = {0};
|
||||
unsigned int pos_id, nor_id, col_id;
|
||||
|
@ -5604,7 +5604,7 @@ static void draw_vertex_array(int dt, const float *vert, const float *nor, const
|
|||
if (color) VertexBuffer_fill_attrib_stride(vbo, col_id, stride, color);
|
||||
}
|
||||
|
||||
Batch *batch = Batch_create(dt, vbo, NULL);
|
||||
Batch *batch = Batch_create(prim_type, vbo, NULL);
|
||||
if (nor && color) {
|
||||
Batch_set_builtin_program(batch, GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR);
|
||||
Batch_Uniform3f(batch, "light", 0.0f, 0.0f, 1.0f);
|
||||
|
@ -5624,6 +5624,7 @@ static void draw_vertex_array(int dt, const float *vert, const float *nor, const
|
|||
Batch_draw(batch);
|
||||
Batch_discard_all(batch);
|
||||
}
|
||||
|
||||
static void draw_particle_arrays_new(int draw_as, int ob_dt, int select,
|
||||
const float *vert, const float *nor, const float *color,
|
||||
int totpoint, float col[4])
|
||||
|
@ -5643,7 +5644,7 @@ static void draw_particle_arrays_new(int draw_as, int ob_dt, int select,
|
|||
else
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
draw_vertex_array(GL_QUADS, vert, nor, color, 0, 4 * totpoint, col);
|
||||
draw_vertex_array(PRIM_QUADS_XXX, vert, nor, color, 0, 4 * totpoint, col);
|
||||
break;
|
||||
default:
|
||||
draw_vertex_array(GL_POINTS, vert, nor, color, 0, totpoint, col);
|
||||
|
@ -8000,11 +8001,11 @@ static void imm_draw_box(const float vec[8][3], bool solid, unsigned pos)
|
|||
|
||||
if (solid) {
|
||||
indices = quad_indices;
|
||||
prim_type = GL_QUADS;
|
||||
prim_type = PRIM_QUADS_XXX;
|
||||
}
|
||||
else {
|
||||
indices = line_indices;
|
||||
prim_type = GL_LINES;
|
||||
prim_type = PRIM_LINES;
|
||||
}
|
||||
|
||||
immBegin(prim_type, 24);
|
||||
|
|
|
@ -461,7 +461,7 @@ void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple, float alpha)
|
|||
immUniform1f("alpha", alpha);
|
||||
immUniform1i("image", activeTex);
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
|
||||
immAttrib2f(texcoord, halfx, halfy);
|
||||
immVertex2f(pos, 0.0f, 0.0f);
|
||||
|
|
|
@ -221,22 +221,14 @@ 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_F32, 2, KEEP_FLOAT);
|
||||
unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniform4f("color", 1.0f, 1.0f, 1.0f, 0.05f);
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
|
||||
immVertex2f(pos, (float)rect->xmax, (float)rect->ymin);
|
||||
immVertex2f(pos, (float)rect->xmax, (float)rect->ymax);
|
||||
immVertex2f(pos, (float)rect->xmin, (float)rect->ymax);
|
||||
immVertex2f(pos, (float)rect->xmin, (float)rect->ymin);
|
||||
|
||||
immEnd();
|
||||
immRecti(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
|
|
|
@ -3100,7 +3100,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
|
|||
}
|
||||
|
||||
/* draw textured quad */
|
||||
immBegin(GL_QUADS, 4);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
|
||||
immAttrib2f(texCoord, 0, 0);
|
||||
immVertex2f(pos, -radius, -radius);
|
||||
|
|
|
@ -132,7 +132,7 @@ static void wm_method_draw_stereo3d_interlace(wmWindow *win)
|
|||
|
||||
immUniform1i("interlace_id", interlace_gpu_id_from_type(interlace_type));
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
|
||||
immAttrib2f(texcoord, halfx, halfy);
|
||||
immVertex2f(pos, 0.0f, 0.0f);
|
||||
|
@ -242,7 +242,7 @@ static void wm_method_draw_stereo3d_sidebyside(wmWindow *win)
|
|||
immUniform1f("alpha", 1.0f);
|
||||
immUniform1i("image", 0); /* default GL_TEXTURE0 unit */
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
|
||||
immAttrib2f(texcoord, halfx, halfy);
|
||||
immVertex2f(pos, soffx, 0.0f);
|
||||
|
@ -312,7 +312,7 @@ static void wm_method_draw_stereo3d_topbottom(wmWindow *win)
|
|||
immUniform1f("alpha", 1.0f);
|
||||
immUniform1i("image", 0); /* default GL_TEXTURE0 unit */
|
||||
|
||||
immBegin(GL_QUADS, 4);
|
||||
immBegin(PRIM_TRIANGLE_FAN, 4);
|
||||
|
||||
immAttrib2f(texcoord, halfx, halfy);
|
||||
immVertex2f(pos, 0.0f, soffy);
|
||||
|
|
Loading…
Reference in New Issue