ecere/gfx/3D: Camera integration support
authorJerome St-Louis <jerome@ecere.com>
Sat, 19 Dec 2015 21:05:59 +0000 (16:05 -0500)
committerJerome St-Louis <jerome@ecere.com>
Sat, 2 Jul 2016 20:41:05 +0000 (16:41 -0400)
- For integrating with Display::DrawMesh() / Display::DrawTranslucency()
- Directly setting viewMatrix and cPosition
- Not recomputing the camera when SetCamera is called with a null surface

ecere/src/gfx/3D/Camera.ec
ecere/src/gfx/Display.ec
ecere/src/gfx/drivers/OpenGLDisplayDriver.ec

index 1aba78c..68583f4 100644 (file)
@@ -582,6 +582,16 @@ public:
       result.z += cPosition.z;
    }
 
+   public void setViewMatrix(Matrix value)
+   {
+      viewMatrix = value;
+   }
+
+   public void setCPosition(Vector3D value)
+   {
+      cPosition = value;
+   }
+
 private:
    Camera()
    {
index a403299..62c6e94 100644 (file)
@@ -613,7 +613,7 @@ public:
             camera.Setup(width, height, null);
 
          // Always calling Update() here had broken interpolation in OrbitWithMouse!
-         if(!camera.cAngle.w)
+         if(!camera.cAngle.w && surface)
             camera.Update();
 
          if(display3D.selection)
index 1df3dde..0c3a9cd 100644 (file)
@@ -3759,7 +3759,7 @@ class OpenGLDisplayDriver : DisplayDriver
       OGLDisplay oglDisplay = display.driverData;
       //Logf("SetCamera\n");
 
-      if(camera)
+      if(surface && camera)
       {
          int left = surface.box.left + surface.offset.x;
          int top = surface.box.top  + surface.offset.y;
@@ -3830,7 +3830,7 @@ class OpenGLDisplayDriver : DisplayDriver
 
          glEnable(GL_MULTISAMPLE_ARB);
       }
-      else if(display.display3D.camera)
+      else if(surface && display.display3D.camera)
       {
          oglDisplay.depthWrite = false;
          glViewport(0,0,display.width,display.height);