Skip to content
slaeshjag edited this page Mar 31, 2013 · 31 revisions

DARNIT_RENDER_LOGIC_OP

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);

DARNIT_RENDER_SCALE

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;

DARNIT_TILESHEET

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);
  • 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);
  • DARNIT_TILESHEET *d_render_tilesheet_free(DARNIT_TILESHEET *tilesheet);
  • 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);

DARNIT_TILE

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);

DARNIT_LINE

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

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_RECT

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);

DARNIT_RENDER

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(void *tilesheet, unsigned int tile, int x, int y);

d_render_logic_op

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.

d_render_tilesheet_load

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.

d_render_tilesheet_new

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.

Clone this wiki locally