Changeset View
Changeset View
Standalone View
Standalone View
intern/gawain/src/gwn_immediate.c
| Show All 22 Lines | |||||
| extern bool gpuMatricesDirty(void); | extern bool gpuMatricesDirty(void); | ||||
| typedef struct { | typedef struct { | ||||
| // TODO: organize this struct by frequency of change (run-time) | // TODO: organize this struct by frequency of change (run-time) | ||||
| #if IMM_BATCH_COMBO | #if IMM_BATCH_COMBO | ||||
| Gwn_Batch* batch; | Gwn_Batch* batch; | ||||
| #endif | #endif | ||||
| Gwn_Context* context; | |||||
| // current draw call | // current draw call | ||||
| GLubyte* buffer_data; | GLubyte* buffer_data; | ||||
| unsigned buffer_offset; | unsigned buffer_offset; | ||||
| unsigned buffer_bytes_mapped; | unsigned buffer_bytes_mapped; | ||||
| unsigned vertex_ct; | unsigned vertex_ct; | ||||
| bool strict_vertex_ct; | bool strict_vertex_ct; | ||||
| Gwn_PrimType prim_type; | Gwn_PrimType prim_type; | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
| void immActivate(void) | void immActivate(void) | ||||
| { | { | ||||
| #if TRUST_NO_ONE | #if TRUST_NO_ONE | ||||
| assert(initialized); | assert(initialized); | ||||
| assert(imm.prim_type == GWN_PRIM_NONE); // make sure we're not between a Begin/End pair | assert(imm.prim_type == GWN_PRIM_NONE); // make sure we're not between a Begin/End pair | ||||
| assert(imm.vao_id == 0); | assert(imm.vao_id == 0); | ||||
| #endif | #endif | ||||
| imm.vao_id = GWN_vao_alloc(); | imm.vao_id = GWN_vao_default(); | ||||
| imm.context = GWN_context_active_get(); | |||||
| } | } | ||||
| void immDeactivate(void) | void immDeactivate(void) | ||||
| { | { | ||||
| #if TRUST_NO_ONE | #if TRUST_NO_ONE | ||||
| assert(initialized); | assert(initialized); | ||||
| assert(imm.prim_type == GWN_PRIM_NONE); // make sure we're not between a Begin/End pair | assert(imm.prim_type == GWN_PRIM_NONE); // make sure we're not between a Begin/End pair | ||||
| assert(imm.vao_id != 0); | assert(imm.vao_id != 0); | ||||
| #endif | #endif | ||||
| GWN_vao_free(imm.vao_id, imm.context); | |||||
| imm.vao_id = 0; | imm.vao_id = 0; | ||||
| imm.prev_enabled_attrib_bits = 0; | imm.prev_enabled_attrib_bits = 0; | ||||
| } | } | ||||
| void immDestroy(void) | void immDestroy(void) | ||||
| { | { | ||||
| immDeactivate(); | immDeactivate(); | ||||
| GWN_buf_id_free(imm.vbo_id); | GWN_buf_id_free(imm.vbo_id); | ||||
| ▲ Show 20 Lines • Show All 810 Lines • Show Last 20 Lines | |||||