diff --git a/graphics/graphics.c b/graphics/graphics.c index ecb2db4..11d7c7a 100644 --- a/graphics/graphics.c +++ b/graphics/graphics.c @@ -110,9 +110,7 @@ void graphics_Init() { case v: io_Printf(#v "\r\n"); switch (gop->Mode->Info->PixelFormat) { CASE(PixelRedGreenBlueReserved8BitPerColor) - graphics_SetPixel = graphics_SetPixel_RGB; CASE(PixelBlueGreenRedReserved8BitPerColor) - graphics_SetPixel = graphics_SetPixel_BGR; CASE(PixelBitMask) CASE(PixelBltOnly) CASE(PixelFormatMax) @@ -131,8 +129,6 @@ void graphics_Init() { } -graphics_SetPixel_Type *graphics_SetPixel; - void graphics_SetPixel_RGB(int posX, int posY, const HelosGraphics_Color *color) { struct { uint8_t R, G, B; diff --git a/graphics/graphics.h b/graphics/graphics.h index 4b86748..3cf10da 100644 --- a/graphics/graphics.h +++ b/graphics/graphics.h @@ -43,14 +43,18 @@ void graphics_SwapBuffer(); void graphics_Invalidate(int left, int top, int width, int height); // Invalidates a rectangular region -// graphics_SetPixel is set by Init() to match one of SetPixel_RGB/BGR according to the framebuffer format. -typedef void(graphics_SetPixel_Type)(int posX, int posY, const HelosGraphics_Color *color); -extern graphics_SetPixel_Type *graphics_SetPixel; - // graphics_SetPixel_RGB/BGR writes the given pixel to the framebuffer in RGB/BGR format. void graphics_SetPixel_RGB(int posX, int posY, const HelosGraphics_Color *color); void graphics_SetPixel_BGR(int posX, int posY, const HelosGraphics_Color *color); +// graphics_SetPixel calls one of SetPixel_RGB/BGR according to the framebuffer format. +static inline void graphics_SetPixel(int posX, int posY, const HelosGraphics_Color *color) { + if (graphics_SystemVideoMode.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) + graphics_SetPixel_BGR(posX, posY, color); + else if (graphics_SystemVideoMode.PixelFormat == PixelRedGreenBlueReserved8BitPerColor) + graphics_SetPixel_RGB(posX, posY, color); +} + void graphics_FillPixel(int startX, int startY, int endX, int endY, const HelosGraphics_Color *color);