Previous 199869 Revisions Next

r34227 Tuesday 6th January, 2015 at 21:50:00 UTC by Couriersud
Fixed two SDL2 bugs:
- Window height was 0 after a switch from fullscreen to windowed if
 sdlmame was started in fullscreen
- Fixed -switchres. This is now working on Ubuntu 14.04 again.
 Performance will vary on your hardware and drivers and I suspect
 SDL to be partly broken.
[src/osd/sdl]draw13.c input.c osdsdl.h video.c window.h

trunk/src/osd/sdl/draw13.c
r242738r242739
186186   // Stats
187187   INT64           m_last_blit_time;
188188   INT64           m_last_blit_pixels;
189
190   // Original display_mode
191   SDL_DisplayMode m_original_mode;
189192};
190193
191194//============================================================
r242738r242739
576579   // allocate memory for our structures
577580   sdl_info *sdl = global_alloc(sdl_info);
578581
582   /* FIXME: On Ubuntu and potentially other Linux OS you should use
583    * to disable panning. This has to be done before every invocation of mame.
584    *
585    * xrandr --output HDMI-0 --panning 0x0+0+0 --fb 0x0
586    *
587    */
588
579589   osd_printf_verbose("Enter drawsdl2_window_create\n");
580590
581591   window->dxdata = sdl;
r242738r242739
590600   if (window->fullscreen() && video_config.switchres)
591601   {
592602      SDL_DisplayMode mode;
593      SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
603      //SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
604        SDL_GetWindowDisplayMode(window->sdl_window, &mode);
605      sdl->m_original_mode = mode;
594606      mode.w = width;
595607      mode.h = height;
596608      if (window->refresh)
r242738r242739
615627            osd_printf_warning("Ignoring depth %d\n", window->depth);
616628         }
617629      }
618      SDL_SetWindowDisplayMode(window->sdl_window, &mode);    // Try to set mode
630        SDL_SetWindowDisplayMode(window->sdl_window, &mode);    // Try to set mode
631#ifndef SDLMAME_WIN32
632        /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
633         * is in place after the mode switch - which will most likely be the case
634         * This is a hack to work around a deficiency in SDL2
635         */
636        SDL_WarpMouseInWindow(window->sdl_window, 1, 1);
637#endif
619638   }
620639   else
621640      SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
r242738r242739
639658   SDL_RaiseWindow(window->sdl_window);
640659   SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
641660
642
643661   sdl->m_blittimer = 3;
644662
645663   SDL_RenderPresent(sdl->m_renderer);
r242738r242739
715733      SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
716734      sdl->m_resize_pending = 0;
717735      SDL_RenderSetViewport(sdl->m_renderer, NULL);
736       //sdlvideo_monitor_refresh(window->monitor());
737
718738   }
719739
720740   //SDL_SelectRenderer(window->sdl_window);
r242738r242739
832852
833853   drawsdl2_destroy_all_textures(window);
834854
835   SDL_DestroyWindow(window->sdl_window);
855    if (window->fullscreen() && video_config.switchres)
856    {
857        SDL_SetWindowFullscreen(window->sdl_window, 0);    // Try to set mode
858        SDL_SetWindowDisplayMode(window->sdl_window, &sdl->m_original_mode);    // Try to set mode
859        SDL_SetWindowFullscreen(window->sdl_window, SDL_WINDOW_FULLSCREEN);    // Try to set mode
860    }
836861
862    SDL_DestroyWindow(window->sdl_window);
863
837864   global_free(sdl);
838865   window->dxdata = NULL;
839866}
trunk/src/osd/sdl/input.c
r242738r242739
19851985            }
19861986            else
19871987            {
1988               if (event.window.data1 != window->width || event.window.data2 != window->height)
1989                  window->window_resize(event.window.data1, event.window.data2);
1988#ifndef SDLMAME_WIN32
1989                /* FIXME: SDL2 sends some spurious resize events on Ubuntu
1990                 * while in fullscreen mode. Ignore them for now.
1991                 */
1992                if (!window->fullscreen())
1993#endif
1994                {
1995                       //printf("event data1,data2 %d x %d %ld\n", event.window.data1, event.window.data2, sizeof(SDL_Event));
1996                       if (event.window.data1 != window->width || event.window.data2 != window->height)
1997                           window->window_resize(event.window.data1, event.window.data2);
1998                }
19901999            }
19912000            focus_window = window;
19922001            break;
trunk/src/osd/sdl/osdsdl.h
r242738r242739
2626      #define SDL13_COMBINE_RESIZE (0)
2727   #endif
2828#else
29    #define SDLMAME_INIT_IN_WORKER_THREAD   (0)
2930   #define SDL13_COMBINE_RESIZE (0)
30   #define SDLMAME_INIT_IN_WORKER_THREAD   (0)
3131#endif
3232
3333#if defined(NO_DEBUGGER)
trunk/src/osd/sdl/video.c
r242738r242739
155155   #if (SDLMAME_SDL2)
156156   SDL_DisplayMode dmode;
157157
158   #if defined(SDLMAME_WIN32)
158159   SDL_GetDesktopDisplayMode(monitor->handle, &dmode);
160    #else
161    SDL_GetCurrentDisplayMode(monitor->handle, &dmode);
162    #endif
159163   monitor->monitor_width = dmode.w;
160164   monitor->monitor_height = dmode.h;
161165   monitor->center_width = dmode.w;
162166   monitor->center_height = dmode.h;
167
168   // FIXME: Use SDL_GetDisplayBounds(monitor->handle, &tt) to update monitor_x
169   // SDL_Rect tt;
163170   #else
164171   #if defined(SDLMAME_WIN32)  // Win32 version
165172   MONITORINFOEX info;
r242738r242739
456463         monitor->monitor_height = dmode.h;
457464         monitor->center_width = dmode.w;
458465         monitor->center_height = dmode.h;
466         // FIXME: this should use SDL_GetDisplayBounds!
459467         monitor->monitor_x = monx;
460468         monitor->handle = i;
461469         // guess the aspect ratio assuming square pixels
trunk/src/osd/sdl/window.h
r242738r242739
6161      m_fullscreen = !video_config.windowed;
6262      prescale = video_config.prescale;
6363
64      if (!m_fullscreen)
65      {
66         windowed_width = config->width;
67         windowed_height = config->height;
68      }
64        windowed_width = config->width;
65        windowed_height = config->height;
6966   }
7067
7168   void video_window_update(running_machine &machine);


Previous 199869 Revisions Next


© 1997-2024 The MAME Team