diff options
Diffstat (limited to 'src/backend.c')
-rw-r--r-- | src/backend.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/backend.c b/src/backend.c index 94f1728..4bb3592 100644 --- a/src/backend.c +++ b/src/backend.c | |||
@@ -1,5 +1,5 @@ | |||
1 | #include <isogfx/backend.h> | 1 | #include <isogfx/backend.h> |
2 | #include <isogfx/isogfx.h> | 2 | #include <isogfx/gfx2d.h> |
3 | 3 | ||
4 | #include <gfx/core.h> | 4 | #include <gfx/core.h> |
5 | #include <gfx/gfx.h> | 5 | #include <gfx/gfx.h> |
@@ -13,7 +13,7 @@ | |||
13 | #include <assert.h> | 13 | #include <assert.h> |
14 | #include <stdlib.h> | 14 | #include <stdlib.h> |
15 | 15 | ||
16 | typedef struct IsoBackend { | 16 | typedef struct Gfx2dBackend { |
17 | Gfx* gfx; | 17 | Gfx* gfx; |
18 | Mesh* quad_mesh; | 18 | Mesh* quad_mesh; |
19 | /// The screen or "iso screen" refers to the colour buffer of the iso graphics | 19 | /// The screen or "iso screen" refers to the colour buffer of the iso graphics |
@@ -29,12 +29,12 @@ typedef struct IsoBackend { | |||
29 | int viewport_x, viewport_y, viewport_width, viewport_height; | 29 | int viewport_x, viewport_y, viewport_width, viewport_height; |
30 | double stretch; // Stretch factor from iso screen dimensions to viewport | 30 | double stretch; // Stretch factor from iso screen dimensions to viewport |
31 | // dimensions. | 31 | // dimensions. |
32 | } IsoBackend; | 32 | } Gfx2dBackend; |
33 | 33 | ||
34 | IsoBackend* iso_backend_init(const IsoGfx* iso) { | 34 | Gfx2dBackend* gfx2d_backend_init(const Gfx2d* iso) { |
35 | assert(iso); | 35 | assert(iso); |
36 | 36 | ||
37 | IsoBackend* backend = calloc(1, sizeof(IsoBackend)); | 37 | Gfx2dBackend* backend = calloc(1, sizeof(Gfx2dBackend)); |
38 | if (!backend) { | 38 | if (!backend) { |
39 | return nullptr; | 39 | return nullptr; |
40 | } | 40 | } |
@@ -45,7 +45,7 @@ IsoBackend* iso_backend_init(const IsoGfx* iso) { | |||
45 | GfxCore* gfxcore = gfx_get_core(backend->gfx); | 45 | GfxCore* gfxcore = gfx_get_core(backend->gfx); |
46 | 46 | ||
47 | int screen_width, screen_height; | 47 | int screen_width, screen_height; |
48 | isogfx_get_screen_size(iso, &screen_width, &screen_height); | 48 | gfx2d_get_screen_size(iso, &screen_width, &screen_height); |
49 | 49 | ||
50 | if (!((backend->screen_texture = gfx_make_texture( | 50 | if (!((backend->screen_texture = gfx_make_texture( |
51 | gfxcore, &(TextureDesc){.width = screen_width, | 51 | gfxcore, &(TextureDesc){.width = screen_width, |
@@ -95,10 +95,10 @@ cleanup: | |||
95 | return nullptr; | 95 | return nullptr; |
96 | } | 96 | } |
97 | 97 | ||
98 | void iso_backend_shutdown(IsoBackend** ppApp) { | 98 | void gfx2d_backend_shutdown(Gfx2dBackend** ppApp) { |
99 | assert(ppApp); | 99 | assert(ppApp); |
100 | 100 | ||
101 | IsoBackend* app = *ppApp; | 101 | Gfx2dBackend* app = *ppApp; |
102 | if (!app) { | 102 | if (!app) { |
103 | return; | 103 | return; |
104 | } | 104 | } |
@@ -106,8 +106,8 @@ void iso_backend_shutdown(IsoBackend** ppApp) { | |||
106 | gfx_destroy(&app->gfx); | 106 | gfx_destroy(&app->gfx); |
107 | } | 107 | } |
108 | 108 | ||
109 | void iso_backend_resize_window( | 109 | void gfx2d_backend_resize_window( |
110 | IsoBackend* app, const IsoGfx* iso, int width, int height) { | 110 | Gfx2dBackend* app, const Gfx2d* iso, int width, int height) { |
111 | assert(app); | 111 | assert(app); |
112 | assert(iso); | 112 | assert(iso); |
113 | 113 | ||
@@ -116,7 +116,7 @@ void iso_backend_resize_window( | |||
116 | 116 | ||
117 | // Virtual screen dimensions. | 117 | // Virtual screen dimensions. |
118 | int screen_width, screen_height; | 118 | int screen_width, screen_height; |
119 | isogfx_get_screen_size(iso, &screen_width, &screen_height); | 119 | gfx2d_get_screen_size(iso, &screen_width, &screen_height); |
120 | 120 | ||
121 | // Stretch the virtual screen onto the viewport while respecting the screen's | 121 | // Stretch the virtual screen onto the viewport while respecting the screen's |
122 | // aspect ratio to prevent distortion. | 122 | // aspect ratio to prevent distortion. |
@@ -135,11 +135,11 @@ void iso_backend_resize_window( | |||
135 | } | 135 | } |
136 | } | 136 | } |
137 | 137 | ||
138 | void iso_backend_render(const IsoBackend* app, const IsoGfx* iso) { | 138 | void gfx2d_backend_render(const Gfx2dBackend* app, const Gfx2d* iso) { |
139 | assert(app); | 139 | assert(app); |
140 | assert(iso); | 140 | assert(iso); |
141 | 141 | ||
142 | const Pixel* screen = isogfx_get_screen_buffer(iso); | 142 | const Pixel* screen = gfx2d_get_screen_buffer(iso); |
143 | assert(screen); | 143 | assert(screen); |
144 | gfx_update_texture(app->screen_texture, &(TextureDataDesc){.pixels = screen}); | 144 | gfx_update_texture(app->screen_texture, &(TextureDataDesc){.pixels = screen}); |
145 | 145 | ||
@@ -162,8 +162,8 @@ void iso_backend_render(const IsoBackend* app, const IsoGfx* iso) { | |||
162 | gfx_end_frame(gfxcore); | 162 | gfx_end_frame(gfxcore); |
163 | } | 163 | } |
164 | 164 | ||
165 | bool iso_backend_get_mouse_position( | 165 | bool gfx2d_backend_get_mouse_position( |
166 | const IsoBackend* app, double window_x, double window_y, double* x, | 166 | const Gfx2dBackend* app, double window_x, double window_y, double* x, |
167 | double* y) { | 167 | double* y) { |
168 | assert(app); | 168 | assert(app); |
169 | 169 | ||