#ifndef SCUFENG_SHAPE_H_ #define SCUFENG_SHAPE_H_ #include #include #include "cglm/types.h" typedef enum { SE_TRIANGLES, SE_TRIANGLE_STRIP, SE_TRIANGLE_FAN, SE_LINES, SE_LINE_STRIP } SEDrawMode; typedef struct { vec3 pos; vec3 scale; vec3 rotation; } SETransform; typedef struct { float pos[3]; float tex_coords[2]; } SEVertex; typedef enum { SE_MESH_COLOR, SE_MESH_TEXTURE } SEMeshType; typedef struct { unsigned int id; float w; float h; } SEMeshTexture; typedef struct { unsigned int vao; unsigned int vbo; size_t verts_n; int draw_mode; SETransform transform; SEMeshType type; union { SEMeshTexture texture; vec4 color; }; } SEMesh; void SEMesh_free(SEMesh *const mesh); void SEMesh_set_draw_mode(SEMesh *mesh, const SEDrawMode mode); void SEMesh_render(const SEMesh *const mesh); void SEMesh_color_set(SEMesh *const mesh, const vec4 color); void SEMesh_rect_dims_get(const SEMesh *const mesh, vec2 dims); void SEMesh_scale_set_to_texture_size(SEMesh *const mesh); /** Set x or y to 0 to automatically calculate that value based on the w/h ratio of the rect's texture. Setting both to 0 will result in scale being { 0, 0 }. */ void SEMesh_rect_textured_scale_set(SEMesh *const mesh, float x, float y); void SEMesh_line_segment_coords_set(SEMesh *const mesh, const vec2 a, const vec2 b); SEMesh SEMesh_line_segment_color_alloc(const vec2 a, const vec2 b, const vec4 color); void SEMesh_bbox_render_2d(const SEMesh *const mesh); void SEMesh_bbox_get_2d( const SEMesh *const mesh, float *const left, float *const top, float *const right, float *const bottom ); /** @param bbox Returns the bbox in order: { left, top, right, bottom }. */ void SEMesh_bbox_get_2d_v(const SEMesh *const mesh, vec4 bbox); bool SEMesh_rect_is_pos_inside(const SEMesh *const mesh, const float x, const float y); SEMesh SEMesh_rect_color_alloc(vec4 color); SEMesh SEMesh_string_alloc( const char *text, const vec3 color ); void SEMesh_render_multiple_2d(SEMesh *const *const meshes, const size_t meshes_n); #endif // SCUFENG_SHAPE_H_