2020-07-19 19:24:48 -04:00
|
|
|
#ifndef LIBDGL_DGLDRAW_H
|
|
|
|
#define LIBDGL_DGLDRAW_H
|
2017-11-26 13:18:33 -05:00
|
|
|
|
2018-04-28 11:30:53 -04:00
|
|
|
#include "dglgfx.h"
|
|
|
|
#include "dglclip.h"
|
|
|
|
#include "dglutil.h"
|
2017-11-26 13:18:33 -05:00
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void pset(SURFACE *surface, int x, int y, uint8 color);
|
|
|
|
static void pset_f(SURFACE *surface, int x, int y, uint8 color);
|
|
|
|
static uint8 pget(const SURFACE *surface, int x, int y);
|
|
|
|
static uint8 pget_f(const SURFACE *surface, int x, int y);
|
|
|
|
|
|
|
|
static void draw_hline(SURFACE *surface, int x1, int x2, int y, uint8 color);
|
|
|
|
void draw_hline_f(SURFACE *surface, int x1, int x2, int y, uint8 color);
|
|
|
|
static void draw_vline(SURFACE *surface, int x, int y1, int y2, uint8 color);
|
|
|
|
void draw_vline_f(SURFACE *surface, int x, int y1, int y2, uint8 color);
|
|
|
|
void draw_line(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
|
|
|
void draw_line_f(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
2017-11-26 13:18:33 -05:00
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
void draw_rect(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
|
|
|
void draw_rect_f(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
|
|
|
void draw_filled_rect(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
|
|
|
void draw_filled_rect_f(SURFACE *surface, int x1, int y1, int x2, int y2, uint8 color);
|
2017-11-26 13:18:33 -05:00
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
void draw_text(SURFACE *surface, int x, int y, uint8 color, const char *text);
|
|
|
|
void draw_text_f(SURFACE *surface, int x, int y, uint8 color, const char *text);
|
|
|
|
void draw_printf(SURFACE *surface, int x, int y, uint8 color, const char *format, ...);
|
|
|
|
void draw_printf_f(SURFACE *surface, int x, int y, uint8 color, const char *format, ...);
|
2017-11-26 13:18:33 -05:00
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
void lowlevel_rect_f(
|
|
|
|
uint8 color,
|
|
|
|
int width,
|
|
|
|
int y_inc,
|
|
|
|
int lines,
|
|
|
|
uint8 *p1,
|
|
|
|
uint8 *p2
|
|
|
|
);
|
2017-11-26 13:18:33 -05:00
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
void lowlevel_filled_rect_f(
|
|
|
|
uint8 color,
|
|
|
|
int y_inc,
|
|
|
|
int width,
|
|
|
|
int lines,
|
|
|
|
uint8 *dest
|
|
|
|
);
|
2017-11-26 13:18:33 -05:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
static void pset(SURFACE *surface, int x, int y, uint8 color) {
|
2017-11-26 13:18:33 -05:00
|
|
|
if (is_point_in_bounds(&surface->clip_region, x, y))
|
2020-07-19 19:24:48 -04:00
|
|
|
pset_f(surface, x, y, color);
|
2017-11-26 13:18:33 -05:00
|
|
|
}
|
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
static void pset_f(SURFACE *surface, int x, int y, uint8 color) {
|
|
|
|
uint32 offset = surface_offset(surface, x, y);
|
2018-04-28 11:30:53 -04:00
|
|
|
surface->pixels[offset] = color;
|
2017-11-26 13:18:33 -05:00
|
|
|
}
|
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
static uint8 pget(const SURFACE *surface, int x, int y) {
|
2017-11-26 13:18:33 -05:00
|
|
|
if (is_point_in_bounds(&surface->clip_region, x, y))
|
2020-07-19 19:24:48 -04:00
|
|
|
return pget_f(surface, x, y);
|
2017-11-26 13:18:33 -05:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
static uint8 pget_f(const SURFACE *surface, int x, int y) {
|
|
|
|
uint32 offset = surface_offset(surface, x, y);
|
2018-04-28 11:30:53 -04:00
|
|
|
return surface->pixels[offset];
|
2017-11-26 13:18:33 -05:00
|
|
|
}
|
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
static void draw_hline(SURFACE *surface, int x1, int x2, int y, uint8 color) {
|
2017-11-26 13:18:33 -05:00
|
|
|
if (x2 < x1)
|
|
|
|
SWAP(int, x1, x2);
|
|
|
|
if (clamp_to_region(&surface->clip_region, &x1, &y, &x2, &y))
|
2020-07-19 19:24:48 -04:00
|
|
|
draw_hline_f(surface, x1, x2, y, color);
|
2017-11-26 13:18:33 -05:00
|
|
|
}
|
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
static void draw_vline(SURFACE *surface, int x, int y1, int y2, uint8 color) {
|
2017-11-26 13:18:33 -05:00
|
|
|
if (y2 < y1)
|
|
|
|
SWAP(int, y1, y2);
|
|
|
|
if (clamp_to_region(&surface->clip_region, &x, &y1, &x, &y2))
|
2020-07-19 19:24:48 -04:00
|
|
|
draw_vline_f(surface, x, y1, y2, color);
|
2017-11-26 13:18:33 -05:00
|
|
|
}
|
|
|
|
|
2020-07-19 19:24:48 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-11-26 13:18:33 -05:00
|
|
|
#endif
|
|
|
|
|