#include <SDL.h>
Go to the source code of this file.
Data Structures | |
struct | XY_bitmap |
XY_bitmap - libcrtxy bitmap type. More... | |
struct | XY_line |
XY_line - libcrtxy structure representing a single line. More... | |
struct | XY_lines |
XY_lines - libcrtxy structure representing a group of lines. More... | |
struct | XY_options |
XY_options - libcrtxy structure containing runtime options (rendering level, screen size, etc. More... | |
Defines | |
#define | XY_FIXED_SHIFT 16 |
How much to shift ints to get a fixed-point value. | |
#define | XY_FIXED_SHIFT_HALF 8 |
For half-shift during mult & divide macros. | |
#define | XY_FIXED_ONE (1 << XY_FIXED_SHIFT) |
Quick way to get '1' as an XY_fixed. | |
#define | XY_FIXED_HALF (1 << (XY_FIXED_SHIFT - 1)) |
Quick way to get '0.5' as an XY_fixed. | |
#define | XY_FIXED_MAX 0x7FFFFFFF |
Maximum value an XY_fixed can hold. | |
#define | XY_FIXED_MIN -(0x80000000) |
Minimum value an XY_fixed can hold. | |
#define | XY_FIXED_NAN XY_FIXED_MAX |
Not-a-number (NAN), occurs when you divide by zero. | |
#define | XY_THIN XY_FIXED_ONE |
Minimum line thickness. | |
#define | XY_INIT_LIB_CONFIG_FILE_GLOBAL CONFDIR "/libcrtxy.conf" |
Where system-wide (global) config file lives. | |
#define | XY_INIT_LIB_CONFIG_FILE_LOCAL ".libcrtxyrc" |
Where user's (local) config file lives. | |
#define | XY_POS_TOP 0x0 |
Position background at the top (default). | |
#define | XY_POS_LEFT 0x0 |
Position background on the left (default). | |
#define | XY_POS_HCENTER 0x1 |
Horizontally center background. | |
#define | XY_POS_VCENTER 0x2 |
Vertically center background. | |
#define | XY_POS_RIGHT 0x4 |
Position background at the right. | |
#define | XY_POS_BOTTOM 0x8 |
Position background at the bottom. | |
#define | XY_SCALE_NONE 0 |
Do not stretch; clip or show solid border(s). | |
#define | XY_SCALE_STRETCH 1 |
Stretch; aspect ratio can be altered. | |
#define | XY_SCALE_KEEP_ASPECT_WIDE 2 |
Stretch w/o alt'ing aspect; fit width. | |
#define | XY_SCALE_KEEP_ASPECT_TALL 3 |
Stretch w/o alt'ing aspect; fit height. | |
#define | XY_mult(a, b) |
Multiply two XY_fixed values. | |
#define | XY_qdiv(a, b) |
Divide one XY_fixed value by another. | |
#define | XY_div(a, b) |
Divide one XY_fixed value by another. | |
#define | XY_FIXED_DIV_ZERO ((1 << XY_FIXED_SHIFT_HALF) - 1) |
The maximum value that, when XY_div() is used to divide two digits, the denominator may be, and be considered zero (due to shifting to reduce precision loss. | |
#define | XY_fpart(a) ((a) & (XY_FIXED_ONE - 1)) |
Return the fractional part of 'a'. | |
#define | XY_rfpart(a) (XY_FIXED_ONE - XY_fpart(a)) |
Return one minus the fractional part of 'a'. | |
#define | XY_ipart(a) ((a) - XY_fpart(a)) |
Returns the integer (whole) part of 'a'. | |
#define | XY_round(a) (XY_ipart((a) + (1 << (XY_FIXED_SHIFT - 1)))) |
Rounds 'a' up to the nearest integer (whole). | |
#define | XY_sin(degrees) (XY_cos(90 - (degrees))) |
Returns sine() of 'degrees'. | |
Typedefs | |
typedef Uint32 | XY_color |
XY_color - libcrtxy color type. | |
typedef Sint32 | XY_fixed |
XY_fixed - libcrtxy fixed-point type. | |
Enumerations | |
enum | XY_bool { XY_FALSE, XY_TRUE } |
XY_bool - libcrtxy boolean type. More... | |
enum | XY_intersection { XY_INTERSECTION_NONE, XY_INTERSECTION_INTERSECTING, XY_INTERSECTION_PARALLEL, XY_INTERSECTION_COINCIDENT } |
XY_intersection - libcrtxy line intersection results. More... | |
enum | XY_opt_fullscreen { XY_OPT_WINDOWED, XY_OPT_FULLSCREEN_REQUEST, XY_OPT_FULLSCREEN_REQUIRED } |
XY_opt_fullscreen - libcrtxy display settings for options.fullscreen. More... | |
enum | XY_opt_alpha { XY_OPT_ALPHA_BLEND, XY_OPT_ALPHA_FAKE, XY_OPT_ALPHA_OFF } |
XY_opt_alpha - libcrtxy alpha-blending settings for options.alpha. More... | |
enum | XY_opt_scaling { XY_OPT_SCALE_BEST, XY_OPT_SCALE_FAST } |
XY_opt_scaling - libcrtxy bitmap scaling quality settings for options.scaling. More... | |
enum | XY_err { XY_ERR_NONE, XY_ERR_OPTION_BAD, XY_ERR_OPTION_UNKNOWN, XY_ERR_FILE_CANT_OPEN, XY_ERR_MEM_CANT_ALLOC, XY_ERR_INIT_VIDEO, XY_ERR_INIT_DISPLAY, XY_ERR_INIT_UNSUPPORTED_BPP, XY_ERR_BITMAP_CANT_DECODE, XY_ERR_BITMAP_CANT_CONVERT, XY_ERR_BITMAP_CANT_SCALE, XY_ERR_LINES_INVALID, NUM_XY_ERRS } |
Functions | |
XY_bool | XY_init (XY_options *opts, XY_fixed canvasw, XY_fixed canvash) |
Initialize SDL (video only) and libcrtxy (with rendering and video options from opts), and set the virtual canvas size. | |
void | XY_quit (void) |
Shut down libcrtxy and SDL. | |
void | XY_start_frame (int fps) |
Mark the start of a frame. | |
int | XY_end_frame (XY_bool throttle) |
Mark the end of a frame. | |
XY_lines * | XY_new_lines (void) |
Create a new line collection. | |
XY_lines * | XY_duplicate_lines (XY_lines *lines) |
Duplicates a collection. | |
XY_bool | XY_free_lines (XY_lines *lines) |
Free a line collection. | |
XY_bool | XY_start_lines (XY_lines *lines) |
Reset a line collection so that it contains no lines. | |
XY_bool | XY_add_line (XY_lines *lines, XY_fixed x1, XY_fixed y1, XY_fixed x2, XY_fixed y2, XY_color color, XY_fixed thickness) |
Add a line to a line collection. | |
XY_bool | XY_translate_lines (XY_lines *lines, XY_fixed x, XY_fixed y) |
Translate all lines within a collection. | |
XY_bool | XY_scale_lines (XY_lines *lines, XY_fixed xscale, XY_fixed yscale) |
Scale all lines within a collection (centered around the origin (0,0)). | |
XY_bool | XY_rotate_lines (XY_lines *lines, int angle) |
Rotate all lines within a collection (centered around the origin (0,0)). | |
void | XY_draw_line (XY_fixed x1, XY_fixed y1, XY_fixed x2, XY_fixed y2, XY_color color, XY_fixed thickness) |
Draw a single line between (x1,y1) and (x2,y2) (in canvas virtual world units) and in the specified color/alpha and thickness. | |
XY_bool | XY_draw_lines (XY_lines *lines) |
Draw a collection of lines. | |
void | XY_draw_one_line (XY_line line) |
Draw a single line using an XY_line struct. | |
void | XY_draw_point (XY_fixed x, XY_fixed y, XY_color color, XY_fixed thickness) |
Draw a point at (x,y) (in canvas virtual world units) in the specified color/alpha and thickness. | |
XY_fixed | XY_cos (int degrees) |
Returns cosine() of 'degrees'. | |
XY_fixed | XY_screenx_to_canvasx (int sx) |
Convert a screen coordinate (an integer; eg, where the mouse was clicked) into canvas virtual world units (fixed point). | |
XY_fixed | XY_screeny_to_canvasy (int sy) |
Convert a screen coordinate (an integer; eg, where the mouse was clicked) into canvas virtual world units (fixed point). | |
void | XY_screen_to_canvas (int sx, int sy, XY_fixed *cx, XY_fixed *cy) |
Convert a screen coordinate (an integer; eg, where the mouse was clicked) into canvas virtual world units (fixed point). | |
XY_fixed | XY_canvasx_to_screenx (int cx) |
Convert a canvas virtual world coordinate (fixed point) into the nearest screen coordinate (an integer). | |
XY_fixed | XY_canvasy_to_screeny (int cy) |
Convert a canvas virtual world coordinate (fixed point) into the nearest screen coordinate (an integer). | |
void | XY_canvas_to_screen (XY_fixed cx, XY_fixed cy, int *sx, int *sy) |
Convert a canvas virtual world coordinate (fixed point) into the nearest screen coordinate (an integer). | |
int | XY_get_screenw (void) |
Returns the screen's current width, in pixels (integer). | |
int | XY_get_screenh (void) |
Returns the screen's current height, in pixels (integer). | |
XY_bool | XY_lines_intersect (XY_line line1, XY_line line2, XY_fixed *intersect_x, XY_fixed *intersect_y, XY_intersection *result) |
Returns whether two lines intersect. | |
XY_bool | XY_line_groups_intersect (XY_lines *lines1, XY_lines *lines2) |
Returns whether any lines in one group intersect any lines in another. | |
void | XY_default_options (XY_options *opts) |
Set opts to default (libcrtxy's compiled-time) options. | |
XY_bool | XY_load_options (XY_options *opts) |
Load global, then local (user) libcrtxy config files into opts. | |
XY_bool | XY_load_options_from_file (char *fname, XY_options *opts, XY_bool ignore_unknowns) |
Load arbitrary config file into opts. | |
int | XY_parse_options (int *argc, char *argv[], XY_options *opts) |
Parse libcrtxy-related command-line arguments into opts. | |
XY_bool | XY_parse_envvars (XY_options *opts) |
Read any libcrtxy-related environment variables into opts. | |
XY_err | XY_errcode (void) |
Gets the most recent error code. | |
const char * | XY_errstr (void) |
Gets a string representing the most recent error code. | |
void | XY_print_options (FILE *fi, XY_options opts) |
Dumps options in opts to the file stream (eg, stderr or an opened logfile). | |
XY_bitmap * | XY_load_bitmap (char *filename) |
Create a bitmap based on an image file. | |
XY_bitmap * | XY_load_bitmap_from_buffer (unsigned char *buffer, int size) |
Create a bitmap based on image data in a buffer. | |
void | XY_free_bitmap (XY_bitmap *bitmap) |
Free a bitmap. | |
XY_bool | XY_set_background (XY_color color, XY_bitmap *bitmap, XY_fixed x, XY_fixed y, int posflags, int scaling) |
Set the background color, and optional bitmap, its position, and options for scaling it to the screen size. | |
void | XY_enable_background (XY_bool enable) |
Enable or disable the background bitmap (affects next frame). | |
XY_color | XY_setcolor (Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
Combines values for R, G, B and A components into an XY_color. | |
void | XY_getcolor (XY_color c, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) |
Breaks an XY_color into its R, G, B and A components. |