Remove bj_renderer from the public API #114
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
OragonEfreet/banjo#114
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
After #107 (draw-callback model) removed
bj_get_framebufferandbj_present, thebj_renderertype's user-facing role collapsed to exactly four lines of ceremony every program has to repeat:A grep across
examples/confirms zero examples touch the renderer between configure and destroy. Banjo also only has one renderer type (BJ_RENDERER_TYPE_SOFTWARE); the enum exists for forward compatibility with GL/Vulkan that hasn't shipped and isn't currently scheduled. Today the abstraction is pure tax.The draw callback already receives an opaque
bj_render_target. That stays — it's the right shape for handing a renderable surface to user code without committing to "this is a CPU bitmap." The renderer object itself adds no value on top of it.Outcome
Public API removals:
bj_create_rendererbj_destroy_rendererbj_renderer_configureenum bj_renderer_type(andBJ_RENDERER_TYPE_SOFTWARE)struct bj_renderer(kept internal as a private framebuffer holder)inc/banjo/renderer.hdeleted; the remaining surface (bj_render_target,bj_render_target_bitmap) moves toinc/banjo/window.hNew behaviour:
bj_bind_window(title, x, y, w, h, flags, err)allocates the software framebuffer at window creation time — the user has nothing else to do before registering a draw callback.bj_unbind_window(window)releases it.bj_window_fire_draw_callback) reads the framebuffer directly fromwindow->framebufferinstead of going throughwindow->bound_renderer.Per-backend refactor (all five real backends + fake):
*_renderer_configure/*_create_renderer/*_destroy_rendererfunctions fold into the existingcreate_window/delete_windowpaths.create_framebuffer(window, err)or similar layer op may help keep window creation focused while still picking up the backend-specific framebuffer setup (X11 XImage, Wayland shm buffer, Win32 HDC/HBITMAP, Cocoa buffer, Emscripten canvas).Migration
Examples: 18 files, each loses the 4-line renderer dance plus the
bj_renderer* renderer = 0;declaration. ~90 lines net deletion across the example tree.Tutorials in headers:
start.c,pong.c,drawing_2d.c,load_bmp.c(and any other paired tutorial blocks) need their walkthroughs updated to reflect the simpler init sequence.Tests:
unit_draw_callback's fixture currently creates a renderer; it switches to plainbj_bind_window.Forward compatibility with GL/Vk
When (if) GL/Vk arrives, options on the table:
bj_bind_window(... flags=BJ_WINDOW_FLAG_GL ...).bj_bind_window_gl(...).That's a real design decision then, not now. Today's removal doesn't lock anything in —
bj_render_targetis still an opaque type whose backing can be any future kind.Acceptance criteria
nm libbanjo.ashows nobj_create_renderer/bj_destroy_renderer/bj_renderer_configuresymbols.grep -r bj_renderer inc/returns nothing public-facing.wc -l examples/*.cdrops by ~90 lines net.renderer.hremoved; references in other headers re-target).Out of scope
bj_window_pixel_mode(window)after this card; reference but don't bundle).draw(state, bitmap)helpers intoon_drawin the examples — separate small cleanup card, possibly bundle with this if the touch overlaps.Depends on