DRWCache: Add a new regular Quad buffer.
This commit is contained in:
parent
18965905d0
commit
8249e1ce5e
|
@ -44,6 +44,7 @@
|
|||
static struct DRWShapeCache {
|
||||
Gwn_Batch *drw_single_vertice;
|
||||
Gwn_Batch *drw_fullscreen_quad;
|
||||
Gwn_Batch *drw_quad;
|
||||
Gwn_Batch *drw_screenspace_circle;
|
||||
Gwn_Batch *drw_plain_axes;
|
||||
Gwn_Batch *drw_single_arrow;
|
||||
|
@ -229,6 +230,7 @@ static Gwn_VertBuf *sphere_wire_vbo(const float rad)
|
|||
}
|
||||
|
||||
/* Quads */
|
||||
/* Use this one for rendering fullscreen passes. For 3D objects use DRW_cache_quad_get(). */
|
||||
Gwn_Batch *DRW_cache_fullscreen_quad_get(void)
|
||||
{
|
||||
if (!SHC.drw_fullscreen_quad) {
|
||||
|
@ -258,6 +260,35 @@ Gwn_Batch *DRW_cache_fullscreen_quad_get(void)
|
|||
return SHC.drw_fullscreen_quad;
|
||||
}
|
||||
|
||||
/* Just a regular quad with 4 vertices. */
|
||||
Gwn_Batch *DRW_cache_quad_get(void)
|
||||
{
|
||||
if (!SHC.drw_quad) {
|
||||
/* Use a triangle instead of a real quad */
|
||||
float pos[4][2] = {{-1.0f, -1.0f}, { 1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, 1.0f}};
|
||||
float uvs[4][2] = {{ 0.0f, 0.0f}, { 1.0f, 0.0f}, {1.0f, 1.0f}, { 0.0f, 1.0f}};
|
||||
|
||||
/* Position Only 2D format */
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos, uvs; } attr_id;
|
||||
if (format.attrib_ct == 0) {
|
||||
attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format);
|
||||
GWN_vertbuf_data_alloc(vbo, 4);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]);
|
||||
}
|
||||
|
||||
SHC.drw_quad = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO);
|
||||
}
|
||||
return SHC.drw_quad;
|
||||
}
|
||||
|
||||
/* Sphere */
|
||||
Gwn_Batch *DRW_cache_sphere_get(void)
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@ void DRW_shape_cache_free(void);
|
|||
|
||||
/* Common Shapes */
|
||||
struct Gwn_Batch *DRW_cache_fullscreen_quad_get(void);
|
||||
struct Gwn_Batch *DRW_cache_quad_get(void);
|
||||
struct Gwn_Batch *DRW_cache_sphere_get(void);
|
||||
struct Gwn_Batch *DRW_cache_single_vert_get(void);
|
||||
struct Gwn_Batch *DRW_cache_single_line_get(void);
|
||||
|
|
Loading…
Reference in New Issue