From 34593e070196d2419038d7038b5adec24d1139ef Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 10 Apr 2023 16:57:59 +0200 Subject: [PATCH] added comments to render-related structs --- src/corelib/render.h | 53 ++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/corelib/render.h b/src/corelib/render.h index 73e117e..4f5006f 100644 --- a/src/corelib/render.h +++ b/src/corelib/render.h @@ -20,41 +20,46 @@ typedef enum drawcmdtype_t { typedef struct spritesheet_t { SDL_Texture* texture; - int w, h; - int tile_width, tile_height; -} spritesheet_t; + int w, h; // width and height of texture + int tile_width, tile_height; // the width and height of each tile of each +} spritesheet_t; // sliced up sheet of sprites + +typedef struct nineslice_t { + SDL_Texture* texture; + float corner_height, corner_width; // the width and height of the corners +} nineslice_t; // nine-sliced texture for ui typedef struct sprite_t { SDL_Texture* texture; - float x, y; - SDL_FPoint origin; - float sx, sy; - float rot; - depth_t depth; - SDL_Rect uv; -} sprite_t; + float x, y; // positions of x,y + SDL_FPoint origin; // the origin point on the sprite + float sx, sy; // the x and y scale of the sprite + float rot; // rotation around origin of the sprite + depth_t depth; // depth to render at, lower is on top, higher is on bottom + SDL_Rect uv; // the source rect to render from the texture +} sprite_t; // a drawable and transformable texture sprite typedef struct rectshape_t { - float x, y, w, h; - float line_width; - int depth; - SDL_Color background; - SDL_Color line; -} rectshape_t; + float x, y, w, h; // the top-left, width and height of a rect + float line_width; // the width of the lines + int depth; // the depth to render at, lower is on top, higher is on bottom + SDL_Color background; // the colour of the background + SDL_Color line; // the colour of the line +} rectshape_t; // a drawable rectangle with outline and background typedef struct drawcmd_t { - drawcmdtype_t type; - depth_t depth; - short ui; + drawcmdtype_t type; // the thing to render + depth_t depth; // the depth to render at + short ui; // 0 if this should be rendered in world space, 1 if this should be rendered in ui space union { - sprite_t sprite; - rectshape_t rect; + sprite_t sprite; // if type is sprite, render this + rectshape_t rect; // if type is rect, render this }; -} drawcmd_t; +} drawcmd_t; // an orderable command to render, should not be directly used, use draw_* functions instead typedef struct view_t { - float x, y; - float width; + float x, y; // the x,y position of the centre of the screen + float width; // the width of the camera } view_t; extern int _render_mode;