-
Notifications
You must be signed in to change notification settings - Fork 1
/
loading.c
101 lines (73 loc) · 2.44 KB
/
loading.c
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
#include <ogcsys.h>
#include <gccore.h>
#include "object.h"
#include "shader.h"
#include "scene.h"
#include "images/loading.h"
#include "loading_tpl.h"
static TPLFile loadingTPL;
static GXTexObj loadimg_texobj;
static shader_info *loadimg_shader;
static void
loadimg_shader_setup (void *dummy)
{
#include "plain-texturing.inc"
}
static void
draw_tex_rect (shader_info *shader, u32 vtxfmt)
{
Mtx mvtmp;
object_loc rect_loc;
scene_info rect_scene;
Mtx44 ortho;
const float xsize = 0.8, ysize = 0.37083333;
/* "Straight" camera. */
scene_set_pos (&rect_scene, (guVector) { 0, 0, 0 });
scene_set_lookat (&rect_scene, (guVector) { 5, 0, 0 });
scene_set_up (&rect_scene, (guVector) { 0, 1, 0 });
scene_update_camera (&rect_scene);
guOrtho (ortho, -1, 1, -1, 1, 1, 15);
object_loc_initialise (&rect_loc, GX_PNMTX0);
guMtxIdentity (mvtmp);
object_set_matrices (&rect_scene, &rect_loc, rect_scene.camera, mvtmp,
NULL, ortho, GX_ORTHOGRAPHIC);
GX_ClearVtxDesc ();
GX_SetVtxDesc (GX_VA_POS, GX_DIRECT);
GX_SetVtxDesc (GX_VA_NRM, GX_DIRECT);
GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);
GX_SetVtxAttrFmt (vtxfmt, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetVtxAttrFmt (vtxfmt, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0);
GX_SetVtxAttrFmt (vtxfmt, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
shader_load (shader);
GX_SetCullMode (GX_CULL_NONE);
GX_Begin (GX_TRIANGLESTRIP, vtxfmt, 4);
GX_Position3f32 (3, -ysize, xsize);
GX_Normal3f32 (-1, 0, 0);
GX_TexCoord2f32 (1, 0);
GX_Position3f32 (3, -ysize, -xsize);
GX_Normal3f32 (-1, 0, 0);
GX_TexCoord2f32 (0, 0);
GX_Position3f32 (3, ysize, xsize);
GX_Normal3f32 (-1, 0, 0);
GX_TexCoord2f32 (1, 1);
GX_Position3f32 (3, ysize, -xsize);
GX_Normal3f32 (-1, 0, 0);
GX_TexCoord2f32 (0, 1);
GX_End ();
}
void
draw_loading_screen (void)
{
TPL_OpenTPLFromMemory (&loadingTPL, (void *) loading_tpl, loading_tpl_size);
TPL_GetTexture (&loadingTPL, loading_image, &loadimg_texobj);
loadimg_shader = create_shader (&loadimg_shader_setup, NULL);
shader_append_texmap (loadimg_shader, &loadimg_texobj, GX_TEXMAP0);
shader_append_texcoordgen (loadimg_shader, GX_TEXCOORD0, GX_TG_MTX2x4,
GX_TG_TEX0, GX_IDENTITY);
GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_FALSE);
GX_SetBlendMode (GX_BM_NONE, GX_BL_ZERO, GX_BL_ZERO, GX_LO_SET);
GX_SetColorUpdate (GX_TRUE);
GX_SetAlphaUpdate (GX_TRUE);
draw_tex_rect (loadimg_shader, GX_VTXFMT0);
free_shader (loadimg_shader);
}