remove typedefs in favor of SDL ones

This commit is contained in:
Sven Balzer 2025-02-25 16:56:12 +01:00
parent 3e32ebd62b
commit b1e657abc3

View File

@ -14,16 +14,6 @@
#include "../assets/shader/basic_vertex_shader.h" #include "../assets/shader/basic_vertex_shader.h"
#include "../assets/shader/basic_pixel_shader.h" #include "../assets/shader/basic_pixel_shader.h"
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
SDL_GPUDevice *device; SDL_GPUDevice *device;
SDL_Window *window; SDL_Window *window;
@ -39,8 +29,8 @@ SDL_GPUBuffer *tiles_instance_buffer;
SDL_GPUBuffer *player_instance_buffer; SDL_GPUBuffer *player_instance_buffer;
SDL_GPUBuffer *quad_instance_buffer; SDL_GPUBuffer *quad_instance_buffer;
int16 window_width; Sint16 window_width;
int16 window_height; Sint16 window_height;
bool Running = true; bool Running = true;
@ -59,14 +49,14 @@ Vertex vertices[] = {
{{ 1, 1, 1, 1 }, {1, 0}}, {{ 1, 1, 1, 1 }, {1, 0}},
}; };
uint16 indices[] = { Uint16 indices[] = {
0, 1, 2, 0, 1, 2,
0, 3, 1, 0, 3, 1,
}; };
struct Instance { struct Instance {
V4 pos_size; V4 pos_size;
uint32 tile_type; Uint32 tile_type;
V4 uv0uv1; V4 uv0uv1;
}; };
@ -77,17 +67,17 @@ Instance tiles_instances[view_width * view_height] = {
Instance player_instance = { {0.5f, 0.5f, 1.0f / view_width, 1.0f / view_height}, 0, {0, 0, 1, 1}}; Instance player_instance = { {0.5f, 0.5f, 1.0f / view_width, 1.0f / view_height}, 0, {0, 0, 1, 1}};
struct Tile { struct Tile {
uint32 type; Uint32 type;
}; };
uint32 map_width = view_width; Uint32 map_width = view_width;
uint32 map_height = view_height; Uint32 map_height = view_height;
Tile* map_tiles; Tile* map_tiles;
struct Player { struct Player {
int64 pos_x; Sint64 pos_x;
int64 pos_y; Sint64 pos_y;
}; };
Player player = { Player player = {
@ -114,12 +104,12 @@ void save_map() {
} }
defer(fclose(file)); defer(fclose(file));
if (fwrite(&map_width, sizeof(uint32), 1, file) != 1) { if (fwrite(&map_width, sizeof(Uint32), 1, file) != 1) {
log_error("fwrite for map_width has failed."); log_error("fwrite for map_width has failed.");
return; return;
} }
if (fwrite(&map_height, sizeof(uint32), 1, file) != 1) { if (fwrite(&map_height, sizeof(Uint32), 1, file) != 1) {
log_error("fwrite for map_height has failed."); log_error("fwrite for map_height has failed.");
return; return;
} }
@ -142,9 +132,9 @@ void load_map() {
return; return;
} }
map_width = read<uint32>(file); map_width = read<Uint32>(file);
map_height = read<uint32>(file); map_height = read<Uint32>(file);
if (file.length != map_width * map_height * sizeof(uint32)) { if (file.length != map_width * map_height * sizeof(Uint32)) {
log_error("Incorrect file.length."); log_error("Incorrect file.length.");
return; return;
} }
@ -166,15 +156,15 @@ void change_map_size(char direction, int amount) {
auto old_map_width = map_width; auto old_map_width = map_width;
auto old_map_height = map_height; auto old_map_height = map_height;
int32 new_x_offset = 0; Sint32 new_x_offset = 0;
int32 new_y_offset = 0; Sint32 new_y_offset = 0;
int32 old_x_offset = 0; Sint32 old_x_offset = 0;
int32 old_y_offset = 0; Sint32 old_y_offset = 0;
int32 to_fill_width = map_width; Sint32 to_fill_width = map_width;
int32 to_fill_height = map_height; Sint32 to_fill_height = map_height;
int32 to_fill_x_offset = 0; Sint32 to_fill_x_offset = 0;
int32 to_fill_y_offset = 0; Sint32 to_fill_y_offset = 0;
if (direction == 'W') { if (direction == 'W') {
player.pos_x = player.pos_x + amount; player.pos_x = player.pos_x + amount;