oculus2

changeset 21:46291bf81d0a

delay switching to fullscreen until after the window has been resized
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 30 Mar 2015 07:27:01 +0300
parents 6a3a9840c303
children 9ee3ab70ca6b
files src/main.c
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/src/main.c	Wed Jan 21 11:29:30 2015 +0200
     1.2 +++ b/src/main.c	Mon Mar 30 07:27:01 2015 +0300
     1.3 @@ -46,6 +46,8 @@
     1.4  static SDL_GLContext ctx;
     1.5  static int win_width, win_height;
     1.6  
     1.7 +static int fullscr_pending;
     1.8 +
     1.9  static unsigned int fbo, fb_tex, fb_depth;
    1.10  static int fb_width, fb_height;
    1.11  static int fb_tex_width, fb_tex_height;
    1.12 @@ -218,7 +220,7 @@
    1.13  
    1.14  void toggle_hmd_fullscreen(void)
    1.15  {
    1.16 -	static int fullscr, prev_x, prev_y;
    1.17 +	static int fullscr, prev_x, prev_y, prev_xsz, prev_ysz;
    1.18  	fullscr = !fullscr;
    1.19  
    1.20  	if(fullscr) {
    1.21 @@ -226,8 +228,11 @@
    1.22  		 * to the rift's part of the desktop before going fullscreen
    1.23  		 */
    1.24  		SDL_GetWindowPosition(win, &prev_x, &prev_y);
    1.25 +		SDL_GetWindowSize(win, &prev_xsz, &prev_ysz);
    1.26 +		SDL_SetWindowSize(win, hmd->Resolution.h, hmd->Resolution.w);
    1.27  		SDL_SetWindowPosition(win, hmd->WindowsPos.x, hmd->WindowsPos.y);
    1.28 -		SDL_SetWindowFullscreen(win, SDL_WINDOW_FULLSCREEN_DESKTOP);
    1.29 +		fullscr_pending = 1;
    1.30 +		/*SDL_SetWindowFullscreen(win, SDL_WINDOW_FULLSCREEN_DESKTOP);*/
    1.31  
    1.32  #ifdef OVR_OS_LINUX
    1.33  		/* on linux for now we have to deal with screen rotation during rendering. The docs are promoting
    1.34 @@ -243,6 +248,7 @@
    1.35  		/* return to windowed mode and move the window back to its original position */
    1.36  		SDL_SetWindowFullscreen(win, 0);
    1.37  		SDL_SetWindowPosition(win, prev_x, prev_y);
    1.38 +		SDL_SetWindowSize(win, prev_xsz, prev_ysz);
    1.39  
    1.40  #ifdef OVR_OS_LINUX
    1.41  		glcfg.OGL.Header.BackBufferSize = hmd->Resolution;
    1.42 @@ -502,6 +508,10 @@
    1.43  	case SDL_WINDOWEVENT:
    1.44  		if(ev->window.event == SDL_WINDOWEVENT_RESIZED) {
    1.45  			reshape(ev->window.data1, ev->window.data2);
    1.46 +			if(fullscr_pending) {
    1.47 +				SDL_SetWindowFullscreen(win, SDL_WINDOW_FULLSCREEN);
    1.48 +				fullscr_pending = 0;
    1.49 +			}
    1.50  		}
    1.51  		break;
    1.52