AxlGfx – Graphics
Basic graphics output over the UEFI GOP (Graphics Output Protocol). Fill rectangles, blit pixel buffers, capture screen regions, and render text with an 8x16 VGA bitmap font. Falls back gracefully on headless systems where GOP is not available.
Header: <axl/axl-gfx.h>
Overview
Not all UEFI systems have a display. Serial-only servers and headless
BMCs typically lack GOP. Always check axl_gfx_available() before
drawing:
#include <axl.h>
if (!axl_gfx_available()) {
axl_printf("No display — running headless\n");
return;
}
AxlGfxInfo info;
axl_gfx_get_info(&info);
axl_printf("Display: %ux%u\n", info.width, info.height);
// Fill background
AxlGfxPixel bg = {0, 0, 0, 0}; // BGRX: black
axl_gfx_fill_rect(0, 0, info.width, info.height, bg);
// Draw text (8x16 VGA font, scalable)
AxlGfxPixel white = {255, 255, 255, 0};
axl_gfx_draw_text(20, 20, "Hello from AXL!", white, 2);
Pixel Format
Pixels use BGRX layout (AxlGfxPixel): blue, green, red, reserved.
This matches the native GOP pixel format on most hardware, avoiding
conversion overhead.
API Reference
Functions
-
bool axl_gfx_available(void)
Check whether a graphics display is available.
- Returns:
true if GOP was found, false on headless/serial systems.
-
int axl_gfx_get_info(AxlGfxInfo *info)
Get framebuffer information.
- Parameters:
info – [out] receives display info
- Returns:
0 on success, -1 if GOP not available.
-
int axl_gfx_fill_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, AxlGfxPixel color)
Fill a rectangle with a solid color.
- Parameters:
x – left edge
y – top edge
w – width in pixels
h – height in pixels
color – fill color
- Returns:
0 on success, -1 if GOP not available.
-
int axl_gfx_blit(const AxlGfxPixel *buffer, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
Blit a pixel buffer to the screen.
buffer must contain at least w * h pixels in row-major order with AxlGfxPixel (BGRX) layout.
- Parameters:
buffer – [in] source pixel buffer
x – destination left edge
y – destination top edge
w – width in pixels
h – height in pixels
- Returns:
0 on success, -1 if GOP not available.
-
int axl_gfx_capture(AxlGfxPixel *buffer, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
Capture a screen region into a pixel buffer.
buffer must have space for at least w * h pixels.
- Parameters:
buffer – [out] destination pixel buffer
x – source left edge
y – source top edge
w – width in pixels
h – height in pixels
- Returns:
0 on success, -1 if GOP not available.
-
int axl_gfx_draw_text(uint32_t x, uint32_t y, const char *text, AxlGfxPixel color, uint32_t scale)
Draw a text string at the given position.
Uses an embedded 8x16 VGA bitmap font. Printable ASCII only (0x20-0x7E); non-printable characters are transparent (existing background pixels are preserved). Output is clamped to screen bounds.
- Parameters:
x – left edge (pixels)
y – top edge (pixels)
text – UTF-8/ASCII text to render
color – text foreground color
scale – scale factor (1 = native 8x16, 2 = 16x32, etc.)
- Returns:
0 on success, -1 if GOP not available or text is NULL.
-
struct AxlGfxInfo
- #include <axl-gfx.h>
Framebuffer information (standard C types, no UEFI types).
-
struct AxlGfxPixel
- #include <axl-gfx.h>
Pixel color in BGRX layout (matches GOP native pixel format).