SHARE
TWEET

Untitled

a guest Feb 18th, 2020 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*===============================================================================================
  2. // Platform API Struct
  3. ===============================================================================================*/
  4.  
  5. // General API for platform
  6. typedef struct gs_platform_i
  7. {
  8.     /*============================================================
  9.     // Platform Initilization / De-Initialization
  10.     ============================================================*/
  11.     gs_result ( * gs_platform_init )();
  12.     gs_result ( * gs_platform_shutdown )();
  13.  
  14.     /*============================================================
  15.     // Platform Util
  16.     ============================================================*/
  17.     u32     ( * gs_platform_ticks )();
  18.     void    ( * gs_platform_delay )( u32 ticks );
  19.  
  20.     /*============================================================
  21.     // Platform UUID
  22.     ============================================================*/
  23.     struct gs_uuid  ( * gs_platform_generate_uuid )();
  24.     void            ( * gs_uuid_to_string )( char* temp_buffer, const struct gs_uuid* uuid ); // Expects a temp buffer with at leat 32 bytes
  25.     u32             ( * gs_hash_uuid )( const struct gs_uuid* uuid );
  26.  
  27.     /*============================================================
  28.     // Platform Input
  29.     ============================================================*/
  30.     struct gs_platform_input* ( * gs_platform_create_input )();
  31.     gs_result ( * gs_platform_process_input )( struct gs_platform_input* input );
  32.  
  33.     b32 ( * gs_platform_key_pressed )( struct gs_platform_input* input, gs_platform_keycode code );
  34.     b32 ( * gs_platform_key_down )( struct gs_platform_input* input, gs_platform_keycode code );
  35.     b32 ( * gs_platform_key_released )( struct gs_platform_input* input, gs_platform_keycode code );
  36.  
  37.     b32 ( * gs_platform_mouse_pressed )( struct gs_platform_input* input, gs_mouse_button_code code );
  38.     b32 ( * gs_platform_mouse_down )( struct gs_platform_input* input, gs_mouse_button_code code );
  39.     b32 ( * gs_platform_mouse_released )( struct gs_platform_input* input, gs_mouse_button_code code );
  40.  
  41.     gs_vec2 ( * gs_platform_mouse_delta )( struct gs_platform_input* input );
  42.     gs_vec2 ( * gs_platform_mouse_position )( struct gs_platform_input* input );
  43.     void ( * gs_platform_mouse_position_f32 )( struct gs_platform_input* input, f32* x, f32* y );
  44.     void ( * gs_platform_mouse_wheel )( struct gs_platform_input* input, f32* x, f32* y );
  45.  
  46.     void ( * gs_platform_press_key )( struct gs_platform_input* input, gs_platform_keycode code );
  47.     void ( * gs_platform_release_key )( struct gs_platform_input* input, gs_platform_keycode code );
  48.  
  49.     /*============================================================
  50.     // Platform Window
  51.     ============================================================*/
  52.     struct gs_platform_window*  ( * gs_platform_create_window )( const char* title, u32 width, u32 height );
  53.     void                        ( * gs_platform_window_swap_buffer )( struct gs_platform_window* win );
  54.     gs_vec2                     ( * gs_platform_window_size )( struct gs_platform_window* win );
  55.     void                        ( * gs_platform_window_width_height )( struct gs_platform_window* win, s32* width, s32* height );
  56.     void                        ( * gs_platform_set_cursor )( struct gs_platform_window* win, gs_platform_cursor cursor );
  57.  
  58.     /*============================================================
  59.     // Platform File IO
  60.     ============================================================*/
  61.  
  62.     // Will return a null buffer if file does not exist or allocation fails
  63.     char*       gs_read_file_contents_into_string_null_term (const char* file_path, const char* mode, usize* sz );
  64.     gs_result   gs_write_str_to_file (const char* contents, const char* mode, usize sz, const char* output_path );
  65.  
  66. } gs_platform_i;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top