Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache.c
| Show All 39 Lines | |||||
| #include "draw_cache.h" | #include "draw_cache.h" | ||||
| #include "draw_cache_impl.h" | #include "draw_cache_impl.h" | ||||
| /* Batch's only (free'd as an array) */ | /* Batch's only (free'd as an array) */ | ||||
| static struct DRWShapeCache { | static struct DRWShapeCache { | ||||
| Gwn_Batch *drw_single_vertice; | Gwn_Batch *drw_single_vertice; | ||||
| Gwn_Batch *drw_fullscreen_quad; | Gwn_Batch *drw_fullscreen_quad; | ||||
| Gwn_Batch *drw_quad; | Gwn_Batch *drw_quad; | ||||
| Gwn_Batch *drw_sphere; | |||||
| Gwn_Batch *drw_screenspace_circle; | Gwn_Batch *drw_screenspace_circle; | ||||
| Gwn_Batch *drw_plain_axes; | Gwn_Batch *drw_plain_axes; | ||||
| Gwn_Batch *drw_single_arrow; | Gwn_Batch *drw_single_arrow; | ||||
| Gwn_Batch *drw_cube; | Gwn_Batch *drw_cube; | ||||
| Gwn_Batch *drw_circle; | Gwn_Batch *drw_circle; | ||||
| Gwn_Batch *drw_square; | Gwn_Batch *drw_square; | ||||
| Gwn_Batch *drw_line; | Gwn_Batch *drw_line; | ||||
| Gwn_Batch *drw_line_endpoints; | Gwn_Batch *drw_line_endpoints; | ||||
| ▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | Gwn_Batch *DRW_cache_fullscreen_quad_get(void) | ||||
| } | } | ||||
| return SHC.drw_fullscreen_quad; | return SHC.drw_fullscreen_quad; | ||||
| } | } | ||||
| /* Just a regular quad with 4 vertices. */ | /* Just a regular quad with 4 vertices. */ | ||||
| Gwn_Batch *DRW_cache_quad_get(void) | Gwn_Batch *DRW_cache_quad_get(void) | ||||
| { | { | ||||
| if (!SHC.drw_quad) { | 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 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}}; | float uvs[4][2] = {{ 0.0f, 0.0f}, { 1.0f, 0.0f}, {1.0f, 1.0f}, { 0.0f, 1.0f}}; | ||||
| /* Position Only 2D format */ | /* Position Only 2D format */ | ||||
| static Gwn_VertFormat format = { 0 }; | static Gwn_VertFormat format = { 0 }; | ||||
| static struct { uint pos, uvs; } attr_id; | static struct { uint pos, uvs; } attr_id; | ||||
| if (format.attrib_ct == 0) { | if (format.attrib_ct == 0) { | ||||
| attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); | attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); | ||||
| Show All 11 Lines | if (!SHC.drw_quad) { | ||||
| SHC.drw_quad = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); | SHC.drw_quad = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); | ||||
| } | } | ||||
| return SHC.drw_quad; | return SHC.drw_quad; | ||||
| } | } | ||||
| /* Sphere */ | /* Sphere */ | ||||
| Gwn_Batch *DRW_cache_sphere_get(void) | Gwn_Batch *DRW_cache_sphere_get(void) | ||||
| { | { | ||||
| return GPU_batch_preset_sphere(2); | if (!SHC.drw_sphere) { | ||||
| SHC.drw_sphere = gpu_batch_sphere(32, 24); | |||||
| } | |||||
| return SHC.drw_sphere; | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Common | /** \name Common | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 2,403 Lines • Show Last 20 Lines | |||||