roo_e/dyn/kpssurf/kpssurf.h

95 lines
2.9 KiB
C

/*
* Roo/E, the Kangaroo Punch Portable GUI Toolkit
* Copyright (C) 2026 Scott Duensing
*
* http://kangaroopunch.com
*
*
* This file is part of Roo/E.
*
* Roo/E is free software: you can redistribute it and/or modify it under the
* terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* Roo/E is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Roo/E. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef KPSSURF_H
#define KPSSURF_H
#include "roo_e.h"
typedef uint32_t ColorT;
typedef struct SurfaceS {
uint16_t width;
uint16_t height;
size_t scanline;
size_t bytes;
union {
uint8_t *bits8;
uint16_t *bits16;
uint32_t *bits32;
} buffer;
} SurfaceT;
typedef struct SurfaceFormatS {
uint32_t rMask;
uint32_t gMask;
uint32_t bMask;
uint32_t aMask;
uint8_t rShift;
uint8_t gShift;
uint8_t bShift;
uint8_t aShift;
uint8_t rLoss;
uint8_t gLoss;
uint8_t bLoss;
uint8_t aLoss;
} SurfaceFormatT;
extern SurfaceT *__surfaceActive;
extern uint8_t __surfaceBitsPerPixel;
extern uint8_t __surfaceBytesPerPixel;
extern SurfaceFormatT __surfaceFormat;
extern void (*surfaceLineH)(int16_t x1, int16_t x2, int16_t y, ColorT c);
extern void (*surfaceLineV)(int16_t x, int16_t y1, int16_t y2, ColorT c);
extern ColorT (*surfacePixelGet)(SurfaceT *surface, int16_t x, int16_t y);
extern void (*surfacePixelSet)(uint16_t x, uint16_t y, ColorT color);
void surfaceBlit(int16_t targetX1, int16_t targetY1, int16_t offsetX, int16_t offsetY, int16_t width, int16_t height, SurfaceT *source);
void surfaceBlitWithTransparency(int16_t targetX, int16_t targetY, SurfaceT *source, ColorT transparent);
void surfaceClear(ColorT color);
ColorT surfaceColorMake(uint8_t r, uint8_t g, uint8_t b);
SurfaceT *surfaceCreate(int16_t width, int16_t height);
void surfaceBox(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT c);
void surfaceBoxFilled(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT c);
void surfaceBoxHighlight(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT highlight, ColorT shadow);
void surfaceDestroy(SurfaceT **surface);
SurfaceT *surfaceGet(void);
int16_t surfaceHeightGet(SurfaceT *surface);
void surfaceLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT color);
SurfaceT *surfaceLoad(char *filename);
void surfaceSave(SurfaceT *surface, char *filename);
void surfaceSet(SurfaceT *surface);
void surfaceShutdown(void);
void surfaceStartup(uint8_t bits);
int16_t surfaceWidthGet(SurfaceT *surface);
#endif // KPSSURF_H