namespace gfx::drivers;
-#if defined(_GLES)
- #define ES1_1
-#else
+#if !defined(_GLES) // OpenGL ES 1
#define SHADERS
#endif
#endif
#if defined(__ANDROID__) || defined(__ODROID__)
- #if defined(__ODROID__) && !defined(ES1_1)
- #define ES1_1
+ #if defined(__ODROID__) && !defined(_GLES)
+ #define _GLES
#endif
#define uint _uint
#undef class
#elif defined(__EMSCRIPTEN__)
- #define ES2
- // #define ES1_1
+#if !defined(_GLES2)
+ #define _GLES2
+#endif
+ // #define _GLES
#define property _property
#define uint _uint
#define APIENTRY
#endif
-#if defined(ES1_1) || defined(ES2) || defined(SHADERS)
+#if defined(_GLES) || defined(_GLES2) || defined(SHADERS)
#undef glRecti
#undef glBegin
}
static GLuint stippleTexture;
-#if defined(ES1_1) || defined(ES2) || defined(SHADERS)
+#if defined(_GLES) || defined(_GLES2) || defined(SHADERS)
static bool stippleEnabled;
#endif
static int primitiveTypes[RenderPrimitiveType] =
{
GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN,
-#if defined(SHADERS) || defined(ES1_1) || defined(ES2)
+#if defined(SHADERS) || defined(_GLES) || defined(_GLES2)
GL_TRIANGLE_FAN, // NOTE: This will only work for single quads
#else
GLIMTKMode::quads,
// Non OpenGL ES friendly stuff
-#if defined(ES1_1) || defined(ES2)
+#if defined(_GLES) || defined(_GLES2)
//#undef GL_UNSIGNED_INT
//#undef GL_DOUBLE
#define GL_CLAMP_TO_EDGE 0x812F
-static bool vboAvailable;
+/*static */bool vboAvailable;
static bool useSingleGLContext = false;
class OGLDisplay : struct
int x, y;
};
-#ifdef _DEBUG
+#if defined(_DEBUG) && !defined(__ANDROID__) && !defined(__EMSCRIPTEN__) && !defined(__ODROID__)
+//#define GL_DEBUGGING
+#endif
+
+#ifdef GL_DEBUGGING
static void APIENTRY openglCallbackFunction(GLenum source,
GLenum type,
GLuint id,
int current;
void * previous;
-#if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__) && !defined(__ODROID__)
-#ifdef _DEBUG
+#ifdef GL_DEBUGGING
static void setupDebugging()
{
if(glDebugMessageCallback)
GLuint unusedIds = 0;
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
- /*
+
glDebugMessageCallback(openglCallbackFunction, null);
glDebugMessageControl(GL_DONT_CARE,
GL_DONT_CARE,
0,
&unusedIds,
GL_TRUE);
- */
}
}
#endif
-#endif
#if defined(__WIN32__)
static HGLRC winCreateContext(HDC hdc)
oglSystem.pow2textures = (extensions && strstr(extensions, "GL_ARB_texture_non_power_of_two")) ? false : true;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &oglSystem.maxTextureSize);
+#ifdef DIAGNOSTICS
+ PrintLn("max texture size: ", oglSystem.maxTextureSize);
+#endif
}
bool CreateDisplaySystem(DisplaySystem displaySystem)
PrintLn("vboAvailable is: ", vboAvailable);
#endif
-# ifdef _DEBUG
+# ifdef GL_DEBUGGING
setupDebugging();
# endif
{
oglDisplay.flipBufW = width;
oglDisplay.flipBufH = height;
-#if defined(ES1_1) || defined(ES2)
+#if defined(_GLES) || defined(_GLES2)
result = true;
#else
oglDisplay.flippingBuffer = renew oglDisplay.flippingBuffer ColorAlpha [width * height];
glColor4fv(oglSurface.foreground);
glBegin(GL_LINES);
-#if defined(ES1_1) || defined(ES2) || defined(SHADERS)
+#if defined(_GLES) || defined(_GLES2) || defined(SHADERS)
if(stippleEnabled)
{
glTexCoord2f(0.5f, 0);
//Logf("Rectangle\n");
glColor4fv(oglSurface.foreground);
-#if defined(ES1_1) || defined(ES2) || defined(SHADERS)
+#if defined(_GLES) || defined(_GLES2) || defined(SHADERS)
if(stippleEnabled)
{
glBegin(GL_LINES);
if(stipple)
{
-#if defined(ES1_1) || defined(ES2) || defined(SHADERS)
+#if defined(_GLES) || defined(_GLES2) || defined(SHADERS)
stippleEnabled = true;
glesLineStipple(1, (uint16)stipple);
#else
}
else
{
-#if defined(ES1_1) || defined(ES2) || defined(SHADERS)
+#if defined(_GLES) || defined(_GLES2) || defined(SHADERS)
stippleEnabled = false;
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
#endif
break;
case fillMode:
-#if !defined(ES1_1) && !defined(ES2)
+#if !defined(_GLES) && !defined(_GLES2)
glPolygonMode(GL_FRONT_AND_BACK, ((FillModeValue)value == solid) ? GL_FILL : GL_LINE);
#endif
break;
case vSync:
{
#if defined(__WIN32__)
- wglSwapIntervalEXT(value ? 1 : 0);
+ if(wglSwapIntervalEXT)
+ wglSwapIntervalEXT(value ? 1 : 0);
#endif
break;
}
{
if(vboAvailable)
{
-#if defined(ES1_1) || defined(ES2)
+#if defined(_GLES) || defined(_GLES2)
if(indices32bit)
{
if(!oglIndices.buffer.buffer)
{
OGLIndices oglIndices = primitive->data;
- GLEAB eab = ((!display.display3D.collectingHits && oglIndices) ? oglIndices.buffer : noEAB);
-
+ GLEAB eab = ((!display.display3D.collectingHits && oglIndices && vboAvailable) ? oglIndices.buffer : noEAB);
+#if defined(_GLES) || defined(_GLES2)
+ if(!vboAvailable && primitive->type.indices32bit)
+ {
+ uint16 * temp = new uint16[primitive->nIndices];
+ uint32 * src = (uint32 *)(oglIndices ? oglIndices.indices : primitive->indices);
+ int i;
+ for(i = 0; i < primitive->nIndices; i++)
+ temp[i] = (uint16)src[i];
+ eab.draw(primitiveTypes[primitive->type.primitiveType], primitive->nIndices, GL_UNSIGNED_SHORT, temp);
+ delete temp;
+ }
+ else
+#endif
eab.draw(primitiveTypes[primitive->type.primitiveType], primitive->nIndices,
primitive->type.indices32bit ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT,
eab.buffer ? 0 : (oglIndices ? oglIndices.indices : primitive->indices));