5 #include <GLES2/gl2ext.h>
9 // #include <EGL/egl.h> // Android 2.3 only
10 // #include <GLES2/gl2extimg.h>
18 #define min(a,b) ((a) < (b) ? (a) : (b))
21 #define max(a,b) ((a) > (b) ? (a) : (b))
27 #define RS_TEXTUREDRECT 3
31 #define SCREEN_UPDATE_AT_VI_UPDATE 1
32 #define SCREEN_UPDATE_AT_VI_CHANGE 2
33 #define SCREEN_UPDATE_AT_CI_CHANGE 3
34 #define SCREEN_UPDATE_AT_1ST_CI_CHANGE 4
35 #define SCREEN_UPDATE_AT_1ST_PRIMITIVE 5
36 #define SCREEN_UPDATE_BEFORE_SCREEN_CLEAR 6
37 #define SCREEN_UPDATE_AT_VI_UPDATE_AND_DRAWN 7
40 #define BLEND_NOOP 0x0000
41 #define BLEND_NOOP5 0xcc48 // Fog * 0 + Mem * 1
42 #define BLEND_NOOP4 0xcc08 // Fog * 0 + In * 1
43 #define BLEND_FOG_ASHADE 0xc800
44 #define BLEND_FOG_3 0xc000 // Fog * AIn + In * 1-A
45 #define BLEND_FOG_MEM 0xc440 // Fog * AFog + Mem * 1-A
46 #define BLEND_FOG_APRIM 0xc400 // Fog * AFog + In * 1-A
47 #define BLEND_BLENDCOLOR 0x8c88
48 #define BLEND_BI_AFOG 0x8400 // Bl * AFog + In * 1-A
49 #define BLEND_BI_AIN 0x8040 // Bl * AIn + Mem * 1-A
50 #define BLEND_MEM 0x4c40 // Mem*0 + Mem*(1-0)?!
51 #define BLEND_FOG_MEM_3 0x44c0 // Mem * AFog + Fog * 1-A
52 #define BLEND_NOOP3 0x0c48 // In * 0 + Mem * 1
53 #define BLEND_PASS 0x0c08 // In * 0 + In * 1
54 #define BLEND_FOG_MEM_IN_MEM 0x0440 // In * AFog + Mem * 1-A
55 #define BLEND_FOG_MEM_FOG_MEM 0x04c0 // In * AFog + Fog * 1-A
56 #define BLEND_OPA 0x0044 // In * AIn + Mem * AMem
57 #define BLEND_XLU 0x0040
58 #define BLEND_MEM_ALPHA_IN 0x4044 // Mem * AIn + Mem * AMem
61 #define OGL_FRAMETIME_NUM 8
69 } color, secondaryColor;
81 // TODO: More EGL stuff, need to do this in Java
82 SDL_Surface *hScreen; // TODO: Do we really need this? Only using it in one place AFAICT..
87 EGLint version_major, version_minor;
92 EGLNativeDisplayType device;
93 EGLNativeWindowType handle;
101 GLuint fb,depth_buffer, color_buffer;
106 unsigned consecutiveSkips;
107 unsigned frameTime[OGL_FRAMETIME_NUM];
109 int frame_vsync, frame_actual, frame_dl;
112 int renderingToTexture;
115 GLint defaultProgram;
116 GLint defaultVertShader;
117 GLint defaultFragShader;
119 float scaleX, scaleY;
121 #define INDEXMAP_SIZE 64
122 #define VERTBUFF_SIZE 256
123 #define ELEMBUFF_SIZE 1024
126 SPVertex vertices[VERTBUFF_SIZE];
127 GLubyte elements[ELEMBUFF_SIZE];
130 //#ifdef __TRIBUFFER_OPT
132 u32 indexmap[INDEXMAP_SIZE];
133 u32 indexmapinv[VERTBUFF_SIZE];
141 unsigned int renderState;
151 void OGL_AddTriangle(int v0, int v1, int v2);
152 void OGL_DrawTriangles();
153 void OGL_DrawTriangle(SPVertex *vertices, int v0, int v1, int v2);
154 void OGL_DrawLine(int v0, int v1, float width);
155 void OGL_DrawRect(int ulx, int uly, int lrx, int lry, float *color);
156 void OGL_DrawTexturedRect(float ulx, float uly, float lrx, float lry, float uls, float ult, float lrs, float lrt, bool flip );
158 void OGL_UpdateFrameTime();
159 void OGL_UpdateScale();
160 void OGL_UpdateStates();
161 void OGL_UpdateViewport();
162 void OGL_UpdateScissor();
163 void OGL_UpdateCullFace();
165 void OGL_ClearDepthBuffer();
166 void OGL_ClearColorBuffer(float *color);
167 void OGL_ResizeWindow(int x, int y, int width, int height);
168 void OGL_SwapBuffers();
169 void OGL_ReadScreen( void *dest, int *width, int *height );
171 int OGL_CheckError();
172 int OGL_IsExtSupported( const char *extension );