Suggestion from "mgh".
[open-ps2-loader.git] / include / renderman.h
blob16ceafc2912a1453cce0056f05f85707c5e96c74
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
48 /** Initializes the rendering manager */
49 void rmInit();
51 /** Sets a new screen mode */
52 int rmSetMode(int force);
54 void rmEnd(void);
56 /** Fills the parameters with the screen width and height */
57 void rmGetScreenExtents(int *w, int *h);
59 /** Manually prepares a texture for rendering (should not be normally needed).
60 * txt->Vram will be nonzero on success.
61 * @param txt The texture to upload (if not uploaded already)
62 * @return 1 if ok, 0 if error uploading happened (likely too big texture) */
63 int rmPrepareTexture(GSTEXTURE* txt);
65 /** Flushes all rendering buffers - renders the gs queue, removes all textures from GS ram */
66 void rmFlush(void);
68 /** Issues immediate rendering of the accumulated operations */
69 void rmDispatch(void);
71 void rmDrawQuad(rm_quad_t* q);
73 void rmSetupQuad(GSTEXTURE* txt, int x, int y, short aligned, int w, int h, short scaled, u64 color, rm_quad_t* q);
75 /** Queues a specified pixmap (tinted with colour) to be rendered on specified position */
76 void rmDrawPixmap(GSTEXTURE* txt, int x, int y, short aligned, int w, int h, short scaled, u64 color);
78 void rmDrawOverlayPixmap(GSTEXTURE* overlay, int x, int y, short aligned, int w, int h, short scaled, u64 color,
79 GSTEXTURE* inlay, int ulx, int uly, int urx, int ury, int blx, int bly, int brx, int bry);
81 /** Queues a opaque rectangle to be rendered */
82 void rmDrawRect(int x, int y, int w, int h, u64 color);
84 /** Queues a single color line to be rendered */
85 void rmDrawLine(int x, int y, int x1, int y1, u64 color);
87 /** Starts the frame - first to call every frame */
88 void rmStartFrame(void);
90 /** Ends the frame - last to call every frame */
91 void rmEndFrame(void);
93 /** Sets the aspect ratio correction for the upcoming operations.
94 * When set, it will treat all pixmap widths/heights (not positions) as scaled with the ratios provided */
95 void rmSetAspectRatio(float width, float height);
97 /** Resets aspect ratio back to 1:1 */
98 void rmResetAspectRatio();
100 /** gets the current aspect ratio */
101 void rmGetAspectRatio(float *w, float *h);
103 void rmApplyAspectRatio(int* w, int* h);
105 void rmSetShiftRatio(float height);
107 void rmResetShiftRatio();
109 void rmApplyShiftRatio(int* y);
111 /** sets the transposition coordiantes (all content is transposed with these values) */
112 void rmSetTransposition(float x, float y);
114 #endif