-// #define DIAGNOSTICS
-
-namespace gfx::drivers;
-
-#if defined(__ANDROID__)
-#include <android/native_activity.h>
-#endif
+#if defined(__WIN32__) || defined(__unix__) || defined(__APPLE__)
-#if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__) && !defined(__ODROID__)
-# include "gl_compat_4_4.h"
+// #define DIAGNOSTICS
+#if defined(_DEBUG) && !defined(__ANDROID__) && !defined(__EMSCRIPTEN__) && !defined(__ODROID__)
+ #define GL_DEBUGGING
#endif
-#if defined(__ANDROID__) || defined(__ODROID__)
-import "egl"
-#endif
+import "Display"
import "glab"
import "immediate"
import "matrixStack"
import "shading"
-#define GL_BGRA_EXT 0x80E1
-
-#if defined(__ANDROID__)
-#include <android/log.h>
-#define printf(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "ecere-app", __VA_ARGS__))
-#endif
+namespace gfx::drivers;
-void CheckGLErrors()
-{
- int e, nCount = 0;
- while((e = glGetError()) && nCount++ < 10)
- printf("GL error %d!\n", e);
-}
+#include "glHelpers.h"
-// We were using PBUFFER for alpha compositing on Linux before, but it does not seem to work, nor be required anymore.
-// #define USEPBUFFER
+// ********** GL PLATFORMS INCLUDES **********
+// UNIX
#if defined(__unix__) || defined(__APPLE__)
- #if !defined(__MINGW32__)
- #define GL_GLEXT_PROTOTYPES
- #endif
+ // EGL
+ #if defined(__ANDROID__) || defined(__ODROID__)
+ import "egl"
- #define pointer _pointer
+ #if defined(__ANDROID__)
+ #include <android/native_activity.h>
+ #include <android/log.h>
+ #define printf(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "ecere-app", __VA_ARGS__))
+ #endif
+ // Emscripten
+ #elif defined(__EMSCRIPTEN__)
+ #define property _property
+ #define uint _uint
- #if !defined(__ANDROID__) && !defined(__ODROID__) && !defined(__EMSCRIPTEN__)
+ #include <emscripten/emscripten.h>
+ #include <emscripten/html5.h>
+
+ #undef property
+ #undef uint
+
+ // GLX
+ #elif !defined(__ANDROID__) && !defined(__ODROID__) && !defined(__EMSCRIPTEN__)
+ #define pointer _pointer
+ #define GL_GLEXT_PROTOTYPES
#define property _property
#define new _new
#undef new
#undef property
#undef class
+ #undef pointer
- #endif
-
-#endif
-
-#if defined(__APPLE__)
- #include <OpenGl/gl.h>
-#endif
-
-#if defined(__WIN32__) || defined(__unix__) || defined(__APPLE__)
-
- #if defined(__WIN32__)
- //#define WIN32_LEAN_AND_MEAN
- #undef _WIN32_WINNT
- #define _WIN32_WINNT 0x0502
- #define String Sting_
- #include <windows.h>
- #undef String
- #endif
-
- #if defined(__ANDROID__) || defined(__ODROID__)
- #if !defined(_GLES)
- #define _GLES
+ #if !defined(__APPLE__)
+ GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count);
+ GLAPI void APIENTRY glUnlockArraysEXT (void);
#endif
- #define uint _uint
- #define property _property
- #define new _new
- #define class _class
- #define Window X11Window
- #define Cursor X11Cursor
- #define Font X11Font
- #define Display X11Display
- #define Time X11Time
- #define KeyCode X11KeyCode
- #define Picture X11Picture
- #define Bool X11Bool
-
- #include <GLES/gl.h>
- #include <GLES/glext.h>
-
- #undef Bool
- #undef Picture
- #undef Window
- #undef Cursor
- #undef Font
- #undef Display
- #undef Time
- #undef KeyCode
- #undef uint
- #undef new
- #undef property
- #undef class
-
- #elif defined(__EMSCRIPTEN__)
-#if !defined(_GLES2)
- #define _GLES2
-#endif
- // #define _GLES
+ import "XInterface"
- #define property _property
- #define uint _uint
-
- #include <GLES2/gl2.h>
-
- #include <emscripten/emscripten.h>
- #include <emscripten/html5.h>
+ // We were using PBUFFER for alpha compositing on Linux before, but it does not seem to work, nor be required anymore.
+ // #define USEPBUFFER
- #undef property
- #undef uint
-
- #else
- #include <GL/gl.h>
#endif
- #undef pointer
-
- import "Display"
+// Apple
+#elif defined(__APPLE__)
+ #include <OpenGl/gl.h>
- #if defined(__unix__) || defined(__APPLE__)
+// WGL
+#elif defined(__WIN32__)
+ //#define WIN32_LEAN_AND_MEAN
+ #undef _WIN32_WINNT
+ #define _WIN32_WINNT 0x0502
+ #define String Sting_
+ #include <windows.h>
+ #undef String
- #if !defined(__ANDROID__) && !defined(__ODROID__) && !defined(__EMSCRIPTEN__)
- import "XInterface"
- #endif
+ #include "wglDefs.h"
+#endif
- #endif
+#if defined(__WIN32__)
+#elif !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__ODROID__) && !defined(__EMSCRIPTEN__)
+default:
+private:
+#endif
/* OpenGL Versions Features Quick Reference
// bool mapBuffer :1; // | - | X | ~ | X | X | X | ~ | - | ~ | -
*/
-// Compiled In Capabilities
-#define ENABLE_GL_SHADERS (!defined(_GLES))
-#define ENABLE_GL_FFP (!defined(_GLES2))
-#define ENABLE_GL_POINTER (!defined(__EMSCRIPTEN__))
-#define ENABLE_GL_FBO (!defined(__EMSCRIPTEN__))
-#define ENABLE_GL_LEGACY (!defined(_GLES) && !defined(_GLES2))
-#define ENABLE_GL_INTDBL (!defined(_GLES) && !defined(_GLES2))
-#define ENABLE_GL_MAPBUF (!defined(_GLES) && !defined(_GLES2))
-#define ENABLE_GL_SELECT (!defined(_GLES) && !defined(_GLES2))
-#define ENABLE_GL_COLORMAT (ENABLE_GL_FFP && !defined(_GLES))
-
-#if ENABLE_GL_SHADERS && ENABLE_GL_FFP
- #define GLEnableClientState (shaders ? glEnableVertexAttribArray : glEnableClientState)
- #define GLDisableClientState (shaders ? glDisableVertexAttribArray : glDisableClientState)
- #define VERTICES (shaders ? GLBufferContents::vertex : GL_VERTEX_ARRAY)
- #define NORMALS (shaders ? GLBufferContents::normal : GL_NORMAL_ARRAY)
- #define TEXTURECOORDS (shaders ? GLBufferContents::texCoord : GL_TEXTURE_COORD_ARRAY)
- #define COLORS (shaders ? GLBufferContents::color : GL_COLOR_ARRAY)
- #define GLVertexPointer(n, t, s, p) (shaders ? glVertexAttribPointer(GLBufferContents::vertex, n, t, GL_FALSE, s, p) : glVertexPointer(n, t, s, p))
- #define GLTexCoordPointer(n, t, s, p) (shaders ? glVertexAttribPointer(GLBufferContents::texCoord, n, t, GL_FALSE, s, p) : glTexCoordPointer(n, t, s, p))
-#elif ENABLE_GL_SHADERS
- #define GLEnableClientState glEnableVertexAttribArray
- #define GLDisableClientState glDisableVertexAttribArray
- #define VERTICES GLBufferContents::vertex
- #define NORMALS GLBufferContents::normal
- #define TEXTURECOORDS GLBufferContents::texCoord
- #define COLORS GLBufferContents::color
- #define GLVertexPointer(n, t, s, p) glVertexAttribPointer(GLBufferContents::vertex, n, t, GL_FALSE, s, p)
- #define GLTexCoordPointer(n, t, s, p) glVertexAttribPointer(GLBufferContents::texCoord, n, t, GL_FALSE, s, p)
-#else
- #define GLEnableClientState glEnableClientState
- #define GLDisableClientState glDisableClientState
- #define VERTICES GL_VERTEX_ARRAY
- #define NORMALS GL_NORMAL_ARRAY
- #define TEXTURECOORDS GL_TEXTURE_COORD_ARRAY
- #define COLORS GL_COLOR_ARRAY
- #define GLVertexPointer glVertexPointer
- #define GLTexCoordPointer glTexCoordPointer
-#endif
-
-#define GL_ARRAY_BUFFER_ARB 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
-#define GL_STATIC_DRAW_ARB 0x88E4
-#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
-#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
-
-#define GL_MULTISAMPLE_ARB 0x809D
-
-#if defined(__WIN32__)
- #include "wglDefs.h"
-
- typedef void (APIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);
- typedef void (APIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void);
-
- static PFNGLLOCKARRAYSEXTPROC glLockArraysEXT = null;
- static PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT = null;
-
- static PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = null;
- static PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = null;
- static PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB = null;
- static PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB = null;
- static PFNWGLQUERYPBUFFERARBPROC wglQueryPbufferARB = null;
- static PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB = null;
- static PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB = null;
- static PFNWGLBINDTEXIMAGEARBPROC wglBindTexImageARB = null;
- static PFNWGLRELEASETEXIMAGEARBPROC wglReleaseTexImageARB = null;
- static PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = null;
- static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = null;
-
-#elif !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__ODROID__) && !defined(__EMSCRIPTEN__)
default:
- GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count);
- GLAPI void APIENTRY glUnlockArraysEXT (void);
+// Capabilities Global set to capabilities of Display being rendered to
+GLCapabilities glcaps;
+// Requiring Graphics Reload:
+bool glcaps_nonPow2Textures, glcaps_vertexBuffer, glcaps_quads, glcaps_intAndDouble;
+// Might toggle without Reload:
+bool glcaps_shaders, glcaps_fixedFunction, glcaps_immediate, glcaps_legacy, glcaps_pointSize, glcaps_frameBuffer;
+// bool mapBuffer;
private:
-#endif
+
+// ********** Errors and Debugging **********
+/*
+void CheckGLErrors()
+{
+ int e, nCount = 0;
+ while((e = glGetError()) && nCount++ < 10)
+ printf("GL error %d!\n", e);
+}
+*/
+#ifdef GL_DEBUGGING
#ifndef APIENTRY
#define APIENTRY
#endif
+static void APIENTRY openglCallbackFunction(GLenum source,
+ GLenum type,
+ GLuint id,
+ GLenum severity,
+ GLsizei length,
+ const GLchar* message,
+ const void* userParam)
+{
+ if(severity == GL_DEBUG_SEVERITY_NOTIFICATION)
+ return;
+ PrintLn("---------------------opengl-callback-start------------");
+ PrintLn("message: ", message);
+ PrintLn("type: ");
+ switch (type)
+ {
+ case GL_DEBUG_TYPE_ERROR: PrintLn("ERROR"); break;
+ case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: PrintLn("DEPRECATED_BEHAVIOR"); break;
+ case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: PrintLn("UNDEFINED_BEHAVIOR"); break;
+ case GL_DEBUG_TYPE_PORTABILITY: PrintLn("PORTABILITY"); break;
+ case GL_DEBUG_TYPE_PERFORMANCE: PrintLn("PERFORMANCE"); break;
+ case GL_DEBUG_TYPE_OTHER: PrintLn("OTHER"); break;
+ }
-#if defined(__ANDROID__) || defined(__ODROID__)
- // Frame Buffer Extensions
- #define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
- #define GL_RENDERBUFFER GL_RENDERBUFFER_OES
- #define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES
- #define glBindFramebuffer glBindFramebufferOES
- #define glBindRenderbuffer glBindRenderbufferOES
- #define glFramebufferTexture2D glFramebufferTexture2DOES
- #define glGenFramebuffers glGenFramebuffersOES
- #define glGenRenderbuffers glGenRenderbuffersOES
- #define glDeleteFramebuffers glDeleteFramebuffersOES
- #define glDeleteRenderbuffers glDeleteRenderbuffersOES
-
- // TOFIX: Grab Screen and BlitDI/StretchDI will have wrong colors
- #undef GL_BGRA_EXT
- #define GL_BGRA_EXT GL_RGBA
-#endif
-
-#if !ENABLE_GL_INTDBL
- #define GL_INT 0x1404
- #define GL_UNSIGNED_INT 0x1405
- #define GL_DOUBLE 0x140A
-#endif
+ PrintLn("id: ", id);
+ Print("severity: ");
+ switch (severity)
+ {
+ case GL_DEBUG_SEVERITY_LOW: PrintLn("LOW"); break;
+ case GL_DEBUG_SEVERITY_MEDIUM: PrintLn("MEDIUM"); break;
+ case GL_DEBUG_SEVERITY_HIGH: PrintLn("HIGH"); break;
+ default: PrintLn("(other)");
+ }
+ PrintLn("---------------------opengl-callback-end--------------");
+}
-#if ENABLE_GL_STIPPLES
- #define GLLineStipple (stipples ? glLineStipple : glsupLineStipple)
-#else
- #define GLLineStipple glsupLineStipple
-#endif
+static void setupDebugging()
+{
+ if(glDebugMessageCallback)
+ {
+ GLuint unusedIds = 0;
-#if ENABLE_GL_COLORMAT
- #define GLColorMaterial(a,b) glColorMaterial(a,b)
-#else
- #define GLColorMaterial(a,b)
-#endif
+ glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
-#ifdef _GLES
- #define GLLightModeli glsupLightModeli
-#else
- #define GLLightModeli glLightModeli
+ glDebugMessageCallback(openglCallbackFunction, null);
+ glDebugMessageControl(GL_DONT_CARE,
+ GL_DONT_CARE,
+ GL_DONT_CARE,
+ 0,
+ &unusedIds,
+ GL_TRUE);
+ }
+}
#endif
-#if ENABLE_GL_LEGACY
- #define GLRecti(x1, y1, x2, y2) (immediate && !shaders ? glRecti(x1, y1, x2, y2) : glimtkRecti(capabilities, x1, y1, x2, y2))
- #define GLBegin(m) (immediate && !shaders ? glBegin(m) : glimtkBegin(m))
- #define GLTexCoord2i (immediate && !shaders ? glTexCoord2i : glimtkTexCoord2i)
- #define GLVertex2i (immediate && !shaders ? glVertex2i : glimtkVertex2i)
- #define GLTexCoord2d (immediate && !shaders ? glTexCoord2d : glimtkTexCoord2d)
- #define GLVertex2d (immediate && !shaders ? glVertex2d : glimtkVertex2d)
- #define GLTexCoord2f (immediate && !shaders ? glTexCoord2f : glimtkTexCoord2f)
- #define GLVertex2f (immediate && !shaders ? glVertex2f : glimtkVertex2f)
- #define GLEnd() (immediate && !shaders ? glEnd() : glimtkEnd(capabilities))
- #define GLColor3f(a,b,c) (immediate && !shaders ? glColor3f(a,b,c) : glimtkColor3f(shaders, a,b,c))
- #define GLColor4ub(a,b,c,d) (immediate && !shaders ? glColor4ub(a,b,c,d) : glimtkColor4ub(shaders,a,b,c,d))
- #define GLColor4f(a,b,c,d) (immediate && !shaders ? glColor4f(a,b,c,d) : glimtkColor4f(shaders,a,b,c,d))
- #define GLColor4fv(v) (immediate && !shaders ? glColor4fv(v) : glimtkColor4fv(shaders, v))
- #define GLNormal3fv (immediate && !shaders ? glNormal3fv : glimtkNormal3fv)
- #define GLNormal3f (immediate && !shaders ? glNormal3f : glimtkNormal3f)
- #define GLTexCoord2fv (immediate && !shaders ? glTexCoord2fv : glimtkTexCoord2fv)
- #define GLVertex3d (immediate && !shaders ? glVertex3d : glimtkVertex3d)
- #define GLVertex3dv (immediate && !shaders ? glVertex3dv : glimtkVertex3dv)
- #define GLVertex3f (immediate && !shaders ? glVertex3f : glimtkVertex3f)
- #define GLVertex3fv (immediate && !shaders ? glVertex3fv : glimtkVertex3fv)
-
- #define GLLoadMatrixd(m) (fixedFunction && !shaders ? glLoadMatrixd(m) : glmsLoadMatrixd(shaders, m))
- #define GLMultMatrixd(m) (fixedFunction && !shaders ? glMultMatrixd(m) : glmsMultMatrixd(shaders, m))
- #define GLFrustum(a,b,c,d,e,f) (fixedFunction && !shaders ? glFrustum(a,b,c,d,e,f) : glmsFrustum(shaders, a,b,c,d,e,f))
- #define GLOrtho(a,b,c,d,e,f) (fixedFunction && !shaders ? glOrtho(a,b,c,d,e,f) : glmsOrtho(shaders, a,b,c,d,e,f))
- #define GLScaled(x, y, z) (fixedFunction && !shaders ? glScaled(x, y, z) : glmsScaled(shaders, x,y,z))
- #define GLScalef(x, y, z) (fixedFunction && !shaders ? glScalef(x, y, z) : glmsScaled(shaders, x,y,z))
- #define GLTranslated(x, y, z) (fixedFunction && !shaders ? glTranslated(x,y,z) : glmsTranslated(shaders, x,y,z))
- #define GLRotated(a, x, y, z) (fixedFunction && !shaders ? glRotated : glmsRotated)
- #define GLMatrixMode(m) (fixedFunction && !shaders ? glMatrixMode(m) : glmsMatrixMode(shaders, m))
- #define GLLoadIdentity() (fixedFunction && !shaders ? glLoadIdentity() : glmsLoadIdentity(shaders))
- #define GLPushMatrix (fixedFunction && !shaders ? glPushMatrix : glmsPushMatrix)
- #define GLPopMatrix() (fixedFunction && !shaders ? glPopMatrix() : glmsPopMatrix(shaders))
-#else
- #define GLRecti(x1, y1, x2, y2) glimtkRecti(capabilities, x1, y1, x2, y2)
- #define GLBegin(m) glimtkBegin(m)
- #define GLTexCoord2i glimtkTexCoord2i
- #define GLVertex2i glimtkVertex2i
- #define GLTexCoord2d glimtkTexCoord2d
- #define GLVertex2d glimtkVertex2d
- #define GLTexCoord2f glimtkTexCoord2f
- #define GLVertex2f glimtkVertex2f
- #define GLEnd() glimtkEnd(capabilities)
- #define GLColor3f(a,b,c) glimtkColor3f(shaders, a,b,c)
- #define GLColor4ub(a,b,c,d) glimtkColor4ub(shaders,a,b,c,d)
- #define GLColor4f(a,b,c,d) glimtkColor4f(shaders,a,b,c,d)
- #define GLColor4fv(v) glimtkColor4fv(shaders, v)
- #define GLNormal3fv glimtkNormal3fv
- #define GLNormal3f glimtkNormal3f
- #define GLTexCoord2fv glimtkTexCoord2fv
- #define GLVertex3d glimtkVertex3d
- #define GLVertex3dv glimtkVertex3dv
- #define GLVertex3f glimtkVertex3f
- #define GLVertex3fv glimtkVertex3fv
-
- #define GLLoadMatrixd(m) glmsLoadMatrixd(shaders, m)
- #define GLMultMatrixd(m) glmsMultMatrixd(shaders, m)
- #define GLFrustum(a,b,c,d,e,f) glmsFrustum(shaders, a,b,c,d,e,f)
- #define GLOrtho(a,b,c,d,e,f) glmsOrtho(shaders, a,b,c,d,e,f)
- #define GLScaled(a,b,c) glmsScaled(shaders, a,b,c)
- #define GLScalef(a,b,c) glmsScaled(shaders, a,b,c)
- #define GLTranslated(a,b,c) glmsTranslated(shaders, a,b,c)
- #define GLRotated(a, x, y, z) glmsRotated(shaders, a, x, y, z)
- #define GLMatrixMode(m) glmsMatrixMode(shaders, m)
- #define GLLoadIdentity() glmsLoadIdentity(shaders)
- #define GLPushMatrix glmsPushMatrix
- #define GLPopMatrix() glmsPopMatrix(shaders)
-#endif
-
-#define GLLoadMatrix GLLoadMatrixd
-#define GLMultMatrix GLMultMatrixd
-#define GLGetMatrix GLGetDoublev
-#define GLTranslate GLTranslated
-#define GLScale GLScaled
static GLuint stippleTexture;
static bool stippleEnabled;
- // TOCHECK: Do we really need to pass shaders?
-public void glsupLineStipple( bool shaders, int i, unsigned short j )
+
+ // TOCHECK: Do we really need to pass glcaps_shaders?
+public void glsupLineStipple( int i, unsigned short j )
{
-#if ENABLE_GL_LEGACY
- bool fixedFunction = false;
-#endif
uint texture[1*16];
int x;
for(x = 0; x < 16; x++)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
// TOOD: Special shading code for stippling?
- GLSetupTexturing(shaders, true);
+ GLSetupTexturing(true);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
GLMatrixMode(MatrixMode::projection);
}
-#ifdef _GLES
+ // Exported to build _GLES version...
public void glsupLightModeli( unsigned int pname, int param )
{
+#if ENABLE_GL_FFP
if(pname == GL_LIGHT_MODEL_TWO_SIDE)
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, param);
+#endif
}
+#ifdef _GLES
void glFogi( unsigned int pname, int param ) { }
void glPolygonMode( unsigned int i, unsigned int j ) { }
void glBlendFuncSeparate(int a, int b, int c, int d)
#endif
#if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
-static inline uint getPrimitiveType(bool quadsSupport, RenderPrimitiveType type)
+static inline uint getPrimitiveType(RenderPrimitiveType type)
{
static int primitiveTypes[RenderPrimitiveType] =
{
GL_LINE_STRIP
};
// NOTE: This will only work for single quads
- return (type == quads && !quadsSupport) ? GL_TRIANGLE_FAN : primitiveTypes[type];
+ return (type == quads && !glcaps_quads) ? GL_TRIANGLE_FAN : primitiveTypes[type];
}
-public void GLSetupTexturing(bool shaders, bool enable)
+public void GLSetupTexturing(bool enable)
{
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_texturing(enable);
#endif
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
(enable ? glEnable : glDisable)(GL_TEXTURE_2D);
#endif
}
-public void GLSetupFog(bool shaders, bool enable)
+public void GLSetupFog(bool enable)
{
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_fog(enable);
#endif
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
(enable ? glEnable : glDisable)(GL_FOG);
#endif
}
bool lightingEnabled;
-public void GLSetupLighting(bool shaders, bool enable)
+public void GLSetupLighting(bool enable)
{
lightingEnabled = enable;
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_lighting(enable);
#endif
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
(enable ? glEnable : glDisable)(GL_LIGHTING);
#endif
}
int x, y;
};
-#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,
- GLenum severity,
- GLsizei length,
- const GLchar* message,
- const void* userParam)
-{
- if(severity == GL_DEBUG_SEVERITY_NOTIFICATION)
- return;
- PrintLn("---------------------opengl-callback-start------------");
- PrintLn("message: ", message);
- PrintLn("type: ");
- switch (type)
- {
- case GL_DEBUG_TYPE_ERROR: PrintLn("ERROR"); break;
- case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: PrintLn("DEPRECATED_BEHAVIOR"); break;
- case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: PrintLn("UNDEFINED_BEHAVIOR"); break;
- case GL_DEBUG_TYPE_PORTABILITY: PrintLn("PORTABILITY"); break;
- case GL_DEBUG_TYPE_PERFORMANCE: PrintLn("PERFORMANCE"); break;
- case GL_DEBUG_TYPE_OTHER: PrintLn("OTHER"); break;
- }
-
- PrintLn("id: ", id);
- Print("severity: ");
- switch (severity)
- {
- case GL_DEBUG_SEVERITY_LOW: PrintLn("LOW"); break;
- case GL_DEBUG_SEVERITY_MEDIUM: PrintLn("MEDIUM"); break;
- case GL_DEBUG_SEVERITY_HIGH: PrintLn("HIGH"); break;
- default: PrintLn("(other)");
- }
- PrintLn("---------------------opengl-callback-end--------------");
-}
-#endif
-
class OGLSystem : struct
{
int maxTextureSize;
int current;
void * previous;
-#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,
- GL_DONT_CARE,
- 0,
- &unusedIds,
- GL_TRUE);
- }
-}
-#endif
-
#if defined(__WIN32__)
static HGLRC winCreateContext(HDC hdc, int * contextVersion, bool * isCompatible)
{
#ifdef _DEBUG
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
#endif
- WGL_CONTEXT_PROFILE_MASK_ARB, coreNotion ? (tryingCompat ? WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : WGL_CONTEXT_CORE_PROFILE_BIT_ARB) : 0,
+ coreNotion ? WGL_CONTEXT_PROFILE_MASK_ARB : 0, coreNotion ? (tryingCompat ? WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : WGL_CONTEXT_CORE_PROFILE_BIT_ARB) : 0,
0,0
};
result = wglCreateContextAttribsARB(hdc, null, attribs);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &oglSystem.maxTextureSize);
#if defined(_GLES)
- capabilities = { fixedFunction = true, vertexBuffer = true, frameBuffer = extensions && strstr(extensions, "GL_OES_framebuffer_object") };
+ capabilities = { fixedFunction = true, vertexBuffer = true, pointSize = true, frameBuffer = extensions && strstr(extensions, "GL_OES_framebuffer_object") };
#elif defined(_GLES2)
- capabilities = { shaders = true, vertexBuffer = true, frameBuffer = true };
+ capabilities = { glcaps_shaders = true, vertexBuffer = true, pointSize = true, frameBuffer = true };
#else
capabilities =
{
nonPow2Textures = extensions && strstr(extensions, "GL_ARB_texture_non_power_of_two");
intAndDouble = true;
+ pointSize = true;
#if ENABLE_GL_LEGACY
legacy = glBegin != null;
immediate = glBegin != null;
{
bool result = false;
OGLSystem oglSystem = displaySystem.driverData = OGLSystem { };
-#if defined(__ANDROID__) || defined(__ODROID__)
- bool shaders = false;
-#endif
#ifdef _GLES
- oglSystem.capabilities = { fixedFunction = true, vertexBuffer = true, frameBuffer = true };
+ oglSystem.capabilities = { fixedFunction = true, vertexBuffer = true, frameBuffer = true, pointSize = true };
#elif defined(_GLES2)
- oglSystem.capabilities = { shaders = true, vertexBuffer = true, frameBuffer = true };
+ oglSystem.capabilities = { shaders = true, vertexBuffer = true, frameBuffer = true, pointSize = true };
#else
- oglSystem.capabilities = { shaders = true, fixedFunction = true, immediate = true, legacy = true, quads = true, intAndDouble = true, vertexBuffer = true, frameBuffer = true, nonPow2Textures = true };
+ oglSystem.capabilities = { shaders = true, fixedFunction = true, immediate = true, legacy = true, pointSize = true, quads = true, intAndDouble = true, vertexBuffer = true, frameBuffer = true, nonPow2Textures = true };
#endif
#ifdef DIAGNOSTICS
GLMatrixMode(GL_PROJECTION);
glShadeModel(GL_FLAT);
- if(!shaders)
+#if !defined(_GLES)
+ if(!glcaps_shaders)
GLLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+#endif
glFogi(GL_FOG_MODE, GL_EXP);
glFogf(GL_FOG_DENSITY, 0);
glEnable(GL_NORMALIZE);
glDepthFunc(GL_LESS);
glClearDepth(1.0);
- glDisable(GL_MULTISAMPLE_ARB);
+ glDisable(GL_MULTISAMPLE);
glViewport(0,0,eglWidth,eglHeight);
GLLoadIdentity();
/*static */bool ::initialDisplaySetup(Display display)
{
OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
+ OGLSystem oglSystem = display.displaySystem.driverData;
bool result = true;
- bool shaders = capabilities.shaders;
-#if ENABLE_GL_LEGACY
- bool fixedFunction = capabilities.fixedFunction;
-#endif
+
+ oglSystem.capabilities = oglDisplay.capabilities;
+ SETCAPS(oglDisplay.capabilities);
+
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
loadShaders(display.displaySystem, "<:ecere>shaders/fixed.vertex", "<:ecere>shaders/fixed.frag");
#if ENABLE_GL_LEGACY
else
#endif
glEnable(GL_BLEND);
+ GLMatrixMode(MatrixMode::texture);
+ GLLoadIdentity();
+
GLMatrixMode(MatrixMode::modelView);
GLLoadIdentity(); // For setting up GLES stack
GLScaled(1.0, 1.0, -1.0);
GLOrtho(0,display.width,display.height,0,0.0,1.0);
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
{
glShadeModel(GL_FLAT);
/*
#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
GLLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
*/
+#if !defined(_GLES)
GLLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+#endif
glFogi(GL_FOG_MODE, GL_EXP);
glFogf(GL_FOG_DENSITY, 0);
glEnable(GL_NORMALIZE);
#endif
glDepthFunc(GL_LESS);
glClearDepth(1.0);
- glDisable(GL_MULTISAMPLE_ARB);
+#if !defined(__EMSCRIPTEN__)
+ glDisable(GL_MULTISAMPLE);
+#endif
+
#if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
display.ambient = Color { 50,50,50 };
#endif
oglDisplay.originalCapabilities = oglDisplay.capabilities;
- // Re-enable shaders if no fixed function support
+ // Re-enable glcaps_shaders if no fixed function support
if(!oglDisplay.capabilities.fixedFunction)
capabilities.shaders = true;
- // Re-enable fixed function if no shaders support
+ // Re-enable fixed function if no glcaps_shaders support
if(!oglDisplay.capabilities.shaders)
+ {
capabilities.fixedFunction = true;
+ capabilities.shaders = false;
+ }
+
+ // Disable things that don't work with glcaps_shaders
+ if(capabilities.shaders)
+ {
+ capabilities.fixedFunction = false;
+ capabilities.legacy = false;
+ capabilities.immediate = false;
+ }
#if !ENABLE_GL_POINTER
// Re-enable vertex buffer if no pointer support
bool DisplaySize(Display display, int width, int height)
{
OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool fixedFunction = capabilities.fixedFunction;
-#endif
- bool shaders = capabilities.shaders;
bool result = false;
#if defined(__WIN32__) || defined(USEPBUFFER)
#endif
result = true;
+ SETCAPS(oglDisplay.capabilities);
+
if(display.alphaBlend && result)
initialDisplaySetup(display);
{
bool result = false;
OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool fixedFunction = capabilities.fixedFunction;
-#endif
- bool shaders = capabilities.shaders;
OGLSurface oglSurface = surface.driverData = OGLSurface { };
-
if(oglSurface)
{
+ SETCAPS(oglDisplay.capabilities);
if(displayWidth != display.width || displayHeight != display.height)
{
displayWidth = display.width;
void PutPixel(Display display, Surface surface,int x,int y)
{
OGLSurface oglSurface = surface.driverData;
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool immediate = capabilities.immediate;
-#endif
- bool shaders = capabilities.shaders;
-
GLColor4fv(oglSurface.foreground);
GLBegin(GL_POINTS);
// glVertex2i(x+surface.offset.x, y+surface.offset.y);
GLVertex2f(x+surface.offset.x + 0.5f, y+surface.offset.y + 0.5f);
-
GLEnd();
}
void DrawLine(Display display, Surface surface, int _x1, int _y1, int _x2, int _y2)
{
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool immediate = capabilities.immediate;
-#endif
- bool shaders = capabilities.shaders;
-
OGLSurface oglSurface = surface.driverData;
float x1 = _x1, x2 = _x2, y1 = _y1, y2 = _y2;
if(_x1 == _x2)
void Rectangle(Display display, Surface surface,int x1,int y1,int x2,int y2)
{
OGLSurface oglSurface = surface.driverData;
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool immediate = capabilities.immediate;
-#endif
- bool shaders = capabilities.shaders;
x1 += surface.offset.x;
y1 += surface.offset.y;
x2 += surface.offset.x;
void Area(Display display, Surface surface,int x1,int y1,int x2,int y2)
{
OGLSurface oglSurface = surface.driverData;
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool immediate = capabilities.immediate;
-#endif
- bool shaders = capabilities.shaders;
GLColor4fv(oglSurface.background);
void Blit(Display display, Surface surface, Bitmap bitmap, int dx, int dy, int sx, int sy, int w, int h)
{
OGLSurface oglSurface = surface.driverData;
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool immediate = capabilities.immediate;
- bool fixedFunction = capabilities.fixedFunction;
-#endif
- bool shaders = capabilities.shaders;
if(!oglSurface.writingText)
{
// glTranslatef(-0.375f, -0.375f, 0.0f);
- GLSetupTexturing(shaders, true);
+ GLSetupTexturing(true);
GLColor4fv(oglSurface.bitmapMult);
}
else if(oglSurface.xOffset)
if(!oglSurface.writingText)
{
- GLSetupTexturing(shaders, false);
+ GLSetupTexturing(false);
//glTranslate(0.375, 0.375, 0.0);
}
void Stretch(Display display, Surface surface, Bitmap bitmap, int dx, int dy, int sx, int sy, int w, int h, int sw, int sh)
{
OGLSurface oglSurface = surface.driverData;
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool immediate = capabilities.immediate;
-#endif
- bool shaders = capabilities.shaders;
//glTranslate(-0.375, -0.375, 0.0);
- GLSetupTexturing(shaders, true);
+ GLSetupTexturing(true);
glBindTexture(GL_TEXTURE_2D, (GLuint)(uintptr)bitmap.driverData);
GLColor4fv(oglSurface.bitmapMult);
GLEnd();
- GLSetupTexturing(shaders, false);
+ GLSetupTexturing(false);
//glTranslate(0.375, 0.375, 0.0);
}
if(bitmap.pixelFormat == pixelFormat888 && !bitmap.paletteShades)
{
-#if ENABLE_GL_LEGACY
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
- bool legacy = capabilities.legacy;
-#endif
-
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
#if ENABLE_GL_LEGACY
- if(legacy)
+ if(glcaps_legacy)
{
glPixelStorei(GL_UNPACK_ROW_LENGTH, bitmap.stride);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx);
if(bitmap.pixelFormat == pixelFormat888 && !bitmap.paletteShades)
{
-#if ENABLE_GL_LEGACY
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
- bool legacy = capabilities.legacy;
-#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
#if ENABLE_GL_LEGACY
- if(legacy)
+ if(glcaps_legacy)
{
glPixelStorei(GL_UNPACK_ROW_LENGTH, bitmap.stride);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, sx);
{
OGLSurface oglSurface = surface.driverData;
OGLSystem oglSystem = display.displaySystem.driverData;
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool immediate = capabilities.immediate;
-#endif
- bool shaders = capabilities.shaders;
oglSystem.loadingFont = true;
//glTranslated(-0.375, -0.375, 0.0);
oglSurface.writingText = true;
- GLSetupTexturing(shaders, true);
+ GLSetupTexturing(true);
if(surface.font.outlineSize)
{
oglSurface.writingText = false;
oglSystem.loadingFont = false;
- GLSetupTexturing(shaders, false);
+ GLSetupTexturing(false);
//glTranslated(0.375, 0.375, 0.0);
}
void LineStipple(Display display, Surface surface, uint32 stipple)
{
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool legacy = capabilities.legacy;
- bool fixedFunction = capabilities.fixedFunction;
-#endif
- bool shaders = capabilities.shaders;
-
if(stipple)
{
#if ENABLE_GL_LEGACY
- if(legacy)
+ if(glcaps_legacy)
{
- stippleEnabled = true;
glLineStipple(1, (uint16)stipple);
glEnable(GL_LINE_STIPPLE);
}
else
#endif
- glsupLineStipple(shaders, 1, (uint16)stipple);
+ {
+ stippleEnabled = true;
+ glsupLineStipple(1, (uint16)stipple);
+ }
}
else
{
#if ENABLE_GL_LEGACY
- if(legacy)
+ if(glcaps_legacy)
glDisable(GL_LINE_STIPPLE);
else
#endif
GLMatrixMode(GL_TEXTURE);
GLLoadIdentity();
GLMatrixMode(MatrixMode::projection);
- GLSetupTexturing(shaders, false); // TODO: Special shading code for stipple?
+ GLSetupTexturing(false); // TODO: Special shading code for stipple?
}
}
}
void SetRenderState(Display display, RenderState state, uint value)
{
OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool legacy = capabilities.legacy;
-#endif
- bool shaders = capabilities.shaders;
-
switch(state)
{
case antiAlias:
#ifndef __EMSCRIPTEN__
if(value)
- glEnable(GL_MULTISAMPLE_ARB);
+ glEnable(GL_MULTISAMPLE);
else
- glDisable(GL_MULTISAMPLE_ARB);
+ glDisable(GL_MULTISAMPLE);
#endif
break;
case fillMode:
#if ENABLE_GL_LEGACY
- if(legacy)
+ if(glcaps_legacy)
glPolygonMode(GL_FRONT_AND_BACK, ((FillModeValue)value == solid) ? GL_FILL : GL_LINE);
#endif
break;
{
float color[4] = { ((Color)value).r/255.0f, ((Color)value).g/255.0f, ((Color)value).b/255.0f, 1.0f };
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_fogColor(color[0], color[1], color[2]);
#endif
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
glFogfv(GL_FOG_COLOR, (float *)&color);
#endif
break;
}
case fogDensity:
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_fogDensity((float)(RenderStateFloat { ui = value }.f * nearPlane));
#endif
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
glFogf(GL_FOG_DENSITY, (float)(RenderStateFloat { ui = value }.f * nearPlane));
#endif
break;
case ambient:
{
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_setGlobalAmbient(((Color)value).r / 255.0f, ((Color)value).g / 255.0f, ((Color)value).b / 255.0f, 1.0f);
#endif
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
{
float ambient[4] = { ((Color)value).r/255.0f, ((Color)value).g/255.0f, ((Color)value).b/255.0f, 1.0f };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
void SetLight(Display display, int id, Light light)
{
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
- bool shaders = capabilities.shaders;
-
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_setLight(display, id, light);
#endif
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
{
if(light != null)
{
void SetCamera(Display display, Surface surface, Camera camera)
{
OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool fixedFunction = capabilities.fixedFunction;
-#endif
- bool shaders = capabilities.shaders;
if(surface && camera)
{
glEnable(GL_DEPTH_TEST);
- GLSetupLighting(shaders, true);
+ GLSetupLighting(true);
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
glShadeModel(GL_SMOOTH);
#endif
glDepthMask((byte)bool::true);
oglDisplay.depthWrite = true;
#ifndef __EMSCRIPTEN__
- glEnable(GL_MULTISAMPLE_ARB);
+ glEnable(GL_MULTISAMPLE);
#endif
}
else if(surface && display.display3D.camera)
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
- GLSetupTexturing(shaders, false);
- GLSetupLighting(shaders, false);
- GLSetupFog(shaders, false);
+ GLSetupTexturing(false);
+ GLSetupLighting(false);
+ GLSetupFog(false);
GLDisableClientState(COLORS);
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_setPerVertexColor(false);
#endif
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
glShadeModel(GL_FLAT);
#endif
glEnable(GL_BLEND);
#if !defined(__EMSCRIPTEN__)
- glDisable(GL_MULTISAMPLE_ARB);
+ glDisable(GL_MULTISAMPLE);
#endif
// *** Restore 2D MODELVIEW Matrix ***
void ApplyMaterial(Display display, Material material, Mesh mesh)
{
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool fixedFunction = capabilities.fixedFunction;
-#endif
- bool shaders = capabilities.shaders;
-
// Basic Properties
if(material.flags.doubleSided)
{
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
GLLightModeli(GL_LIGHT_MODEL_TWO_SIDE, !material.flags.singleSideLight);
#endif
glDisable(GL_CULL_FACE);
else
{
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
GLLightModeli(GL_LIGHT_MODEL_TWO_SIDE, bool::false);
#endif
glEnable(GL_CULL_FACE);
}
// Fog
- GLSetupFog(shaders, !material.flags.noFog);
+ GLSetupFog(!material.flags.noFog);
// Maps
if(material.baseMap && (mesh.texCoords || mesh.flags.texCoords1))
{
Bitmap map = material.baseMap;
- GLSetupTexturing(shaders, true);
+ GLSetupTexturing(true);
glBindTexture(GL_TEXTURE_2D, (GLuint)(uintptr)map.driverData);
GLMatrixMode(GL_TEXTURE);
}
}
else
- GLSetupTexturing(shaders, false);
+ GLSetupTexturing(false);
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_setMaterial(material, mesh.flags.colors);
#endif
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
{
if(mesh.flags.colors)
{
OGLMesh oglMesh = mesh.data;
if(oglMesh)
{
- OGLDisplay oglSystem = displaySystem.driverData;
- GLCapabilities capabilities = oglSystem.capabilities;
- bool vertexBuffer = capabilities.vertexBuffer;
+ OGLSystem oglSystem = displaySystem.driverData;
+ SETCAPS(oglSystem.capabilities);
if(!mesh.flags.vertices)
{
- oglMesh.vertices.free(vertexBuffer);
+ oglMesh.vertices.free(glcaps_vertexBuffer);
delete mesh.vertices;
}
if(!mesh.flags.normals)
{
- oglMesh.normals.free(vertexBuffer);
+ oglMesh.normals.free(glcaps_vertexBuffer);
delete mesh.normals;
}
if(!mesh.flags.texCoords1)
{
- oglMesh.texCoords.free(vertexBuffer);
+ oglMesh.texCoords.free(glcaps_vertexBuffer);
delete mesh.texCoords;
}
if(!mesh.flags.texCoords2)
{
- oglMesh.texCoords2.free(vertexBuffer);
+ oglMesh.texCoords2.free(glcaps_vertexBuffer);
// delete mesh.texCoords2;
}
if(!mesh.flags.colors)
{
- oglMesh.colors.free(vertexBuffer);
+ oglMesh.colors.free(glcaps_vertexBuffer);
delete mesh.colors;
}
if(!mesh.flags)
void UnlockMesh(DisplaySystem displaySystem, Mesh mesh, MeshFeatures flags)
{
OGLSystem oglSystem = displaySystem.driverData;
- GLCapabilities capabilities = oglSystem.capabilities;
- bool vertexBuffer = capabilities.vertexBuffer;
- if(vertexBuffer)
+ SETCAPS(oglSystem.capabilities);
+ if(glcaps_vertexBuffer)
{
OGLMesh oglMesh = mesh.data;
if(!flags) flags = mesh.flags;
if(flags.vertices)
- oglMesh.vertices.upload(vertexBuffer,
- mesh.nVertices * (mesh.flags.doubleVertices ? sizeof(Vector3D) : sizeof(Vector3Df)), mesh.vertices); //, GL_STATIC_DRAW_ARB );
+ oglMesh.vertices.upload(
+ mesh.nVertices * (mesh.flags.doubleVertices ? sizeof(Vector3D) : sizeof(Vector3Df)), mesh.vertices);
if(flags.normals)
- oglMesh.normals.upload(vertexBuffer,
- mesh.nVertices * (mesh.flags.doubleNormals ? sizeof(Vector3D) : sizeof(Vector3Df)), mesh.normals); //, GL_STATIC_DRAW_ARB );
+ oglMesh.normals.upload(
+ mesh.nVertices * (mesh.flags.doubleNormals ? sizeof(Vector3D) : sizeof(Vector3Df)), mesh.normals);
if(flags.texCoords1)
- oglMesh.texCoords.upload(vertexBuffer,
- mesh.nVertices * sizeof(Pointf), mesh.texCoords); //, GL_STATIC_DRAW_ARB );
+ oglMesh.texCoords.upload(
+ mesh.nVertices * sizeof(Pointf), mesh.texCoords);
if(flags.colors)
- oglMesh.colors.upload(vertexBuffer,
- mesh.nVertices * sizeof(ColorRGBAf), mesh.colors); //, GL_STATIC_DRAW_ARB );
+ oglMesh.colors.upload(
+ mesh.nVertices * sizeof(ColorRGBAf), mesh.colors);
}
}
void FreeIndices(DisplaySystem displaySystem, OGLIndices oglIndices)
{
OGLSystem oglSystem = displaySystem.driverData;
- GLCapabilities capabilities = oglSystem.capabilities;
- bool vertexBuffer = capabilities.vertexBuffer;
+ SETCAPS(oglSystem.capabilities);
if(oglIndices)
{
- oglIndices.buffer.free(vertexBuffer);
+ oglIndices.buffer.free(glcaps_vertexBuffer);
delete oglIndices.indices;
delete oglIndices;
}
void UnlockIndices(DisplaySystem displaySystem, OGLIndices oglIndices, bool indices32bit, int nIndices)
{
OGLSystem oglSystem = displaySystem.driverData;
- GLCapabilities capabilities = oglSystem.capabilities;
- bool vertexBuffer = capabilities.vertexBuffer;
- if(vertexBuffer)
+ SETCAPS(oglSystem.capabilities);
+ if(glcaps_vertexBuffer)
{
#if !ENABLE_GL_INTDBL
if(indices32bit)
glGenBuffers(1, &oglIndices.buffer.buffer);
if(glabCurElementBuffer != oglIndices.buffer.buffer)
GLABBindBuffer(GL_ELEMENT_ARRAY_BUFFER, oglIndices.buffer.buffer);
- glimtkBufferDatai(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32) * nIndices, oglIndices.indices, GL_STATIC_DRAW_ARB);
+ glimtkBufferDatai(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32) * nIndices, oglIndices.indices, GL_STATIC_DRAW);
}
else
#endif
- oglIndices.buffer.upload(vertexBuffer,
+ oglIndices.buffer.upload(
nIndices * (indices32bit ? sizeof(uint32) : sizeof(uint16)),
- oglIndices.indices); //GL_STATIC_DRAW_ARB);
+ oglIndices.indices);
}
}
void SelectMesh(Display display, Mesh mesh)
{
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_SHADERS && ENABLE_GL_FFP
- bool shaders = capabilities.shaders;
-#endif
-
#if !defined( __ANDROID__) && !defined(__APPLE__) && !defined(__ODROID__) && !defined(__EMSCRIPTEN__)
- bool vertexBuffer = capabilities.vertexBuffer;
-
#if defined(__WIN32__)
if(glUnlockArraysEXT)
#endif
- if(!vertexBuffer && display.display3D.mesh)
+ if(!glcaps_vertexBuffer && display.display3D.mesh)
glUnlockArraysEXT();
-
#endif
if(mesh)
{
GLEnableClientState(VERTICES);
if(!display.display3D.collectingHits && oglMesh)
{
- oglMesh.vertices.use(capabilities, vertex, 3, (mesh.flags.doubleVertices ? GL_DOUBLE : GL_FLOAT), 0, oglMesh.vertices.buffer ? null : (double *)mesh.vertices);
+ oglMesh.vertices.use(vertex, 3, (mesh.flags.doubleVertices ? GL_DOUBLE : GL_FLOAT), 0, oglMesh.vertices.buffer ? null : (double *)mesh.vertices);
// *** Normals Stream ***
if(mesh.normals || mesh.flags.normals)
{
GLEnableClientState(NORMALS);
- oglMesh.normals.use(capabilities, normal, 3, GL_FLOAT, 0, oglMesh.normals.buffer ? null : mesh.normals);
+ oglMesh.normals.use(normal, 3, GL_FLOAT, 0, oglMesh.normals.buffer ? null : mesh.normals);
}
else
GLDisableClientState(NORMALS);
// *** Texture Coordinates Stream ***
if(mesh.texCoords || mesh.flags.texCoords1)
{
- GLEnableClientState(TEXTURECOORDS);
- oglMesh.texCoords.use(capabilities, texCoord, 2, GL_FLOAT, 0, oglMesh.texCoords.buffer ? null : mesh.texCoords);
+ GLEnableClientState(TEXCOORDS);
+ oglMesh.texCoords.use(texCoord, 2, GL_FLOAT, 0, oglMesh.texCoords.buffer ? null : mesh.texCoords);
}
else
- GLDisableClientState(TEXTURECOORDS);
+ GLDisableClientState(TEXCOORDS);
// *** Color Stream ***
if(mesh.colors || mesh.flags.colors)
{
GLEnableClientState(COLORS);
- oglMesh.colors.use(capabilities, color, 4, GL_FLOAT, 0, oglMesh.colors.buffer ? null : mesh.colors);
+ oglMesh.colors.use(color, 4, GL_FLOAT, 0, oglMesh.colors.buffer ? null : mesh.colors);
}
else
GLDisableClientState(COLORS);
}
else
{
- noAB.use(capabilities, vertex, 3, (mesh.flags.doubleVertices ? GL_DOUBLE : GL_FLOAT), 0, (double *)mesh.vertices);
+ noAB.use(vertex, 3, (mesh.flags.doubleVertices ? GL_DOUBLE : GL_FLOAT), 0, (double *)mesh.vertices);
if((mesh.normals || mesh.flags.normals) && !display.display3D.collectingHits)
{
GLEnableClientState(NORMALS);
- noAB.use(capabilities, normal, 3, GL_FLOAT, 0, mesh.normals);
+ noAB.use(normal, 3, GL_FLOAT, 0, mesh.normals);
}
else
GLDisableClientState(NORMALS);
if((mesh.texCoords || mesh.flags.texCoords1) && !display.display3D.collectingHits)
{
- GLEnableClientState(TEXTURECOORDS);
- noAB.use(capabilities, texCoord, 2, GL_FLOAT, 0, mesh.texCoords);
+ GLEnableClientState(TEXCOORDS);
+ noAB.use(texCoord, 2, GL_FLOAT, 0, mesh.texCoords);
}
else
- GLDisableClientState(TEXTURECOORDS);
+ GLDisableClientState(TEXCOORDS);
if((mesh.colors || mesh.flags.colors) && !display.display3D.collectingHits)
{
GLEnableClientState(COLORS);
- noAB.use(capabilities, color, 4, GL_FLOAT, 0, mesh.colors);
+ noAB.use(color, 4, GL_FLOAT, 0, mesh.colors);
}
else
GLDisableClientState(COLORS);
#if defined(__WIN32__)
if(glLockArraysEXT)
#endif
- if(!vertexBuffer)
+ if(!glcaps_vertexBuffer)
glLockArraysEXT(0, mesh.nVertices);
#endif
}
void DrawPrimitives(Display display, PrimitiveSingle * primitive, Mesh mesh)
{
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
- bool vertexBuffer = capabilities.vertexBuffer;
-
if(primitive->type.vertexRange)
- glDrawArrays(getPrimitiveType(oglDisplay.capabilities.quads, primitive->type.primitiveType), primitive->first, primitive->nVertices);
+ {
+ GLFlushMatrices();
+ glDrawArrays(getPrimitiveType(primitive->type.primitiveType), primitive->first, primitive->nVertices);
+ }
else
{
OGLIndices oglIndices = primitive->data;
- GLEAB eab = ((!display.display3D.collectingHits && oglIndices && vertexBuffer) ? oglIndices.buffer : noEAB);
+ GLEAB eab = ((!display.display3D.collectingHits && oglIndices && glcaps_vertexBuffer) ? oglIndices.buffer : noEAB);
#if !ENABLE_GL_INTDBL
- if(!vertexBuffer && primitive->type.indices32bit)
+ if(!glcaps_vertexBuffer && 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(vertexBuffer, getPrimitiveType(oglDisplay.capabilities.quads, primitive->type.primitiveType), primitive->nIndices, GL_UNSIGNED_SHORT, temp);
+ eab.draw(getPrimitiveType(primitive->type.primitiveType), primitive->nIndices, GL_UNSIGNED_SHORT, temp);
delete temp;
}
else
#endif
- eab.draw(vertexBuffer, getPrimitiveType(oglDisplay.capabilities.quads, primitive->type.primitiveType), primitive->nIndices,
+ eab.draw(getPrimitiveType(primitive->type.primitiveType), primitive->nIndices,
primitive->type.indices32bit ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT,
eab.buffer ? 0 : (oglIndices ? oglIndices.indices : primitive->indices));
GLABBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
void PushMatrix(Display display)
{
-#if ENABLE_GL_LEGACY
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
- bool fixedFunction = capabilities.fixedFunction;
- bool shaders = capabilities.shaders;
-#endif
GLPushMatrix();
}
void PopMatrix(Display display, bool setMatrix)
{
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool fixedFunction = capabilities.fixedFunction;
-#endif
- bool shaders = capabilities.shaders;
GLPopMatrix();
}
void SetTransform(Display display, Matrix transMatrix, bool viewSpace, bool useCamera)
{
- OGLDisplay oglDisplay = display.driverData;
- GLCapabilities capabilities = oglDisplay.capabilities;
-#if ENABLE_GL_LEGACY
- bool fixedFunction = capabilities.fixedFunction;
-#endif
- bool shaders = capabilities.shaders;
Matrix matrix = transMatrix;
Camera camera = useCamera ? display.display3D.camera : null;
--- /dev/null
+#if defined(__EMSCRIPTEN__)
+ #if !defined(_GLES2)
+ #define _GLES2
+ #endif
+#elif defined(__ANDROID__) || defined(__ODROID__)
+ #ifndef _GLES
+ #define _GLES
+ #endif
+#endif
+
+#if defined(_GLES2)
+ #include <GLES2/gl2.h>
+#elif defined(_GLES)
+/*
+#define uint _uint
+#define property _property
+#define new _new
+#define class _class
+#define Window X11Window
+#define Cursor X11Cursor
+#define Font X11Font
+#define Display X11Display
+#define Time X11Time
+#define KeyCode X11KeyCode
+#define Picture X11Picture
+#define Bool X11Bool
+*/
+ #define GL_GLEXT_PROTOTYPES
+ #include <GLES/gl.h>
+ #include <GLES/glext.h>
+
+/*
+#undef Bool
+#undef Picture
+#undef Window
+#undef Cursor
+#undef Font
+#undef Display
+#undef Time
+#undef KeyCode
+#undef uint
+#undef new
+#undef property
+#undef class
+*/
+#else
+ #include <gl_compat_4_4.h>
+#endif
+
+#ifdef _GLES
+ // Frame Buffer Extensions
+ #define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
+ #define GL_RENDERBUFFER GL_RENDERBUFFER_OES
+ #define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES
+ #define glBindFramebuffer glBindFramebufferOES
+ #define glBindRenderbuffer glBindRenderbufferOES
+ #define glFramebufferTexture2D glFramebufferTexture2DOES
+ #define glGenFramebuffers glGenFramebuffersOES
+ #define glGenRenderbuffers glGenRenderbuffersOES
+ #define glDeleteFramebuffers glDeleteFramebuffersOES
+ #define glDeleteRenderbuffers glDeleteRenderbuffersOES
+ #define glBlitFramebuffer glBlitFramebufferOES // (a,b,c,d,,f,g,h,i,j)
+
+ // TOFIX: Grab Screen and BlitDI/StretchDI will have wrong colors
+ #undef GL_BGRA_EXT
+ #define GL_BGRA_EXT GL_RGBA
+#else
+ #define GL_BGRA_EXT 0x80E1
+#endif
+
+// Compiled In Capabilities
+#define ENABLE_GL_SHADERS (!defined(_GLES))
+#define ENABLE_GL_FFP (!defined(_GLES2))
+#define ENABLE_GL_POINTER (!defined(__EMSCRIPTEN__))
+#define ENABLE_GL_FBO (!defined(__EMSCRIPTEN__))
+#define ENABLE_GL_LEGACY (!defined(_GLES) && !defined(_GLES2))
+#define ENABLE_GL_INTDBL (!defined(_GLES) && !defined(_GLES2))
+#define ENABLE_GL_MAPBUF (!defined(_GLES) && !defined(_GLES2))
+#define ENABLE_GL_SELECT (!defined(_GLES) && !defined(_GLES2))
+#define ENABLE_GL_COLORMAT (ENABLE_GL_FFP && !defined(_GLES))
+
+#if ENABLE_GL_SHADERS && ENABLE_GL_FFP
+ #define GLEnableClientState (glcaps_shaders ? glEnableVertexAttribArray : glEnableClientState)
+ #define GLDisableClientState (glcaps_shaders ? glDisableVertexAttribArray : glDisableClientState)
+ #define VERTICES (glcaps_shaders ? GLBufferContents::vertex : GL_VERTEX_ARRAY)
+ #define NORMALS (glcaps_shaders ? GLBufferContents::normal : GL_NORMAL_ARRAY)
+ #define TEXCOORDS (glcaps_shaders ? GLBufferContents::texCoord : GL_TEXTURE_COORD_ARRAY)
+ #define COLORS (glcaps_shaders ? GLBufferContents::color : GL_COLOR_ARRAY)
+ #define GLVertexPointer(n, t, s, p) (glcaps_shaders ? glVertexAttribPointer(GLBufferContents::vertex, n, t, GL_FALSE, s, p) : glVertexPointer(n, t, s, p))
+ #define GLColorPointer(n, t, s, p) (glcaps_shaders ? glVertexAttribPointer(GLBufferContents::color, n, t, GL_FALSE, s, p) : glColorPointer(n, t, s, p))
+ #define GLTexCoordPointer(n, t, s, p) (glcaps_shaders ? glVertexAttribPointer(GLBufferContents::texCoord, n, t, GL_FALSE, s, p) : glTexCoordPointer(n, t, s, p))
+#elif ENABLE_GL_SHADERS
+ #define GLEnableClientState glEnableVertexAttribArray
+ #define GLDisableClientState glDisableVertexAttribArray
+ #define VERTICES GLBufferContents::vertex
+ #define NORMALS GLBufferContents::normal
+ #define TEXCOORDS GLBufferContents::texCoord
+ #define COLORS GLBufferContents::color
+ #define GLVertexPointer(n, t, s, p) glVertexAttribPointer(GLBufferContents::vertex, n, t, GL_FALSE, s, p)
+ #define GLColorPointer(n, t, s, p) glVertexAttribPointer(GLBufferContents::color, n, t, GL_FALSE, s, p)
+ #define GLTexCoordPointer(n, t, s, p) glVertexAttribPointer(GLBufferContents::texCoord, n, t, GL_FALSE, s, p)
+#else
+ #define GLEnableClientState glEnableClientState
+ #define GLDisableClientState glDisableClientState
+ #define VERTICES GL_VERTEX_ARRAY
+ #define NORMALS GL_NORMAL_ARRAY
+ #define TEXCOORDS GL_TEXTURE_COORD_ARRAY
+ #define COLORS GL_COLOR_ARRAY
+ #define GLVertexPointer glVertexPointer
+ #define GLColorPointer glColorPointer
+ #define GLTexCoordPointer glTexCoordPointer
+#endif
+
+#if ENABLE_GL_INTDBL && ENABLE_GL_SHADERS
+ #define GLLoadMatrixd(m) (glcaps_fixedFunction ? glLoadMatrixd(m) : glmsLoadMatrixd(m))
+ #define GLMultMatrixd(m) (glcaps_fixedFunction ? glMultMatrixd(m) : glmsMultMatrixd(m))
+ #define GLFrustum(a,b,c,d,e,f) (glcaps_fixedFunction ? glFrustum(a,b,c,d,e,f) : glmsFrustum(a,b,c,d,e,f))
+ #define GLOrtho(a,b,c,d,e,f) (glcaps_fixedFunction ? glOrtho(a,b,c,d,e,f) : glmsOrtho(a,b,c,d,e,f))
+ #define GLScaled(x, y, z) (glcaps_fixedFunction ? glScaled(x, y, z) : glmsScaled(x,y,z))
+ #define GLScalef(x, y, z) (glcaps_fixedFunction ? glScalef(x, y, z) : glmsScaled(x,y,z))
+ #define GLTranslated(x, y, z) (glcaps_fixedFunction ? glTranslated(x,y,z) : glmsTranslated(x,y,z))
+ #define GLRotated(a, x, y, z) (glcaps_fixedFunction ? glRotated(a, x,y,z) : glmsRotated(a,x,y,z))
+ #define GLMatrixMode(m) (glcaps_fixedFunction ? glMatrixMode(m) : glmsMatrixMode(m))
+ #define GLLoadIdentity() (glcaps_fixedFunction ? glLoadIdentity() : glmsLoadIdentity())
+ #define GLPushMatrix() (glcaps_fixedFunction ? glPushMatrix() : glmsPushMatrix())
+ #define GLPopMatrix() (glcaps_fixedFunction ? glPopMatrix() : glmsPopMatrix())
+ #define GLFlushMatrices() (glcaps_fixedFunction ? (void)0 : glmsFlushMatrices())
+ #define GLLoadMatrix(m) (glmsLoadMatrix(m), glmsFlushMatrices())
+#elif ENABLE_GL_INTDBL
+ #define GLLoadMatrixd glLoadMatrixd
+ #define GLMultMatrixd glMultMatrixd
+ #define GLFrustum glFrustum
+ #define GLOrtho glOrtho
+ #define GLScaled glScaled
+ #define GLScalef glScalef
+ #define GLTranslated glTranslated
+ #define GLRotated glRotated
+ #define GLMatrixMode glMatrixMode
+ #define GLLoadIdentity glLoadIdentity
+ #define GLPushMatrix glPushMatrix
+ #define GLPopMatrix glPopMatrix
+ #define GLFlushMatrices() ((void)0)
+ #define GLLoadMatrix(m) (glmsLoadMatrix(m), glmsFlushMatrices())
+#else
+ #define GLLoadMatrixd glmsLoadMatrixd
+ #define GLMultMatrixd glmsMultMatrixd
+ #define GLFrustum glmsFrustum
+ #define GLOrtho glmsOrtho
+ #define GLScaled glmsScaled
+ #define GLScalef glmsScaled
+ #define GLTranslated glmsTranslated
+ #define GLRotated glmsRotated
+ #define GLMatrixMode glmsMatrixMode
+ #define GLLoadIdentity glmsLoadIdentity
+ #define GLPushMatrix glmsPushMatrix
+ #define GLPopMatrix glmsPopMatrix
+ #define GLFlushMatrices() glmsFlushMatrices()
+ #define GLLoadMatrix(m) (glmsLoadMatrix(m), glmsFlushMatrices())
+#endif
+
+#if ENABLE_GL_LEGACY
+ #define GLRecti(x1, y1, x2, y2) (glcaps_immediate ? glRecti(x1, y1, x2, y2) : glimtkRecti(x1, y1, x2, y2))
+ #define GLBegin(m) (glcaps_immediate ? glBegin(m) : glimtkBegin(m))
+ #define GLEnd() (glcaps_immediate ? glEnd() : glimtkEnd())
+ #define GLVertex2i(x,y) (glcaps_immediate ? glVertex2i(x,y) : glimtkVertex2i(x,y))
+ #define GLVertex2f(x,y) (glcaps_immediate ? glVertex2f(x,y) : glimtkVertex2f(x,y))
+ #define GLVertex2d(x,y) (glcaps_immediate ? glVertex2d(x,y) : glimtkVertex2d(x,y))
+ #define GLVertex3f(x,y,z) (glcaps_immediate ? glVertex3f(x,y,z) : glimtkVertex3f(x,y,z))
+ #define GLVertex3d(x,y,z) (glcaps_immediate ? glVertex3d(x,y,z) : glimtkVertex3d(x,y,z))
+ #define GLVertex3fv(v) (glcaps_immediate ? glVertex3fv(v) : glimtkVertex3fv(v))
+ #define GLVertex3dv(v) (glcaps_immediate ? glVertex3dv(v) : glimtkVertex3dv(v))
+ #define GLTexCoord2i(x,y) (glcaps_immediate ? glTexCoord2i(x,y) : glimtkTexCoord2i(x,y))
+ #define GLTexCoord2f(x,y) (glcaps_immediate ? glTexCoord2f(x,y) : glimtkTexCoord2f(x,y))
+ #define GLTexCoord2d(x,y) (glcaps_immediate ? glTexCoord2d(x,y) : glimtkTexCoord2d(x,y))
+ #define GLTexCoord2fv(v) (glcaps_immediate ? glTexCoord2fv(v) : glimtkTexCoord2fv(v))
+ #define GLNormal3f(x,y,z) (glcaps_immediate ? glNormal3f : glimtkNormal3f)
+ #define GLNormal3fv(v) (glcaps_immediate ? glNormal3fv(v) : glimtkNormal3fv(v))
+ #define GLColor3f(a,b,c) (glcaps_immediate ? glColor3f(a,b,c) : glimtkColor3f(a,b,c))
+ #define GLColor4ub(a,b,c,d) (glcaps_immediate ? glColor4ub(a,b,c,d) : glimtkColor4ub(a,b,c,d))
+ #define GLColor4f(a,b,c,d) (glcaps_immediate ? glColor4f(a,b,c,d) : glimtkColor4f(a,b,c,d))
+ #define GLColor4fv(v) (glcaps_immediate ? glColor4fv(v) : glimtkColor4fv(v))
+#else
+ #define GLRecti glimtkRecti
+ #define GLBegin glimtkBegin
+ #define GLTexCoord2i glimtkTexCoord2i
+ #define GLVertex2i glimtkVertex2i
+ #define GLTexCoord2d glimtkTexCoord2d
+ #define GLVertex2d glimtkVertex2d
+ #define GLTexCoord2f glimtkTexCoord2f
+ #define GLVertex2f glimtkVertex2f
+ #define GLEnd glimtkEnd
+ #define GLColor3f glimtkColor3f
+ #define GLColor4ub glimtkColor4ub
+ #define GLColor4f glimtkColor4f
+ #define GLColor4fv glimtkColor4fv
+ #define GLNormal3fv glimtkNormal3fv
+ #define GLNormal3f glimtkNormal3f
+ #define GLTexCoord2fv glimtkTexCoord2fv
+ #define GLVertex3d glimtkVertex3d
+ #define GLVertex3dv glimtkVertex3dv
+ #define GLVertex3f glimtkVertex3f
+ #define GLVertex3fv glimtkVertex3fv
+#endif
+
+#define GLMultMatrix GLMultMatrixd
+#define GLGetMatrix GLGetDoublev
+#define GLTranslate GLTranslated
+#define GLScale GLScaled
+
+#if !ENABLE_GL_INTDBL
+ #define GL_INT 0x1404
+ #define GL_UNSIGNED_INT 0x1405
+ #define GL_DOUBLE 0x140A
+#endif
+
+#if ENABLE_GL_STIPPLES
+ #define GLLineStipple (stipples ? glLineStipple : glsupLineStipple)
+#else
+ #define GLLineStipple glsupLineStipple
+#endif
+
+#if ENABLE_GL_COLORMAT
+ #define GLColorMaterial(a,b) glColorMaterial(a,b)
+#else
+ #define GLColorMaterial(a,b)
+#endif
+
+#ifdef _GLES
+ #define GLLightModeli glsupLightModeli
+#else
+ #define GLLightModeli glLightModeli
+#endif
+
+#define SETCAPS(caps) \
+ glcaps = caps; \
+ glcaps_shaders = glcaps.shaders; \
+ glcaps_fixedFunction = glcaps.fixedFunction; \
+ glcaps_nonPow2Textures = glcaps.nonPow2Textures; \
+ glcaps_vertexBuffer = glcaps.vertexBuffer; \
+ glcaps_quads = glcaps.quads; \
+ glcaps_intAndDouble = glcaps.intAndDouble; \
+ glcaps_immediate = glcaps.immediate; \
+ glcaps_legacy = glcaps.legacy; \
+ glcaps_pointSize = glcaps.pointSize; \
+ glcaps_frameBuffer = glcaps.frameBuffer;
+
+extern GLCapabilities glcaps;
+extern bool glcaps_nonPow2Textures, glcaps_vertexBuffer, glcaps_quads, glcaps_intAndDouble;
+extern bool glcaps_shaders, glcaps_fixedFunction, glcaps_immediate, glcaps_legacy, glcaps_pointSize, glcaps_frameBuffer;
+
+#if ENABLE_GL_INTDBL
+ #define GL_INDEX_INT GL_UNSIGNED_INT
+#else
+ #define GL_INDEX_INT GL_UNSIGNED_SHORT
+#endif
// OpenGL Immediate Mode Transition Kit
-
-#if defined(__ANDROID__) || defined(__ODROID__)
- #include <GLES/gl.h>
- #ifndef _GLES
- #define _GLES
- #endif
-#elif defined(__EMSCRIPTEN__)
- #include <GLES2/gl2.h>
- #ifndef _GLES2
- #define _GLES2
- #endif
-#else
- #include "gl_compat_4_4.h"
-#endif
-
import "glab"
import "shading"
-#define ENABLE_GL_SHADERS (!defined(_GLES))
-#define ENABLE_GL_FFP (!defined(_GLES2))
-#define ENABLE_GL_POINTER (!defined(__EMSCRIPTEN__))
-#define ENABLE_GL_FBO (!defined(__EMSCRIPTEN__))
-#define ENABLE_GL_LEGACY (!defined(_GLES) && !defined(_GLES2))
-#define ENABLE_GL_INTDBL (!defined(_GLES) && !defined(_GLES2))
-#define ENABLE_GL_MAPBUF (!defined(_GLES) && !defined(_GLES2))
-#define ENABLE_GL_SELECT (!defined(_GLES) && !defined(_GLES2))
-#define ENABLE_GL_COLORMAT (ENABLE_GL_FFP && !defined(_GLES))
-
-#if ENABLE_GL_SHADERS && ENABLE_GL_FFP
- #define GLEnableClientState (shaders ? glEnableVertexAttribArray : glEnableClientState)
- #define GLDisableClientState (shaders ? glDisableVertexAttribArray : glDisableClientState)
- #define VERTICES (shaders ? GLBufferContents::vertex : GL_VERTEX_ARRAY)
- #define NORMALS (shaders ? GLBufferContents::normal : GL_NORMAL_ARRAY)
- #define TEXTURECOORDS (shaders ? GLBufferContents::texCoord : GL_TEXTURE_COORD_ARRAY)
- #define COLORS (shaders ? GLBufferContents::color : GL_COLOR_ARRAY)
- #define GLVertexPointer(n, t, s, p) (shaders ? glVertexAttribPointer(GLBufferContents::vertex, n, t, GL_FALSE, s, p) : glVertexPointer(n, t, s, p))
- #define GLTexCoordPointer(n, t, s, p) (shaders ? glVertexAttribPointer(GLBufferContents::texCoord, n, t, GL_FALSE, s, p) : glTexCoordPointer(n, t, s, p))
-#elif ENABLE_GL_SHADERS
- #define GLEnableClientState glEnableVertexAttribArray
- #define GLDisableClientState glDisableVertexAttribArray
- #define VERTICES GLBufferContents::vertex
- #define NORMALS GLBufferContents::normal
- #define TEXTURECOORDS GLBufferContents::texCoord
- #define COLORS GLBufferContents::color
- #define GLVertexPointer(n, t, s, p) glVertexAttribPointer(GLBufferContents::vertex, n, t, GL_FALSE, s, p)
- #define GLTexCoordPointer(n, t, s, p) glVertexAttribPointer(GLBufferContents::texCoord, n, t, GL_FALSE, s, p)
-#else
- #define GLEnableClientState glEnableClientState
- #define GLDisableClientState glDisableClientState
- #define VERTICES GL_VERTEX_ARRAY
- #define NORMALS GL_NORMAL_ARRAY
- #define TEXTURECOORDS GL_TEXTURE_COORD_ARRAY
- #define COLORS GL_COLOR_ARRAY
- #define GLVertexPointer glVertexPointer
- #define GLTexCoordPointer glTexCoordPointer
-#endif
+#include "glHelpers.h"
public enum GLIMTKMode
{
static int vertexStride = 4;
static int vertexOffset = 2;
-public void glimtkRecti(GLCapabilities capabilities, int a, int b, int c, int d)
+public void glimtkRecti(int a, int b, int c, int d)
{
glimtkBegin(quads);
glimtkVertex2i(a, b);
glimtkVertex2i(a, d);
glimtkVertex2i(c, d);
glimtkVertex2i(c, b);
- glimtkEnd(capabilities);
+ glimtkEnd();
}
public void glimtkBegin(GLIMTKMode mode)
GLAB streamVecAB, streamNorAB;
-public void glimtkEnd(GLCapabilities capabilities)
+public void glimtkEnd()
{
- bool vertexBuffer = capabilities.vertexBuffer;
-#if ENABLE_GL_SHADERS
- bool shaders = capabilities.shaders;
-#endif
GLIMTKMode mode = beginMode;
if(mode == quads) mode = triangles;
else if(mode == polygon) mode = triangleFan;
- GLEnableClientState(TEXTURECOORDS);
+ GLEnableClientState(TEXCOORDS);
- if(vertexBuffer)
+ if(glcaps_vertexBuffer)
{
- streamVecAB.upload(vertexBuffer, vertexStride * sizeof(float) * vertexCount, vertexPointer);
- streamVecAB.use(capabilities, texCoord, 2, GL_FLOAT, vertexStride * sizeof(float), 0);
+ streamVecAB.upload(vertexStride * sizeof(float) * vertexCount, vertexPointer);
+ streamVecAB.use(texCoord, 2, GL_FLOAT, vertexStride * sizeof(float), 0);
}
else
- noAB.use(capabilities, texCoord, 2, GL_FLOAT, vertexStride * sizeof(float), vertexPointer);
+ noAB.use(texCoord, 2, GL_FLOAT, vertexStride * sizeof(float), vertexPointer);
if(vertexColorValues)
{
GLEnableClientState(COLORS);
- if(vertexBuffer)
- streamVecAB.use(capabilities, color, 4, GL_FLOAT, vertexStride * sizeof(float), (void *)(2 * sizeof(float)));
+ if(glcaps_vertexBuffer)
+ streamVecAB.use(color, 4, GL_FLOAT, vertexStride * sizeof(float), (void *)(2 * sizeof(float)));
else
- noAB.use(capabilities, color, 4, GL_FLOAT, vertexStride * sizeof(float), vertexPointer + 2);
+ noAB.use(color, 4, GL_FLOAT, vertexStride * sizeof(float), vertexPointer + 2);
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_setPerVertexColor(true);
#endif
}
- if(vertexBuffer)
- streamVecAB.use(capabilities, vertex, numVertexCoords, GL_FLOAT, vertexStride * sizeof(float), (void *)(vertexOffset * sizeof(float)));
+ if(glcaps_vertexBuffer)
+ streamVecAB.use(vertex, numVertexCoords, GL_FLOAT, vertexStride * sizeof(float), (void *)(vertexOffset * sizeof(float)));
else
- noAB.use(capabilities, vertex, numVertexCoords, GL_FLOAT, vertexStride * sizeof(float), vertexPointer + vertexOffset);
+ noAB.use(vertex, numVertexCoords, GL_FLOAT, vertexStride * sizeof(float), vertexPointer + vertexOffset);
if(normalCount && normalCount == vertexCount)
{
GLEnableClientState(NORMALS);
- if(vertexBuffer)
+ if(glcaps_vertexBuffer)
{
- streamNorAB.upload(vertexBuffer, 3*sizeof(float) * vertexCount, normalPointer);
- streamNorAB.use(capabilities, normal, 3, GL_FLOAT, 3*sizeof(float), 0);
+ streamNorAB.upload(3*sizeof(float) * vertexCount, normalPointer);
+ streamNorAB.use(normal, 3, GL_FLOAT, 3*sizeof(float), 0);
}
else
- noAB.use(capabilities, normal, 3, GL_FLOAT, 3*sizeof(float),normalPointer);
+ noAB.use(normal, 3, GL_FLOAT, 3*sizeof(float),normalPointer);
}
+ GLFlushMatrices();
glDrawArrays(mode, 0, vertexCount);
if(normalCount)
GLDisableClientState(COLORS);
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_setPerVertexColor(false);
#endif
}
- GLDisableClientState(TEXTURECOORDS);
+ GLDisableClientState(TEXCOORDS);
normalCount = 0;
vertexColorValues = false;
static unsigned short *shortBDBuffer = null;
static unsigned int shortBDSize = 0;
-public void glimtkVertexPointeri(bool shaders, int numCoords, int stride, int *pointer, int numVertices)
+public void glimtkVertexPointeri(int numCoords, int stride, int *pointer, int numVertices)
{
if(pointer)
{
GLVertexPointer(numCoords, GL_SHORT, stride, 0);
}
-public void glimtkVertexPointerd(bool shaders, int numCoords, int stride, double *pointer, int numVertices)
+public void glimtkVertexPointerd(int numCoords, int stride, double *pointer, int numVertices)
{
if(pointer)
{
GLVertexPointer(numCoords, GL_FLOAT, stride, 0);
}
-public void glimtkTexReuseIntVP(bool shaders, int numCoords)
+public void glimtkTexReuseIntVP(int numCoords)
{
GLTexCoordPointer(numCoords, GL_SHORT, 0, floatVPBuffer);
}
-public void glimtkTexReuseDoubleVP(bool shaders, int numCoords)
+public void glimtkTexReuseDoubleVP(int numCoords)
{
GLTexCoordPointer(numCoords, GL_FLOAT, 0, floatVPBuffer);
}
-public void glimtkColor4f(bool shaders, float r, float g, float b, float a)
+public void glimtkColor4f(float r, float g, float b, float a)
{
if(beginMode != unset)
{
else
{
#if ENABLE_GL_SHADERS
- if(shaders)
+ if(glcaps_shaders)
shader_color(r, g, b, a);
#endif
#if ENABLE_GL_FFP
- if(!shaders)
+ if(!glcaps_shaders)
{
glColor4f(r, g, b, a);
if(lightingEnabled)
}
}
-public void glimtkColor3f( bool usingShaders, float r, float g, float b )
+public void glimtkColor3f( float r, float g, float b )
{
- glimtkColor4f(usingShaders, r, g, b, 1.0f);
+ glimtkColor4f(r, g, b, 1.0f);
}
-public void glimtkColor4ub(bool usingShaders, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+public void glimtkColor4ub(byte r, byte g, byte b, byte a)
{
- glimtkColor4f(usingShaders, r/255.0f, g/255.0f, b/255.0f, a/255.0f);
+ glimtkColor4f(r/255.0f, g/255.0f, b/255.0f, a/255.0f);
}
-public void glimtkColor4fv(bool shaders, float * a)
+public void glimtkColor4fv(float * a)
{
- glimtkColor4f(shaders, a[0], a[1], a[2], a[3]);
+ glimtkColor4f(a[0], a[1], a[2], a[3]);
}
public void glimtkBufferDatad(int target, int size, void * data, int usage)
// Matrix Stack Implementation
-
-#if defined(__ANDROID__) || defined(__ODROID__)
- #include <GLES/gl.h>
- #ifndef _GLES
- #define _GLES
- #endif
-#elif defined(__EMSCRIPTEN__)
- #include <GLES2/gl2.h>
- #ifndef _GLES2
- #define _GLES2
- #endif
-#else
- #include "gl_compat_4_4.h"
-#endif
-
import "Display"
import "shading"
-#define ENABLE_GL_SHADERS (!defined(_GLES))
-#define ENABLE_GL_FFP (!defined(_GLES2))
+#include "glHelpers.h"
#if defined(ECERE_NO3D) || defined(ECERE_VANILLA)
public union Matrix
#endif
public enum MatrixMode { modelView = 0x1700, projection = 0x1701, texture = 0x1702 };
-public enum GLMSWhatToGet { projectionMatrix = 0x0BA7, modelViewMatrix = 0x0BA6, textureMatrix = 0x0BA8 };
+public enum GLMSWhatToGet { modelViewMatrix = 0x0BA6, projectionMatrix = 0x0BA7, textureMatrix = 0x0BA8 };
double nearPlane = 1;
/*static */Matrix matrixStack[3][32];
/*static */int matrixIndex[3];
/*static */int curStack = 0;
+bool stackModified[3];
-static void LoadCurMatrix(bool shaders)
+public void glmsLoadMatrix(Matrix matrix)
{
- double * i = matrixStack[curStack][matrixIndex[curStack]].array;
- float m[16] =
- {
- (float)i[0],(float)i[1],(float)i[2],(float)i[3],
- (float)i[4],(float)i[5],(float)i[6],(float)i[7],
- (float)i[8],(float)i[9],(float)i[10],(float)i[11],
- (float)i[12],(float)i[13],(float)i[14],(float)i[15]
- };
-
-#if ENABLE_GL_SHADERS
- if(shaders)
- shader_LoadMatrixf((MatrixMode) (0x1700 + curStack), m);
-#endif
-
-#if ENABLE_GL_FFP
- if(!shaders)
- glLoadMatrixf(m);
-#endif
-}
-
-public void glmsLoadMatrix(bool shaders, Matrix matrix)
-{
- float m[16] =
- {
- (float)matrix.m[0][0], (float)matrix.m[0][1], (float)matrix.m[0][2], (float)matrix.m[0][3],
- (float)matrix.m[1][0], (float)matrix.m[1][1], (float)matrix.m[1][2], (float)matrix.m[1][3],
- (float)matrix.m[2][0], (float)matrix.m[2][1], (float)matrix.m[2][2], (float)matrix.m[2][3],
- (float)matrix.m[3][0], (float)matrix.m[3][1], (float)matrix.m[3][2], (float)matrix.m[3][3]
- };
-#if ENABLE_GL_SHADERS
- if(shaders)
- {
- memcpy(matrixStack[curStack][matrixIndex[curStack]].array, matrix.array, sizeof(Matrix));
- shader_LoadMatrixf((MatrixMode) (0x1700 + curStack), m);
- }
-#endif
-
-#if ENABLE_GL_FFP
- if(!shaders)
- glLoadMatrixf(m);
-#endif
+ memcpy(matrixStack[curStack][matrixIndex[curStack]].array, matrix.array, sizeof(Matrix));
+ stackModified[curStack] = true;
}
-public void glmsLoadIdentity(bool shaders)
+public void glmsLoadIdentity()
{
matrixStack[curStack][matrixIndex[curStack]].Identity();
- LoadCurMatrix(shaders);
+ stackModified[curStack] = true;
}
public void glmsPushMatrix()
}
}
-public void glmsPopMatrix(bool shaders)
+public void glmsPopMatrix()
{
if(matrixIndex[curStack] > 0)
{
matrixIndex[curStack]--;
- LoadCurMatrix(shaders);
+ stackModified[curStack] = true;
}
}
-public void glmsLoadMatrixf(bool shaders, float * i)
+public void glmsLoadMatrixf(float * i)
{
double m[16] =
{
i[3*4+0], i[3*4+1], i[3*4+2], i[3*4+3]
};
memcpy(matrixStack[curStack][matrixIndex[curStack]].array, m, 16*sizeof(double));
- LoadCurMatrix(shaders);
+ stackModified[curStack] = true;
}
-public void glmsLoadMatrixd(bool shaders, double * i)
+public void glmsLoadMatrixd(double * i)
{
memcpy(matrixStack[curStack][matrixIndex[curStack]].array, i, sizeof(Matrix));
- LoadCurMatrix(shaders);
+ stackModified[curStack] = true;
}
-public void glmsOrtho(bool shaders, double l, double r, double b, double t, double n, double f )
+public void glmsOrtho(double l, double r, double b, double t, double n, double f )
{
Matrix m
{ {
Matrix res;
res.Multiply(m, matrixStack[curStack][matrixIndex[curStack]]);
matrixStack[curStack][matrixIndex[curStack]] = res;
- LoadCurMatrix(shaders);
+ stackModified[curStack] = true;
}
-public void glmsScaled( bool shaders, double a, double b, double c )
+public void glmsScaled(double a, double b, double c)
{
Matrix m, r;
m.Scale(a,b,c);
r.Multiply(m, matrixStack[curStack][matrixIndex[curStack]]);
matrixStack[curStack][matrixIndex[curStack]] = r;
- LoadCurMatrix(shaders);
+ stackModified[curStack] = true;
}
-public void glmsTranslated( bool shaders, double a, double b, double c )
+public void glmsTranslated( double a, double b, double c)
{
Matrix m, r;
m.Translate(a,b,c);
r.Multiply(m, matrixStack[curStack][matrixIndex[curStack]]);
matrixStack[curStack][matrixIndex[curStack]] = r;
- LoadCurMatrix(shaders);
+ stackModified[curStack] = true;
}
#if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
-public void glmsFrustum( bool shaders, double l, double r, double b, double t, double n, double f )
+public void glmsFrustum(double l, double r, double b, double t, double n, double f)
{
nearPlane = n;
n = 1;
Matrix res;
res.Multiply(m, matrixStack[curStack][matrixIndex[curStack]]);
matrixStack[curStack][matrixIndex[curStack]] = res;
- LoadCurMatrix(shaders);
+ stackModified[curStack] = true;
}
}
-public void glmsRotated( bool shaders, double angle, double x, double y, double z)
+public void glmsRotated( double angle, double x, double y, double z)
{
Quaternion q;
Matrix m, r;
m.RotationQuaternion(q);
r.Multiply(m, matrixStack[curStack][matrixIndex[curStack]]);
matrixStack[curStack][matrixIndex[curStack]] = r;
- LoadCurMatrix(shaders);
+ stackModified[curStack] = true;
}
-public void glmsMultMatrixd( bool shaders, double * i )
+public void glmsMultMatrixd(double * i)
{
Matrix r;
r.Multiply((Matrix *)i, matrixStack[curStack][matrixIndex[curStack]]);
matrixStack[curStack][matrixIndex[curStack]] = r;
- LoadCurMatrix(shaders);
+ stackModified[curStack] = true;
}
public void glmsGetDoublev(GLMSWhatToGet what, double * i)
}
#endif
-public void glmsMatrixMode(bool shaders, MatrixMode mode)
+public void glmsMatrixMode(MatrixMode mode)
{
curStack = (mode == modelView) ? 0 : (mode == projection) ? 1 : 2;
+}
+
+public void glmsFlushMatrices()
+{
+ int stack;
+#if ENABLE_GL_SHADERS
+ bool mvModified = false, prjViewModified = false;
+#endif
+ for(stack = 0; stack < 3; stack++)
+ {
+ if(stackModified[stack])
+ {
+ Matrix * matrix = &matrixStack[stack][matrixIndex[stack]];
+#if ENABLE_GL_SHADERS
+ if(glcaps_shaders)
+ {
+ if(stack == 0)
+ {
+ Matrix t, inv;
+ double * i = inv.array;
+
+ mvModified = true;
+ prjViewModified = true;
+
+ t.Transpose(matrix);
+ inv.Inverse(t);
+ {
+ float m[16] =
+ {
+ (float)i[0],(float)i[1],(float)i[2],(float)i[3],
+ (float)i[4],(float)i[5],(float)i[6],(float)i[7],
+ (float)i[8],(float)i[9],(float)i[10],(float)i[11],
+ (float)i[12],(float)i[13],(float)i[14],(float)i[15]
+ };
+ shader_LoadNormalMatrix(m);
+ }
+ }
+ else if(stack == 1)
+ prjViewModified = true;
+ else
+ {
+ float m[16] =
+ {
+ (float)matrix->m[0][0], (float)matrix->m[0][1], (float)matrix->m[0][2], (float)matrix->m[0][3],
+ (float)matrix->m[1][0], (float)matrix->m[1][1], (float)matrix->m[1][2], (float)matrix->m[1][3],
+ (float)matrix->m[2][0], (float)matrix->m[2][1], (float)matrix->m[2][2], (float)matrix->m[2][3],
+ (float)matrix->m[3][0], (float)matrix->m[3][1], (float)matrix->m[3][2], (float)matrix->m[3][3]
+ };
+ shader_LoadMatrixf((MatrixMode) (0x1700 + stack), m);
+ }
+ }
+#endif
#if ENABLE_GL_FFP
- if(!shaders)
- glMatrixMode(mode);
+ if(!glcaps_shaders)
+ {
+ float m[16] =
+ {
+ (float)matrix->m[0][0], (float)matrix->m[0][1], (float)matrix->m[0][2], (float)matrix->m[0][3],
+ (float)matrix->m[1][0], (float)matrix->m[1][1], (float)matrix->m[1][2], (float)matrix->m[1][3],
+ (float)matrix->m[2][0], (float)matrix->m[2][1], (float)matrix->m[2][2], (float)matrix->m[2][3],
+ (float)matrix->m[3][0], (float)matrix->m[3][1], (float)matrix->m[3][2], (float)matrix->m[3][3]
+ };
+ glMatrixMode(stack + 0x1700);
+ glLoadMatrixf(m);
+ }
+#endif
+ stackModified[stack] = false;
+ }
+#if ENABLE_GL_SHADERS
+ if(glcaps_shaders && stack == 1 && prjViewModified)
+ {
+ Matrix * mv = &matrixStack[0][matrixIndex[0]];
+ Matrix * prj = &matrixStack[1][matrixIndex[1]];
+ Matrix mat;
+ mat.Multiply(mv, prj);
+ {
+ float m[16] =
+ {
+ (float)mat.m[0][0], (float)mat.m[0][1], (float)mat.m[0][2], (float)mat.m[0][3],
+ (float)mat.m[1][0], (float)mat.m[1][1], (float)mat.m[1][2], (float)mat.m[1][3],
+ (float)mat.m[2][0], (float)mat.m[2][1], (float)mat.m[2][2], (float)mat.m[2][3],
+ (float)mat.m[3][0], (float)mat.m[3][1], (float)mat.m[3][2], (float)mat.m[3][3]
+ };
+ float mvz[4] = { (float)mv->m[0][2], (float)mv->m[1][2], (float)mv->m[2][2], (float)mv->m[3][2] };
+ shader_LoadPrjMVMatrix(m, mvModified ? mvz : null);
+ }
+ }
#endif
+ }
}