Skip to content

Commit 5038f39

Browse files
committed
Load sun/moon texture from respective file
1 parent 5326e08 commit 5038f39

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

assets/terrain/moon.png

1.26 KB
Loading

assets/terrain/sun.png

951 Bytes
Loading

source/graphics/gfx_util.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ void gutil_sky_box(mat4 view_matrix, float celestial_angle, vec3 color_top,
184184
gfx_fog(false);
185185
gfx_texture(true);
186186
gfx_blending(MODE_BLEND2);
187-
gfx_bind_texture(&texture_gui2);
188187

189188
mat4 tmp;
190189
glm_translate_to(view_matrix,
@@ -193,19 +192,20 @@ void gutil_sky_box(mat4 view_matrix, float celestial_angle, vec3 color_top,
193192
glm_rotate_x(tmp, glm_rad(celestial_angle * 360.0F), model_view);
194193
gfx_matrix_modelview(model_view);
195194

195+
gfx_bind_texture(&texture_sun);
196196
gfx_draw_quads(
197197
4, (int16_t[]) {-30, 100, -30, -30, 100, 30, 30, 100, 30, 30, 100, -30},
198198
(uint8_t[]) {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
199199
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
200-
(uint16_t[]) {201, 65, 201, 65 + 32, 201 + 32, 65 + 32, 201 + 32, 65});
200+
(uint16_t[]) {0, 0, 0, 256, 256, 256, 256, 0});
201201

202-
gfx_draw_quads(
203-
4,
204-
(int16_t[]) {-20, -100, -20, 20, -100, -20, 20, -100, 20, -20, -100,
205-
20},
206-
(uint8_t[]) {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
207-
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
208-
(uint16_t[]) {201, 32, 201, 32 + 32, 201 + 32, 32 + 32, 201 + 32, 32});
202+
gfx_bind_texture(&texture_moon);
203+
gfx_draw_quads(4,
204+
(int16_t[]) {-20, -100, -20, 20, -100, -20, 20, -100, 20,
205+
-20, -100, 20},
206+
(uint8_t[]) {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
207+
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
208+
(uint16_t[]) {0, 0, 0, 256, 256, 256, 256, 0});
209209

210210
gfx_blending(MODE_OFF);
211211
gfx_write_buffers(true, true, true);

source/platform/texture.c

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ struct tex_gfx texture_gui2;
3636
struct tex_gfx texture_controls;
3737
struct tex_gfx texture_pointer;
3838
struct tex_gfx texture_clouds;
39+
struct tex_gfx texture_sun;
40+
struct tex_gfx texture_moon;
3941

4042
#define distance_2d(x1, y1, x2, y2) \
4143
(((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
@@ -72,6 +74,8 @@ void tex_init() {
7274
tex_gfx_load_file(&texture_pointer, "pointer.png", TEX_FMT_RGBA16, false);
7375
tex_gfx_load_file(&texture_clouds, "environment/clouds.png", TEX_FMT_IA4,
7476
false);
77+
tex_gfx_load_file(&texture_sun, "terrain/sun.png", TEX_FMT_RGB16, false);
78+
tex_gfx_load_file(&texture_moon, "terrain/moon.png", TEX_FMT_RGB16, false);
7579

7680
size_t fog_size = 128;
7781
uint8_t* fog = malloc(fog_size * fog_size * 4);

source/platform/texture.h

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ extern struct tex_gfx texture_gui2;
6262
extern struct tex_gfx texture_controls;
6363
extern struct tex_gfx texture_pointer;
6464
extern struct tex_gfx texture_clouds;
65+
extern struct tex_gfx texture_sun;
66+
extern struct tex_gfx texture_moon;
6567

6668
void tex_init(void);
6769

0 commit comments

Comments
 (0)