Public bj_renderer_pixel_mode accessor #111
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
OragonEfreet/banjo#111
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?
Context
After #107 lands, examples that need to precompute colours at setup time can't reach the renderer's framebuffer (it's only accessible from inside the draw callback). Three examples —
physics_kinematics.c,physics_particle.c,random_distribution.c— work around this by hardcoding the renderer's pixel mode:This works today because all software renderers use XRGB8888. It breaks the day banjo ships a non-XRGB renderer (RGB565 for embedded, anything new the renderer abstraction is supposed to enable). The hardcode is a tax the type system should be paying for us.
Outcome
A public accessor on
bj_renderer:Returns the pixel mode of the renderer's framebuffer (the one a
bj_render_target_bitmapinside the draw callback would yield). NULL renderer returns whatever sentinel is most useful (zero or a dedicatedBJ_PIXEL_MODE_UNKNOWN).Three example migrations to follow:
physics_kinematics.c— drop theFB_PIXEL_MODEdefine; use the accessor inreset_ball.physics_particle.c— same drop; use the accessor ininit_asteroidsandinitialize.random_distribution.c— same drop; use the accessor ininit_distributions.After this the only remaining hardcoded-pixel-mode in examples is the one inside the on_draw helper for things like
bj_set_bitmap_color(fb, bj_make_bitmap_pixel(fb, 22, 26, 32), BJ_BITMAP_CLEAR_COLOR)— those are fine, the framebuffer is in scope.Depends on
Out of scope
bj_bitmap_pixel_modeintrospection — already public.