pspsdk-1.0+beta2
pspgu.h
Go to the documentation of this file.
1 /*
2  * PSP Software Development Kit - http://www.pspdev.org
3  * -----------------------------------------------------------------------
4  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5  *
6  * Copyright (c) 2005 Jesper Svennevid
7  */
8 
9 #ifndef __pspgu_h__
10 #define __pspgu_h__
11 
12 #include <psptypes.h>
13 #include <pspge.h>
14 
19 #if defined(__cplusplus)
20 extern "C" {
21 #endif
22 
23 /* PI, float-sized */
24 #define GU_PI (3.141593f)
25 
26 /* Boolean values for convenience */
27 #define GU_FALSE (0)
28 #define GU_TRUE (1)
29 
30 /* Primitive types */
31 #define GU_POINTS (0)
32 #define GU_LINES (1)
33 #define GU_LINE_STRIP (2)
34 #define GU_TRIANGLES (3)
35 #define GU_TRIANGLE_STRIP (4)
36 #define GU_TRIANGLE_FAN (5)
37 #define GU_SPRITES (6)
38 
39 /* States */
40 #define GU_ALPHA_TEST (0)
41 #define GU_DEPTH_TEST (1)
42 #define GU_SCISSOR_TEST (2)
43 #define GU_STENCIL_TEST (3)
44 #define GU_BLEND (4)
45 #define GU_CULL_FACE (5)
46 #define GU_DITHER (6)
47 #define GU_FOG (7)
48 #define GU_CLIP_PLANES (8)
49 #define GU_TEXTURE_2D (9)
50 #define GU_LIGHTING (10)
51 #define GU_LIGHT0 (11)
52 #define GU_LIGHT1 (12)
53 #define GU_LIGHT2 (13)
54 #define GU_LIGHT3 (14)
55 #define GU_LINE_SMOOTH (15)
56 #define GU_PATCH_CULL_FACE (16)
57 #define GU_COLOR_TEST (17)
58 #define GU_COLOR_LOGIC_OP (18)
59 #define GU_FACE_NORMAL_REVERSE (19)
60 #define GU_PATCH_FACE (20)
61 #define GU_FRAGMENT_2X (21)
62 
63 /* Matrix modes */
64 #define GU_PROJECTION (0)
65 #define GU_VIEW (1)
66 #define GU_MODEL (2)
67 #define GU_TEXTURE (3)
68 
69 /* Vertex Declarations Begin */
70 #define GU_TEXTURE_SHIFT(n) ((n)<<0)
71 #define GU_TEXTURE_8BIT GU_TEXTURE_SHIFT(1)
72 #define GU_TEXTURE_16BIT GU_TEXTURE_SHIFT(2)
73 #define GU_TEXTURE_32BITF GU_TEXTURE_SHIFT(3)
74 #define GU_TEXTURE_BITS GU_TEXTURE_SHIFT(3)
75 
76 #define GU_COLOR_SHIFT(n) ((n)<<2)
77 #define GU_COLOR_5650 GU_COLOR_SHIFT(4)
78 #define GU_COLOR_5551 GU_COLOR_SHIFT(5)
79 #define GU_COLOR_4444 GU_COLOR_SHIFT(6)
80 #define GU_COLOR_8888 GU_COLOR_SHIFT(7)
81 #define GU_COLOR_BITS GU_COLOR_SHIFT(7)
82 
83 #define GU_NORMAL_SHIFT(n) ((n)<<5)
84 #define GU_NORMAL_8BIT GU_NORMAL_SHIFT(1)
85 #define GU_NORMAL_16BIT GU_NORMAL_SHIFT(2)
86 #define GU_NORMAL_32BITF GU_NORMAL_SHIFT(3)
87 #define GU_NORMAL_BITS GU_NORMAL_SHIFT(3)
88 
89 #define GU_VERTEX_SHIFT(n) ((n)<<7)
90 #define GU_VERTEX_8BIT GU_VERTEX_SHIFT(1)
91 #define GU_VERTEX_16BIT GU_VERTEX_SHIFT(2)
92 #define GU_VERTEX_32BITF GU_VERTEX_SHIFT(3)
93 #define GU_VERTEX_BITS GU_VERTEX_SHIFT(3)
94 
95 #define GU_WEIGHT_SHIFT(n) ((n)<<9)
96 #define GU_WEIGHT_8BIT GU_WEIGHT_SHIFT(1)
97 #define GU_WEIGHT_16BIT GU_WEIGHT_SHIFT(2)
98 #define GU_WEIGHT_32BITF GU_WEIGHT_SHIFT(3)
99 #define GU_WEIGHT_BITS GU_WEIGHT_SHIFT(3)
100 
101 #define GU_INDEX_SHIFT(n) ((n)<<11)
102 #define GU_INDEX_8BIT GU_INDEX_SHIFT(1)
103 #define GU_INDEX_16BIT GU_INDEX_SHIFT(2)
104 #define GU_INDEX_BITS GU_INDEX_SHIFT(3)
105 
106 #define GU_WEIGHTS(n) ((((n)-1)&7)<<14)
107 #define GU_WEIGHTS_BITS GU_WEIGHTS(8)
108 #define GU_VERTICES(n) ((((n)-1)&7)<<18)
109 #define GU_VERTICES_BITS GU_VERTICES(8)
110 
111 #define GU_TRANSFORM_SHIFT(n) ((n)<<23)
112 #define GU_TRANSFORM_3D GU_TRANSFORM_SHIFT(0)
113 #define GU_TRANSFORM_2D GU_TRANSFORM_SHIFT(1)
114 #define GU_TRANSFORM_BITS GU_TRANSFORM_SHIFT(1)
115 /* Vertex Declarations End */
116 
117 /* Pixel Formats */
118 #define GU_PSM_5650 (0) /* Display, Texture, Palette */
119 #define GU_PSM_5551 (1) /* Display, Texture, Palette */
120 #define GU_PSM_4444 (2) /* Display, Texture, Palette */
121 #define GU_PSM_8888 (3) /* Display, Texture, Palette */
122 #define GU_PSM_T4 (4) /* Texture */
123 #define GU_PSM_T8 (5) /* Texture */
124 #define GU_PSM_T16 (6) /* Texture */
125 #define GU_PSM_T32 (7) /* Texture */
126 #define GU_PSM_DXT1 (8) /* Texture */
127 #define GU_PSM_DXT3 (9) /* Texture */
128 #define GU_PSM_DXT5 (10) /* Texture */
129 
130 /* Spline Mode */
131 #define GU_FILL_FILL (0)
132 #define GU_OPEN_FILL (1)
133 #define GU_FILL_OPEN (2)
134 #define GU_OPEN_OPEN (3)
135 
136 /* Shading Model */
137 #define GU_FLAT (0)
138 #define GU_SMOOTH (1)
139 
140 /* Logical operation */
141 #define GU_CLEAR (0)
142 #define GU_AND (1)
143 #define GU_AND_REVERSE (2)
144 #define GU_COPY (3)
145 #define GU_AND_INVERTED (4)
146 #define GU_NOOP (5)
147 #define GU_XOR (6)
148 #define GU_OR (7)
149 #define GU_NOR (8)
150 #define GU_EQUIV (9)
151 #define GU_INVERTED (10)
152 #define GU_OR_REVERSE (11)
153 #define GU_COPY_INVERTED (12)
154 #define GU_OR_INVERTED (13)
155 #define GU_NAND (14)
156 #define GU_SET (15)
157 
158 /* Texture Filter */
159 #define GU_NEAREST (0)
160 #define GU_LINEAR (1)
161 #define GU_NEAREST_MIPMAP_NEAREST (4)
162 #define GU_LINEAR_MIPMAP_NEAREST (5)
163 #define GU_NEAREST_MIPMAP_LINEAR (6)
164 #define GU_LINEAR_MIPMAP_LINEAR (7)
165 
166 /* Texture Map Mode */
167 #define GU_TEXTURE_COORDS (0)
168 #define GU_TEXTURE_MATRIX (1)
169 #define GU_ENVIRONMENT_MAP (2)
170 
171 /* Texture Level Mode */
172 #define GU_TEXTURE_AUTO (0)
173 #define GU_TEXTURE_CONST (1)
174 #define GU_TEXTURE_SLOPE (2)
175 
176 /* Texture Projection Map Mode */
177 #define GU_POSITION (0)
178 #define GU_UV (1)
179 #define GU_NORMALIZED_NORMAL (2)
180 #define GU_NORMAL (3)
181 
182 /* Wrap Mode */
183 #define GU_REPEAT (0)
184 #define GU_CLAMP (1)
185 
186 /* Front Face Direction */
187 #define GU_CW (0)
188 #define GU_CCW (1)
189 
190 /* Test Function */
191 #define GU_NEVER (0)
192 #define GU_ALWAYS (1)
193 #define GU_EQUAL (2)
194 #define GU_NOTEQUAL (3)
195 #define GU_LESS (4)
196 #define GU_LEQUAL (5)
197 #define GU_GREATER (6)
198 #define GU_GEQUAL (7)
199 
200 /* Clear Buffer Mask */
201 #define GU_COLOR_BUFFER_BIT (1)
202 #define GU_STENCIL_BUFFER_BIT (2)
203 #define GU_DEPTH_BUFFER_BIT (4)
204 #define GU_FAST_CLEAR_BIT (16)
205 
206 /* Texture Effect */
207 #define GU_TFX_MODULATE (0)
208 #define GU_TFX_DECAL (1)
209 #define GU_TFX_BLEND (2)
210 #define GU_TFX_REPLACE (3)
211 #define GU_TFX_ADD (4)
212 
213 /* Texture Color Component */
214 #define GU_TCC_RGB (0)
215 #define GU_TCC_RGBA (1)
216 
217 /* Blending Op */
218 #define GU_ADD (0)
219 #define GU_SUBTRACT (1)
220 #define GU_REVERSE_SUBTRACT (2)
221 #define GU_MIN (3)
222 #define GU_MAX (4)
223 #define GU_ABS (5)
224 
225 /* Blending Factor */
226 #define GU_SRC_COLOR (0)
227 #define GU_ONE_MINUS_SRC_COLOR (1)
228 #define GU_SRC_ALPHA (2)
229 #define GU_ONE_MINUS_SRC_ALPHA (3)
230 #define GU_DST_COLOR (0)
231 #define GU_ONE_MINUS_DST_COLOR (1)
232 #define GU_DST_ALPHA (4)
233 #define GU_ONE_MINUS_DST_ALPHA (5)
234 #define GU_FIX (10)
235 
236 /* Stencil Operations */
237 #define GU_KEEP (0)
238 #define GU_ZERO (1)
239 #define GU_REPLACE (2)
240 #define GU_INVERT (3)
241 #define GU_INCR (4)
242 #define GU_DECR (5)
243 
244 /* Light Components */
245 #define GU_AMBIENT (1)
246 #define GU_DIFFUSE (2)
247 #define GU_SPECULAR (4)
248 #define GU_AMBIENT_AND_DIFFUSE (GU_AMBIENT|GU_DIFFUSE)
249 #define GU_DIFFUSE_AND_SPECULAR (GU_DIFFUSE|GU_SPECULAR)
250 #define GU_UNKNOWN_LIGHT_COMPONENT (8)
251 
252 /* Light modes */
253 #define GU_SINGLE_COLOR (0)
254 #define GU_SEPARATE_SPECULAR_COLOR (1)
255 
256 /* Light Type */
257 #define GU_DIRECTIONAL (0)
258 #define GU_POINTLIGHT (1)
259 #define GU_SPOTLIGHT (2)
260 
261 /* Contexts */
262 #define GU_DIRECT (0)
263 #define GU_CALL (1)
264 #define GU_SEND (2)
265 
266 /* List Queue */
267 #define GU_TAIL (0)
268 #define GU_HEAD (1)
269 
270 /* Sync behavior (mode) */
271 #define GU_SYNC_FINISH (0)
272 #define GU_SYNC_SIGNAL (1)
273 #define GU_SYNC_DONE (2)
274 #define GU_SYNC_LIST (3)
275 #define GU_SYNC_SEND (4)
276 
277 /* behavior (what) */
278 #define GU_SYNC_WAIT (0)
279 #define GU_SYNC_NOWAIT (1)
280 
281 /* Sync behavior (what) [see pspge.h] */
282 #define GU_SYNC_WHAT_DONE (0)
283 #define GU_SYNC_WHAT_QUEUED (1)
284 #define GU_SYNC_WHAT_DRAW (2)
285 #define GU_SYNC_WHAT_STALL (3)
286 #define GU_SYNC_WHAT_CANCEL (4)
287 
288 /* Signals */
289 #define GU_CALLBACK_SIGNAL (1)
290 #define GU_CALLBACK_FINISH (4)
291 
292 /* Signal behavior */
293 #define GU_BEHAVIOR_SUSPEND (1)
294 #define GU_BEHAVIOR_CONTINUE (2)
295 
296 /* Color Macros, maps 8 bit unsigned channels into one 32-bit value */
297 #define GU_ABGR(a,b,g,r) (((a) << 24)|((b) << 16)|((g) << 8)|(r))
298 #define GU_ARGB(a,r,g,b) GU_ABGR((a),(b),(g),(r))
299 #define GU_RGBA(r,g,b,a) GU_ARGB((a),(r),(g),(b))
300 
301 /* Color Macro, maps floating point channels (0..1) into one 32-bit value */
302 #define GU_COLOR(r,g,b,a) GU_RGBA((u32)((r) * 255.0f),(u32)((g) * 255.0f),(u32)((b) * 255.0f),(u32)((a) * 255.0f))
303 
304 typedef void (*GuSwapBuffersCallback)(void** display,void** render);
305 
308 
316 void sceGuDepthBuffer(void* zbp, int zbw);
317 
332 void sceGuDispBuffer(int width, int height, void* dispbp, int dispbw);
333 
352 void sceGuDrawBuffer(int psm, void* fbp, int fbw);
353 
361 void sceGuDrawBufferList(int psm, void* fbp, int fbw);
362 
373 int sceGuDisplay(int state);
374 
390 void sceGuDepthFunc(int function);
391 
397 void sceGuDepthMask(int mask);
398 
399 void sceGuDepthOffset(unsigned int offset);
400 
414 void sceGuDepthRange(int near, int far);
415 
416 void sceGuFog(float near, float far, unsigned int color);
417 
423 void sceGuInit(void);
424 
430 void sceGuTerm(void);
431 
432 void sceGuBreak(int a0);
433 void sceGuContinue(void);
434 
446 void* sceGuSetCallback(int signal, void (*callback)(int));
447 
458 void sceGuSignal(int signal, int behavior);
459 
468 void sceGuSendCommandf(int cmd, float argument);
469 
478 void sceGuSendCommandi(int cmd, int argument);
479 
490 void* sceGuGetMemory(int size);
491 
505 void sceGuStart(int cid, void* list);
506 
520 int sceGuFinish(void);
521 
533 int sceGuFinishId(unsigned int id);
534 
540 void sceGuCallList(const void* list);
541 
548 void sceGuCallMode(int mode);
549 
555 int sceGuCheckList(void);
556 
568 void sceGuSendList(int mode, const void* list, PspGeContext* context);
569 
575 void* sceGuSwapBuffers(void);
576 
603 int sceGuSync(int mode, int what);
604 
671 void sceGuDrawArray(int prim, int vtype, int count, const void* indices, const void* vertices);
672 
692 void sceGuBeginObject(int vtype, int count, const void* indices, const void* vertices);
693 
697 void sceGuEndObject(void);
698 
707 void sceGuSetStatus(int state, int status);
708 
717 int sceGuGetStatus(int state);
718 
726 void sceGuSetAllStatus(int status);
727 
735 int sceGuGetAllStatus(void);
736 
758 void sceGuEnable(int state);
759 
767 void sceGuDisable(int state);
768 
787 void sceGuLight(int light, int type, int components, const ScePspFVector3* position);
788 
797 void sceGuLightAtt(int light, float atten0, float atten1, float atten2);
798 
813 void sceGuLightColor(int light, int component, unsigned int color);
814 
827 void sceGuLightMode(int mode);
828 
837 void sceGuLightSpot(int light, const ScePspFVector3* direction, float exponent, float cutoff);
838 
849 void sceGuClear(int flags);
850 
856 void sceGuClearColor(unsigned int color);
857 
863 void sceGuClearDepth(unsigned int depth);
864 
871 void sceGuClearStencil(unsigned int stencil);
872 
879 void sceGuPixelMask(unsigned int mask);
880 
886 void sceGuColor(unsigned int color);
887 
908 void sceGuColorFunc(int func, unsigned int color, unsigned int mask);
909 
920 void sceGuColorMaterial(int components);
921 
939 void sceGuAlphaFunc(int func, int value, int mask);
940 
941 void sceGuAmbient(unsigned int color);
942 void sceGuAmbientColor(unsigned int color);
943 
978 void sceGuBlendFunc(int op, int src, int dest, unsigned int srcfix, unsigned int destfix);
979 
980 void sceGuMaterial(int mode, int color);
981 
985 void sceGuModelColor(unsigned int emissive, unsigned int ambient, unsigned int diffuse, unsigned int specular);
986 
1004 void sceGuStencilFunc(int func, int ref, int mask);
1005 
1024 void sceGuStencilOp(int fail, int zfail, int zpass);
1025 
1032 void sceGuSpecular(float power);
1033 
1045 void sceGuFrontFace(int order);
1046 
1072 void sceGuLogicalOp(int op);
1073 
1081 void sceGuSetDither(const ScePspIMatrix4* matrix);
1082 
1092 void sceGuShadeModel(int mode);
1093 
1116 void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void* src, int dx, int dy, int destw, void* dest);
1117 
1127 void sceGuTexEnvColor(unsigned int color);
1128 
1143 void sceGuTexFilter(int min, int mag);
1144 
1151 void sceGuTexFlush(void);
1152 
1183 void sceGuTexFunc(int tfx, int tcc);
1184 
1199 void sceGuTexImage(int mipmap, int width, int height, int tbw, const void* tbp);
1200 
1212 void sceGuTexLevelMode(unsigned int mode, float bias);
1213 
1226 void sceGuTexMapMode(int mode, unsigned int a1, unsigned int a2);
1227 
1244 void sceGuTexMode(int tpsm, int maxmips, int a2, int swizzle);
1245 
1255 void sceGuTexOffset(float u, float v);
1256 
1268 void sceGuTexProjMapMode(int mode);
1269 
1279 void sceGuTexScale(float u, float v);
1280 void sceGuTexSlope(float slope);
1281 
1288 void sceGuTexSync();
1289 
1300 void sceGuTexWrap(int u, int v);
1301 
1310 void sceGuClutLoad(int num_blocks, const void* cbp);
1311 
1326 void sceGuClutMode(unsigned int cpsm, unsigned int shift, unsigned int mask, unsigned int a3);
1327 
1341 void sceGuOffset(unsigned int x, unsigned int y);
1342 
1353 void sceGuScissor(int x, int y, int stopX, int stopY);
1354 
1368 void sceGuViewport(int cx, int cy, int width, int height);
1369 
1379 void sceGuDrawBezier(int vtype, int ucount, int vcount, const void* indices, const void* vertices);
1380 
1387 void sceGuPatchDivide(unsigned int ulevel, unsigned int vlevel);
1388 
1389 void sceGuPatchFrontFace(unsigned int a0);
1390 
1396 void sceGuPatchPrim(int prim);
1397 
1398 void sceGuDrawSpline(int vtype, int ucount, int vcount, int uedge, int vedge, const void* indices, const void* vertices);
1399 
1412 void sceGuSetMatrix(int type, const ScePspFMatrix4* matrix);
1413 
1427 void sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4* matrix);
1428 
1442 void sceGuMorphWeight(int index, float weight);
1443 
1444 void sceGuDrawArrayN(int primitive_type, int vertex_type, int count, int a3, const void* indices, const void* vertices);
1445 
1456 void guSwapBuffersBehaviour(int behaviour);
1457 
1480 
1483 #if defined(__cplusplus)
1484 };
1485 #endif
1486 
1487 #endif