conworlds

diff src/vr/vr.c @ 8:90abf4b93cc9

fixed line endings fixed viewport when returning to original framebuffer
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 22 Aug 2014 17:24:43 +0300
parents bd8202d6d28d
children c2eecf764daa
line diff
     1.1 --- a/src/vr/vr.c	Fri Aug 22 16:55:16 2014 +0300
     1.2 +++ b/src/vr/vr.c	Fri Aug 22 17:24:43 2014 +0300
     1.3 @@ -4,6 +4,9 @@
     1.4  #include "vr_impl.h"
     1.5  
     1.6  
     1.7 +static void swap_buffers(void);
     1.8 +
     1.9 +
    1.10  static struct vr_module *vrm;
    1.11  static float idmat[] = {
    1.12  	1, 0, 0, 0,
    1.13 @@ -176,13 +179,18 @@
    1.14  
    1.15  int vr_swap_buffers(void)
    1.16  {
    1.17 +	int res = 0;
    1.18 +
    1.19  	if(vrm && vrm->present) {
    1.20 -		vrm->present();
    1.21 -		return 1;
    1.22 +		res = vrm->present();
    1.23 +	}
    1.24 +
    1.25 +	if(!res) {
    1.26 +		swap_buffers();
    1.27  	}
    1.28  	return 0;
    1.29  }
    1.30 -
    1.31 +
    1.32  void vr_output_texture(unsigned int tex, float umin, float vmin, float umax, float vmax)
    1.33  {
    1.34  	float halfu = (umax + umin) * 0.5f;
    1.35 @@ -203,4 +211,24 @@
    1.36  	if(vrm && vrm->recenter) {
    1.37  		vrm->recenter();
    1.38  	}
    1.39 -}
    1.40 \ No newline at end of file
    1.41 +}
    1.42 +
    1.43 +
    1.44 +#ifdef __unix__
    1.45 +#include <GL/glx.h>
    1.46 +
    1.47 +static void swap_buffers(void)
    1.48 +{
    1.49 +	glXSwapBuffers(glXGetCurrentDisplay(), glXGetCurrentDrawable());
    1.50 +}
    1.51 +
    1.52 +#endif
    1.53 +
    1.54 +#ifdef WIN32
    1.55 +#include <windows.h>
    1.56 +
    1.57 +static void swap_buffers(void)
    1.58 +{
    1.59 +	SwapBuffers(wglGetCurrentDC());
    1.60 +}
    1.61 +#endif