ohsp

Prototype for a game with dual thruster controls.
git clone git://git.amin.space/ohsp.git
Log | Files | Refs | LICENSE

platform_sdl.h (1084B)


      1 #ifndef PLATFORM_SDL_H
      2 
      3 #include <SDL2/SDL.h>
      4 #include "game.h"
      5 
      6 #include <stdbool.h>
      7 
      8 #define GAME_LIB_PATH "./release/game.so"
      9 #define MAX_CONTROLLERS 4
     10 #define DEADZONE_THRESHOLD 9000
     11 #define INPUT_RECORD_SIZE (UPDATES_PER_SECOND * 10) // 10 seconds of input frames
     12 
     13 struct SDLOffscreenBuffer
     14 {
     15     // NOTE(amin): pixels are always 32-bits wide. Memory order: BB GG RR XX.
     16     SDL_Texture *texture;
     17     void *memory;
     18     unsigned int width;
     19     unsigned int height;
     20     unsigned int pitch;
     21 };
     22 
     23 struct SDLWindowDimension
     24 {
     25     int width;
     26     int height;
     27 };
     28 
     29 struct SDLGameCode
     30 {
     31     bool is_valid;
     32     void *game_code_library;
     33     time_t last_write_time;
     34     game_update_t *game_update;
     35     game_render_t *game_render;
     36 };
     37 
     38 enum SDLInputRecordState
     39 {
     40     INACTIVE,
     41     RECORDING,
     42     PLAYING_BACK,
     43 };
     44 
     45 struct SDLInputRecord
     46 {
     47     struct GameControllerInput input_buffer[INPUT_RECORD_SIZE];
     48     struct GameState initial_state;
     49     uint64_t record_head;
     50     uint64_t playback_head;
     51     enum SDLInputRecordState state;
     52     bool initial_state_recorded;
     53 };
     54 
     55 #define PLATFORM_SDL_H
     56 #endif