Ylva And Malin
ym_gfx_sprite.h
Go to the documentation of this file.
1 #pragma once
2 #include <ym_core.h>
3 #include <ym_memory.h>
4 #include <ym_gfx_gl.h>
5 
8 ym_gfx_load_png(const char* filename,
9  u8** out_image,
10  int* out_width,
11  int* out_height);
12 
13 typedef GLuint ym_sheet_id;
14 typedef GLuint ym_sprite_id;
15 
16 // Initialize all needed functionality for drawing sprites,
17 // Setup vbo, ibo, vao, shaders, texture_coordinates, etc.
19 ym_errc
20 ym_sprite_init(ym_mem_region* memory_region,
21  ym_gfx_window* window);
22 
24 ym_errc
26 
27 // Need to figure out how we can do allocations here,
28 // Do we need to support complex deallocations,
29 // or can we just force the loading of sprite sheets so that
30 //
32 ym_errc
33 ym_sprite_load_sheet(const char* filename,
34  uint col_count,
35  uint row_count,
36  ym_sheet_id* out_sheet_id);
37 
39 ym_errc
41 
42 // Think if this should be done async, i.e. just add to some
43 // sort of draw container/queue.
44 // Cannot be a straight queue, as we need to keep layering information
45 // need to keep the container sorted on layering somehow.
46 // Should also be sorted as much as possible on the sheet_id and sprite_id as well,
47 // so that we don't need to do so many uniform calls.
49 // This can actually be done async, in that case it is best if we also supply a present layer
50 // function, so I can decide layering and when they should be drawn, that way I can basically
51 // do my own buffering solutions.
52 ym_errc
54  ym_sprite_id sprite_id,
55  uint layer,
56  ym_vec2 pos);
57 
59 ym_errc
61  ym_sprite_id sprite_id,
62  uint layer,
63  ym_vec2 pos,
64  ym_vec2 scale,
65  float angle);
66 
67 // Will be used so we can start drawing async. As soon as this command is run,
68 // The render thread will start drawing this layer in the background if possible.
69 // Think about if this is really a good idea.
70 ym_errc
72 
73 void
YM_NO_DISCARD ym_errc ym_sprite_delete_sheet(ym_sheet_id sheet_id)
Definition: ym_gfx_sprite.c:263
YM_NO_DISCARD ym_errc ym_gfx_load_png(const char *filename, u8 **out_image, int *out_width, int *out_height)
PNG loading.
Definition: ym_gfx_sprite.c:84
void ym_sprite_set_camera_pos(ym_vec3 camera_pos)
Definition: ym_gfx_sprite.c:365
Definition: ym_math.h:8
#define YM_NO_DISCARD
YM_NO_DISCARD is a platform independent macro informing the compiler to warn if a return value from a...
Definition: ym_attributes.h:94
YM_NO_DISCARD ym_errc ym_sprite_shutdown()
Definition: ym_gfx_sprite.c:228
Definition: ym_memory.h:8
ym_errc ym_sprite_draw(ym_sheet_id sheet_id, ym_sprite_id sprite_id, uint layer, ym_vec2 pos)
Definition: ym_gfx_sprite.c:272
YM_NO_DISCARD ym_errc ym_sprite_load_sheet(const char *filename, uint col_count, uint row_count, ym_sheet_id *out_sheet_id)
Definition: ym_gfx_sprite.c:245
ym_errc
Used to indicate erroneous behavior within a a function.
Definition: ym_error.h:36
ym_errc ym_sprite_commit_layer(uint layer)
GLuint ym_sheet_id
Definition: ym_gfx_sprite.h:13
YM_NO_DISCARD ym_errc ym_sprite_init(ym_mem_region *memory_region, ym_gfx_window *window)
ym_sprite API implementation
Definition: ym_gfx_sprite.c:116
Definition: ym_math.h:14
ym_errc ym_sprite_draw_extd(ym_sheet_id sheet_id, ym_sprite_id sprite_id, uint layer, ym_vec2 pos, ym_vec2 scale, float angle)
Definition: ym_gfx_sprite.c:305
GLuint ym_sprite_id
Definition: ym_gfx_sprite.h:14
void ym_gfx_window
Simple typedef for void, as no direct handling of the window is legal.
Definition: ym_gfx.h:22
unsigned uint
Definition: ym_types.h:22
uint8_t u8
Definition: ym_types.h:8