Compare commits

...
Author SHA1 Message Date
codegirl007 c1f3d0e61b revert example testing 2026-08-01 23:27:08 -07:00
codegirl007 a85380fb71 sprite batching 2026-08-01 23:25:17 -07:00
codegirl007 21d2a2c0e4 trim atlas of excess transparent pixels from pngs 2026-08-01 12:42:21 -07:00
+24 -4
View File
@@ -270,9 +270,13 @@ end_frame :: proc(app: ^App) {
app.render_pass = sdl.BeginGPURenderPass(cmd, &color_info, 1, nil)
sdl.BindGPUGraphicsPipeline(app.render_pass, app.pipeline)
for q, i in app.draw_list {
i := 0
for i < n {
run := texture_run_len(app.draw_list[:], i)
q0 := app.draw_list[i]
sampler_binding := sdl.GPUTextureSamplerBinding {
texture = q.texture,
texture = q0.texture,
sampler = app.sampler,
}
sdl.BindGPUFragmentSamplers(app.render_pass, 0, &sampler_binding, 1)
@@ -282,9 +286,11 @@ end_frame :: proc(app: ^App) {
offset = u32(i * SPRITE_VERTS_SIZE),
}
sdl.BindGPUVertexBuffers(app.render_pass, 0, &vb_binding, 1)
sdl.DrawGPUPrimitives(app.render_pass, SPRITE_VERT_COUNT, 1, 0, 0)
}
sdl.DrawGPUPrimitives(app.render_pass, u32(run * SPRITE_VERT_COUNT), 1, 0, 0)
i += run
}
sdl.EndGPURenderPass(app.render_pass)
app.render_pass = nil
@@ -418,3 +424,17 @@ create_sprite_pipeline :: proc(app: ^App) -> ^sdl.GPUGraphicsPipeline {
return pipeline
}
texture_run_len :: proc(list: []Queued_Sprite, start: int) -> int {
if start < 0 || start >= len(list) do return 0
tex := list[start].texture
n := 1
for i in start + 1 ..< len(list) {
if list[i].texture != tex do break
n += 1
}
return n
}