-
Notifications
You must be signed in to change notification settings - Fork 3
darnit_render.h
- DARNIT_RENDER_LOGIC_OP - Set a logic function that is applied when rendering to the framebuffer
- DARNIT_RENDER_SCALE - Set how tilesheets are interpolated when stretched.
- DARNIT_TILESHEET - Functions for handling tilesheets
- DARNIT_TILE - Functions for rendering tiles (quads)
- DARNIT_LINE - Functions for rendering lines
- DARNIT_CIRCLE - Functions for rendering circles
- DARNIT_POINT - Functions for rendering points
- DARNIT_RECT - Functions for rendering filled solid-color rectangles.
- DARNIT_RENDER - General functions not specific to any special kind of rendering.
Used with d_render_logic_op to wrap glLogicOp.
typedef enum {
DARNIT_RENDER_LOGIC_OP_NONE = 0,
DARNIT_RENDER_LOGIC_OP_AND = 1,
DARNIT_RENDER_LOGIC_OP_NAND = 2,
DARNIT_RENDER_LOGIC_OP_OR = 3,
DARNIT_RENDER_LOGIC_OP_NOR = 4,
DARNIT_RENDER_LOGIC_OP_XOR = 5,
} DARNIT_RENDER_LOGIC_OP;- void d_render_logic_op(DARNIT_RENDER_LOGIC_OP logicop);
Used with d_render_tilesheet_scale_algorithm to change how a tilesheet is interpolated if it's stretched when rendered. Default is DARNIT_SCALE_NEAREST.
typedef enum {
DARNIT_SCALE_NEAREST = 1,
DARNIT_SCALE_LINEAR = 2,
} DARNIT_RENDER_SCALE;A DARNIT_TILESHEET is a texture with a virtual tile grid applied over it. Tilesheets are memory managed, if you load the same tilesheet several time, only one copy is present in memory. While this saves VRAM, it also means that if you apply an animation to it or update a region of it with new pixel data, it affects everything that uses the tilesheet. Changes persists until everything that uses it has been unloaded, then the tilesheet itself is unloaded too.
If a tilesheet is already loaded or not is determined via the path to the image file. So if you overlay a directory with an LDI and then try to load a tilesheet inside the LDI, and it has the same path as an already loaded image, the already loaded one will trigger as the same one.
- DARNIT_TILESHEET *d_render_tilesheet_load(const char *fname, unsigned int wsq, unsigned int hsq, DARNIT_PFORMAT target_format);
- DARNIT_TILESHEET *d_render_tilesheet_isom_load(const char *fname, unsigned int wsq, unsigned int hsq, DARNIT_PFORMAT target_format);
- DARNIT_TILESHEET *d_render_tilesheet_new(int tiles_w, int tiles_h, int tile_w, int tile_h, DARNIT_PFORMAT format);
- DARNIT_TILESHEET *d_render_tilesheet_free(DARNIT_TILESHEET *tilesheet);
- void d_render_tilesheet_update(DARNIT_TILESHEET *tilesheet, int sheet_x, int sheet_y, int change_w, int change_h, void *data);
- void d_render_tilesheet_geometrics(DARNIT_TILESHEET *tilesheet, int *w, int *h, int *tile_w, int *tile_h);
- int d_render_tilesheet_animation_apply(DARNIT_TILESHEET *tilesheet, const char *fname);
- void d_render_tilesheet_animate(DARNIT_TILESHEET *tilesheet);
- void d_render_tilesheet_scale_algorithm(DARNIT_TILESHEET *tilesheet, DARNIT_RENDER_SCALE scaling);
- int d_render_texture_get(DARNIT_TILESHEET *tilesheet, int *w, int *h);
DARNIT_TILE is used to batch-render tiles. They do not have to be all groped together like a tilemap, they can be placed whereever on the screen. All tiles in a DARNIT_TILE has to be using the same tilesheet though.
- void d_render_tile_init(DARNIT_TILE *buf, unsigned int tile, unsigned int tile_ts, int x, int y);
- void d_render_tile_move(DARNIT_TILE *tile_p, unsigned int tile, int x, int y);
- void d_render_tile_tilesheet_coord_set(DARNIT_TILE *tile_p, unsigned int tile, unsigned int x, unsigned int y, unsigned int w, unsigned int h);
- void d_render_tile_size_set(DARNIT_TILE *buf, unsigned int tile, int w, int h);
- void d_render_tile_set(DARNIT_TILE *tile_p, unsigned int tile, unsigned int tile_ts);
- void d_render_tile_tilesheet(DARNIT_TILE *tile_p, DARNIT_TILESHEET *tilesheet);
- void d_render_tile_clear(DARNIT_TILE *tile_p, unsigned int tile);
- void d_render_tile_draw(DARNIT_TILE *tile_p, unsigned int tiles);
- DARNIT_TILE *d_render_tile_new(unsigned int tiles, DARNIT_TILESHEET *tilesheet);
- DARNIT_TILE *d_render_tile_free(DARNIT_TILE *tile_p);
Like DARNIT_TILE, but with lines. No texture mapping or color mapping is done, just while lines. Use d_render_tint to change the color on all the lines in the DARNIT_LINE drawn.
- DARNIT_LINE *d_render_line_new(unsigned int lines, unsigned int line_w);
- void d_render_line_move(DARNIT_LINE *line_p, unsigned int line, int x1, int y1, int x2, int y2);
- void d_render_line_draw(DARNIT_LINE *line_p, int lines);
- void d_render_line_get(DARNIT_LINE *buf, unsigned int line, int *x, int *y, int *x2, int *y2);
- DARNIT_LINE *d_render_line_free(DARNIT_LINE *line_p);
DARNIT_CIRCLE is a special case of DARNIT_LINE in which a bunch on lines are used to apprioximate a circle. No texture or color mapping is done, use d_render_tint to color the circle.
- DARNIT_CIRCLE *d_render_circle_new(unsigned int lines, unsigned int line_w);
- void d_render_circle_move(DARNIT_CIRCLE *circle_p, int x, int y, int radius);
- void d_render_circle_draw(DARNIT_CIRCLE *circle_p);
- DARNIT_CIRCLE *d_render_circle_free(DARNIT_CIRCLE *circle_p);
DARNIT_POINT is a buffer containing coordinates to draw points at.
- DARNIT_POINT *d_render_point_new(unsigned int points, unsigned int point_w);
- void d_render_point_move(DARNIT_POINT *point_p, int x, int y);
- void d_render_point_draw(DARNIT_POINT *point_p, int points);
- DARNIT_POINT *d_render_point_free(DARNIT_POINT *point_p);
DARNIT_RECT renders filled rectangles. No texture or color mapping is done, use d_render_tint for coloring the rectangles.
- DARNIT_RECT *d_render_rect_new(unsigned int rects);
- void d_render_rect_move(DARNIT_RECT *rect_p, unsigned int rect, int x1, int y1, int x2, int y2);
- void d_render_rect_draw(DARNIT_RECT *rect_p, int rects);
- void d_render_rect_get(DARNIT_RECT *buf, unsigned int rect, int *x1, int *y1, int *x2, int *y2);
- DARNIT_RECT *d_render_rect_free(DARNIT_RECT *rect_p);
Various rendering functions that are used for pretty much all kinds of rendering.
- void d_render_begin();
- void d_render_end();
- void d_render_blend_enable();
- void d_render_blend_disable();
- void d_render_tint(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
- void d_render_tint_get(unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a);
- void d_render_clearcolor_set(unsigned char r, unsigned char g, unsigned char b);
- void d_render_offset(int x, int y);
- void d_render_fade_in(unsigned int time, unsigned char r, unsigned char g, unsigned char b);
- void d_render_fade_out(unsigned int time);
- int d_render_fade_status();
- void d_render_state_restore();
- void d_render_tile_blit(DARNIT_TILESHEET *tilesheet, unsigned int tile, int x, int y);
void d_render_logic_op(DARNIT_RENDER_LOGIC_OP logicop);
Selects a logic operation to use when overwriting pixels in the framebuffer. This is a wrapper of glLogicOp.
Arguments
- logicop - The logic operation to use when overwriting pixels in the framebuffer. See DARNIT_RENDER_LOGIC_OP for a list of logic operations available.
Return value None.
DARNIT_TILESHEET *d_render_tilesheet_load(const char *fname, unsigned int wsq, unsigned int hsq, DARNIT_PFORMAT target_format);
Loads a tilesheet from file. The tilesheet can be an image of any of the supported image formats.
Arguments
- fname - Filename of the tilesheet to load
- wsq - The width of each tile. If a tile on the right side of the tilesheet doesn't fit, it is ignored.
- hsq - The height of each tile. If a row of tile doesn't fit at the very bottom, it is ignored.
- target_format - Downsamples the image to the selected bit depth. A 16 bpp format is recommended as they're faster on limited systems.
Return value
Returns NULL on failure. Anything else is a valid DARNIT_TILESHEET.
DARNIT_TILESHEET *d_render_tilesheet_isom_load(const char *fname, unsigned int wsq, unsigned int hsq, DARNIT_PFORMAT target_format);
Loads a tilesheet from file. The tilesheet can be an image of any of the supported image formats. This funnction differs from d_render_tilesheet_load in the way that the tiles are trimmed from the top until a pixel that isn't completely transparent is found. This makes for more efficient rendering when drawing isometric maps as the amount of unrendered pixels are reduced. This makes a difference on low-bandwidth systems.
Arguments
- fname - Filename of the tilesheet to load
- wsq - The width of each tile. If a tile on the right side of the tilesheet doesn't fit, it is ignored.
- hsq - The height of each tile. If a row of tile doesn't fit at the very bottom, it is ignored.
- target_format - Downsamples the image to the selected bit depth. A 16 bpp format is recommended as they're faster on limited systems.
Return value
Returns NULL on failure. Anything else is a valid DARNIT_TILESHEET.
DARNIT_TILESHEET *d_render_tilesheet_new(int tiles_w, int tiles_h, int tile_w, int tile_h, DARNIT_PFORMAT format);
Creates a new blank tilesheet. To fill in pixel data into the tilesheet, use d_render_tilesheet_update.
Arguments
- tiles_w - How many tiles on the width that the tilesheet needs to fit
- tiles_h - How many tiles on the hight that the tilesheet needs to fit
- tile_w - How wide each tile is
- tile_h - How tall each tile is
- format - What pixel format the tilesheet should use
Return value
Returns NULL on failure. Anything else is a valid DARNIT_TILESHEET.
DARNIT_TILESHEET *d_render_tilesheet_free(DARNIT_TILESHEET *tilesheet);
Tries to free a tilesheet. If not successful (tilesheet us used by other resources,) the internal reference counter is decreased and another attempt to unload it will happen next time something using the tilesheet unloads.
Arguments
- tilesheet - The DARNIT_TILESHEET to unload
Return value
Returns NULL if the tilesheet was free'd. If not (in used by other resources,) tilesheet will be returned.
void d_render_tilesheet_update(DARNIT_TILESHEET *tilesheet, int sheet_x, int sheet_y, int change_w, int change_h, void *data);
Updates an area in the tilesheet texture with new texture data found in data. This operation affects everything using the tilesheet, and changes persists until everything that uses the tilesheet is unloaded. data should be in RGBA8 format unless the tilesheet you're updating is RGB0A8. If the tilesheet is in RGB0A8, then you should also upload RGB0A8 data.
Arguments
- tilesheet - The DARNIT_TILESHEET to update
- sheet_x - The X-coordinate in pixels at which the rectangle to update starts. 0 is to the left.
- sheet_y - The Y-coordinate in pixels at which the rectangle to update starts. 0 is at the top.
- change_w - The width of the rectangle to update in pixels.
- change_h - The height of the rectangle to update in pixels.
- data - A memory buffer containing the new pixels to load the tilesheet with. Pixels must be ordered in rows.
Return value None.
void d_render_tilesheet_geometrics(DARNIT_TILESHEET *tilesheet, int *w, int *h, int *tile_w, int *tile_h);
Returns the width and height of a tilesheet, as well as the tile width and height.
Arguments
- tilesheet - The DARNIT_TILESHEET to get information about
- w - The width of the tilesheet in pixels. This pointer can be NULL.
- h - The height of the tilehseet in pixels. This pointer can be NULL.
- tile_w - The width of a tile in pixels. This pointer can be NULL.
- tile_h - The height of a tile in pixels. This pointer can be NULL.
Return value None.
int d_render_tilesheet_animation_apply(DARNIT_TILESHEET *tilesheet, const char *fname);
Applies a TMA to a tilesheet. This animation will affect everything that uses a tilesheet. The animation will persist until the tilesheet is no longer used by anything. Please note that animation does not happen automatically. Once per frame, you need to call d_render_tilesheet_animate.
Arguments
- tilesheet - The DARNIT_TILESHEET to apply the animation to
- fname - The TMA file to apply to tilesheet.
Return value None.
void d_render_tilesheet_animate(DARNIT_TILESHEET *tilesheet);
Runs the animation procedure for a tilesheet.
Arguments
- tilesheet - The DARNIT_TILESHEET to animate
Return value None.
void d_render_tilesheet_scale_algorithm(DARNIT_TILESHEET *tilesheet, DARNIT_RENDER_SCALE scaling);
Sets the scaling algorithm to use for the tilesheet when a tile is stretched.
Arguments
- tilesheet - The tilesheet to change the scaling algorithm for
- scaling - A scaling algorithm from DARNIT_RENDER_SCALE to use
Return value None.
int d_render_texture_get(DARNIT_TILESHEET *tilesheet, int *w, int *h);
Returns the OpenGL texture ID for the given tilesheet, and the width and height of it if the w and h pointers are NON-NUL.
Arguments
- tilesheet - The tilesheet to get size and/or texture ID from
- w - Pointer to the integer that will be set to the texture width in pixels
- h - Pointer to the integer that will be set to the texture height in pixels
Return value
The OpenGL texture ID for this tilesheet.
void d_render_tile_init(DARNIT_TILE *buf, unsigned int tile, unsigned int tile_ts, int x, int y);
Sets the tile number tile in buf to render tile tile_ts from its associated tilesheet. This resets size information to the size of the tile, and positions it on the screen at the coordinates x, y.
Arguments
- buf - The DARNIT_TILE to modify a tile in
- tile - Index of the tile inside the buffer to modify
- tile_ts - Index of the tile in the tilesheet to set the tile buffer tile to
- x - The X-position to place the tile at
- y - The Y-position to place the tile at
Return value none.
void d_render_tile_move(DARNIT_TILE *tile_p, unsigned int tile, int x, int y);
Moves a tile inside a DARNIT_TILE. This will reset its size.
Arguments
- tile_p - The tile cache to modify a tile in
- tile - The tile index in the tile buffer to modify
- x - The X-coordinate to move the tile to
- y - The Y-coordinate to move the tile to
Return value None.
void d_render_tile_tilesheet_coord_set(DARNIT_TILE *tile_p, unsigned int tile, unsigned int x, unsigned int y, unsigned int w, unsigned int h);
Changes the coordinates for a tile on a tilesheet. That is, its position on the screen remains unchanged, but the graphics from the tilesheet is updated. The size of the tile is not updated.
Arguments
- tile_p - The tile buffer to update a tile in
- tile - The tile in the tile buffer to update
- x - The X-position on the tilesheet (in pixels) to use
- y - The Y-position on the tilesheet (in pixels) to use
- w - The width of the area to use when rendering the tile
- h - The height of the area to use when rendering the tile
Return value None.
void d_render_tile_size_set(DARNIT_TILE *buf, unsigned int tile, int w, int h);
Sets the size of a tile in a tile buffer. This can be used to scale a tile, as it doesn't modify tilesheet coordinates.
Arguments
- buf - The tile buffer to modify a tile in
- tile - The tile index in the tile buffer of the tile to modify
- w - The new width of the tile
- h - The new height of the tile
Return value None.
void d_render_tile_set(DARNIT_TILE *tile_p, unsigned int tile, unsigned int tile_ts);
Sets the tilesheet tile that should be rendered by a tile buffer tile. This does not modify the rendered size of a tile.
Arguments
- tile_p - The tile buffer to modify a tile in
- tile - The tile buffer tile index to modify
- tile_ts - The tilesheet tile index to set to the tile buffer tile
Return value None.
void d_render_tile_tilesheet(DARNIT_TILE *tile_p, DARNIT_TILESHEET *tilesheet);
Sets a new tilesheet to a tile cache. This does not update any tilesheet coordinates. If a tilesheet of different size is loaded in, distortion will happen, as coordinates are saved as floats between 0 and 1.
Arguments
- tile_p - The tile buffer to set tilesheet for
- tilesheet - The tilesheet to set
Return value None.
void d_render_tile_clear(DARNIT_TILE *tile_p, unsigned int tile);
Makes a tile in a tile cache invisible, discarding position and tilesheet coordinates.
Arguments
- tile_p - The tile cache to modify a tile in
- tile - The tile index of the tile to clear
Return value None.
void d_render_tile_draw(DARNIT_TILE *tile_p, unsigned int tiles);
Draws tiles from a tile buffer starting from index 0.
Arguments
- tile_p - Tile cache to draw
- tiles - Number of tiles to draw from the tile cache
Return value None.
DARNIT_TILE *d_render_tile_new(unsigned int tiles, DARNIT_TILESHEET *tilesheet);
Allocates a tile cache with room for tiles number of tiles, and sets tilesheet to it.
Arguments
- tiles - The number of tiles to make room for
- tilesheet * The tilesheet to render tiles with
Return value
Returns NULL on failure, anything else is a valid tile cache.
DARNIT_TILE *d_render_tile_free(DARNIT_TILE *tile_p);
Free's a tile cache and returns a NULL-pointer for compact pointer clearing.
Arguments
- tile_p - The tile cache to free
Return value
Returns NULL for compact pointer clearing.
DARNIT_LINE *d_render_line_new(unsigned int lines, unsigned int line_w);
Allocates a buffer for untextured and non-colored lines.
Arguments
- lines - The number of lines to make space for
- line_w - The width of the lines to draw in pixels
Return value
Returns NULL on fauilure, anything else is a valid line buffer.
void d_render_line_move(DARNIT_LINE *line_p, unsigned int line, int x1, int y1, int x2, int y2);
Sets the position to draw the line with index line.
Arguments
- line_p - The line buffer to modify a line in
- line - The line index of the line you want to modify. 0 is the first line.
- x1 - The X-coordinate for where the line starts
- y1 - The Y-coordinate for where the line starts
- x2 - The X-coordinate for where the line ends
- y2 - The Y-coordinate for where the line ends
Return value None.
void d_render_line_draw(DARNIT_LINE *line_p, int lines);
Draws lines number of lines in the line buffer, starting with line 0.
Arguments
- line_p - The line buffer to draw lines from
- lines - The number of lines to draw
Return value None.
void d_render_line_get(DARNIT_LINE *buf, unsigned int line, int *x, int *y, int *x2, int *y2);
Returns an approximation of the coordinates line with index line in the buffer.
Arguments
- buf - The line chache to get a line coordinate from
- line - The line index to get the coordinates of
- x - The X-coordinate of where the line starts will be written here
- y - The Y-coordinate of where the line starts will be written here
- x2 - The X-coordinate of where the line ends will we written here
- y2 - The Y-coordinate of where the line ends will be written here
Return value None.
DARNIT_LINE *d_render_line_free(DARNIT_LINE *line_p);
Frees a line cache and returns a NULL-pointer for compact clearing.
Arguments
- line_p - The line buffer to free
Return value
Returns NULL for compact pointer clearing.
DARNIT_POINT *d_render_point_new(unsigned int points, unsigned int point_w);
Allocates a buffer for untextured and non-colored points.
Arguments
- points - The number of points to make space for
- point_w - The width and height of the points to draw in pixels
Return value
Returns NULL on fauilure, anything else is a valid point buffer.
void d_render_point_move(DARNIT_POINT *point_p, unsigned int point, int x, int y);
Sets the position to draw the point with index point.
Arguments
- point_p - The point buffer to modify a point in
- point - The point index of the point you want to modify. 0 is the first point.
- x - The X-coordinate for the point
- y - The Y-coordinate for the point
Return value None.
void d_render_point_draw(DARNIT_POINT *point_p, int points);
Draws point number of points in the point buffer, starting with point 0.
Arguments
- point_p - The line buffer to draw points from
- points - The number of points to draw
Return value None.
DARNIT_POINT *d_render_point_free(DARNIT_POINT *point_p);
Frees a point cache and returns a NULL-pointer for compact clearing.
Arguments
- point_p - The point buffer to free
Return value
Returns NULL for compact pointer clearing.
DARNIT_CIRCLE *d_render_circle_new(unsigned int lines, unsigned int line_w);
Creates a cache with lines, which are used to approximate a circle.
Arguments
- lines - The number of lines to be used to approximate the circle
- line_w - The pixel-width of the lines that are drawn
Return value
Returns NULL on failure, anything else is a valid DARNIT_CIRCLE.
void d_render_circle_move(DARNIT_CIRCLE *circle_p, int x, int y, int radius);
Moves the center of the circle to the provided coordinates and sets its size.
Arguments
- circle_p - The circle to move
- x - the X-coordinate to move the center to
- y - The Y-coordinate to move the center to
- radius - The radius of the circle
Return value None.
void d_render_circle_draw(DARNIT_CIRCLE *circle_p);
Draws the circle on the screen.
Arguments
- circle_p - The circle to draw
Return value None.
DARNIT_CIRCLE *d_render_circle_free(DARNIT_CIRCLE *circle_p);
Frees a circle and returns a NULL-pointer for compact pointer clearing.
Arguments
- circle_p - The circle to free
Return value
Returns a NULL-pointer for compact pointer clearing.
DARNIT_RECT *d_render_rect_new(unsigned int rects);
Creates a cache for uncolored filled rectangles with space for rects rectangles.
Arguments
- rects - The number of rectangles to make space for
Return value
Returns NULL on failure, anything else is a valid DARNIT_RECT.
void d_render_rect_move(DARNIT_RECT *rect_p, unsigned int rect, int x1, int y1, int x2, int y2);
Moves and resizes a rectangle in a rectangle buffer.
Arguments
- rect_p - The rectangle buffer to move a rectangle in
- rect - The index of the rectangle to move
- x1 - X-coordinate for the first corner
- y1 - Y-coordinate for the first corner
- x2 - X-coordinate for the diagonally opposite corner
- y2 - Y-coordinate for the diagonally opposite corner
Return value None.
void d_render_rect_draw(DARNIT_RECT *rect_p, int rects);
Renders rects rectangles from the rectangle cache, starting at index 0.
Arguments
- rect_p - The rectangle buffer to render from
- rects - The amount of rectangles to render
Return value None.
void d_render_rect_get(DARNIT_RECT *buf, unsigned int rect, int *x1, int *y1, int *x2, int *y2);
Gives you an approximation of the position of a rectangle in a rectangle cache.
Arguments
- buf - The rectangle cache to get the position of a rectangle from
- rect - The rectangle index in the rectangle cache to get coordinates from
- x1 - This is where the first X-coordinate will be written. Set to NULL if you don't want it.
- y1 - This is where the first Y-coordinate will be written. Set to NULL if you don't want it.
- x2 - This is where the diagonally opposite X-coordinate will be written. Set to NULL if you don't want it.
- y2 - This is where the diagonally opposite Y-coordinate will be written. Set to NULL if you don't want it.
Return value None.
DARNIT_RECT *d_render_rect_free(DARNIT_RECT *rect_p);
Frees a DARNIT_RECT and returns a NULL-pointer for compact pointer clearing.
Arguments
- rect_p - The rectangle cache to free
Return value
Returns NULL for compact pointer clearing.
void d_render_begin();
Initialized OpenGL's client state for rendering. Must be called before any rendering can be done. This is a wrapper around glEnableClientState.
Arguments None.
Return value None.
void d_render_end();
Resets OpenGL's client state to not be prepared for rendering. Should probably be done before calling d_loop. This is a wrapper around glDisableClientState.
Arguments None.
Return value None.
void d_render_blend_enable();
Enables blending. Should be kept to a minumum, as blending is very very slow on handheld platforms.
Arguments None.
Return value None.
void d_render_blend_disable();
Disables blending. When blending is disabled, alpha bits are ignored.
Arguments None.
Return value None.
void d_render_tint(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
Tints rendering by reducing the intensity of the rgba color channels induvidually. All values are between 0 and 255. 0 means no color information on that channel, 255 means no reduction in intensity on that color channel. For example, rendering something white, and then tinting to (255, 127, 0, 255) will make it orange (#FF7F00.) This is a wrapper of glColor4b.
The default value is (255, 255, 255, 255).
Arguments
- r - How much intensity to keep for the red color channel
- g - How much intensity to keep for the green color channel
- b - How much intensity to keep for the blue color channel
- a - How much intensity to keep for the alpha channel
Return value None.
void d_render_tint_get(unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a);
Sets r, g, b and a to the color channel preservation values used. A pointer can be NULL if you don't wish to know about that color channel.
Arguments
- r - Tinting value for red color channel
- g - Tinting value for green color channel
- b - Tinting value for blue color channel
- a - Tinting value for alpha channel
Return value None.
void d_render_clearcolor_set(unsigned char r, unsigned char g, unsigned char b);
Set the default color for pixels that has not had anything rendered on them. This is a wrapper for glClearColor. Default is (0, 0, 0,) black.
Argument
- r - Color value for the red channel
- g - Color value for the green channel
- b - Color value for the blue channel
Return value None.
void d_render_offset(int x, int y);
Offsets all rendering done after being called by adding x and y to all coordinates. Some rendering functions like text doesn't support changing coordinates after their caches has been created, so this is the only way to move such objects around. x and y are absolute and does not add to previous calls.
Arguments
- x - The amount to add to all X coordinates
- y - The amount to add to all Y coordinates
Return value None.
void d_render_fade_in(unsigned int time, unsigned char r, unsigned char g, unsigned char b);
Fades in to a solid color.
Argument
- time - Number of milliseconds it should take to fade in completely to the provided color
- r - The red channel of the color to fade in to
- g - The green channel of the color to fade in to
- b - The blue channel of the color to fade in to
Return value None.
void d_render_fade_out(unsigned int time);
Fades out from a previous d_render_fade_out call.
Arguments
- time - The number of milliseconds it should take to fade out completely from a solid color.
Return value None.
int d_render_fade_status();
Returns the status of the fade progress
Arguments None.
Return value
- 0 - No fading in progress
- 1 - Currently fading in to a solid color
- 2 - Completely faded in to a solid color
- -1 - Currently fading out from a solid color
void d_render_state_restore();
The idea is that this function will restore the last libDarnit state after any user-runned OpenGL code has poked the state of OpenGL. This function is not completely implemented yet and will probably not work as expected.
Arguments None.
Return value None.
void d_render_tile_blit(DARNIT_TILESHEET *tilesheet, unsigned int tile, int x, int y);
The use of this function is discouraged as in tends to lead to slow code. Use it only for quick prototypes or when you got like one tile to render that moves every frame anyway.
Render a tile at the provided coordinates.
Arguments
- tilesheet - The tilesheet to render a tile from
- tile - The tile index on the tilesheet to render
- x - The X-coordinate to render at
- y - The Y-coordinate to render at
Return value None.