Add shadows and light effects
[mercenary-reloaded.git] / src / libovr / ovr.c
old mode 100755 (executable)
new mode 100644 (file)
index 8a9007f..5890425
@@ -42,6 +42,7 @@
 #include <math.h>
 #include <errno.h>
 #include "../libsdl/print.h"
+#include "../libopengl/opengl.h"
 #include "ovr.h"
 
 #include <OVR_CAPI.h>
@@ -337,7 +338,7 @@ void begin_render_ovr(void)
 
 static int initial_observer_reset = 1;
 
-void begin_render_ovr_eye(int eye, double *camera_x, double *camera_y, double *camera_z)
+void begin_render_ovr_eye(int eye, double *camera_x, double *camera_y, double *camera_z, int *width, int *height)
 {
        int curIndex;
        GLuint chainTexId;
@@ -348,9 +349,12 @@ void begin_render_ovr_eye(int eye, double *camera_x, double *camera_y, double *c
        ovr_GetTextureSwapChainCurrentIndex(session, textureSwapChain[eye], &curIndex);
        ovr_GetTextureSwapChainBufferGL(session, textureSwapChain[eye], curIndex, &chainTexId);
        glBindFramebuffer(GL_FRAMEBUFFER, fboId[eye]);
+       current_framebuffer = fboId[eye];
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, (multisampling > 1) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D, chainTexId, 0);
 
        glViewport(0, 0, TextureSize[eye].w, TextureSize[eye].h);
+       *width = TextureSize[eye].w;
+       *height = TextureSize[eye].h;
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glFrustum(
@@ -400,6 +404,7 @@ void end_render_ovr_eye(int eye)
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, (multisampling > 1) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D, 0, 0);
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, (multisampling > 1) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D, 0, 0);
        glBindFramebuffer(GL_FRAMEBUFFER, 0);
+       current_framebuffer = 0;
 
        // Commit the changes to the texture swap chain
        ovr_CommitTextureSwapChain(session, textureSwapChain[eye]);