2024-07-08 00:44:20 +00:00
|
|
|
#ifndef RENDERING_H
|
|
|
|
#define RENDERING_H
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
typedef struct push_sprite_args {
|
|
|
|
char *path;
|
|
|
|
t_color color;
|
|
|
|
double rotation;
|
|
|
|
SDL_BlendMode blend_mode;
|
|
|
|
bool flip_x;
|
|
|
|
bool flip_y;
|
|
|
|
} t_push_sprite_args;
|
|
|
|
|
|
|
|
/* clears all render queues */
|
|
|
|
void render_queue_clear(void);
|
|
|
|
|
|
|
|
/* 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, layer 0, and alpha blending */
|
|
|
|
void push_sprite(char *path, t_frect rect);
|
|
|
|
|
|
|
|
/* pushes a sprite onto the sprite render queue */
|
|
|
|
/* note that if args is zeroed out, the color will be transparent black */
|
|
|
|
void push_sprite_ex(t_frect rect, t_push_sprite_args args);
|
|
|
|
|
|
|
|
/* pushes a filled rectangle onto the rectangle render queue */
|
|
|
|
void push_rectangle(t_frect rect, t_color color);
|
|
|
|
|
|
|
|
/* pushes a filled circle onto the circle render queue */
|
|
|
|
void push_circle(t_fvec2 position, float radius, t_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 */
|
|
|
|
void unfurl_triangle(const char *path,
|
|
|
|
t_fvec3 v0,
|
|
|
|
t_fvec3 v1,
|
|
|
|
t_fvec3 v2,
|
|
|
|
t_shvec2 uv0,
|
|
|
|
t_shvec2 uv1,
|
|
|
|
t_shvec2 uv2);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
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,
|
|
|
|
// t_fvec3 position,
|
|
|
|
// t_fvec2 scaling,
|
|
|
|
// t_frect uvs);
|
2024-07-10 16:15:28 +00:00
|
|
|
|
2024-07-08 00:44:20 +00:00
|
|
|
/* renders the background, then the primitives in all render queues */
|
|
|
|
void render(void);
|
|
|
|
|
|
|
|
#endif
|