fixed the alternate device mode.
[open-ps2-loader.git] / include / renderman.h
blob1934525f348208959bdaf79d7abcf0c0e0f26e52
1 #ifndef __RENDERMAN_H
2 #define __RENDERMAN_H
4 #include <gsToolkit.h>
6 #define DIM_UNDEF -1
8 #define ALIGN_NONE 0
9 #define ALIGN_CENTER 1
11 #define SCALING_NONE 0
12 #define SCALING_RATIO 1
14 /// GSKit CLUT base struct. This should've been in gsKit from the start :)
15 typedef struct {
16 u8 PSM; ///< Pixel Storage Method (Color Format)
17 u8 ClutPSM; ///< CLUT Pixel Storage Method (Color Format)
18 u32 *Clut; ///< EE CLUT Memory Pointer
19 u32 VramClut; ///< GS VRAM CLUT Memory Pointer
20 } GSCLUT;
22 typedef struct {
23 float x, y;
24 float u, v;
25 } rm_tx_coord_t;
27 typedef struct {
28 rm_tx_coord_t ul;
29 rm_tx_coord_t br;
30 u64 color;
31 GSTEXTURE* txt;
32 } rm_quad_t;
34 // Some convenience globals
35 const u64 gColWhite;
36 const u64 gColBlack;
37 const u64 gColDarker;
38 const u64 gColFocus;
39 const u64 gDefaultCol;
40 const u64 gDefaultAlpha;
42 enum rm_vmode {
43 RM_VMODE_AUTO = 0,
44 RM_VMODE_PAL,
45 RM_VMODE_NTSC
46 } ;
48 /** Initializes the rendering manager
49 * @param vsyncon 1 == vsync enabled, 0 == vsync disabled
50 * @param vmodeset Video mode
52 void rmInit(int vsyncon, enum rm_vmode vmodeset);
54 /** Sets a new screen mode */
55 void rmSetMode(int vsyncon, enum rm_vmode vmodeset);
57 void rmEnd(void);
59 /** Fills the parameters with the screen width and height */
60 void rmGetScreenExtents(int *w, int *h);
62 /** Manually prepares a texture for rendering (should not be normally needed).
63 * txt->Vram will be nonzero on success.
64 * @param txt The texture to upload (if not uploaded already)
65 * @return 1 if ok, 0 if error uploading happened (likely too big texture) */
66 int rmPrepareTexture(GSTEXTURE* txt);
68 /** Flushes all rendering buffers - renders the gs queue, removes all textures from GS ram */
69 void rmFlush(void);
71 /** Issues immediate rendering of the accumulated operations */
72 void rmDispatch(void);
74 void rmDrawQuad(rm_quad_t* q);
76 void rmSetupQuad(GSTEXTURE* txt, int x, int y, short aligned, int w, int h, short scaled, u64 color, rm_quad_t* q);
78 /** Queues a specified pixmap (tinted with colour) to be rendered on specified position */
79 void rmDrawPixmap(GSTEXTURE* txt, int x, int y, short aligned, int w, int h, short scaled, u64 color);
81 void rmDrawOverlayPixmap(GSTEXTURE* overlay, int x, int y, short aligned, int w, int h, short scaled, u64 color,
82 GSTEXTURE* inlay, int ulx, int uly, int urx, int ury, int blx, int bly, int brx, int bry);
84 /** Queues a opaque rectangle to be rendered */
85 void rmDrawRect(int x, int y, int w, int h, u64 color);
87 /** Queues a single color line to be rendered */
88 void rmDrawLine(int x, int y, int x1, int y1, u64 color);
90 /** Starts the frame - first to call every frame */
91 void rmStartFrame(void);
93 /** Ends the frame - last to call every frame */
94 void rmEndFrame(void);
96 /** Sets the clipping rectangle */
97 void rmClip(int x, int y, int w, int h);
99 /** Sets cipping to none */
100 void rmUnclip(void);
102 /** Sets the aspect ratio correction for the upcoming operations.
103 * When set, it will treat all pixmap widths/heights (not positions) as scaled with the ratios provided */
104 void rmSetAspectRatio(float width, float height);
106 /** Resets aspect ratio back to 1:1 */
107 void rmResetAspectRatio();
109 /** gets the current aspect ratio */
110 void rmGetAspectRatio(float *w, float *h);
112 void rmApplyAspectRatio(int* w, int* h);
114 void rmSetShiftRatio(float height);
116 void rmResetShiftRatio();
118 void rmApplyShiftRatio(int* y);
120 /** sets the transposition coordiantes (all content is transposed with these values) */
121 void rmSetTransposition(float x, float y);
123 #endif