-
Notifications
You must be signed in to change notification settings - Fork 0
/
win32sdl_platform.h
101 lines (80 loc) · 1.95 KB
/
win32sdl_platform.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//
// Created by doug on 4/16/15.
//
#ifndef PHYSICA_SDL_PLATFORM_H
#define PHYSICA_SDL_PLATFORM_H
#include "gl/glew.h"
#include "gl/glu.h"
enum gamepad_buttons {
BUTTON_A = 0,
BUTTON_B = 1,
BUTTON_X = 2,
BUTTON_Y = 3,
BUTTON_L_BUMPER = 4,
BUTTON_R_BUMPER = 5,
BUTTON_L_STICK = 9,
BUTTON_R_STICK = 10,
};
enum gamepad_axes {
L_STICK_X = 0,
L_STICK_Y = 1,
L_TRIGGER = 2,
R_STICK_X = 3,
R_STICK_Y = 4,
R_TRIGGER = 5
};
struct offscreen_buffer_
{
void *memory;
int width;
int height;
int pitch;
int bytes_per_pixel;
};
struct basic_program_ {
GLuint id, vao, ellipse_outline_vao, vbo, ibo;
GLint transform_loc, color_loc, vertex_modelspace_loc;
i32 ellipse_ibo_count;
};
struct texture_program_ {
GLuint id, vao, vbo, uv_vbo, ibo;
GLint transform_loc;
GLint uv_transform_loc;
GLint vertex_modelspace_loc;
GLint vertex_uv_loc;
GLint texture_sampler_loc;
};
struct platform_context_ {
SDL_Renderer* renderer;
SDL_Window* window;
SDL_Texture* texture;
SDL_GLContext gl_context;
game_input_* next_input;
game_input_* prev_input;
SDL_GameController* controller_handle;
};
#define TASK_QUEUE_MAX_ENTRIES 256
struct task_queue_;
typedef void task_callback_(task_queue_* queue, void* data);
struct task_ {
task_callback_* callback;
void* data;
};
struct task_queue_ {
i32 volatile write_index;
i32 volatile read_index;
i32 volatile remaining;
task_ tasks[TASK_QUEUE_MAX_ENTRIES];
SDL_sem* semaphore;
};
typedef void start_task_func(task_queue_* queue, task_callback_* callback, void* data);
typedef void wait_on_queue_func(task_queue_* queue);
struct platform_services_ {
task_queue_* primary_queue;
task_queue_* secondary_queue;
task_queue_* render_queue;
start_task_func* start_task;
wait_on_queue_func* wait_on_queue;
};
void platform_debug_print(char* str);
#endif //PHYSICA_SDL_PLATFORM_H