forked from LeenkxTeam/LNXSDK
t3du - Restore VR code
This commit is contained in:
@ -518,12 +518,44 @@ class RenderPath {
|
|||||||
return Reflect.field(kha.Shaders, handle + "_comp");
|
return Reflect.field(kha.Shaders, handle + "_comp");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (kha_krom && lnx_vr)
|
#if lnx_vr
|
||||||
public function drawStereo(drawMeshes: Int->Void) {
|
public function drawStereo(drawMeshes: Void->Void) {
|
||||||
for (eye in 0...2) {
|
var vr = kha.vr.VrInterface.instance;
|
||||||
Krom.vrBeginRender(eye);
|
var appw = iron.App.w();
|
||||||
drawMeshes(eye);
|
var apph = iron.App.h();
|
||||||
Krom.vrEndRender(eye);
|
var halfw = Std.int(appw / 2);
|
||||||
|
var g = currentG;
|
||||||
|
|
||||||
|
if (vr != null && vr.IsPresenting()) {
|
||||||
|
// Left eye
|
||||||
|
Scene.active.camera.V.setFrom(Scene.active.camera.leftV);
|
||||||
|
Scene.active.camera.P.self = vr.GetProjectionMatrix(0);
|
||||||
|
g.viewport(0, 0, halfw, apph);
|
||||||
|
drawMeshes();
|
||||||
|
|
||||||
|
// Right eye
|
||||||
|
begin(g, additionalTargets);
|
||||||
|
Scene.active.camera.V.setFrom(Scene.active.camera.rightV);
|
||||||
|
Scene.active.camera.P.self = vr.GetProjectionMatrix(1);
|
||||||
|
g.viewport(halfw, 0, halfw, apph);
|
||||||
|
drawMeshes();
|
||||||
|
}
|
||||||
|
else { // Simulate
|
||||||
|
Scene.active.camera.buildProjection(halfw / apph);
|
||||||
|
|
||||||
|
// Left eye
|
||||||
|
g.viewport(0, 0, halfw, apph);
|
||||||
|
drawMeshes();
|
||||||
|
|
||||||
|
// Right eye
|
||||||
|
begin(g, additionalTargets);
|
||||||
|
Scene.active.camera.transform.move(Scene.active.camera.right(), 0.032);
|
||||||
|
Scene.active.camera.buildMatrix();
|
||||||
|
g.viewport(halfw, 0, halfw, apph);
|
||||||
|
drawMeshes();
|
||||||
|
|
||||||
|
Scene.active.camera.transform.move(Scene.active.camera.right(), -0.032);
|
||||||
|
Scene.active.camera.buildMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
Reference in New Issue
Block a user