2024-09-16 06:07:01 +00:00
|
|
|
#ifndef TWN_RENDERING_H
|
|
|
|
#define TWN_RENDERING_H
|
2024-07-08 00:44:20 +00:00
|
|
|
|
2024-09-16 13:17:00 +00:00
|
|
|
#include "twn_util.h"
|
|
|
|
#include "twn_option.h"
|
|
|
|
#include "twn_camera.h"
|
2024-08-26 21:33:37 +00:00
|
|
|
#include "twn_engine_api.h"
|
2024-07-08 00:44:20 +00:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2024-09-23 17:43:16 +00:00
|
|
|
typedef struct PushSpriteArgs {
|
2024-07-08 00:44:20 +00:00
|
|
|
char *path;
|
2024-09-23 17:43:16 +00:00
|
|
|
Rect rect;
|
2024-07-30 12:30:35 +00:00
|
|
|
|
|
|
|
m_option_list(
|
2024-10-01 17:52:19 +00:00
|
|
|
Rect, texture_region,
|
|
|
|
Color, color,
|
2024-07-30 12:30:35 +00:00
|
|
|
float, rotation,
|
|
|
|
bool, flip_x,
|
2024-07-31 21:23:32 +00:00
|
|
|
bool, flip_y,
|
2024-07-31 22:25:23 +00:00
|
|
|
bool, stretch )
|
2024-09-23 17:43:16 +00:00
|
|
|
} PushSpriteArgs;
|
2024-07-08 00:44:20 +00:00
|
|
|
|
|
|
|
/* pushes a sprite onto the sprite render queue */
|
|
|
|
/* this is a simplified version of push_sprite_ex for the most common case. */
|
2024-07-30 12:30:35 +00:00
|
|
|
/* it assumes you want no color modulation, no rotation, no flip */
|
2024-09-23 17:43:16 +00:00
|
|
|
TWN_API void push_sprite(PushSpriteArgs args);
|
|
|
|
#define m_sprite(...) (push_sprite((PushSpriteArgs){__VA_ARGS__}))
|
2024-07-08 00:44:20 +00:00
|
|
|
|
|
|
|
/* pushes a filled rectangle onto the rectangle render queue */
|
2024-09-23 17:43:16 +00:00
|
|
|
TWN_API void push_rectangle(Rect rect, Color color);
|
2024-07-08 00:44:20 +00:00
|
|
|
|
|
|
|
/* pushes a filled circle onto the circle render queue */
|
2024-09-23 17:43:16 +00:00
|
|
|
TWN_API void push_circle(Vec2 position, float radius, Color color);
|
2024-07-08 00:44:20 +00:00
|
|
|
|
2024-10-07 09:32:06 +00:00
|
|
|
TWN_API void push_text(char *string, Vec2 position, int height_px, Color color, const char *font);
|
|
|
|
TWN_API int text_get_width(char *string, int height_px, const char *font);
|
2024-08-23 02:41:52 +00:00
|
|
|
|
2024-10-02 17:18:07 +00:00
|
|
|
TWN_API void push_9slice(char *texture_path, int texture_w, int texture_h, int border_thickness, Rect rect, Color color);
|
|
|
|
|
2024-07-10 16:15:28 +00:00
|
|
|
/* pushes a textured 3d triangle onto the render queue */
|
|
|
|
/* vertices are in absolute coordinates, relative to world origin */
|
|
|
|
/* texture coordinates are in pixels */
|
2024-08-26 21:33:37 +00:00
|
|
|
TWN_API void unfurl_triangle(const char *path,
|
2024-09-23 17:43:16 +00:00
|
|
|
Vec3 v0,
|
|
|
|
Vec3 v1,
|
|
|
|
Vec3 v2,
|
2024-10-01 17:52:19 +00:00
|
|
|
Vec2 uv0,
|
|
|
|
Vec2 uv1,
|
|
|
|
Vec2 uv2);
|
2024-07-10 16:15:28 +00:00
|
|
|
|
2024-09-16 06:07:01 +00:00
|
|
|
// TODO: decide whether it's needed to begin with?
|
|
|
|
// intended usage for it is baked lighting, i would think.
|
2024-07-10 16:15:28 +00:00
|
|
|
/* pushes a colored textured 3d triangle onto the render queue */
|
|
|
|
// void unfurl_colored_triangle(const char *path,
|
2024-09-23 17:43:16 +00:00
|
|
|
// Vec3 v0,
|
|
|
|
// Vec3 v1,
|
|
|
|
// Vec3 v2,
|
|
|
|
// Vec2sh uv0,
|
|
|
|
// Vec2sh uv1,
|
|
|
|
// Vec2sh uv2,
|
|
|
|
// Color c0,
|
|
|
|
// Color c1,
|
|
|
|
// Color c2);
|
2024-07-10 16:15:28 +00:00
|
|
|
|
2024-07-14 16:18:10 +00:00
|
|
|
// TODO:
|
2024-07-10 16:15:28 +00:00
|
|
|
// http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat2
|
2024-07-14 16:18:10 +00:00
|
|
|
// void unfurl_billboard(const char *path,
|
2024-09-23 17:43:16 +00:00
|
|
|
// Vec2 position,
|
|
|
|
// Vec2 scaling,
|
|
|
|
// Rect uvs);
|
2024-07-10 16:15:28 +00:00
|
|
|
|
2024-07-29 12:21:39 +00:00
|
|
|
/* pushes a camera state to be used for all future unfurl_* commands */
|
2024-09-23 17:43:16 +00:00
|
|
|
TWN_API void set_camera(const Camera *camera);
|
2024-07-29 12:21:39 +00:00
|
|
|
|
2024-09-26 18:02:56 +00:00
|
|
|
/* expects '*' masks that will be expanded to 6 names: 'up', 'down', 'east', 'west', 'north' and 'south' */
|
|
|
|
TWN_API void push_skybox(const char *paths);
|
|
|
|
|
2024-10-01 13:10:36 +00:00
|
|
|
TWN_API void push_fog(float start, float end, float density, Color color);
|
|
|
|
|
2024-07-08 00:44:20 +00:00
|
|
|
#endif
|