bool depthWrite;
int x, y;
uint vao;
+ int maxTMU;
#if defined(__WIN32__)
HDC hdc;
}
#endif
-#if ENABLE_GL_FFP
-static int maxTMU = 0;
-
-static void disableRemainingTMUs(int lastTMU)
-{
- int t;
- for(t = lastTMU; t < maxTMU; t++)
- {
- glActiveTexture(GL_TEXTURE0 + t);
- glClientActiveTexture(GL_TEXTURE0 + t);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_TEXTURE_CUBE_MAP);
- GLDisableClientState(TEXCOORDS);
- }
- glActiveTexture(GL_TEXTURE0);
- glClientActiveTexture(GL_TEXTURE0);
- maxTMU = lastTMU;
-}
-#endif
-
class OpenGLDisplayDriver : DisplayDriver
{
class_property(name) = "OpenGL";
vao = glBindVertexArray != null && !oglDisplay.compat;
#endif
#if ENABLE_GL_FBO
- shaders = glBindFramebuffer != null;
+ frameBuffer = glBindFramebuffer != null;
#endif
vertexBuffer = glBindBuffer != null;
// mapBuffer = glMapBuffer != null;
glDisableVertexAttribArray(GLBufferContents::vertex);
glDisableVertexAttribArray(GLBufferContents::tangent1);
glDisableVertexAttribArray(GLBufferContents::tangent2);
+#if ENABLE_GL_VAO
glBindVertexArray(0);
+#endif
glUseProgram(0);
}
#endif
void WriteText(Display display, Surface surface, int x, int y, const char * text, int len, int prevGlyph, int * rPrevGlyph)
{
- if(len && text[0])
+ if(len && text[0] && surface.font)
{
OGLSurface oglSurface = surface.driverData;
OGLSystem oglSystem = display.displaySystem.driverData;
}
}
}
+#if ENABLE_GL_FFP
+ void ::disableRemainingTMUs(Display display, int lastTMU)
+ {
+ OGLDisplay oglDisplay = display.driverData;
+ int t;
+ for(t = lastTMU; t < oglDisplay.maxTMU; t++)
+ {
+ glActiveTexture(GL_TEXTURE0 + t);
+ glClientActiveTexture(GL_TEXTURE0 + t);
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_TEXTURE_CUBE_MAP);
+ GLDisableClientState(TEXCOORDS);
+ }
+ glActiveTexture(GL_TEXTURE0);
+ glClientActiveTexture(GL_TEXTURE0);
+ oglDisplay.maxTMU = lastTMU;
+ }
+#endif
#if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
void SetRenderState(Display display, RenderState state, uint value)
#endif
// *** Restore 2D MODELVIEW Matrix ***
+ GLMatrixMode(MatrixMode::modelView);
+ GLPopMatrix();
+
+ // *** Restore 2D TEXTURE Matrix ***
+ GLMatrixMode(MatrixMode::texture);
GLPopMatrix();
// *** Restore 2D PROJECTION Matrix ***
GLMatrixMode(MatrixMode::projection);
GLPopMatrix();
- // *** Restore 2D TEXTURE Matrix ***
- GLMatrixMode(MatrixMode::texture);
- GLPopMatrix();
+ // NOTE: We expect the 2D projection matrix to be the active one for GetSurface to call glOrtho()
#if ENABLE_GL_SHADERS
if(glCaps_shaders)
#if ENABLE_GL_FFP
if(!glCaps_shaders)
{
- disableRemainingTMUs(1);
+ disableRemainingTMUs(display, 0);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
glDisable(GL_TEXTURE_CUBE_MAP);
#if _GLES
glDisable(GL_TEXTURE_GEN_STR);
#if ENABLE_GL_FFP
if(!glCaps_shaders)
{
- if(tmu > 1)
- {
- oglMesh.texCoords.use(texCoord, 2, GL_FLOAT, 0, oglMesh.texCoords.buffer ? null : mesh.texCoords);
- GLEnableClientState(TEXCOORDS);
- }
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ /* // This did not have the desired effect with a GL_ALPHA texture
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
+ */
if(flags.cubeMap)
{
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
#endif
+
+ GLDisableClientState(TEXCOORDS);
}
else
{
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
#endif
+
+ if(tmu > 1)
+ oglMesh.texCoords.use(texCoord, 2, GL_FLOAT, 0, oglMesh.texCoords.buffer ? null : mesh.texCoords);
+ GLEnableClientState(TEXCOORDS);
}
glClientActiveTexture(GL_TEXTURE0);
}
GLMatrixMode(MatrixMode::texture);
{
- double * s = display.display3D.camera.inverseTranspose.array;
- Quaternion q = display.display3D.camera.cOrientation;
- Matrix mat;
- Euler e = q;
- //e.yaw *= -1;
- q = e;
- mat.RotationQuaternion(q);
- mat.Scale(2,-2,-2);
- s = mat.array;
-
+ double * s = display.display3D.camera.viewMatrix.array;
+ double k = 2.0;
Matrix m
{ {
- s[0],s[1],s[2],0,
- s[4],s[5],s[6],0,
- s[8],s[9],s[10],0,
+ k*s[0],-k*s[4],-k*s[8], 0,
+ k*s[1],-k*s[5],-k*s[9], 0,
+ k*s[2],-k*s[6],-k*s[10],0,
0,0,0,1
} };
GLLoadMatrixd(m.array);
#if ENABLE_GL_FFP
if(!glCaps_shaders)
{
- disableRemainingTMUs(tmu);
+ disableRemainingTMUs(display, tmu);
if(mesh.flags.colors)
{
if(oglMesh)
{
OGLSystem oglSystem = displaySystem.driverData;
+ GLCapabilities caps = glCaps;
SETCAPS(oglSystem.capabilities);
+
if(!mesh.flags.vertices)
{
- oglMesh.vertices.free(glCaps_vertexBuffer);
+ oglMesh.vertices.free();
delete mesh.vertices;
}
if(!mesh.flags.normals)
{
- oglMesh.normals.free(glCaps_vertexBuffer);
+ oglMesh.normals.free();
delete mesh.normals;
}
if(!mesh.flags.tangents)
{
- oglMesh.tangents.free(glCaps_vertexBuffer);
+ oglMesh.tangents.free();
delete mesh.tangents;
}
if(!mesh.flags.lightVectors)
{
- oglMesh.lightVectors.free(glCaps_vertexBuffer);
+ oglMesh.lightVectors.free();
delete mesh.lightVectors;
}
if(!mesh.flags.texCoords1)
{
- oglMesh.texCoords.free(glCaps_vertexBuffer);
+ oglMesh.texCoords.free();
delete mesh.texCoords;
}
if(!mesh.flags.texCoords2)
{
- oglMesh.texCoords2.free(glCaps_vertexBuffer);
+ oglMesh.texCoords2.free();
// delete mesh.texCoords2;
}
if(!mesh.flags.colors)
{
- oglMesh.colors.free(glCaps_vertexBuffer);
+ oglMesh.colors.free();
delete mesh.colors;
}
if(!mesh.flags)
delete oglMesh;
mesh.data = null;
}
+ SETCAPS(caps);
}
}
void UnlockMesh(DisplaySystem displaySystem, Mesh mesh, MeshFeatures flags)
{
OGLSystem oglSystem = displaySystem.driverData;
+ GLCapabilities caps = glCaps;
SETCAPS(oglSystem.capabilities);
+
if(glCaps_vertexBuffer)
{
OGLMesh oglMesh = mesh.data;
if(flags.lightVectors)
oglMesh.lightVectors.allocate(mesh.nVertices * sizeof(ColorRGB), mesh.lightVectors, staticDraw);
}
+ SETCAPS(caps);
}
bool LockMesh(DisplaySystem displaySystem, Mesh mesh, MeshFeatures flags)
void FreeIndices(DisplaySystem displaySystem, OGLIndices oglIndices)
{
OGLSystem oglSystem = displaySystem.driverData;
+ GLCapabilities caps = glCaps;
SETCAPS(oglSystem.capabilities);
+
if(oglIndices)
{
- oglIndices.buffer.free(glCaps_vertexBuffer);
+ oglIndices.buffer.free();
delete oglIndices.indices;
delete oglIndices;
}
+ SETCAPS(caps);
}
void * AllocateIndices(DisplaySystem displaySystem, int nIndices, bool indices32bit)
void UnlockIndices(DisplaySystem displaySystem, OGLIndices oglIndices, bool indices32bit, int nIndices)
{
OGLSystem oglSystem = displaySystem.driverData;
+ GLCapabilities caps = glCaps;
SETCAPS(oglSystem.capabilities);
+
if(glCaps_vertexBuffer)
{
if(!glCaps_intAndDouble && indices32bit)
nIndices * (indices32bit ? sizeof(uint32) : sizeof(uint16)),
oglIndices.indices, staticDraw);
}
+ SETCAPS(caps);
}
uint16 * LockIndices(DisplaySystem displaySystem, OGLIndices oglIndices)