1 #ifndef OPENGL_H 2 #define OPENGL_H 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include <boolean.h> 9 #include <glsm/glsmsym.h> 10 #include "gSP.h" 11 12 #include "../../Graphics/RSP/gSP_state.h" 13 14 #define RS_NONE 0 15 #define RS_TRIANGLE 1 16 #define RS_RECT 2 17 #define RS_TEXTUREDRECT 3 18 #define RS_LINE 4 19 20 21 #define SCREEN_UPDATE_AT_VI_UPDATE 1 22 #define SCREEN_UPDATE_AT_VI_CHANGE 2 23 #define SCREEN_UPDATE_AT_CI_CHANGE 3 24 #define SCREEN_UPDATE_AT_1ST_CI_CHANGE 4 25 #define SCREEN_UPDATE_BEFORE_SCREEN_CLEAR 6 26 #define SCREEN_UPDATE_AT_VI_UPDATE_AND_DRAWN 7 27 28 29 #define BLEND_NOOP 0x0000 30 #define BLEND_NOOP5 0xcc48 // Fog * 0 + Mem * 1 31 #define BLEND_NOOP4 0xcc08 // Fog * 0 + In * 1 32 #define BLEND_FOG_ASHADE 0xc800 33 #define BLEND_FOG_3 0xc000 // Fog * AIn + In * 1-A 34 #define BLEND_FOG_MEM 0xc440 // Fog * AFog + Mem * 1-A 35 #define BLEND_FOG_APRIM 0xc400 // Fog * AFog + In * 1-A 36 #define BLEND_BLENDCOLOR 0x8c88 37 #define BLEND_BI_AFOG 0x8400 // Bl * AFog + In * 1-A 38 #define BLEND_BI_AIN 0x8040 // Bl * AIn + Mem * 1-A 39 #define BLEND_MEM 0x4c40 // Mem*0 + Mem*(1-0)?! 40 #define BLEND_FOG_MEM_3 0x44c0 // Mem * AFog + Fog * 1-A 41 #define BLEND_NOOP3 0x0c48 // In * 0 + Mem * 1 42 #define BLEND_PASS 0x0c08 // In * 0 + In * 1 43 #define BLEND_FOG_MEM_IN_MEM 0x0440 // In * AFog + Mem * 1-A 44 #define BLEND_FOG_MEM_FOG_MEM 0x04c0 // In * AFog + Fog * 1-A 45 #define BLEND_OPA 0x0044 // In * AIn + Mem * AMem 46 #define BLEND_XLU 0x0040 47 #define BLEND_MEM_ALPHA_IN 0x4044 // Mem * AIn + Mem * AMem 48 49 #define INDEXMAP_SIZE 64 50 #define VERTBUFF_SIZE 256 51 #define ELEMBUFF_SIZE 1024 52 53 typedef struct 54 { 55 float x, y, z, w; 56 struct 57 { 58 float r, g, b, a; 59 } color, secondaryColor; 60 float s0, t0, s1, t1; 61 } GLVertex; 62 63 typedef struct triangles_t 64 { 65 struct SPVertex vertices[VERTBUFF_SIZE]; 66 GLubyte elements[ELEMBUFF_SIZE]; 67 int num; 68 } triangles_t; 69 70 typedef struct 71 { 72 bool screenUpdate; 73 74 int frame_dl; 75 int frame_prevdl; 76 int mustRenderDlist; 77 int renderingToTexture; 78 79 uint32_t heightOffset; 80 float scaleX, scaleY; 81 82 83 struct triangles_t triangles; 84 85 unsigned int renderState; 86 87 GLVertex rect[4]; 88 } GLInfo; 89 90 struct TexturedRectParams 91 { 92 float ulx, uly, lrx, lry; 93 float uls, ult, lrs, lrt; 94 bool flip; 95 }; 96 97 extern GLInfo OGL; 98 99 bool OGL_Start(); 100 void OGL_Stop(); 101 102 void OGL_AddTriangle(int v0, int v1, int v2); 103 void OGL_DrawTriangles(void); 104 void OGL_DrawDMATriangles(uint32_t _numVtx); 105 void OGL_DrawTriangle(struct SPVertex *vertices, int v0, int v1, int v2); 106 void OGL_DrawLLETriangle(uint32_t _numVtx); 107 void OGL_DrawLine(int v0, int v1, float width); 108 void OGL_DrawRect(int ulx, int uly, int lrx, int lry, float *color); 109 void OGL_DrawTexturedRect(const struct TexturedRectParams *_params); 110 111 void OGL_UpdateFrameTime(); 112 void OGL_UpdateScale(); 113 114 void OGL_ClearDepthBuffer(bool _fullsize); 115 void OGL_ClearColorBuffer(float *color); 116 void OGL_ResizeWindow(int x, int y, int width, int height); 117 void OGL_SwapBuffers(); 118 void OGL_ReadScreen( void *dest, int *width, int *height ); 119 120 int OGL_CheckError(); 121 int OGL_IsExtSupported( const char *extension ); 122 123 float OGL_GetScaleX(void); 124 125 float OGL_GetScaleY(void); 126 127 uint32_t OGL_GetHeightOffset(void); 128 129 uint32_t OGL_GetScreenWidth(void); 130 131 uint32_t OGL_GetScreenHeight(void); 132 133 #ifdef __cplusplus 134 } 135 #endif 136 137 #endif 138 139