#if defined(__WIN32__)
#define WIN32_LEAN_AND_MEAN
#undef _WIN32_WINNT
-#define _WIN32_WINNT 0x0500
+#define _WIN32_WINNT 0x0502
#define String Sting_
#include <windows.h>
#undef String
typedef int (APIENTRY * PFNWGLRELEASEPBUFFERDCARBPROC) (void * hPbuffer, HDC hDC);
typedef BOOL (APIENTRY * PFNWGLDESTROYPBUFFERARBPROC) (void * hPbuffer);
typedef BOOL (APIENTRY * PFNWGLQUERYPBUFFERARBPROC) (void * hPbuffer, int iAttribute, int *piValue);
+typedef const char * (APIENTRY * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
+typedef BOOL (APIENTRY * PFNWGLBINDTEXIMAGEARBPROC) (void * hPbuffer, int iBuffer);
+typedef BOOL (APIENTRY * PFNWGLRELEASETEXIMAGEARBPROC) (void * hPbuffer, int iBuffer);
static PFNGLMAPBUFFERARBPROC glMapBufferARB = null;
static PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB = null;
EGL_SAMPLES, 0, //2,*/
EGL_NONE
};
- EGLint w, h, dummy, format;
+ EGLint w, h, format;
EGLint numConfigs;
EGLConfig config;
EGLSurface surface;
void glesOrtho( double l, double r, double b, double t, double n, double f )
{
- Matrix m =
+ Matrix m
{ {
(2 / (r - l)), 0, 0, 0,
0, (2 / (t - b)), 0, 0,
0, 0, (-2 / (f - n)), 0,
(-(r + l) / (r - l)), (-(t + b) / (t - b)), (-(f + n) / (f - n)), 1
- } }, res;
+ } };
+ Matrix res;
res.Multiply(m, matrixStack[curStack][matrixIndex[curStack]]);
matrixStack[curStack][matrixIndex[curStack]] = res;
LoadCurMatrix();
double B = ((t + b) / (t - b));
double C = (-(f + n) / (f - n));
double D = (-2*f*n/(f-n));
- Matrix m =
+ Matrix m
{ {
(2.0*n / (r - l)), 0, 0, 0,
0, (2.0*n / (t - b)), 0, 0,
A, B, C,-1,
0, 0, D, 0
- } }, res;
+ } };
+ Matrix res;
res.Multiply(m, matrixStack[curStack][matrixIndex[curStack]]);
matrixStack[curStack][matrixIndex[curStack]] = res;
LoadCurMatrix();
void glesLineStipple( int i, unsigned short j )
{
uint texture[1*16];
- int c;
int x;
for(x = 0; x < 16; x++)
{
#ifdef __ANDROID__
glGenBuffers(count, buffer);
#else
+#if defined(__WIN32__)
if(glGenBuffersARB)
+#endif
glGenBuffersARB(count, buffer);
#endif
}
#ifdef __ANDROID__
glDeleteBuffers(count, buffer);
#else
+#if defined(__WIN32__)
if(glDeleteBuffersARB)
+#endif
glDeleteBuffersARB(count, buffer);
#endif
}
#ifdef __ANDROID__
glBindBuffer(target, buffer);
#else
+#if defined(__WIN32__)
if(glBindBufferARB)
+#endif
glBindBufferARB(target, buffer);
#endif
}
{
#ifdef __ANDROID__
if(type == GL_DOUBLE)
- glesBufferDatad(target, size, data, usage);
+ glesBufferDatad(target, size, (void *)data, usage);
else if(type == GL_UNSIGNED_INT)
- glesBufferDatai(target, size, data, usage);
+ glesBufferDatai(target, size, (void *)data, usage);
else
glBufferData(target, size, data, usage);
#else
+
+#if defined(__WIN32__)
if(glBufferDataARB)
+#endif
glBufferDataARB(target, size, data, usage);
#endif
int imageBuffers[2];
byte * pboMemory1, * pboMemory2;
*/
-#else
+#elif !defined(__ANDROID__)
GLXContext glContext;
Pixmap pixmap;
HDC hdc;
HGLRC glrc;
HWND hwnd;
-#else
+#elif !defined(__ANDROID__)
XVisualInfo * visualInfo;
GLXContext glContext;
GLXDrawable glxDrawable;
bool LockSystem(DisplaySystem displaySystem)
{
+#if !defined(__ANDROID__)
OGLSystem oglSystem = displaySystem.driverData;
if(useSingleGLContext) return true;
#if defined(__WIN32__)
#elif defined(__unix__) || defined(__APPLE__)
//if(previous) return true;
// printf("Making SYSTEM current\n");
-#if !defined(__ANDROID__)
glXMakeCurrent(xGlobalDisplay, (GLXDrawable)oglSystem.glxDrawable, oglSystem.glContext);
-#endif
//previous = oglSystem.glContext;
#endif
+#endif
return true;
}
bool Lock(Display display)
{
+#if !defined(__ANDROID__)
OGLDisplay oglDisplay = display.driverData;
-
if(useSingleGLContext) return true;
#if defined(__WIN32__)
wglMakeCurrent(oglDisplay.hdc, oglDisplay.glrc);
#elif defined(__unix__) || defined(__APPLE__)
// if(previous) glXMakeCurrent(xGlobalDisplay, None, null);
// printf(" Making DISPLAY current\n");
- #if defined(__ANDROID__)
- #else
glXMakeCurrent(xGlobalDisplay, (GLXDrawable)display.window, oglDisplay.glContext);
- #endif
#endif
+#endif
return true;
}
{
bool result = false;
OGLDisplay oglDisplay = display.driverData;
+#if !defined(__ANDROID__)
OGLSystem oglSystem = display.displaySystem.driverData;
+#endif
if(!oglDisplay)
oglDisplay = display.driverData = OGLDisplay { };
//printf("Inside CreateDisplay\n");
#endif
if(result)
{
-#if !defined(__OLDX__)
+#if defined(__WIN32__)
if(glBlendFuncSeparate)
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
else
-#endif
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+#else
+#if !defined(__OLDX__)
+ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+#else
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+#endif
+#endif
glEnable(GL_BLEND);
glMatrixMode(GL_MODELVIEW);
bool DisplaySize(Display display, int width, int height)
{
OGLDisplay oglDisplay = display.driverData;
- OGLSystem oglSystem = display.displaySystem.driverData;
bool result = false;
//printf("Inside DisplaySize\n");
#if defined(__WIN32__) || defined(USEPBUFFER)
+ OGLSystem oglSystem = display.displaySystem.driverData;
if(display.alphaBlend)
{
#if defined(__WIN32__)
void Update(Display display, Box updateBox)
{
+#if defined(__WIN32__) || defined(USEPBUFFER)
OGLDisplay oglDisplay = display.driverData;
+#endif
//Logf("DisplayScreen\n");
glFlush();
break;
}
case fogDensity:
- value *= nearPlane;
- glFogf(GL_FOG_DENSITY, *(float *)(void *)&value);
+ glFogf(GL_FOG_DENSITY, (float)(RenderStateFloat { ui = value }.f * nearPlane));
break;
case blend:
if(value) glEnable(GL_BLEND); else glDisable(GL_BLEND);
}
}
- bool AllocateMesh(DisplaySystem displaySystem, Mesh mesh)
+ bool AllocateMesh(DisplaySystem displaySystem, Mesh mesh, MeshFeatures flags, int nVertices)
{
bool result = false;
if(mesh.data)
{
OGLMesh oglMesh = mesh.data;
-
- if(mesh.flags.vertices && !oglMesh.vertices && !mesh.vertices)
+ if(mesh.nVertices == nVertices)
{
- mesh.vertices = mesh.flags.doubleVertices ? (Vector3Df *)new Vector3D[mesh.nVertices] : new Vector3Df[mesh.nVertices];
- GLGenBuffers(1, &oglMesh.vertices);
- }
- if(mesh.flags.normals && !oglMesh.normals && !mesh.normals)
- {
- GLGenBuffers( 1, &oglMesh.normals);
- mesh.normals = mesh.flags.doubleNormals ? (Vector3Df *)new Vector3D[mesh.nVertices] : new Vector3Df[mesh.nVertices];
- }
- if(mesh.flags.texCoords1 && !oglMesh.texCoords && !mesh.texCoords)
- {
- GLGenBuffers( 1, &oglMesh.texCoords);
- mesh.texCoords = new Pointf[mesh.nVertices];
+ // Same number of vertices, adding features (Leaves the other features pointers alone)
+ if(mesh.flags != flags)
+ {
+ if(!mesh.flags.vertices && flags.vertices)
+ {
+ if(flags.doubleVertices)
+ {
+ mesh.vertices = (Vector3Df *)new Vector3D[nVertices];
+ }
+ else
+ mesh.vertices = new Vector3Df[nVertices];
+ if(!oglMesh.vertices)
+ GLGenBuffers(1, &oglMesh.vertices);
+ }
+ if(!mesh.flags.normals && flags.normals)
+ {
+ if(flags.doubleNormals)
+ {
+ mesh.normals = (Vector3Df *)new Vector3D[nVertices];
+ }
+ else
+ mesh.normals = new Vector3Df[nVertices];
+ if(!oglMesh.normals)
+ GLGenBuffers( 1, &oglMesh.normals);
+ }
+ if(!mesh.flags.texCoords1 && flags.texCoords1)
+ {
+ mesh.texCoords = new Pointf[nVertices];
+ if(!oglMesh.texCoords)
+ GLGenBuffers( 1, &oglMesh.texCoords);
+ }
+ if(!mesh.flags.colors && flags.colors)
+ {
+ mesh.colors = new ColorRGBAf[nVertices];
+ if(!oglMesh.colors)
+ GLGenBuffers( 1, &oglMesh.colors);
+ }
+ }
}
- if(mesh.flags.colors && !oglMesh.colors && !mesh.colors)
+ else
{
- GLGenBuffers( 1, &oglMesh.colors);
- mesh.colors = new ColorRGBAf[mesh.nVertices];
+ // New number of vertices, reallocate all current and new features
+ flags |= mesh.flags;
+ if(flags.vertices)
+ {
+ if(flags.doubleVertices)
+ {
+ mesh.vertices = (Vector3Df *)renew mesh.vertices Vector3D[nVertices];
+ }
+ else
+ mesh.vertices = renew mesh.vertices Vector3Df[nVertices];
+ if(!oglMesh.vertices)
+ GLGenBuffers(1, &oglMesh.vertices);
+ }
+ if(flags.normals)
+ {
+ if(flags.doubleNormals)
+ {
+ mesh.normals = (Vector3Df *)renew mesh.normals Vector3D[nVertices];
+ }
+ else
+ mesh.normals = renew mesh.normals Vector3Df[nVertices];
+ if(!oglMesh.normals)
+ GLGenBuffers( 1, &oglMesh.normals);
+ }
+ if(flags.texCoords1)
+ {
+ mesh.texCoords = renew mesh.texCoords Pointf[nVertices];
+ if(!oglMesh.texCoords)
+ GLGenBuffers( 1, &oglMesh.texCoords);
+ }
+ if(flags.colors)
+ {
+ mesh.colors = renew mesh.colors ColorRGBAf[nVertices];
+ if(!oglMesh.colors)
+ GLGenBuffers( 1, &oglMesh.colors);
+ }
}
result = true;
}
if(vboAvailable)
{
- if(!(flags.vertices) || oglMesh.vertices)
+ if(flags.vertices && oglMesh.vertices)
{
GLBindBuffer(GL_ARRAY_BUFFER_ARB, oglMesh.vertices);
GLBufferData( mesh.flags.doubleVertices ? GL_DOUBLE : GL_FLOAT, GL_ARRAY_BUFFER_ARB, mesh.nVertices * (mesh.flags.doubleVertices ? sizeof(Vector3D) : sizeof(Vector3Df)), mesh.vertices, GL_STATIC_DRAW_ARB );
}
- if(!(flags.normals) || oglMesh.normals)
+ if(flags.normals && oglMesh.normals)
{
GLBindBuffer(GL_ARRAY_BUFFER_ARB, oglMesh.normals);
GLBufferData( mesh.flags.doubleNormals ? GL_DOUBLE : GL_FLOAT, GL_ARRAY_BUFFER_ARB, mesh.nVertices * (mesh.flags.doubleNormals ? sizeof(Vector3D) : sizeof(Vector3Df)), mesh.normals, GL_STATIC_DRAW_ARB );
}
- if(!(flags.texCoords1) || oglMesh.texCoords)
+ if(flags.texCoords1 && oglMesh.texCoords)
{
GLBindBuffer(GL_ARRAY_BUFFER_ARB, oglMesh.texCoords);
GLBufferData( GL_FLOAT, GL_ARRAY_BUFFER_ARB, mesh.nVertices * sizeof(Pointf), mesh.texCoords, GL_STATIC_DRAW_ARB );
}
- if(!(flags.colors) || oglMesh.colors)
+ if(flags.colors && oglMesh.colors)
{
GLBindBuffer( GL_ARRAY_BUFFER_ARB, oglMesh.colors);
GLBufferData( GL_FLOAT, GL_ARRAY_BUFFER_ARB, mesh.nVertices * sizeof(ColorRGBAf), mesh.colors, GL_STATIC_DRAW_ARB );
//Logf("SelectMesh\n");
#if !defined( __ANDROID__) && !defined(__APPLE__)
- if(display.display3D.mesh && glUnlockArraysEXT)
- glUnlockArraysEXT();
+#if defined(__WIN32__)
+ if(glUnlockArraysEXT)
+#endif
+ if(display.display3D.mesh)
+ glUnlockArraysEXT();
#endif
if(mesh)
{
}
#if !defined(__ANDROID__) && !defined(__APPLE__)
- if(glLockArraysEXT) glLockArraysEXT(0, mesh.nVertices);
+
+#if defined(__WIN32__)
+ if(glLockArraysEXT)
+#endif
+ glLockArraysEXT(0, mesh.nVertices);
#endif
}
else
useSingleGLContext = useSingle;
}
-default dllexport void * __attribute__((stdcall)) IS_GLGetContext(DisplaySystem displaySystem)
+default dllexport void *
+#if defined(__WIN32__)
+__attribute__((stdcall))
+#endif
+IS_GLGetContext(DisplaySystem displaySystem)
{
if(displaySystem)
{
- OGLSystem system = displaySystem.driverData;
#if defined(__WIN32__)
+ OGLSystem system = displaySystem.driverData;
return system.glrc;
-#else
+#elif !defined(__ANDROID__)
+ OGLSystem system = displaySystem.driverData;
return system.glContext;
+#else
+ return eglContext;
#endif
}
return null;