diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-31 19:39:17 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-01 01:30:36 +0300 |
commit | 052538edc1fba109d3427471047611888ed13bea (patch) | |
tree | 8d3bfbd0b1045d7e62647b8cff9f4e4aa28ef56d /source/blender/gpu/intern | |
parent | 3e7feaff44b70972751c9a62b83bde50a9c09592 (diff) |
Cleanup: Use GPUBatch for icon and area drawing
This is in order to remove GPU_draw_primitive to streamline the drawing
abstraction.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_batch_presets.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c index 8adb1ba1ed3..6a1645a71d8 100644 --- a/source/blender/gpu/intern/gpu_batch_presets.c +++ b/source/blender/gpu/intern/gpu_batch_presets.c @@ -62,6 +62,7 @@ static struct { static struct { struct { GPUBatch *panel_drag_widget; + GPUBatch *quad; } batch; float panel_drag_widget_pixelsize; @@ -330,6 +331,24 @@ GPUBatch *GPU_batch_preset_panel_drag_widget(const float pixelsize, return g_presets_2d.batch.panel_drag_widget; } +/* To be used with procedural placement inside shader. */ +GPUBatch *GPU_batch_preset_quad(void) +{ + if (!g_presets_2d.batch.quad) { + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(preset_2d_format()); + GPU_vertbuf_data_alloc(vbo, 4); + + float pos_data[4][2] = {{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}}; + GPU_vertbuf_attr_fill(vbo, g_presets_2d.attr_id.pos, pos_data); + /* Don't fill the color. */ + + g_presets_2d.batch.quad = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO); + + gpu_batch_presets_register(g_presets_2d.batch.quad); + } + return g_presets_2d.batch.quad; +} + /** \} */ /* -------------------------------------------------------------------- */ |