cb6d9e61d1
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.6 KiB
2.6 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, example, tested, tests, test_file_path, file_path, params, output
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | example | tested | tests | test_file_path | file_path | params | output | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| sprite_batch | function | cpp | gfx | 0.1.0 | impure | sprite_batch_create(int cap=4096) -> SpriteBatch; sprite_batch_begin/draw/end | Batched textured quad renderer sobre sokol_gfx. Begin/draw/end con auto-flush por atlas change o capacity full. Vertex layout pos+uv+color, alpha blending estandar, GLSL 330 / GLES 300. Issue 0072b runtime gamedev — base de plataformeros, top-down, UI sprites. |
|
|
|
false | error_go_core | fn::gfx::SpriteBatch b = fn::gfx::sprite_batch_create(4096); // por frame, dentro de un sg_pass: fn::gfx::sprite_batch_begin(b, view_proj); fn::gfx::sprite_batch_draw(b, atlas_img, 1024, 1024, {0,0,32,32}, {100,100,32,32}, fn::math2d::Color::white()); fn::gfx::sprite_batch_draw(b, atlas_img, 1024, 1024, {32,0,32,32}, {200,100,32,32}, fn::math2d::Color::rgba(255,0,0)); fn::gfx::sprite_batch_end(b); | false | cpp/functions/gfx/sprite_batch.cpp |
|
Quads renderizados via sg_draw cuando flush. Una sola draw call por atlas binding. |
sprite_batch
Renderer batched de sprites 2D sobre sokol_gfx. Patron clasico:
sprite_batch_createuna vez (despues desg_setup).- Por frame, dentro de un sg_pass:
sprite_batch_begin(b, view_proj)— pasa la matriz view-projection del camera_2d.sprite_batch_draw(...)por sprite. Auto-flush cuando cambia atlas o se llena.sprite_batch_end(b)— flush final.
Alpha blending activado por defecto (premultiplicado o no — usar el atlas que tengas; el shader hace texture(u_tex, v_uv) * tint).
Sampler linear filter + clamp-to-edge. Para pixel art, crear sampler propio con SG_FILTER_NEAREST y bindearlo manualmente (override no soportado por ahora — sub-issue futuro si hace falta).
Performance: 1 draw call por atlas. 10K sprites @ 60 FPS sobre WebGL2 modesto. Cap por defecto 4096 quads/flush; subir si tu juego dibuja >4K sprites del mismo atlas.