77 lines
2.6 KiB
C
77 lines
2.6 KiB
C
#ifndef TWN_RENDERING_H
|
|
#define TWN_RENDERING_H
|
|
|
|
#include "util.h"
|
|
#include "macros/option.h"
|
|
#include "camera.h"
|
|
#include "twn_engine_api.h"
|
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
typedef struct push_sprite_args {
|
|
char *path;
|
|
t_frect rect;
|
|
|
|
m_option_list(
|
|
t_fvec2, texture_origin,
|
|
t_color, color,
|
|
float, rotation,
|
|
bool, flip_x,
|
|
bool, flip_y,
|
|
bool, stretch )
|
|
} t_push_sprite_args;
|
|
|
|
/* pushes a sprite onto the sprite render queue */
|
|
/* this is a simplified version of push_sprite_ex for the most common case. */
|
|
/* it assumes you want no color modulation, no rotation, no flip */
|
|
TWN_API void push_sprite(t_push_sprite_args args);
|
|
#define m_sprite(...) (push_sprite((t_push_sprite_args){__VA_ARGS__}))
|
|
|
|
/* pushes a filled rectangle onto the rectangle render queue */
|
|
TWN_API void push_rectangle(t_frect rect, t_color color);
|
|
|
|
/* pushes a filled circle onto the circle render queue */
|
|
TWN_API void push_circle(t_fvec2 position, float radius, t_color color);
|
|
|
|
TWN_API void push_text(char *string, t_fvec2 position, int height_px, t_color color, const char *font_path);
|
|
TWN_API int get_text_width(char *string, int height_px, const char *font_path);
|
|
|
|
/* 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 unfurl_triangle(const char *path,
|
|
t_fvec3 v0,
|
|
t_fvec3 v1,
|
|
t_fvec3 v2,
|
|
t_shvec2 uv0,
|
|
t_shvec2 uv1,
|
|
t_shvec2 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,
|
|
// t_fvec3 v0,
|
|
// t_fvec3 v1,
|
|
// t_fvec3 v2,
|
|
// t_shvec2 uv0,
|
|
// t_shvec2 uv1,
|
|
// t_shvec2 uv2,
|
|
// t_color c0,
|
|
// t_color c1,
|
|
// t_color c2);
|
|
|
|
// TODO:
|
|
// http://www.lighthouse3d.com/opengl/billboarding/index.php?billCheat2
|
|
// void unfurl_billboard(const char *path,
|
|
// t_fvec3 position,
|
|
// t_fvec2 scaling,
|
|
// t_frect uvs);
|
|
|
|
/* pushes a camera state to be used for all future unfurl_* commands */
|
|
TWN_API void set_camera(const t_camera *camera);
|
|
|
|
#endif
|