townengine/include/twn_draw.h

110 lines
4.0 KiB
C
Raw Normal View History

2024-10-07 14:53:09 +00:00
#ifndef TWN_DRAW_H
#define TWN_DRAW_H
#include "twn_types.h"
2024-10-07 14:53:09 +00:00
#include "twn_option.h"
#include "twn_camera.h"
#include "twn_engine_api.h"
#include <stdbool.h>
/* pushes a sprite onto the sprite render queue */
TWN_API void draw_sprite(char const *path,
Rect rect,
Rect const *texture_region, /* optional, default: NULL */
Color color, /* optional, default: all 255 */
float rotation, /* optional, default: 0 */
bool flip_x, /* optional, default: false */
bool flip_y, /* optional, default: false */
bool stretch); /* optional, default: false */
/* pushes a filled rectangle onto the rectangle render queue */
TWN_API void draw_rectangle(Rect rect, Color color);
/* pushes a filled circle onto the circle render queue */
TWN_API void draw_circle(Vec2 position, float radius, Color color);
/* TODO: have font optional, with something minimal coming embedded */
TWN_API void draw_text(char const *string,
Vec2 position,
int height_px, /* optional, default: 22 */
Color color, /* optional, default: all 0 */
char const *font);
TWN_API int draw_text_width(char const *string,
int height_px, /* TODO: make optional */
char const *font);
TWN_API void draw_9slice(char const *texture_path,
int texture_w,
int texture_h,
int border_thickness,
Rect rect,
Color color); /* TODO: make optional */
/* pushes a textured 3d triangle onto the render queue */
/* vertices are in absolute coordinates, relative to world origin */
/* texture coordinates are in pixels */
TWN_API void draw_triangle(char const *path,
Vec3 v0,
Vec3 v1,
Vec3 v2,
Vec2 uv0,
Vec2 uv1,
Vec2 uv2);
// TODO: decide whether it's needed to begin with?
// intended usage for it is baked lighting, i would think.
/* pushes a colored textured 3d triangle onto the render queue */
// void unfurl_colored_triangle(const char *path,
// Vec3 v0,
// Vec3 v1,
// Vec3 v2,
// Vec2sh uv0,
// Vec2sh uv1,
// Vec2sh uv2,
// Color c0,
// Color c1,
// Color c2);
// TODO:
// http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat2
// void unfurl_billboard(const char *path,
// Vec2 position,
// Vec2 scaling,
// Rect uvs);
/* pushes a camera state to be used for all future unfurl_* commands */
TWN_API void draw_camera(const Camera *camera);
/* expects '*' masks that will be expanded to 6 names: 'up', 'down', 'east', 'west', 'north' and 'south' */
TWN_API void draw_skybox(const char *paths);
TWN_API void draw_fog(float start, float end, float density, Color color);
#ifndef TWN_NOT_C
typedef struct DrawSpriteArgs {
char const *path;
Rect rect;
m_option_list(
Rect, texture_region,
Color, color,
float, rotation,
bool, flip_x,
bool, flip_y,
bool, stretch )
} DrawSpriteArgs;
TWN_API void draw_sprite_args(DrawSpriteArgs args);
#define m_sprite(...) (draw_sprite_args((DrawSpriteArgs){__VA_ARGS__}))
/* TODO: define more */
#endif /* TWN_NOT_C */
#endif