2024-07-29 10:20:11 +00:00
|
|
|
#ifndef RENDERING_INTERNAL_API_H
|
|
|
|
#define RENDERING_INTERNAL_API_H
|
2024-07-14 13:04:12 +00:00
|
|
|
#include "../textures.h"
|
2024-07-08 00:44:20 +00:00
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
#include <SDL2/SDL.h>
|
2024-07-10 16:15:28 +00:00
|
|
|
#include <glad/glad.h>
|
2024-07-08 00:44:20 +00:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
struct sprite_primitive {
|
|
|
|
t_frect rect;
|
|
|
|
t_color color;
|
2024-07-27 12:10:19 +00:00
|
|
|
float rotation;
|
2024-07-14 13:04:12 +00:00
|
|
|
t_texture_key texture_key;
|
2024-07-08 00:44:20 +00:00
|
|
|
bool flip_x;
|
|
|
|
bool flip_y;
|
2024-07-27 12:10:19 +00:00
|
|
|
};
|
|
|
|
|
2024-07-08 00:44:20 +00:00
|
|
|
struct rect_primitive {
|
|
|
|
t_frect rect;
|
|
|
|
t_color color;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct circle_primitive {
|
|
|
|
float radius;
|
|
|
|
t_color color;
|
|
|
|
t_fvec2 position;
|
|
|
|
};
|
|
|
|
|
2024-07-16 02:31:54 +00:00
|
|
|
enum primitive_2d_type {
|
|
|
|
PRIMITIVE_2D_SPRITE,
|
|
|
|
PRIMITIVE_2D_RECT,
|
|
|
|
PRIMITIVE_2D_CIRCLE,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct primitive_2d {
|
|
|
|
enum primitive_2d_type type;
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct sprite_primitive sprite;
|
|
|
|
struct rect_primitive rect;
|
|
|
|
struct circle_primitive circle;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-14 13:04:12 +00:00
|
|
|
/* union for in-place recalculation of texture coordinates */
|
|
|
|
union uncolored_space_triangle {
|
|
|
|
/* pending for sending, uvs are not final as texture atlases could update */
|
|
|
|
struct uncolored_space_triangle_primitive {
|
|
|
|
t_fvec3 v0;
|
|
|
|
t_fvec2 uv0; /* in pixels */
|
|
|
|
t_fvec3 v1;
|
|
|
|
t_fvec2 uv1; /* in pixels */
|
|
|
|
t_fvec3 v2;
|
|
|
|
t_fvec2 uv2; /* in pixels */
|
|
|
|
} primitive;
|
|
|
|
|
|
|
|
/* structure that is passed in opengl vertex array */
|
|
|
|
struct uncolored_space_triangle_payload {
|
|
|
|
t_fvec3 v0;
|
|
|
|
t_fvec2 uv0;
|
|
|
|
t_fvec3 v1;
|
|
|
|
t_fvec2 uv1;
|
|
|
|
t_fvec3 v2;
|
|
|
|
t_fvec2 uv2;
|
|
|
|
} payload;
|
|
|
|
};
|
|
|
|
|
2024-07-10 16:15:28 +00:00
|
|
|
/* batch of primitives with overlapping properties */
|
|
|
|
struct mesh_batch {
|
2024-07-14 13:04:12 +00:00
|
|
|
GLuint buffer; /* server side storage */
|
|
|
|
uint8_t *primitives;
|
2024-07-10 16:15:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mesh_batch_item {
|
2024-07-14 13:04:12 +00:00
|
|
|
t_texture_key key;
|
2024-07-10 16:15:28 +00:00
|
|
|
struct mesh_batch value;
|
|
|
|
};
|
|
|
|
|
2024-07-08 00:44:20 +00:00
|
|
|
#endif
|