sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
vux.c
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# (c) 2009 Lion
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#include <libvux.h>
12#include <stdlib.h>
13
14#include "vux.h"
15
16
17
18
19
20
21static const VU_MATRIX VuInitMatrix = {{
22 {1.0f, 0.0f, 0.0f, 0.0f},
23 {0.0f, 1.0f, 0.0f, 0.0f},
24 {0.0f, 0.0f, 1.0f, 0.0f},
25 {0.0f, 0.0f, 0.0f, 1.0f}
26 }};
27VU_MATRIX VuWorldMatrix;
28VU_MATRIX VuViewMatrix;
29VU_MATRIX VuPrjectionMatrix;
30VU_MATRIX VuLocalScreenMatrix;
31
32float vu_projection;
33int vu_projection_type; //0=vu_projection , 1=VuPrjectionMatrix
34unsigned short vu_offset_x;
35unsigned short vu_offset_y;
36VU_FCVECTOR vu_light_ambient;
37float vu_fog_near;
38float vu_fog_far;
39float vu_near_plane_w;
40float vu_near_plane_h;
41
42__attribute__((constructor))
43static void __VuInit_ctor(void)
44{
45 VuInit();
46}
47
48void VuInit(void)
49{
50 VuSetWorldMatrix(NULL);
51 VuSetViewMatrix(NULL);
52 VuSetProjectionMatrix(NULL);
53 VuSetLocalScreenMatrix(NULL);
54 VuSetGeometryXYOffset(2048, 2048);
55 VuSetProjection(500.0f);
56 VuSetAmbientLight(0.2f, 0.2f, 0.2f);
57 vu_fog_near = 25000.0f;
58 vu_fog_far = 45000.0f;
59 VuSetProjectionNearPlaneWH(300.0f, 300.0f);
60}
61
62
63
64void VuSetGeometryXYOffset(unsigned short x, unsigned short y)
65{
66
67 vu_offset_x = x;
68 vu_offset_y = y;
69}
70
71
72
73
74void VuSetProjection(float z)
75{
76
77 vu_projection = z;
78 vu_projection_type = 0;
79}
80
81
82
83
84void VuSetProjectionMatrix(const VU_MATRIX *projection)
85{
86 if (!projection)
87 {
88 VuPrjectionMatrix = VuInitMatrix;
89 }
90 else
91 {
92 VuPrjectionMatrix = *projection;
93 }
94
95 vu_projection_type = 1; // use projection matrix
96}
97
98
99
100
101void VuSetProjectionType(unsigned int type)
102{
103 vu_projection_type = type;
104}
105
106
107
108
109void VuSetWorldMatrix(const VU_MATRIX *world)
110{
111 if (!world)
112 {
113 VuWorldMatrix = VuInitMatrix;
114 return;
115 }
116 VuWorldMatrix = *world;
117}
118
119
120
121
122void VuSetViewMatrix(const VU_MATRIX *view)
123{
124 if (!view)
125 {
126 VuViewMatrix = VuInitMatrix;
127 return;
128 }
129 VuViewMatrix = *view;
130}
131
132
133
134
135
136void VuSetLocalScreenMatrix(const VU_MATRIX *m)
137{
138 if (!m)
139 {
140 VuLocalScreenMatrix = VuInitMatrix;
141 return;
142 }
143 VuLocalScreenMatrix = *m;
144}
145
146
147
148
149void VuSetProjectionNearPlaneWH(unsigned int w, unsigned int h)
150{
151
152 vu_near_plane_w = w;
153 vu_near_plane_h = h;
154}
155
156
157
158
159void VuSetAmbientLight(float r, float g, float b)
160{
161
162 vu_light_ambient.r = r;
163 vu_light_ambient.g = g;
164 vu_light_ambient.b = b;
165 vu_light_ambient.a = 1.0f;
166}