mirror of
https://github.com/holub/mame
synced 2025-06-28 15:14:21 +03:00
Safety commit before pull. More code alignment. (nw)
This commit is contained in:
parent
84c053f76e
commit
fba518ef0c
@ -143,17 +143,16 @@ class sdl_info13 : public osd_renderer
|
||||
{
|
||||
public:
|
||||
sdl_info13(sdl_window_info *w)
|
||||
: osd_renderer(w), m_blittimer(0), m_renderer(NULL),
|
||||
: osd_renderer(w, FLAG_NONE), m_blittimer(0), m_renderer(NULL),
|
||||
m_last_hofs(0), m_last_vofs(0),
|
||||
m_resize_pending(0), m_resize_width(0), m_resize_height(0),
|
||||
m_last_blit_time(0), m_last_blit_pixels(0)
|
||||
{}
|
||||
|
||||
/* virtual */ int create(int width, int height);
|
||||
/* virtual */ void resize(int width, int height);
|
||||
/* virtual */ int draw(UINT32 dc, int update);
|
||||
/* virtual */ void set_target_bounds();
|
||||
/* virtual */ int xy_to_render_target(int x, int y, int *xt, int *yt);
|
||||
/* virtual */ int create(const int width, const int height);
|
||||
/* virtual */ void resize(const int width, const int height);
|
||||
/* virtual */ int draw(const UINT32 dc, const int update);
|
||||
/* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt);
|
||||
/* virtual */ void destroy_all_textures();
|
||||
/* virtual */ void destroy();
|
||||
/* virtual */ void clear();
|
||||
@ -594,11 +593,28 @@ int sdl_info13::create(int width, int height)
|
||||
* xrandr --output HDMI-0 --panning 0x0+0+0 --fb 0x0
|
||||
*
|
||||
*/
|
||||
osd_printf_verbose("Enter sdl_info::create\n");
|
||||
|
||||
osd_printf_verbose("Enter sdl_info13::create\n");
|
||||
#if (SDLMAME_SDL2)
|
||||
|
||||
if (check_flag(FLAG_NEEDS_OPENGL))
|
||||
{
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||
|
||||
/* FIXME: A reminder that gamma is wrong throughout MAME. Currently, SDL2.0 doesn't seem to
|
||||
* support the following attribute although my hardware lists GL_ARB_framebuffer_sRGB as an extension.
|
||||
*
|
||||
* SDL_GL_SetAttribute( SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1 );
|
||||
*
|
||||
*/
|
||||
m_extra_flags = SDL_WINDOW_OPENGL;
|
||||
}
|
||||
else
|
||||
m_extra_flags = 0;
|
||||
|
||||
// create the SDL window
|
||||
m_extra_flags = (window().fullscreen() ?
|
||||
// soft driver also used | SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_MOUSE_FOCUS
|
||||
m_extra_flags |= (window().fullscreen() ?
|
||||
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
|
||||
|
||||
#if defined(SDLMAME_WIN32)
|
||||
@ -608,9 +624,14 @@ int sdl_info13::create(int width, int height)
|
||||
window().m_sdl_window = SDL_CreateWindow(window().m_title,
|
||||
window().monitor()->position_size().x, window().monitor()->position_size().y,
|
||||
width, height, m_extra_flags);
|
||||
//window().m_sdl_window = SDL_CreateWindow(window().m_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
// width, height, m_extra_flags);
|
||||
|
||||
if (!window().m_sdl_window )
|
||||
{
|
||||
if (check_flag(FLAG_NEEDS_OPENGL))
|
||||
osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
|
||||
else
|
||||
osd_printf_error("Window creation failed: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
@ -639,6 +660,15 @@ int sdl_info13::create(int width, int height)
|
||||
{
|
||||
//SDL_SetWindowDisplayMode(window().m_sdl_window, NULL); // Use desktop
|
||||
}
|
||||
|
||||
// show window
|
||||
|
||||
SDL_ShowWindow(window().m_sdl_window);
|
||||
//SDL_SetWindowFullscreen(window().m_sdl_window, window().fullscreen);
|
||||
SDL_RaiseWindow(window().m_sdl_window);
|
||||
|
||||
SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
|
||||
|
||||
// create renderer
|
||||
|
||||
if (video_config.waitvsync)
|
||||
@ -653,18 +683,48 @@ int sdl_info13::create(int width, int height)
|
||||
|
||||
//SDL_SelectRenderer(window().sdl_window);
|
||||
|
||||
// show window
|
||||
|
||||
SDL_ShowWindow(window().m_sdl_window);
|
||||
//SDL_SetWindowFullscreen(window().sdl_window, window().fullscreen);
|
||||
SDL_RaiseWindow(window().m_sdl_window);
|
||||
|
||||
SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
|
||||
|
||||
m_blittimer = 3;
|
||||
|
||||
SDL_RenderPresent(m_renderer);
|
||||
osd_printf_verbose("Leave sdl_info13::create\n");
|
||||
|
||||
#else
|
||||
m_extra_flags = (window().fullscreen() ? SDL_FULLSCREEN : SDL_RESIZABLE);
|
||||
m_extra_flags |= SDL_DOUBLEBUF;
|
||||
|
||||
if (check_flag(FLAG_NEEDS_OPENGL))
|
||||
{
|
||||
m_extra_flags |= SDL_OPENGL;
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||
#if (SDL_VERSION_ATLEAST(1,2,10)) && (!defined(SDLMAME_EMSCRIPTEN))
|
||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, video_config.waitvsync ? 1 : 0);
|
||||
#endif
|
||||
//load_gl_lib(window().machine());
|
||||
}
|
||||
|
||||
// create the SDL surface (which creates the window in windowed mode)
|
||||
m_sdlsurf = SDL_SetVideoMode(width, height,
|
||||
0, SDL_SWSURFACE | SDL_ANYFORMAT | m_extra_flags);
|
||||
|
||||
if (!m_sdlsurf)
|
||||
return 1;
|
||||
if ( (video_config.mode == VIDEO_MODE_OPENGL) && !(m_sdlsurf->flags & SDL_OPENGL) )
|
||||
{
|
||||
osd_printf_error("OpenGL not supported on this driver!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
window().m_width = m_sdlsurf->w;
|
||||
window().m_height = m_sdlsurf->h;
|
||||
|
||||
window().m_screen_width = 0;
|
||||
window().m_screen_height = 0;
|
||||
|
||||
|
||||
// set the window title
|
||||
SDL_WM_SetCaption(window().m_title, "SDLMAME");
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -685,6 +745,38 @@ void sdl_info13::resize(int width, int height)
|
||||
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// sdl_info::destroy
|
||||
//============================================================
|
||||
|
||||
void sdl_info13::destroy()
|
||||
{
|
||||
// free the memory in the window
|
||||
|
||||
destroy_all_textures();
|
||||
|
||||
if (window().fullscreen() && video_config.switchres)
|
||||
{
|
||||
SDL_SetWindowFullscreen(window().m_sdl_window, 0); // Try to set mode
|
||||
SDL_SetWindowDisplayMode(window().m_sdl_window, &m_original_mode); // Try to set mode
|
||||
SDL_SetWindowFullscreen(window().m_sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode
|
||||
}
|
||||
|
||||
SDL_DestroyWindow(window().m_sdl_window);
|
||||
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// sdl_info::clear
|
||||
//============================================================
|
||||
|
||||
void sdl_info13::clear()
|
||||
{
|
||||
m_blittimer = 2;
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// drawsdl_xy_to_render_target
|
||||
//============================================================
|
||||
@ -701,15 +793,6 @@ int sdl_info13::xy_to_render_target(int x, int y, int *xt, int *yt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// sdl_info::get_primitives
|
||||
//============================================================
|
||||
|
||||
void sdl_info13::set_target_bounds()
|
||||
{
|
||||
window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect());
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// sdl_info::draw
|
||||
//============================================================
|
||||
@ -823,37 +906,6 @@ int sdl_info13::draw(UINT32 dc, int update)
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// sdl_info13::clear
|
||||
//============================================================
|
||||
|
||||
void sdl_info13::clear()
|
||||
{
|
||||
m_blittimer = 2;
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// sdl_info13::destroy
|
||||
//============================================================
|
||||
|
||||
void sdl_info13::destroy()
|
||||
{
|
||||
// free the memory in the window
|
||||
|
||||
destroy_all_textures();
|
||||
|
||||
if (window().fullscreen() && video_config.switchres)
|
||||
{
|
||||
SDL_SetWindowFullscreen(window().m_sdl_window, 0); // Try to set mode
|
||||
SDL_SetWindowDisplayMode(window().m_sdl_window, &m_original_mode); // Try to set mode
|
||||
SDL_SetWindowFullscreen(window().m_sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode
|
||||
}
|
||||
|
||||
SDL_DestroyWindow(window().m_sdl_window);
|
||||
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// texture handling
|
||||
//============================================================
|
||||
|
@ -74,17 +74,16 @@ class sdl_info_bgfx : public osd_renderer
|
||||
{
|
||||
public:
|
||||
sdl_info_bgfx(sdl_window_info *w)
|
||||
: osd_renderer(w), m_blittimer(0), m_renderer(NULL),
|
||||
: osd_renderer(w, FLAG_NONE), m_blittimer(0), m_renderer(NULL),
|
||||
m_last_hofs(0), m_last_vofs(0),
|
||||
m_resize_pending(0), m_resize_width(0), m_resize_height(0),
|
||||
m_last_blit_time(0), m_last_blit_pixels(0)
|
||||
{}
|
||||
|
||||
/* virtual */ int create(int width, int height);
|
||||
/* virtual */ void resize(int width, int height);
|
||||
/* virtual */ int draw(UINT32 dc, int update);
|
||||
/* virtual */ void set_target_bounds();
|
||||
/* virtual */ int xy_to_render_target(int x, int y, int *xt, int *yt);
|
||||
/* virtual */ int create(const int width, const int height);
|
||||
/* virtual */ void resize(const int width, const int height);
|
||||
/* virtual */ int draw(const UINT32 dc, const int update);
|
||||
/* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt);
|
||||
/* virtual */ void destroy_all_textures();
|
||||
/* virtual */ void destroy();
|
||||
/* virtual */ void clear();
|
||||
@ -253,15 +252,6 @@ int sdl_info_bgfx::xy_to_render_target(int x, int y, int *xt, int *yt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// sdl_info_bgfx::get_primitives
|
||||
//============================================================
|
||||
|
||||
void sdl_info_bgfx::set_target_bounds()
|
||||
{
|
||||
window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect());
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// sdl_info_bgfx::draw
|
||||
//============================================================
|
||||
|
@ -156,11 +156,14 @@ enum
|
||||
// TYPES
|
||||
//============================================================
|
||||
|
||||
struct texture_info;
|
||||
//============================================================
|
||||
// Textures
|
||||
//============================================================
|
||||
|
||||
/* texture_info holds information about a texture */
|
||||
struct texture_info
|
||||
class texture_info
|
||||
{
|
||||
public:
|
||||
texture_info()
|
||||
: hash(0), flags(0), rawwidth(0), rawheight(0),
|
||||
rawwidth_create(0), rawheight_create(0),
|
||||
@ -219,7 +222,7 @@ class sdl_info_ogl : public osd_renderer
|
||||
{
|
||||
public:
|
||||
sdl_info_ogl(sdl_window_info *window)
|
||||
: osd_renderer(window), m_blittimer(0), m_extra_flags(0),
|
||||
: osd_renderer(window, FLAG_NEEDS_OPENGL), m_blittimer(0), m_extra_flags(0),
|
||||
#if (SDLMAME_SDL2)
|
||||
m_gl_context_id(0),
|
||||
#else
|
||||
@ -248,11 +251,10 @@ public:
|
||||
m_texVerticex[i] = 0.0f;
|
||||
}
|
||||
|
||||
/* virtual */ int create(int width, int height);
|
||||
/* virtual */ void resize(int width, int height);
|
||||
/* virtual */ int draw(UINT32 dc, int update);
|
||||
/* virtual */ void set_target_bounds();
|
||||
/* virtual */ int xy_to_render_target(int x, int y, int *xt, int *yt);
|
||||
/* virtual */ int create(const int width, const int height);
|
||||
/* virtual */ void resize(const int width, int const height);
|
||||
/* virtual */ int draw(const UINT32 dc, const int update);
|
||||
/* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt);
|
||||
/* virtual */ void destroy_all_textures();
|
||||
/* virtual */ void destroy();
|
||||
/* virtual */ void clear();
|
||||
@ -393,6 +395,10 @@ void sdl_info_ogl::set_blendmode(int blendmode)
|
||||
|
||||
// core functions
|
||||
|
||||
//============================================================
|
||||
// STATIC VARIABLES
|
||||
//============================================================
|
||||
|
||||
static void drawogl_exit(void);
|
||||
static void load_gl_lib(running_machine &machine);
|
||||
|
||||
@ -440,7 +446,7 @@ static int shown_video_info = 0;
|
||||
static int dll_loaded = 0;
|
||||
|
||||
//============================================================
|
||||
// drawogl_init
|
||||
// drawsdl_init
|
||||
//============================================================
|
||||
|
||||
static osd_renderer *drawogl_create(sdl_window_info *window)
|
||||
@ -456,10 +462,10 @@ int drawogl_init(running_machine &machine, sdl_draw_info *callbacks)
|
||||
|
||||
dll_loaded = 0;
|
||||
|
||||
load_gl_lib(machine);
|
||||
if (SDLMAME_SDL2)
|
||||
{
|
||||
osd_printf_verbose("Using SDL multi-window OpenGL driver (SDL 2.0+)\n");
|
||||
load_gl_lib(machine);
|
||||
}
|
||||
else
|
||||
osd_printf_verbose("Using SDL single-window OpenGL driver (SDL 1.2)\n");
|
||||
@ -710,8 +716,18 @@ void sdl_info_ogl::initialize_gl()
|
||||
|
||||
int sdl_info_ogl::create(int width, int height)
|
||||
{
|
||||
/* FIXME: On Ubuntu and potentially other Linux OS you should use
|
||||
* to disable panning. This has to be done before every invocation of mame.
|
||||
*
|
||||
* xrandr --output HDMI-0 --panning 0x0+0+0 --fb 0x0
|
||||
*
|
||||
*/
|
||||
osd_printf_verbose("Enter sdl_info::create\n");
|
||||
|
||||
#if (SDLMAME_SDL2)
|
||||
|
||||
if (check_flag(FLAG_NEEDS_OPENGL))
|
||||
{
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||
|
||||
/* FIXME: A reminder that gamma is wrong throughout MAME. Currently, SDL2.0 doesn't seem to
|
||||
@ -720,17 +736,16 @@ int sdl_info_ogl::create(int width, int height)
|
||||
* SDL_GL_SetAttribute( SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1 );
|
||||
*
|
||||
*/
|
||||
|
||||
osd_printf_verbose("Enter sdl_info_ogl::create\n");
|
||||
m_extra_flags = SDL_WINDOW_OPENGL;
|
||||
}
|
||||
else
|
||||
m_extra_flags = 0;
|
||||
|
||||
// create the SDL window
|
||||
// soft driver also used | SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_MOUSE_FOCUS
|
||||
m_extra_flags = (window().fullscreen() ?
|
||||
m_extra_flags |= (window().fullscreen() ?
|
||||
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
|
||||
|
||||
m_extra_flags |= SDL_WINDOW_OPENGL;
|
||||
|
||||
|
||||
#if defined(SDLMAME_WIN32)
|
||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||
#endif
|
||||
@ -743,7 +758,10 @@ int sdl_info_ogl::create(int width, int height)
|
||||
|
||||
if (!window().m_sdl_window )
|
||||
{
|
||||
if (check_flag(FLAG_NEEDS_OPENGL))
|
||||
osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
|
||||
else
|
||||
osd_printf_error("Window creation failed: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -771,9 +789,6 @@ int sdl_info_ogl::create(int width, int height)
|
||||
{
|
||||
//SDL_SetWindowDisplayMode(window().m_sdl_window, NULL); // Use desktop
|
||||
}
|
||||
// create renderer
|
||||
|
||||
//SDL_SelectRenderer(window().sdl_window);
|
||||
|
||||
// show window
|
||||
|
||||
@ -783,6 +798,7 @@ int sdl_info_ogl::create(int width, int height)
|
||||
|
||||
SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
|
||||
|
||||
// create renderer
|
||||
|
||||
m_gl_context_id = SDL_GL_CreateContext(window().m_sdl_window);
|
||||
if (!m_gl_context_id)
|
||||
@ -795,14 +811,17 @@ int sdl_info_ogl::create(int width, int height)
|
||||
|
||||
#else
|
||||
m_extra_flags = (window().fullscreen() ? SDL_FULLSCREEN : SDL_RESIZABLE);
|
||||
m_extra_flags |= SDL_OPENGL | SDL_DOUBLEBUF;
|
||||
m_extra_flags |= SDL_DOUBLEBUF;
|
||||
|
||||
if (check_flag(FLAG_NEEDS_OPENGL))
|
||||
{
|
||||
m_extra_flags |= SDL_OPENGL;
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||
#if (SDL_VERSION_ATLEAST(1,2,10)) && (!defined(SDLMAME_EMSCRIPTEN))
|
||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, video_config.waitvsync ? 1 : 0);
|
||||
#endif
|
||||
|
||||
load_gl_lib(window().machine());
|
||||
//load_gl_lib(window().machine());
|
||||
}
|
||||
|
||||
// create the SDL surface (which creates the window in windowed mode)
|
||||
m_sdlsurf = SDL_SetVideoMode(width, height,
|
||||
@ -810,6 +829,11 @@ int sdl_info_ogl::create(int width, int height)
|
||||
|
||||
if (!m_sdlsurf)
|
||||
return 1;
|
||||
if ( (video_config.mode == VIDEO_MODE_OPENGL) && !(m_sdlsurf->flags & SDL_OPENGL) )
|
||||
{
|
||||
osd_printf_error("OpenGL not supported on this driver!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
window().m_width = m_sdlsurf->w;
|
||||
window().m_height = m_sdlsurf->h;
|
||||
@ -817,11 +841,6 @@ int sdl_info_ogl::create(int width, int height)
|
||||
window().m_screen_width = 0;
|
||||
window().m_screen_height = 0;
|
||||
|
||||
if ( (video_config.mode == VIDEO_MODE_OPENGL) && !(m_sdlsurf->flags & SDL_OPENGL) )
|
||||
{
|
||||
osd_printf_error("OpenGL not supported on this driver!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// set the window title
|
||||
SDL_WM_SetCaption(window().m_title, "SDLMAME");
|
||||
@ -876,6 +895,47 @@ void sdl_info_ogl::resize(int width, int height)
|
||||
|
||||
}
|
||||
|
||||
|
||||
//============================================================
|
||||
// sdl_info::destroy
|
||||
//============================================================
|
||||
|
||||
void sdl_info_ogl::destroy()
|
||||
{
|
||||
|
||||
// free the memory in the window
|
||||
|
||||
destroy_all_textures();
|
||||
|
||||
#if (SDLMAME_SDL2)
|
||||
SDL_GL_DeleteContext(m_gl_context_id);
|
||||
if (window().fullscreen() && video_config.switchres)
|
||||
{
|
||||
SDL_SetWindowFullscreen(window().m_sdl_window, 0); // Try to set mode
|
||||
SDL_SetWindowDisplayMode(window().m_sdl_window, &m_original_mode); // Try to set mode
|
||||
SDL_SetWindowFullscreen(window().m_sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode
|
||||
}
|
||||
|
||||
SDL_DestroyWindow(window().m_sdl_window);
|
||||
#else
|
||||
if (m_sdlsurf)
|
||||
{
|
||||
SDL_FreeSurface(m_sdlsurf);
|
||||
m_sdlsurf = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// sdl_info::clear
|
||||
//============================================================
|
||||
|
||||
void sdl_info_ogl::clear()
|
||||
{
|
||||
//FIXME: Handled in sdl_info::draw as well
|
||||
m_blittimer = 3;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// drawsdl_xy_to_render_target
|
||||
//============================================================
|
||||
@ -891,15 +951,6 @@ int sdl_info_ogl::xy_to_render_target(int x, int y, int *xt, int *yt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// sdl_info::get_primitives
|
||||
//============================================================
|
||||
|
||||
void sdl_info_ogl::set_target_bounds()
|
||||
{
|
||||
window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect());
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// loadGLExtensions
|
||||
//============================================================
|
||||
@ -1210,36 +1261,6 @@ void sdl_info_ogl::loadGLExtensions()
|
||||
_once = 0;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// sdl_info::destroy
|
||||
//============================================================
|
||||
|
||||
void sdl_info_ogl::destroy()
|
||||
{
|
||||
|
||||
// free the memory in the window
|
||||
|
||||
destroy_all_textures();
|
||||
|
||||
#if (SDLMAME_SDL2)
|
||||
SDL_GL_DeleteContext(m_gl_context_id);
|
||||
if (window().fullscreen() && video_config.switchres)
|
||||
{
|
||||
SDL_SetWindowFullscreen(window().m_sdl_window, 0); // Try to set mode
|
||||
SDL_SetWindowDisplayMode(window().m_sdl_window, &m_original_mode); // Try to set mode
|
||||
SDL_SetWindowFullscreen(window().m_sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode
|
||||
}
|
||||
|
||||
SDL_DestroyWindow(window().m_sdl_window);
|
||||
#else
|
||||
if (m_sdlsurf)
|
||||
{
|
||||
SDL_FreeSurface(m_sdlsurf);
|
||||
m_sdlsurf = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// sdl_info::draw
|
||||
//============================================================
|
||||
@ -3167,12 +3188,3 @@ void sdl_info_ogl::destroy_all_textures()
|
||||
window().m_primlist->release_lock();
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// TEXCOPY FUNCS
|
||||
//============================================================
|
||||
|
||||
void sdl_info_ogl::clear()
|
||||
{
|
||||
//FIXME: Handled in sdl_info::draw as well
|
||||
m_blittimer = 3;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class sdl_info : public osd_renderer
|
||||
public:
|
||||
|
||||
sdl_info(sdl_window_info *w)
|
||||
: osd_renderer(w),
|
||||
: osd_renderer(w, FLAG_NONE),
|
||||
m_blittimer(0),
|
||||
m_extra_flags(0),
|
||||
|
||||
@ -72,11 +72,10 @@ public:
|
||||
m_old_blitheight(0)
|
||||
{ }
|
||||
|
||||
/* virtual */ int create(int width, int height);
|
||||
/* virtual */ void resize(int width, int height);
|
||||
/* virtual */ int draw(UINT32 dc, int update);
|
||||
/* virtual */ void set_target_bounds();
|
||||
/* virtual */ int xy_to_render_target(int x, int y, int *xt, int *yt);
|
||||
/* virtual */ int create(const int width, const int height);
|
||||
/* virtual */ void resize(const int width, const int height);
|
||||
/* virtual */ int draw(const UINT32 dc, const int update);
|
||||
/* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt);
|
||||
/* virtual */ void destroy_all_textures();
|
||||
/* virtual */ void destroy();
|
||||
/* virtual */ void clear();
|
||||
@ -431,23 +430,45 @@ static void drawsdl_show_info(struct SDL_RendererInfo *render_info)
|
||||
|
||||
int sdl_info::create(int width, int height)
|
||||
{
|
||||
/* FIXME: On Ubuntu and potentially other Linux OS you should use
|
||||
* to disable panning. This has to be done before every invocation of mame.
|
||||
*
|
||||
* xrandr --output HDMI-0 --panning 0x0+0+0 --fb 0x0
|
||||
*
|
||||
*/
|
||||
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
|
||||
|
||||
osd_printf_verbose("Enter sdl_info::create\n");
|
||||
|
||||
#if (SDLMAME_SDL2)
|
||||
|
||||
osd_printf_verbose("Enter sdl_info::create\n");
|
||||
if (check_flag(FLAG_NEEDS_OPENGL))
|
||||
{
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||
|
||||
/* FIXME: A reminder that gamma is wrong throughout MAME. Currently, SDL2.0 doesn't seem to
|
||||
* support the following attribute although my hardware lists GL_ARB_framebuffer_sRGB as an extension.
|
||||
*
|
||||
* SDL_GL_SetAttribute( SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1 );
|
||||
*
|
||||
*/
|
||||
m_extra_flags = SDL_WINDOW_OPENGL;
|
||||
}
|
||||
else
|
||||
m_extra_flags = 0;
|
||||
|
||||
/* set hints ... */
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, sm->sdl_scale_mode);
|
||||
|
||||
// create the SDL window
|
||||
// soft driver also used | SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_MOUSE_FOCUS
|
||||
m_extra_flags = (window().fullscreen() ?
|
||||
m_extra_flags |= (window().fullscreen() ?
|
||||
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
|
||||
|
||||
#if defined(SDLMAME_WIN32)
|
||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||
#endif
|
||||
// create the SDL window
|
||||
window().m_sdl_window = SDL_CreateWindow(window().m_title,
|
||||
window().monitor()->position_size().x, window().monitor()->position_size().y,
|
||||
width, height, m_extra_flags);
|
||||
@ -456,7 +477,10 @@ int sdl_info::create(int width, int height)
|
||||
|
||||
if (!window().m_sdl_window )
|
||||
{
|
||||
osd_printf_error("Unable to create window: %s\n", SDL_GetError());
|
||||
if (check_flag(FLAG_NEEDS_OPENGL))
|
||||
osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
|
||||
else
|
||||
osd_printf_error("Window creation failed: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -484,9 +508,6 @@ int sdl_info::create(int width, int height)
|
||||
{
|
||||
//SDL_SetWindowDisplayMode(window().m_sdl_window, NULL); // Use desktop
|
||||
}
|
||||
// create renderer
|
||||
|
||||
//SDL_SelectRenderer(window().sdl_window);
|
||||
|
||||
// show window
|
||||
|
||||
@ -496,18 +517,17 @@ int sdl_info::create(int width, int height)
|
||||
|
||||
SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
|
||||
|
||||
/* FIXME: Bug in SDL 1.3 */
|
||||
if (window().fullscreen())
|
||||
SDL_SetWindowGrab(window().m_sdl_window, SDL_TRUE);
|
||||
|
||||
// create a texture
|
||||
// create renderer
|
||||
|
||||
if (video_config.waitvsync)
|
||||
m_sdl_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD |*/ SDL_RENDERER_PRESENTVSYNC);
|
||||
m_sdl_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||
else
|
||||
m_sdl_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0);
|
||||
m_sdl_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_ACCELERATED);
|
||||
|
||||
//SDL_SelectRenderer(window().sdl_window);
|
||||
if (!m_sdl_renderer)
|
||||
{
|
||||
fatalerror("Error on creating renderer: %s\n", SDL_GetError());
|
||||
}
|
||||
|
||||
{
|
||||
struct SDL_RendererInfo render_info;
|
||||
@ -539,11 +559,28 @@ int sdl_info::create(int width, int height)
|
||||
|
||||
m_extra_flags |= sm->m_extra_flags;
|
||||
|
||||
if (check_flag(FLAG_NEEDS_OPENGL))
|
||||
{
|
||||
m_extra_flags |= SDL_DOUBLEBUF | SDL_OPENGL;
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||
#if (SDL_VERSION_ATLEAST(1,2,10)) && (!defined(SDLMAME_EMSCRIPTEN))
|
||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, video_config.waitvsync ? 1 : 0);
|
||||
#endif
|
||||
//load_gl_lib(window().machine());
|
||||
}
|
||||
|
||||
// create the SDL surface (which creates the window in windowed mode)
|
||||
m_sdlsurf = SDL_SetVideoMode(width, height,
|
||||
0, SDL_SWSURFACE | SDL_ANYFORMAT | m_extra_flags);
|
||||
|
||||
if (!m_sdlsurf)
|
||||
return 1;
|
||||
if ( (video_config.mode == VIDEO_MODE_OPENGL) && !(m_sdlsurf->flags & SDL_OPENGL) )
|
||||
{
|
||||
osd_printf_error("OpenGL not supported on this driver!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
window().m_width = m_sdlsurf->w;
|
||||
window().m_height = m_sdlsurf->h;
|
||||
if (sm->is_yuv)
|
||||
@ -645,11 +682,12 @@ void sdl_info::destroy()
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// sdl_info::draw
|
||||
// sdl_info::clear
|
||||
//============================================================
|
||||
|
||||
void sdl_info::clear()
|
||||
{
|
||||
//FIXME: Handled in sdl_info::draw as well
|
||||
m_blittimer = 3;
|
||||
}
|
||||
|
||||
@ -659,28 +697,17 @@ void sdl_info::clear()
|
||||
|
||||
int sdl_info::xy_to_render_target(int x, int y, int *xt, int *yt)
|
||||
{
|
||||
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
|
||||
|
||||
*xt = x - m_last_hofs;
|
||||
*yt = y - m_last_vofs;
|
||||
if (*xt<0 || *xt >= window().m_blitwidth)
|
||||
return 0;
|
||||
if (*yt<0 || *xt >= window().m_blitheight)
|
||||
if (*yt<0 || *yt >= window().m_blitheight)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// drawsdl_window_get_primitives
|
||||
//============================================================
|
||||
|
||||
void sdl_info::set_target_bounds()
|
||||
{
|
||||
window().m_target->set_bounds(window().m_blitwidth, window().m_blitheight, window().monitor()->aspect());
|
||||
}
|
||||
|
||||
//============================================================
|
||||
// drawsdl_window_draw
|
||||
// sdl_info::draw
|
||||
//============================================================
|
||||
|
||||
int sdl_info::draw(UINT32 dc, int update)
|
||||
|
@ -1031,7 +1031,8 @@ void sdl_window_info::video_window_update(running_machine &machine)
|
||||
}
|
||||
|
||||
// ensure the target bounds are up-to-date, and then get the primitives
|
||||
renderer().set_target_bounds();
|
||||
|
||||
m_target->set_bounds(m_blitwidth, m_blitheight, monitor()->aspect());
|
||||
|
||||
render_primitive_list &primlist = m_target->get_primitives();
|
||||
|
||||
|
@ -37,24 +37,30 @@ class sdl_window_info;
|
||||
class osd_renderer
|
||||
{
|
||||
public:
|
||||
osd_renderer(sdl_window_info *window)
|
||||
: m_window(window) { }
|
||||
|
||||
static const int FLAG_NONE = 0;
|
||||
static const int FLAG_NEEDS_OPENGL = 1;
|
||||
|
||||
osd_renderer(sdl_window_info *window, const int flags)
|
||||
: m_window(window), m_flags(flags) { }
|
||||
|
||||
virtual ~osd_renderer() { }
|
||||
|
||||
sdl_window_info &window() { return *m_window; }
|
||||
int flags() const { return m_flags; }
|
||||
bool check_flag(const int flag) { return ((m_flags & flag)) == flag; }
|
||||
|
||||
virtual int create(int width, int height) = 0;
|
||||
virtual void resize(int width, int height) = 0;
|
||||
virtual int draw(UINT32 dc, int update) = 0;
|
||||
virtual void set_target_bounds() = 0;
|
||||
virtual int xy_to_render_target(int x, int y, int *xt, int *yt) = 0;
|
||||
virtual int create(const int width, const int height) = 0;
|
||||
virtual void resize(const int width, const int height) = 0;
|
||||
virtual int draw(const UINT32 dc, const int update) = 0;
|
||||
virtual int xy_to_render_target(const int x, const int y, int *xt, int *yt) = 0;
|
||||
virtual void destroy_all_textures() = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void clear() = 0;
|
||||
|
||||
private:
|
||||
sdl_window_info *m_window;
|
||||
int m_flags;
|
||||
};
|
||||
|
||||
#define OSDWORK_CALLBACK(name) void *name(void *param, ATTR_UNUSED int threadid)
|
||||
|
Loading…
Reference in New Issue
Block a user