big rendering overhaul (cleaning and api abstraction)

This commit is contained in:
veclavtalica
2025-01-14 23:20:54 +03:00
parent b7cb37c06a
commit 5059802d09
25 changed files with 290 additions and 424 deletions

View File

@ -133,7 +133,7 @@ void finally_draw_billboard_batch(struct MeshBatch const *batch,
command.vertices = (AttributeArrayPointer) {
.arity = 3,
.type = GL_FLOAT,
.type = TWN_FLOAT,
.stride = offsetof(ElementIndexedBillboard, v1),
.offset = offsetof(ElementIndexedBillboard, v0),
.buffer = buffer
@ -141,7 +141,7 @@ void finally_draw_billboard_batch(struct MeshBatch const *batch,
command.texcoords = (AttributeArrayPointer) {
.arity = 2,
.type = GL_FLOAT,
.type = TWN_FLOAT,
.stride = offsetof(ElementIndexedBillboard, v1),
.offset = offsetof(ElementIndexedBillboard, uv0),
.buffer = buffer
@ -149,7 +149,7 @@ void finally_draw_billboard_batch(struct MeshBatch const *batch,
command.colors = (AttributeArrayPointer) {
.arity = 4,
.type = GL_UNSIGNED_BYTE,
.type = TWN_UNSIGNED_BYTE,
.stride = offsetof(ElementIndexedBillboard, v1),
.offset = offsetof(ElementIndexedBillboard, c0),
.buffer = buffer
@ -159,14 +159,19 @@ void finally_draw_billboard_batch(struct MeshBatch const *batch,
command.texture_key = texture_key;
command.element_buffer = get_quad_element_buffer();
command.element_count = 6 * (GLsizei)primitives_len;
command.range_end = 6 * (GLsizei)primitives_len;
command.element_count = 6 * (uint32_t)primitives_len;
command.range_end = 6 * (uint32_t)primitives_len;
/* TODO: support alpha blended case, with distance sort */
TextureMode mode = textures_get_mode(&ctx.texture_cache, texture_key);
if (mode == TEXTURE_MODE_GHOSTLY)
mode = TEXTURE_MODE_SEETHROUGH;
use_texture_mode(mode);
command.texture_mode = mode;
command.pipeline = PIPELINE_SPACE;
command.depth_range_high = depth_range_high;
command.depth_range_low = depth_range_low;
DeferredCommand final_command = {
.type = DEFERRED_COMMAND_TYPE_DRAW,