openTRI 0.1
triGraphics.h
1/*
2 * triGraphics.h: Header for 2D Graphics Engine
3 * This file is part of the "tri Engine".
4 *
5 * Copyright (C) 2007 tri
6 * Copyright (C) 2007 Alexander Berl 'Raphael' <raphael@fx-world.org>
7 *
8 * $Id$
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#ifndef __TRIGRAPHICS_H__
26#define __TRIGRAPHICS_H__
27
28#include <pspgu.h>
29#include "triImage.h"
30
31
36// To override default display list size (256Kb)
37#define TRI_DLIST_SIZE_KB(x) triU32 triDlistSizeUser = ((x)*1024);
38
39// Constants
40//--------------------------------------------------
41#define SCREEN_WIDTH 480
42#define SCREEN_HEIGHT 272
43
44#define FRAME_BUFFER_WIDTH 512
45#define FRAME_BUFFER_SIZE (FRAME_BUFFER_WIDTH*SCREEN_HEIGHT)
46
47
48
49/* triEnable/Disable */
50#define TRI_ALPHA_TEST 0
51#define TRI_DEPTH_TEST 1
52#define TRI_SCISSOR_TEST 2
53#define TRI_STENCIL_TEST 3
54#define TRI_BLEND 4
55#define TRI_CULL_FACE 5
56#define TRI_DITHER 6
57#define TRI_FOG 7
58#define TRI_CLIP_PLANES 8
59#define TRI_TEXTURE_2D 9
60#define TRI_LIGHTING 10
61#define TRI_LIGHT0 11
62#define TRI_LIGHT1 12
63#define TRI_LIGHT2 13
64#define TRI_LIGHT3 14
65#define TRI_AALINE 15
66#define TRI_COLORKEY 17
67#define TRI_LOGICAL_OP 18
68#define TRI_NORMAL_REVERSE 19
69#define TRI_VBLANK 32
70#define TRI_PSEUDO_FSAA 33
71#define TRI_SMOOTH_DITHER 34
72#define TRI_DEPTH_MASK 35
73#define TRI_DEPTH_WRITE 35
74
75
76
77extern void* triFramebuffer;
78extern void* triFramebuffer2;
79extern void* triDepthbuffer;
80extern triS32 triPsm;
81extern triS32 triBpp;
82
101void triInit( triS32 psm, triBool doublebuffer );
102
105void triClose();
106
107
111void triBegin();
112
115void triEnd();
116
119void triSync();
120
124
129
133triFloat triCPULoad();
134
138triFloat triGPULoad();
139
143triFloat triFps();
144
148triFloat triFpsMax();
149
153triFloat triFpsMin();
154
155void triPerspective( triFloat fov );
156void triOrtho();
157
158
159void triEnable( triU32 state );
160void triDisable( triU32 state );
161
162
163void triClear( triU32 color );
164
165// Set clipping area
166void triSetClip( triS32 x, triS32 y, triS32 width, triS32 height );
167// Reset clipping area
168void triResetClip();
169
170
171void triRendertoscreen();
172void triRendertotexture( triS32 psm, void* tbp, triS32 tw, triS32 th, triS32 tbw );
173void triRendertoimage( triImage* img );
174
175void triCopyToScreen( triS32 x, triS32 y, triS32 w, triS32 h, triS32 sx, triS32 sy, triS32 sbw, void* src );
176void triCopyFromScreen( triS32 x, triS32 y, triS32 w, triS32 h, triS32 dx, triS32 dy, triS32 dbw, void* dst );
177
185void triDrawLine( triFloat x0, triFloat y0, triFloat x1, triFloat y1, triU32 color );
186
192void triDrawLines( triVec2* p, triS32 num, triU32 color );
193
201void triDrawRect( triFloat x, triFloat y, triFloat width, triFloat height, triU32 color );
202
210void triDrawRectOutline( triFloat x, triFloat y, triFloat width, triFloat height, triU32 color );
211
220void triDrawRectRotate( triFloat x, triFloat y, triFloat width, triFloat height, triU32 color, triFloat angle );
221
232void triDrawRectGrad( triFloat x, triFloat y, triFloat width, triFloat height, triU32 color1, triU32 color2, triU32 color3, triU32 color4 );
233
240void triDrawCircle( triFloat x, triFloat y, triFloat radius, triU32 color );
241
248void triDrawCircleOutline( triFloat x, triFloat y, triFloat radius, triU32 color );
249
257void triDrawCircleGrad( triFloat x, triFloat y, triFloat radius, triU32 color1, triU32 color2 );
258
268void triDrawTri( triFloat x0, triFloat y0, triFloat x1, triFloat y1, triFloat x2, triFloat y2, triU32 color );
269
279void triDrawTriOutline( triFloat x0, triFloat y0, triFloat x1, triFloat y1, triFloat x2, triFloat y2, triU32 color );
280
292void triDrawTriGrad( triFloat x0, triFloat y0, triFloat x1, triFloat y1, triFloat x2, triFloat y2, triU32 color1, triU32 color2, triU32 color3 );
293
302void triDrawRegPoly( triFloat x, triFloat y, triFloat radius, triU32 color, triU32 numSteps, triFloat angle );
303
312void triDrawRegPolyOutline( triFloat x, triFloat y, triFloat radius, triU32 color, triU32 numSteps, triFloat angle );
313
323void triDrawRegPolyGrad( triFloat x, triFloat y, triFloat radius, triU32 color1, triU32 color2, triU32 numSteps, triFloat angle );
324
334void triDrawStar( triFloat x, triFloat y, triFloat radiusInner, triFloat radiusOuter, triU32 color, triU32 numSteps, triFloat angle );
335
345void triDrawStarOutline( triFloat x, triFloat y, triFloat radiusInner, triFloat radiusOuter, triU32 color, triU32 numSteps, triFloat angle );
346
357void triDrawStarGrad( triFloat x, triFloat y, triFloat radiusInner, triFloat radiusOuter, triU32 color1, triU32 color2, triU32 numSteps, triFloat angle );
358
359
360void triColorOp( triS32 op );
361void trinoColorOp();
362
363void triImageTint( triS32 mode, triS32 comp, triU32 vcolor, triU32 ccolor );
364void triImageNoTint();
365// const alpha overrides Tint mode!
366void triImageConstAlpha( triU32 alpha );
367void triImageBlend( triS32 op, triS32 srcOp, triS32 dstOp, triU32 src_fix, triU32 dst_fix );
368void triImageNoBlend();
369void triImageColorkey( triU32 color );
370void triImageNoColorkey();
371
372
378void triSpriteMode( triFloat width, triFloat height, triFloat angle );
379
387void triDrawSprite( triFloat x, triFloat y, triFloat u, triFloat v, triImage* img );
388
399void triBltSprite( triFloat x, triFloat y, triFloat u, triFloat v, triImage* img );
400
401
409void triDrawImageCenterScaled( triFloat x, triFloat y, triFloat scale, triImage* img );
410
411
420void triDrawImageScaled( triFloat x, triFloat y, triFloat width, triFloat height, triImage* img );
421
428void triDrawImage2( triFloat x, triFloat y, triImage* img );
429
442void triDrawImage( triFloat x, triFloat y, triFloat width, triFloat height,
443 triFloat u0, triFloat v0, triFloat u1, triFloat v1,
444 triImage* img );
445
452void triDrawImageRotate2( triFloat x, triFloat y, triFloat angle, triImage* img );
453
466void triDrawImageRotate( triFloat x, triFloat y, triFloat width, triFloat height,
467 triFloat u0, triFloat v0, triFloat u1, triFloat v1,
468 triFloat angle, triImage* img );
469
470
476void triDrawImageAnimation( triFloat x, triFloat y, triImageAnimation* ani );
477
484void triDrawImageAnimationRotate( triFloat x, triFloat y, triFloat angle, triImageAnimation* ani );
485
488#endif // __TRIGRAPHICS_H__
void triDrawImageScaled(triFloat x, triFloat y, triFloat width, triFloat height, triImage *img)
Render an image scaled by a factor.
void triDrawSprite(triFloat x, triFloat y, triFloat u, triFloat v, triImage *img)
Render a sprite.
void triDrawRectGrad(triFloat x, triFloat y, triFloat width, triFloat height, triU32 color1, triU32 color2, triU32 color3, triU32 color4)
Draw Rectangle from (x,y) to (x+width,y+height) with gradient.
void triDrawRectOutline(triFloat x, triFloat y, triFloat width, triFloat height, triU32 color)
Draw rectangle from (x,y) to (x+width,y+height) in color 'color' with outline only.
void triClose()
Close graphics and free all resources.
void triDrawImageCenterScaled(triFloat x, triFloat y, triFloat scale, triImage *img)
Render an image centered at position x,y scaled by a factor.
void triSpriteMode(triFloat width, triFloat height, triFloat angle)
Set sprite mode.
void triDrawCircle(triFloat x, triFloat y, triFloat radius, triU32 color)
Draw Circle.
void triDrawCircleOutline(triFloat x, triFloat y, triFloat radius, triU32 color)
Draw Circle (outline only)
void triBltSprite(triFloat x, triFloat y, triFloat u, triFloat v, triImage *img)
Render a sprite without effects (no blending, transparency, etc.)
void triDrawLine(triFloat x0, triFloat y0, triFloat x1, triFloat y1, triU32 color)
Draw a line from (x0,y0) to (x1,y1) in color 'color'.
triFloat triFpsMax()
Return the maximal FPS.
void triDrawLines(triVec2 *p, triS32 num, triU32 color)
Draw a line strip consisting of num points in color 'color'.
triFloat triFps()
Return the current FPS.
void triInit(triS32 psm, triBool doublebuffer)
Initialize graphics.
void triDrawImage(triFloat x, triFloat y, triFloat width, triFloat height, triFloat u0, triFloat v0, triFloat u1, triFloat v1, triImage *img)
Render an image.
void triDrawTriGrad(triFloat x0, triFloat y0, triFloat x1, triFloat y1, triFloat x2, triFloat y2, triU32 color1, triU32 color2, triU32 color3)
Draw arbitrary triangle with outline only.
void triSync()
Sync CPU to GU for the current immediate block.
triFloat triCPULoad()
Return the current CPU load in percent.
void triDrawImage2(triFloat x, triFloat y, triImage *img)
Render an image at full size.
void triDrawImageAnimation(triFloat x, triFloat y, triImageAnimation *ani)
Render an image animation.
void triVblank()
Wait for Vblank.
void triDrawImageAnimationRotate(triFloat x, triFloat y, triFloat angle, triImageAnimation *ani)
Render an image animation with rotation.
void triEnd()
End an immediate render command block.
void triDrawRegPolyGrad(triFloat x, triFloat y, triFloat radius, triU32 color1, triU32 color2, triU32 numSteps, triFloat angle)
Draw regular Polygon (Pentagon,Hexagon,Octagon,etc) with gradient.
void triDrawTri(triFloat x0, triFloat y0, triFloat x1, triFloat y1, triFloat x2, triFloat y2, triU32 color)
Draw arbitrary triangle.
void triDrawImageRotate2(triFloat x, triFloat y, triFloat angle, triImage *img)
Render an image with rotation.
void triSwapbuffers()
Wait for rendering to finish and swap front- and backbuffer.
void triDrawStarGrad(triFloat x, triFloat y, triFloat radiusInner, triFloat radiusOuter, triU32 color1, triU32 color2, triU32 numSteps, triFloat angle)
Draw Star with gradient.
void triBegin()
Begin an immediate render command block This is needed when you depend on the render result (e....
void triDrawRect(triFloat x, triFloat y, triFloat width, triFloat height, triU32 color)
Draw filled rectangle from (x,y) to (x+width,y+height) in color 'color'.
void triDrawRegPolyOutline(triFloat x, triFloat y, triFloat radius, triU32 color, triU32 numSteps, triFloat angle)
Draw regular Polygon (Pentagon,Hexagon,Octagon,etc) with outline only.
void triDrawStarOutline(triFloat x, triFloat y, triFloat radiusInner, triFloat radiusOuter, triU32 color, triU32 numSteps, triFloat angle)
Draw Star with outline only.
void triDrawRectRotate(triFloat x, triFloat y, triFloat width, triFloat height, triU32 color, triFloat angle)
Draw Rectangle from (x,y) to (x+width,y+height) in color 'color' rotated by angle degree around it's ...
void triDrawTriOutline(triFloat x0, triFloat y0, triFloat x1, triFloat y1, triFloat x2, triFloat y2, triU32 color)
Draw arbitrary triangle with outline only.
void triDrawRegPoly(triFloat x, triFloat y, triFloat radius, triU32 color, triU32 numSteps, triFloat angle)
Draw regular Polygon (Pentagon,Hexagon,Octagon,etc)
triFloat triFpsMin()
Return the minimal FPS.
triFloat triGPULoad()
Return the current GPU load in percent.
void triDrawCircleGrad(triFloat x, triFloat y, triFloat radius, triU32 color1, triU32 color2)
Draw Circle with gradient.
void triDrawStar(triFloat x, triFloat y, triFloat radiusInner, triFloat radiusOuter, triU32 color, triU32 numSteps, triFloat angle)
Draw Star.
void triDrawImageRotate(triFloat x, triFloat y, triFloat width, triFloat height, triFloat u0, triFloat v0, triFloat u1, triFloat v1, triFloat angle, triImage *img)
Render an image with rotation.
ImageAnimation struct.
Definition: triImage.h:234
Image struct.
Definition: triImage.h:158
2D float Vector
Definition: triTypes.h:85