ecere/gfx/drivers/GL/matrixStack: Added glGetDoublev()
authorJerome St-Louis <jerome@ecere.com>
Sun, 10 Apr 2016 12:21:06 +0000 (08:21 -0400)
committerJerome St-Louis <jerome@ecere.com>
Sat, 11 Jun 2016 07:07:15 +0000 (03:07 -0400)
- Implemented support for querying matrices

ecere/src/gfx/drivers/gl3/matrixStack.ec

index 6dd68fe..e3a5fce 100644 (file)
@@ -88,6 +88,7 @@ public union Matrix
 #endif
 
 public enum MatrixMode { modelView = 0x1700, projection = 0x1701, texture = 0x1702 };
+public enum GLMSWhatToGet { projectionMatrix = 0x0BA7, modelViewMatrix = 0x0BA6, textureMatrix = 0x0BA8 };
 
 double nearPlane = 1;
 
@@ -268,6 +269,26 @@ public void glmsMultMatrixd( double * i )
    matrixStack[curStack][matrixIndex[curStack]] = r;
    LoadCurMatrix();
 }
+
+public void glmsGetDoublev(GLMSWhatToGet what, double * i)
+{
+   int ix;
+   switch(what)
+   {
+      case modelViewMatrix:
+         ix = MatrixMode::modelView-0x1700;
+         memcpy(i, matrixStack[ix][matrixIndex[ix]].array, sizeof(Matrix));
+         break;
+      case projectionMatrix:
+         ix = MatrixMode::projection-0x1700;
+         memcpy(i, matrixStack[ix][matrixIndex[ix]].array, sizeof(Matrix));
+         break;
+      case textureMatrix:
+         ix = MatrixMode::texture-0x1700;
+         memcpy(i, matrixStack[ix][matrixIndex[ix]].array, sizeof(Matrix));
+         break;
+   }
+}
 #endif
 
 public void glmsMatrixMode(MatrixMode mode)