Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/intern/gpu_batch_presets.c')
-rw-r--r--source/blender/gpu/intern/gpu_batch_presets.c45
1 files changed, 19 insertions, 26 deletions
diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c
index 3d9b4326c7e..6a1645a71d8 100644
--- a/source/blender/gpu/intern/gpu_batch_presets.c
+++ b/source/blender/gpu/intern/gpu_batch_presets.c
@@ -35,7 +35,6 @@
#include "GPU_batch.h"
#include "GPU_batch_presets.h" /* own include */
#include "GPU_batch_utils.h"
-#include "gpu_shader_private.h"
/* -------------------------------------------------------------------- */
/** \name Local Structures
@@ -63,6 +62,7 @@ static struct {
static struct {
struct {
GPUBatch *panel_drag_widget;
+ GPUBatch *quad;
} batch;
float panel_drag_widget_pixelsize;
@@ -331,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;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -380,18 +398,6 @@ bool gpu_batch_presets_unregister(GPUBatch *preset_batch)
return false;
}
-void gpu_batch_presets_reset(void)
-{
- BLI_mutex_lock(&g_presets_3d.mutex);
- /* Reset vao caches for these every time we switch opengl context.
- * This way they will draw correctly for each window. */
- LISTBASE_FOREACH (LinkData *, link, &presets_list) {
- GPUBatch *preset = link->data;
- GPU_batch_vao_cache_clear(preset);
- }
- BLI_mutex_unlock(&g_presets_3d.mutex);
-}
-
void gpu_batch_presets_exit(void)
{
LinkData *link;
@@ -404,17 +410,4 @@ void gpu_batch_presets_exit(void)
BLI_mutex_end(&g_presets_3d.mutex);
}
-/**
- * This function only needs to be accessed externally because
- * we are drawing UI batches with the DRW old context.
- *
- * And now we use it for drawing the entire area.
- *
- * XXX (Clément) - to cleanup in the upcoming 2.91 refactor.
- **/
-void GPU_batch_presets_reset()
-{
- gpu_batch_presets_reset();
-}
-
/** \} */