summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
Diffstat (limited to 'demos')
-rw-r--r--demos/checkerboard/checkerboard.c48
-rw-r--r--demos/isomap/isomap.c35
2 files changed, 40 insertions, 43 deletions
diff --git a/demos/checkerboard/checkerboard.c b/demos/checkerboard/checkerboard.c
index dbc817c..9d1791e 100644
--- a/demos/checkerboard/checkerboard.c
+++ b/demos/checkerboard/checkerboard.c
@@ -76,11 +76,10 @@ static bool init(GfxAppState* state, int argc, const char** argv) {
76 isogfx_resize(iso, SCREEN_WIDTH, SCREEN_HEIGHT); 76 isogfx_resize(iso, SCREEN_WIDTH, SCREEN_HEIGHT);
77 77
78 if (!isogfx_make_world( 78 if (!isogfx_make_world(
79 iso, &(WorldDesc){ 79 iso, &(WorldDesc){.tile_width = TILE_WIDTH,
80 .tile_width = TILE_WIDTH, 80 .tile_height = TILE_HEIGHT,
81 .tile_height = TILE_HEIGHT, 81 .world_width = WORLD_WIDTH,
82 .world_width = WORLD_WIDTH, 82 .world_height = WORLD_HEIGHT})) {
83 .world_height = WORLD_HEIGHT})) {
84 return false; 83 return false;
85 } 84 }
86 85
@@ -89,7 +88,7 @@ static bool init(GfxAppState* state, int argc, const char** argv) {
89 state->red = isogfx_make_tile(iso, &tile_set[Red]); 88 state->red = isogfx_make_tile(iso, &tile_set[Red]);
90 make_checkerboard(iso, black, white); 89 make_checkerboard(iso, black, white);
91 90
92 if (!(state->backend = IsoBackendInit(iso))) { 91 if (!(state->backend = iso_backend_init(iso))) {
93 return false; 92 return false;
94 } 93 }
95 94
@@ -99,7 +98,7 @@ static bool init(GfxAppState* state, int argc, const char** argv) {
99static void shutdown(GfxAppState* state) { 98static void shutdown(GfxAppState* state) {
100 assert(state); 99 assert(state);
101 100
102 IsoBackendShutdown(&state->backend); 101 iso_backend_shutdown(&state->backend);
103 isogfx_del(&state->iso); 102 isogfx_del(&state->iso);
104} 103}
105 104
@@ -116,7 +115,7 @@ static void update(GfxAppState* state, double t, double dt) {
116 gfx_app_get_mouse_position(&mouse_x, &mouse_y); 115 gfx_app_get_mouse_position(&mouse_x, &mouse_y);
117 116
118 // Map from window coordinates to virtual screen coordinates. 117 // Map from window coordinates to virtual screen coordinates.
119 IsoBackendGetMousePosition( 118 iso_backend_get_mouse_position(
120 state->backend, mouse_x, mouse_y, &mouse_x, &mouse_y); 119 state->backend, mouse_x, mouse_y, &mouse_x, &mouse_y);
121 120
122 isogfx_pick_tile(iso, mouse_x, mouse_y, &state->xpick, &state->ypick); 121 isogfx_pick_tile(iso, mouse_x, mouse_y, &state->xpick, &state->ypick);
@@ -135,32 +134,31 @@ static void render(GfxAppState* state) {
135 isogfx_draw_tile(iso, state->xpick, state->ypick, state->red); 134 isogfx_draw_tile(iso, state->xpick, state->ypick, state->red);
136 } 135 }
137 136
138 IsoBackendRender(state->backend, iso); 137 iso_backend_render(state->backend, iso);
139} 138}
140 139
141static void resize(GfxAppState* state, int width, int height) { 140static void resize(GfxAppState* state, int width, int height) {
142 assert(state); 141 assert(state);
143 142
144 IsoBackendResizeWindow(state->backend, state->iso, width, height); 143 iso_backend_resize_window(state->backend, state->iso, width, height);
145} 144}
146 145
147int main(int argc, const char** argv) { 146int main(int argc, const char** argv) {
148 GfxAppState state = {0}; 147 GfxAppState state = {0};
149 gfx_app_run( 148 gfx_app_run(
150 &(GfxAppDesc){ 149 &(GfxAppDesc){.argc = argc,
151 .argc = argc, 150 .argv = argv,
152 .argv = argv, 151 .width = WINDOW_WIDTH,
153 .width = WINDOW_WIDTH, 152 .height = WINDOW_HEIGHT,
154 .height = WINDOW_HEIGHT, 153 .max_fps = MAX_FPS,
155 .max_fps = MAX_FPS, 154 .update_delta_time =
156 .update_delta_time = MAX_FPS > 0 ? 1.0 / (double)MAX_FPS : 0.0, 155 MAX_FPS > 0 ? 1.0 / (double)MAX_FPS : 0.0,
157 .title = "Isometric Renderer", 156 .title = "Isometric Renderer",
158 .app_state = &state}, 157 .app_state = &state},
159 &(GfxAppCallbacks){ 158 &(GfxAppCallbacks){.init = init,
160 .init = init, 159 .update = update,
161 .update = update, 160 .render = render,
162 .render = render, 161 .resize = resize,
163 .resize = resize, 162 .shutdown = shutdown});
164 .shutdown = shutdown});
165 return 0; 163 return 0;
166} 164}
diff --git a/demos/isomap/isomap.c b/demos/isomap/isomap.c
index a233659..5adf6f1 100644
--- a/demos/isomap/isomap.c
+++ b/demos/isomap/isomap.c
@@ -49,7 +49,7 @@ static bool init(GfxAppState* state, int argc, const char** argv) {
49 state->stag = isogfx_make_sprite(iso, state->stag_sheet); 49 state->stag = isogfx_make_sprite(iso, state->stag_sheet);
50 isogfx_set_sprite_position(iso, state->stag, 5, 4); 50 isogfx_set_sprite_position(iso, state->stag, 5, 4);
51 51
52 if (!(state->backend = IsoBackendInit(iso))) { 52 if (!(state->backend = iso_backend_init(iso))) {
53 return false; 53 return false;
54 } 54 }
55 55
@@ -74,32 +74,31 @@ static void render(GfxAppState* state) {
74 74
75 IsoGfx* iso = state->iso; 75 IsoGfx* iso = state->iso;
76 isogfx_render(iso); 76 isogfx_render(iso);
77 IsoBackendRender(state->backend, iso); 77 iso_backend_render(state->backend, iso);
78} 78}
79 79
80static void resize(GfxAppState* state, int width, int height) { 80static void resize(GfxAppState* state, int width, int height) {
81 assert(state); 81 assert(state);
82 82
83 IsoBackendResizeWindow(state->backend, state->iso, width, height); 83 iso_backend_resize_window(state->backend, state->iso, width, height);
84} 84}
85 85
86int main(int argc, const char** argv) { 86int main(int argc, const char** argv) {
87 GfxAppState state = {0}; 87 GfxAppState state = {0};
88 gfx_app_run( 88 gfx_app_run(
89 &(GfxAppDesc){ 89 &(GfxAppDesc){.argc = argc,
90 .argc = argc, 90 .argv = argv,
91 .argv = argv, 91 .width = WINDOW_WIDTH,
92 .width = WINDOW_WIDTH, 92 .height = WINDOW_HEIGHT,
93 .height = WINDOW_HEIGHT, 93 .max_fps = MAX_FPS,
94 .max_fps = MAX_FPS, 94 .update_delta_time =
95 .update_delta_time = MAX_FPS > 0 ? 1.0 / (double)MAX_FPS : 0.0, 95 MAX_FPS > 0 ? 1.0 / (double)MAX_FPS : 0.0,
96 .title = "Isometric Renderer", 96 .title = "Isometric Renderer",
97 .app_state = &state}, 97 .app_state = &state},
98 &(GfxAppCallbacks){ 98 &(GfxAppCallbacks){.init = init,
99 .init = init, 99 .update = update,
100 .update = update, 100 .render = render,
101 .render = render, 101 .resize = resize,
102 .resize = resize, 102 .shutdown = shutdown});
103 .shutdown = shutdown});
104 return 0; 103 return 0;
105} 104}