summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author couriersud <couriersud@arcor.de>2015-02-05 01:06:37 +0100
committer couriersud <couriersud@arcor.de>2015-02-05 01:06:37 +0100
commitdabb6b1799c61931bce3f28b42df683a26cfb384 (patch)
tree05b83bffb9fee235e34bb24529f52d6e6ef89bdc /src/osd
parentccf953911fa293eb7b4b886894ae9c538c4f1c46 (diff)
Moved all window related code to window.c. (nw)
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/sdl/draw13.c96
-rw-r--r--src/osd/sdl/drawbgfx.c94
-rw-r--r--src/osd/sdl/drawogl.c112
-rw-r--r--src/osd/sdl/drawsdl.c148
-rw-r--r--src/osd/sdl/input.c22
-rw-r--r--src/osd/sdl/video.c6
-rw-r--r--src/osd/sdl/window.c157
-rw-r--r--src/osd/sdl/window.h70
8 files changed, 301 insertions, 404 deletions
diff --git a/src/osd/sdl/draw13.c b/src/osd/sdl/draw13.c
index 119b536ca36..0faaf3009bc 100644
--- a/src/osd/sdl/draw13.c
+++ b/src/osd/sdl/draw13.c
@@ -118,7 +118,7 @@ public:
private:
Uint32 m_sdl_access;
- SDL_Renderer * m_renderer;
+ SDL_Renderer * m_sdl_renderer;
render_texinfo m_texinfo; // copy of the texture info
HashT m_hash; // hash value for the texture (must be >= pointer size)
UINT32 m_flags; // rendering flags
@@ -143,7 +143,7 @@ class sdl_info13 : public osd_renderer
{
public:
sdl_info13(sdl_window_info *w)
- : osd_renderer(w, FLAG_NONE), m_blittimer(0), m_renderer(NULL),
+ : osd_renderer(w, FLAG_NONE), m_blittimer(0), m_sdl_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)
@@ -171,7 +171,7 @@ public:
SDL_Surface *m_sdlsurf;
#endif
- SDL_Renderer * m_renderer;
+ SDL_Renderer * m_sdl_renderer;
simple_list<texture_info> m_texlist; // list of active textures
float m_last_hofs;
@@ -389,7 +389,7 @@ void texture_info::render_quad(const render_primitive *prim, const int x, const
SDL_SetTextureBlendMode(m_texture_id, m_sdl_blendmode);
set_coloralphamode(m_texture_id, &prim->color);
- SDL_RenderCopy(m_renderer, m_texture_id, NULL, &target_rect);
+ SDL_RenderCopy(m_sdl_renderer, m_texture_id, NULL, &target_rect);
}
void sdl_info13::render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y)
@@ -423,9 +423,9 @@ void sdl_info13::render_quad(texture_info *texture, const render_primitive *prim
UINT32 sb = (UINT32)(255.0f * prim->color.b);
UINT32 sa = (UINT32)(255.0f * prim->color.a);
- SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
- SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa);
- SDL_RenderFillRect(m_renderer, &target_rect);
+ SDL_SetRenderDrawBlendMode(m_sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
+ SDL_SetRenderDrawColor(m_sdl_renderer, sr, sg, sb, sa);
+ SDL_RenderFillRect(m_sdl_renderer, &target_rect);
}
}
@@ -595,11 +595,11 @@ int sdl_info13::create(int width, int height)
}
if (video_config.waitvsync)
- m_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
+ m_sdl_renderer = SDL_CreateRenderer(window().sdl_window(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
else
- m_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_ACCELERATED);
+ m_sdl_renderer = SDL_CreateRenderer(window().sdl_window(), -1, SDL_RENDERER_ACCELERATED);
- if (!m_renderer)
+ if (!m_sdl_renderer)
{
fatalerror("Error on creating renderer: %s\n", SDL_GetError());
}
@@ -608,7 +608,7 @@ int sdl_info13::create(int width, int height)
m_blittimer = 3;
- SDL_RenderPresent(m_renderer);
+ SDL_RenderPresent(m_sdl_renderer);
osd_printf_verbose("Leave sdl_info13::create\n");
#else
@@ -623,15 +623,8 @@ int sdl_info13::create(int width, int height)
void sdl_info13::resize(int width, int height)
{
- m_resize_pending = 1;
- m_resize_height = height;
- m_resize_width = width;
-
- window().m_width = width;
- window().m_height = height;
-
+ SDL_RenderSetViewport(m_sdl_renderer, NULL);
m_blittimer = 3;
-
}
@@ -641,29 +634,7 @@ void sdl_info13::resize(int width, int height)
void sdl_info13::destroy()
{
-
- // free the memory in the window
-
destroy_all_textures();
-
-#if (SDLMAME_SDL2)
- if (check_flag(FLAG_NEEDS_OPENGL))
- 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, &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
}
//============================================================
@@ -685,9 +656,9 @@ int sdl_info13::xy_to_render_target(int x, int y, int *xt, int *yt)
*xt = x - m_last_hofs;
*yt = y - m_last_vofs;
- if (*xt<0 || *xt >= window().m_blitwidth)
+ if (*xt<0 || *xt >= window().blitwidth())
return 0;
- if (*yt<0 || *yt >= window().m_blitheight)
+ if (*yt<0 || *yt >= window().blitheight())
return 0;
return 1;
}
@@ -724,25 +695,26 @@ int sdl_info13::draw(UINT32 dc, int update)
return 0;
}
+#if 0
if (m_resize_pending)
{
SDL_SetWindowSize(window().m_sdl_window, m_resize_width, m_resize_height);
- SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
+ SDL_GetWindowSize(window().m_sdl_window, &window().width(), &window().height());
m_resize_pending = 0;
- SDL_RenderSetViewport(m_renderer, NULL);
+ SDL_RenderSetViewport(m_sdl_renderer, NULL);
//sdlvideo_monitor_refresh(window().monitor());
}
-
+#endif
//SDL_SelectRenderer(window().sdl_window);
if (m_blittimer > 0)
{
/* SDL Underlays need alpha = 0 ! */
- SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_NONE);
+ SDL_SetRenderDrawBlendMode(m_sdl_renderer, SDL_BLENDMODE_NONE);
//SDL_SetRenderDrawColor(0,0,0,255);
- SDL_SetRenderDrawColor(m_renderer, 0,0,0,0);
- SDL_RenderFillRect(m_renderer, NULL);
+ SDL_SetRenderDrawColor(m_sdl_renderer, 0,0,0,0);
+ SDL_RenderFillRect(m_sdl_renderer, NULL);
m_blittimer--;
}
@@ -760,17 +732,17 @@ int sdl_info13::draw(UINT32 dc, int update)
}
else
{
- ch = window().m_height;
- cw = window().m_width;
+ ch = window().height();
+ cw = window().width();
}
if (video_config.centerv)
{
- vofs = (ch - window().m_blitheight) / 2.0f;
+ vofs = (ch - window().blitheight()) / 2.0f;
}
if (video_config.centerh)
{
- hofs = (cw - window().m_blitwidth) / 2.0f;
+ hofs = (cw - window().blitwidth()) / 2.0f;
}
}
@@ -792,9 +764,9 @@ int sdl_info13::draw(UINT32 dc, int update)
sb = (int)(255.0f * prim->color.b);
sa = (int)(255.0f * prim->color.a);
- SDL_SetRenderDrawBlendMode(m_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
- SDL_SetRenderDrawColor(m_renderer, sr, sg, sb, sa);
- SDL_RenderDrawLine(m_renderer, prim->bounds.x0 + hofs, prim->bounds.y0 + vofs,
+ SDL_SetRenderDrawBlendMode(m_sdl_renderer, map_blendmode(PRIMFLAG_GET_BLENDMODE(prim->flags)));
+ SDL_SetRenderDrawColor(m_sdl_renderer, sr, sg, sb, sa);
+ SDL_RenderDrawLine(m_sdl_renderer, prim->bounds.x0 + hofs, prim->bounds.y0 + vofs,
prim->bounds.x1 + hofs, prim->bounds.y1 + vofs);
break;
case render_primitive::QUAD:
@@ -814,7 +786,7 @@ int sdl_info13::draw(UINT32 dc, int update)
m_last_blit_pixels = blit_pixels;
m_last_blit_time = -osd_ticks();
- SDL_RenderPresent(m_renderer);
+ SDL_RenderPresent(m_sdl_renderer);
m_last_blit_time += osd_ticks();
return 0;
@@ -840,7 +812,7 @@ copy_info_t *texture_info::compute_size_type()
if ((m_is_rotated == bi->blitter->m_is_rot)
&& (m_sdl_blendmode == bi->bm_mask))
{
- if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
+ if (RendererSupportsFormat(m_sdl_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
{
int perf = bi->perf;
if (perf == 0)
@@ -860,7 +832,7 @@ copy_info_t *texture_info::compute_size_type()
{
if ((m_is_rotated == bi->blitter->m_is_rot)
&& (m_sdl_blendmode == bi->bm_mask))
- if (RendererSupportsFormat(m_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
+ if (RendererSupportsFormat(m_sdl_renderer, bi->dst_fmt, m_sdl_access, bi->dstname))
return bi;
}
//FIXME: crash implement a -do nothing handler */
@@ -898,7 +870,7 @@ bool texture_info::matches(const render_primitive &prim, const quad_setup_data &
texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsource, const quad_setup_data &setup, UINT32 flags)
{
// fill in the core data
- m_renderer = renderer;
+ m_sdl_renderer = renderer;
m_hash = texture_compute_hash(texsource, flags);
m_flags = flags;
m_texinfo = texsource;
@@ -947,7 +919,7 @@ texture_info::texture_info(SDL_Renderer *renderer, const render_texinfo &texsour
m_copyinfo = compute_size_type();
- m_texture_id = SDL_CreateTexture(m_renderer, m_copyinfo->dst_fmt, m_sdl_access,
+ m_texture_id = SDL_CreateTexture(m_sdl_renderer, m_copyinfo->dst_fmt, m_sdl_access,
m_setup.rotwidth, m_setup.rotheight);
if (!m_texture_id)
@@ -1120,7 +1092,7 @@ texture_info * sdl_info13::texture_update(const render_primitive &prim)
// if we didn't find one, create a new texture
if (texture == NULL && prim.texture.base != NULL)
{
- texture = global_alloc(texture_info(m_renderer, prim.texture, setup, prim.flags));
+ texture = global_alloc(texture_info(m_sdl_renderer, prim.texture, setup, prim.flags));
/* add us to the texture list */
m_texlist.prepend(*texture);
diff --git a/src/osd/sdl/drawbgfx.c b/src/osd/sdl/drawbgfx.c
index 0adc8523082..a9804dc1b2a 100644
--- a/src/osd/sdl/drawbgfx.c
+++ b/src/osd/sdl/drawbgfx.c
@@ -76,7 +76,6 @@ public:
sdl_info_bgfx(sdl_window_info *w)
: 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)
{}
@@ -101,12 +100,6 @@ public:
float m_last_hofs;
float m_last_vofs;
- // resize information
-
- UINT8 m_resize_pending;
- UINT32 m_resize_width;
- UINT32 m_resize_height;
-
// Stats
INT64 m_last_blit_time;
INT64 m_last_blit_pixels;
@@ -144,76 +137,13 @@ int drawbgfx_init(running_machine &machine, sdl_draw_info *callbacks)
int sdl_info_bgfx::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 drawsdl2_window_create\n");
-
- UINT32 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, extra_flags);
-
- if (window().fullscreen() && video_config.switchres)
- {
- SDL_DisplayMode mode;
- //SDL_GetCurrentDisplayMode(window().monitor()->handle, &mode);
- SDL_GetWindowDisplayMode(window().m_sdl_window, &mode);
- m_original_mode = mode;
- mode.w = width;
- mode.h = height;
- if (window().m_refresh)
- mode.refresh_rate = window().m_refresh;
-
- SDL_SetWindowDisplayMode(window().m_sdl_window, &mode); // Try to set mode
-#ifndef SDLMAME_WIN32
- /* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
- * is in place after the mode switch - which will most likely be the case
- * This is a hack to work around a deficiency in SDL2
- */
- SDL_WarpMouseInWindow(window().m_sdl_window, 1, 1);
-#endif
- }
- else
- {
- //SDL_SetWindowDisplayMode(window().m_sdl_window, NULL); // Use desktop
- }
// create renderer
- if (video_config.waitvsync)
- m_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
- else
- m_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_ACCELERATED);
-
- if (!m_renderer)
- {
- fatalerror("Error on creating renderer: %s\n", SDL_GetError());
- }
-
- //SDL_SelectRenderer(window().m_sdl_window);
- SDL_ShowWindow(window().m_sdl_window);
- //SDL_SetWindowFullscreen(window().window_id, 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);
-
bgfx::sdlSetWindow(window().m_sdl_window);
bgfx::init();
- bgfx::reset(window().m_width, window().m_height, BGFX_RESET_VSYNC);
+ bgfx::reset(window().width(), window().height(), BGFX_RESET_VSYNC);
// Enable debug text.
bgfx::setDebug(BGFX_DEBUG_STATS);// BGFX_DEBUG_TEXT);
@@ -227,13 +157,6 @@ int sdl_info_bgfx::create(int width, int height)
void sdl_info_bgfx::resize(int width, int height)
{
- m_resize_pending = 1;
- m_resize_height = height;
- m_resize_width = width;
-
- window().m_width = width;
- window().m_height = height;
-
m_blittimer = 3;
}
@@ -245,9 +168,9 @@ int sdl_info_bgfx::xy_to_render_target(int x, int y, int *xt, int *yt)
{
*xt = x - m_last_hofs;
*yt = y - m_last_vofs;
- if (*xt<0 || *xt >= window().m_blitwidth)
+ if (*xt<0 || *xt >= window().blitwidth())
return 0;
- if (*yt<0 || *yt >= window().m_blitheight)
+ if (*yt<0 || *yt >= window().blitheight())
return 0;
return 1;
}
@@ -265,7 +188,7 @@ int sdl_info_bgfx::draw(UINT32 dc, int update)
, 0
);
// Set view 0 default viewport.
- bgfx::setViewRect(0, 0, 0, window().m_blitwidth, window().m_blitheight);
+ bgfx::setViewRect(0, 0, 0, window().blitwidth(), window().blitheight());
// This dummy draw call is here to make sure that view 0 is cleared
// if no other draw calls are submitted to view 0.
@@ -298,15 +221,6 @@ void sdl_info_bgfx::destroy()
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);
-
// Shutdown bgfx.
bgfx::shutdown();
}
diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c
index fc7ebe74bec..930adcbc377 100644
--- a/src/osd/sdl/drawogl.c
+++ b/src/osd/sdl/drawogl.c
@@ -58,7 +58,7 @@ typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum m_target);
typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum m_target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum m_target, GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum m_target, GLenum internalformat, GLsizei m_width, GLsizei m_height);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum m_target, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum m_target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
#endif
@@ -165,7 +165,7 @@ class texture_info
{
public:
texture_info()
- : hash(0), flags(0), rawwidth(0), rawheight(0),
+ : hash(0), flags(0), rawwidth(0), rawheight(0),
rawwidth_create(0), rawheight_create(0),
type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0),
texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL),
@@ -223,6 +223,7 @@ class sdl_info_ogl : public osd_renderer
public:
sdl_info_ogl(sdl_window_info *window)
: osd_renderer(window, FLAG_NEEDS_OPENGL), m_blittimer(0),
+ m_screen_width(0), m_screen_height(0),
#if (SDLMAME_SDL2)
m_gl_context_id(0),
#else
@@ -277,6 +278,8 @@ public:
void texture_all_disable();
INT32 m_blittimer;
+ int m_screen_width;
+ int m_screen_height;
#if (SDLMAME_SDL2)
SDL_GLContext m_gl_context_id;
@@ -712,7 +715,7 @@ int sdl_info_ogl::create(int width, int height)
#if (SDLMAME_SDL2)
// create renderer
- m_gl_context_id = SDL_GL_CreateContext(window().m_sdl_window);
+ m_gl_context_id = SDL_GL_CreateContext(window().sdl_window());
if (!m_gl_context_id)
{
osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
@@ -724,6 +727,9 @@ int sdl_info_ogl::create(int width, int height)
#else
#endif
+ m_screen_width = 0;
+ m_screen_height = 0;
+
m_blittimer = 0;
m_surf_w = 0;
m_surf_h = 0;
@@ -755,21 +761,9 @@ int sdl_info_ogl::create(int width, int height)
void sdl_info_ogl::resize(int width, int height)
{
#if (SDLMAME_SDL2)
- //SDL_GL_MakeCurrent(window().sdl_window, gl_context_id);
- SDL_SetWindowSize(window().m_sdl_window, width, height);
- SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
m_blittimer = 3;
-#else
- SDL_FreeSurface(window().m_sdlsurf);
-
- window().m_sdlsurf = SDL_SetVideoMode(width, height, 0,
- SDL_SWSURFACE | SDL_ANYFORMAT | window().m_extra_flags);
-
- window().m_width = window().m_sdlsurf->w;
- window().m_height = window().m_sdlsurf->h;
#endif
m_init_context = 1;
-
}
@@ -785,23 +779,9 @@ void sdl_info_ogl::destroy()
destroy_all_textures();
#if (SDLMAME_SDL2)
- if (check_flag(FLAG_NEEDS_OPENGL))
- 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, &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 (window().m_sdlsurf)
- {
- SDL_FreeSurface(window().m_sdlsurf);
- window().m_sdlsurf = NULL;
- }
+ SDL_GL_DeleteContext(m_gl_context_id);
#endif
+
}
//============================================================
@@ -823,9 +803,9 @@ int sdl_info_ogl::xy_to_render_target(int x, int y, int *xt, int *yt)
*xt = x - m_last_hofs;
*yt = y - m_last_vofs;
- if (*xt<0 || *xt >= window().m_blitwidth)
+ if (*xt<0 || *xt >= window().blitwidth())
return 0;
- if (*yt<0 || *yt >= window().m_blitheight)
+ if (*yt<0 || *yt >= window().blitheight())
return 0;
return 1;
}
@@ -844,7 +824,7 @@ void sdl_info_ogl::destroy_all_textures()
return;
#if (SDLMAME_SDL2)
- SDL_GL_MakeCurrent(window().m_sdl_window, m_gl_context_id);
+ SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id);
#endif
if(window().m_primlist)
@@ -1132,7 +1112,7 @@ void sdl_info_ogl::loadGLExtensions()
if ( m_useglsl )
{
- if ( window().m_prescale != 1 )
+ if ( window().prescale() != 1 )
{
m_useglsl = 0;
if (_once)
@@ -1242,7 +1222,7 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
}
#if (SDLMAME_SDL2)
- SDL_GL_MakeCurrent(window().m_sdl_window, m_gl_context_id);
+ SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id);
#else
if (!m_init_context)
{
@@ -1251,10 +1231,10 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
{
if (window().index() == 0)
{
- if ((screen->width() != window().m_screen_width) || (screen->height() != window().m_screen_height))
+ if ((screen->width() != m_screen_width) || (screen->height() != m_screen_height))
{
- window().m_screen_width = screen->width();
- window().m_screen_height = screen->height();
+ m_screen_width = screen->width();
+ m_screen_height = screen->height();
// force all textures to be regenerated
destroy_all_textures();
@@ -1305,15 +1285,15 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
}
if ( !m_initialized ||
- window().m_width!= m_surf_w || window().m_height!= m_surf_h )
+ window().width()!= m_surf_w || window().height()!= m_surf_h )
{
if ( !m_initialized )
{
loadGLExtensions();
}
- m_surf_w=window().m_width;
- m_surf_h=window().m_height;
+ m_surf_w=window().width();
+ m_surf_h=window().height();
// we're doing nothing 3d, so the Z-buffer is currently not interesting
glDisable(GL_DEPTH_TEST);
@@ -1354,10 +1334,10 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
// |_________|
// (0,h) (w,h)
- glViewport(0.0, 0.0, (GLsizei)window().m_width, (GLsizei)window().m_height);
+ glViewport(0.0, 0.0, (GLsizei)window().width(), (GLsizei)window().height());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0.0, (GLdouble)window().m_width, (GLdouble)window().m_height, 0.0, 0.0, -1.0);
+ glOrtho(0.0, (GLdouble)window().width(), (GLdouble)window().height(), 0.0, 0.0, -1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -1384,17 +1364,17 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
}
else
{
- ch = window().m_height;
- cw = window().m_width;
+ ch = window().height();
+ cw = window().width();
}
if (video_config.centerv)
{
- vofs = (ch - window().m_blitheight) / 2.0f;
+ vofs = (ch - window().blitheight()) / 2.0f;
}
if (video_config.centerh)
{
- hofs = (cw - window().m_blitwidth) / 2.0f;
+ hofs = (cw - window().blitwidth()) / 2.0f;
}
}
@@ -1470,7 +1450,7 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags));
// compute the effective width based on the direction of the line
- effwidth = prim->m_width;
+ effwidth = prim->width();
if (effwidth < 0.5f)
effwidth = 0.5f;
@@ -1575,12 +1555,12 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
// 1:1 tex coord CCW (0/0) (1/0) (1/1) (0/1) on texture dimensions
m_texVerticex[0]=(GLfloat)0.0;
m_texVerticex[1]=(GLfloat)0.0;
- m_texVerticex[2]=(GLfloat)window().m_width;
+ m_texVerticex[2]=(GLfloat)window().width();
m_texVerticex[3]=(GLfloat)0.0;
- m_texVerticex[4]=(GLfloat)window().m_width;
- m_texVerticex[5]=(GLfloat)window().m_height;
+ m_texVerticex[4]=(GLfloat)window().width();
+ m_texVerticex[5]=(GLfloat)window().height();
m_texVerticex[6]=(GLfloat)0.0;
- m_texVerticex[7]=(GLfloat)window().m_height;
+ m_texVerticex[7]=(GLfloat)window().height();
}
if(i>0) // first fetch already done
@@ -1626,7 +1606,7 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
#if (!SDLMAME_SDL2)
SDL_GL_SwapBuffers();
#else
- SDL_GL_SwapWindow(window().m_sdl_window);
+ SDL_GL_SwapWindow(window().sdl_window());
#endif
return 0;
}
@@ -1784,8 +1764,8 @@ void sdl_info_ogl::texture_compute_size_subroutine(texture_info *texture, UINT32
texture->xprescale--;
while (texture->yprescale > 1 && height_create * texture->yprescale > m_texture_max_height)
texture->yprescale--;
- if (PRIMFLAG_GET_SCREENTEX(flags) && (texture->xprescale != window().m_prescale || texture->yprescale != window().m_prescale))
- osd_printf_warning("SDL: adjusting prescale from %dx%d to %dx%d\n", window().m_prescale, window().m_prescale, texture->xprescale, texture->yprescale);
+ if (PRIMFLAG_GET_SCREENTEX(flags) && (texture->xprescale != window().prescale() || texture->yprescale != window().prescale()))
+ osd_printf_warning("SDL: adjusting prescale from %dx%d to %dx%d\n", window().prescale(), window().prescale(), texture->xprescale, texture->yprescale);
width *= texture->xprescale;
height *= texture->yprescale;
@@ -1964,8 +1944,8 @@ int sdl_info_ogl::texture_shader_create(const render_texinfo *texsource, texture
{
int uniform_location;
int i;
- int surf_w_pow2 = get_valid_pow2_value (window().m_blitwidth, texture->texpow2);
- int surf_h_pow2 = get_valid_pow2_value (window().m_blitheight, texture->texpow2);
+ int surf_w_pow2 = get_valid_pow2_value (window().blitwidth(), texture->texpow2);
+ int surf_h_pow2 = get_valid_pow2_value (window().blitheight(), texture->texpow2);
assert ( texture->type==TEXTURE_TYPE_SHADER );
@@ -2012,7 +1992,7 @@ int sdl_info_ogl::texture_shader_create(const render_texinfo *texsource, texture
pfn_glUniform2fvARB(uniform_location, 1, &(color_texture_pow2_sz[0]));
GL_CHECK_ERROR_NORMAL();
- GLfloat screen_texture_sz[2] = { (GLfloat)window().m_blitwidth, (GLfloat)window().m_blitheight };
+ GLfloat screen_texture_sz[2] = { (GLfloat)window().blitwidth(), (GLfloat)window().blitheight() };
uniform_location = pfn_glGetUniformLocationARB(m_glsl_program[i], "screen_texture_sz");
pfn_glUniform2fvARB(uniform_location, 1, &(screen_texture_sz[0]));
GL_CHECK_ERROR_NORMAL();
@@ -2068,7 +2048,7 @@ int sdl_info_ogl::texture_shader_create(const render_texinfo *texsource, texture
}
osd_printf_verbose("GL texture: mpass screen-bmp 2x %dx%d (pow2 %dx%d)\n",
- window().m_width, window().m_height, surf_w_pow2, surf_h_pow2);
+ window().width(), window().height(), surf_w_pow2, surf_h_pow2);
}
// GL_TEXTURE0
@@ -2147,8 +2127,8 @@ texture_info *sdl_info_ogl::texture_create(const render_texinfo *texsource, UINT
texture->texinfo.seqid = -1; // force set data
if (PRIMFLAG_GET_SCREENTEX(flags))
{
- texture->xprescale = window().m_prescale;
- texture->yprescale = window().m_prescale;
+ texture->xprescale = window().prescale();
+ texture->yprescale = window().prescale();
}
else
{
@@ -2778,11 +2758,11 @@ void sdl_info_ogl::texture_coord_update(texture_info *texture, const render_prim
}
else if ( texture->type == TEXTURE_TYPE_SHADER && shaderIdx>m_glsl_program_mb2sc )
{
- int surf_w_pow2 = get_valid_pow2_value (window().m_width, texture->texpow2);
- int surf_h_pow2 = get_valid_pow2_value (window().m_height, texture->texpow2);
+ int surf_w_pow2 = get_valid_pow2_value (window().width(), texture->texpow2);
+ int surf_h_pow2 = get_valid_pow2_value (window().height(), texture->texpow2);
- ustop = (float)(window().m_width) / (float)surf_w_pow2;
- vstop = (float)(window().m_height) / (float)surf_h_pow2;
+ ustop = (float)(window().width()) / (float)surf_w_pow2;
+ vstop = (float)(window().height()) / (float)surf_h_pow2;
}
else
{
diff --git a/src/osd/sdl/drawsdl.c b/src/osd/sdl/drawsdl.c
index 47fe6669761..840f5fa62d6 100644
--- a/src/osd/sdl/drawsdl.c
+++ b/src/osd/sdl/drawsdl.c
@@ -52,8 +52,6 @@ public:
sdl_info(sdl_window_info *w, int extra_flags)
: osd_renderer(w, extra_flags),
- m_blittimer(0),
-
#if (SDLMAME_SDL2)
m_sdl_renderer(NULL),
m_texture_id(NULL),
@@ -216,12 +214,11 @@ int drawsdl_scale_mode(const char *s)
static osd_renderer *drawsdl_create(sdl_window_info *window)
{
- const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
-
// FIXME: QUALITY HINTS
#if (SDLMAME_SDL2)
return global_alloc(sdl_info(window, osd_renderer::FLAG_NONE));
#else
+ const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
return global_alloc(sdl_info(window, sm->m_extra_flags));
#endif
}
@@ -279,7 +276,7 @@ void sdl_info::setup_texture(int tempwidth, int tempheight)
int m_hw_scale_width =0;
int m_hw_scale_height = 0;
- window().m_target->compute_minimum_size(m_hw_scale_width, m_hw_scale_height);
+ window().target()->compute_minimum_size(m_hw_scale_width, m_hw_scale_height);
if (video_config.prescale)
{
m_hw_scale_width *= video_config.prescale;
@@ -315,7 +312,7 @@ void sdl_info::yuv_overlay_init()
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
int minimum_width, minimum_height;
- window().m_target->compute_minimum_size(minimum_width, minimum_height);
+ window().target()->compute_minimum_size(minimum_width, minimum_height);
if (video_config.prescale)
{
@@ -339,7 +336,7 @@ void sdl_info::yuv_overlay_init()
m_yuv_bitmap = global_alloc_array(UINT16, minimum_width*minimum_height);
m_yuvsurf = SDL_CreateYUVOverlay(minimum_width * sdl_sm->mult_w, minimum_height * sdl_sm->mult_h,
- sdl_sm->pixel_format, window().m_sdlsurf);
+ sdl_sm->pixel_format, window().sdl_surface());
if ( m_yuvsurf == NULL ) {
osd_printf_error("SDL: Couldn't create SDL_yuv_overlay: %s\n", SDL_GetError());
@@ -421,9 +418,9 @@ static void drawsdl_show_info(struct SDL_RendererInfo *render_info)
int sdl_info::create(int width, int height)
{
- const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
#if (SDLMAME_SDL2)
+ const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
// create renderer
@@ -432,9 +429,9 @@ int sdl_info::create(int width, int height)
if (video_config.waitvsync)
- m_sdl_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
+ m_sdl_renderer = SDL_CreateRenderer(window().sdl_window(), -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
else
- m_sdl_renderer = SDL_CreateRenderer(window().m_sdl_window, -1, SDL_RENDERER_ACCELERATED);
+ m_sdl_renderer = SDL_CreateRenderer(window().sdl_window(), -1, SDL_RENDERER_ACCELERATED);
if (!m_sdl_renderer)
{
@@ -483,32 +480,14 @@ int sdl_info::create(int width, int height)
void sdl_info::resize(int width, int height)
{
-#if (!SDLMAME_SDL2)
- const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
-#endif
#if (SDLMAME_SDL2)
- SDL_SetWindowSize(window().m_sdl_window, width, height);
- SDL_GetWindowSize(window().m_sdl_window, &window().m_width, &window().m_height);
-
+ SDL_RenderSetViewport(m_sdl_renderer, NULL);
#else
- if (m_yuvsurf != NULL)
- {
- SDL_FreeYUVOverlay(m_yuvsurf);
- m_yuvsurf = NULL;
- }
- SDL_FreeSurface(window().m_sdlsurf);
-
- window().m_sdlsurf = SDL_SetVideoMode(width, height, 0,
- SDL_SWSURFACE | SDL_ANYFORMAT | window().m_extra_flags);
-
- window().m_width = window().m_sdlsurf->w;
- window().m_height = window().m_sdlsurf->h;
-
- if (sdl_sm->is_yuv)
+ const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
+ if (sdl_sm->is_yuv)
{
yuv_overlay_init();
}
-
#endif
}
@@ -520,33 +499,10 @@ void sdl_info::resize(int width, int height)
void sdl_info::destroy()
{
-#if (SDLMAME_SDL2)
- //SDL_SelectRenderer(window().sdl_window);
- SDL_DestroyTexture(m_texture_id);
- //SDL_DestroyRenderer(window().sdl_window);
- if (window().fullscreen() && video_config.switchres)
- {
- SDL_SetWindowFullscreen(window().m_sdl_window, 0); // Try to set mode
- SDL_SetWindowDisplayMode(window().m_sdl_window, &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_yuvsurf != NULL)
- {
- SDL_FreeYUVOverlay(m_yuvsurf);
- m_yuvsurf = NULL;
- }
-
- if (window().m_sdlsurf)
- {
- SDL_FreeSurface(window().m_sdlsurf);
- window().m_sdlsurf = NULL;
- }
-#endif
// free the memory in the window
+ destroy_all_textures();
+
if (m_yuv_lookup != NULL)
{
global_free_array(m_yuv_lookup);
@@ -577,9 +533,9 @@ int sdl_info::xy_to_render_target(int x, int y, int *xt, int *yt)
{
*xt = x - m_last_hofs;
*yt = y - m_last_vofs;
- if (*xt<0 || *xt >= window().m_blitwidth)
+ if (*xt<0 || *xt >= window().blitwidth())
return 0;
- if (*yt<0 || *yt >= window().m_blitheight)
+ if (*yt<0 || *yt >= window().blitheight())
return 0;
return 1;
}
@@ -590,7 +546,16 @@ int sdl_info::xy_to_render_target(int x, int y, int *xt, int *yt)
void sdl_info::destroy_all_textures()
{
- /* nothing to be done in soft mode */
+#if (SDLMAME_SDL2)
+ SDL_DestroyTexture(m_texture_id);
+ m_texture_id = NULL;
+#else
+ if (m_yuvsurf != NULL)
+ {
+ SDL_FreeYUVOverlay(m_yuvsurf);
+ m_yuvsurf = NULL;
+ }
+#endif
}
@@ -618,29 +583,29 @@ int sdl_info::draw(UINT32 dc, int update)
// lock it if we need it
#if (!SDLMAME_SDL2)
- pitch = window().m_sdlsurf->pitch;
- bpp = window().m_sdlsurf->format->BytesPerPixel;
- rmask = window().m_sdlsurf->format->Rmask;
- gmask = window().m_sdlsurf->format->Gmask;
- bmask = window().m_sdlsurf->format->Bmask;
+ pitch = window().sdl_surface()->pitch;
+ bpp = window().sdl_surface()->format->BytesPerPixel;
+ rmask = window().sdl_surface()->format->Rmask;
+ gmask = window().sdl_surface()->format->Gmask;
+ bmask = window().sdl_surface()->format->Bmask;
// amask = sdlsurf->format->Amask;
- if (window().m_blitwidth != m_old_blitwidth || window().m_blitheight != m_old_blitheight)
+ if (window().blitwidth() != m_old_blitwidth || window().blitheight() != m_old_blitheight)
{
if (sm->is_yuv)
yuv_overlay_init();
- m_old_blitwidth = window().m_blitwidth;
- m_old_blitheight = window().m_blitheight;
+ m_old_blitwidth = window().blitwidth();
+ m_old_blitheight = window().blitheight();
m_blittimer = 3;
}
- if (SDL_MUSTLOCK(window().m_sdlsurf))
- SDL_LockSurface(window().m_sdlsurf);
+ if (SDL_MUSTLOCK(window().sdl_surface()))
+ SDL_LockSurface(window().sdl_surface());
// Clear if necessary
if (m_blittimer > 0)
{
- memset(window().m_sdlsurf->pixels, 0, window().m_height * window().m_sdlsurf->pitch);
+ memset(window().sdl_surface()->pixels, 0, window().height() * window().sdl_surface()->pitch);
m_blittimer--;
}
@@ -658,18 +623,19 @@ int sdl_info::draw(UINT32 dc, int update)
#endif
}
else
- surfptr = (UINT8 *)window().m_sdlsurf->pixels;
+ surfptr = (UINT8 *)window().sdl_surface()->pixels;
#else
//SDL_SelectRenderer(window().sdl_window);
- if (window().m_blitwidth != m_old_blitwidth || window().m_blitheight != m_old_blitheight)
+ if (window().blitwidth() != m_old_blitwidth || window().blitheight() != m_old_blitheight)
{
- SDL_RenderSetViewport(m_sdl_renderer, NULL);
+ //SDL_RenderSetViewport(m_sdl_renderer, NULL);
- SDL_DestroyTexture(m_texture_id);
- setup_texture(window().m_blitwidth, window().m_blitheight);
- m_old_blitwidth = window().m_blitwidth;
- m_old_blitheight = window().m_blitheight;
+ if (m_texture_id != NULL)
+ SDL_DestroyTexture(m_texture_id);
+ setup_texture(window().blitwidth(), window().blitheight());
+ m_old_blitwidth = window().blitwidth();
+ m_old_blitheight = window().blitheight();
m_blittimer = 3;
}
@@ -697,8 +663,8 @@ int sdl_info::draw(UINT32 dc, int update)
#endif
// get ready to center the image
vofs = hofs = 0;
- blitwidth = window().m_blitwidth;
- blitheight = window().m_blitheight;
+ blitwidth = window().blitwidth();
+ blitheight = window().blitheight();
// figure out what coordinate system to use for centering - in window mode it's always the
// SDL surface size. in fullscreen the surface covers all monitors, so center according to
@@ -710,8 +676,8 @@ int sdl_info::draw(UINT32 dc, int update)
}
else
{
- ch = window().m_height;
- cw = window().m_width;
+ ch = window().height();
+ cw = window().width();
}
// do not crash if the window's smaller than the blit area
@@ -721,7 +687,7 @@ int sdl_info::draw(UINT32 dc, int update)
}
else if (video_config.centerv)
{
- vofs = (ch - window().m_blitheight) / 2;
+ vofs = (ch - window().blitheight()) / 2;
}
if (blitwidth > cw)
@@ -730,7 +696,7 @@ int sdl_info::draw(UINT32 dc, int update)
}
else if (video_config.centerh)
{
- hofs = (cw - window().m_blitwidth) / 2;
+ hofs = (cw - window().blitwidth()) / 2;
}
m_last_hofs = hofs;
@@ -744,8 +710,8 @@ int sdl_info::draw(UINT32 dc, int update)
if (!sm->is_yuv)
{
surfptr += ((vofs * pitch) + (hofs * bpp));
- mamewidth = blitwidth; //m_sdlsurf->w;
- mameheight = blitheight; //m_sdlsurf->h;
+ mamewidth = blitwidth; //sdl_surface()->w;
+ mameheight = blitheight; //sdl_surface()->h;
}
else
{
@@ -770,10 +736,10 @@ int sdl_info::draw(UINT32 dc, int update)
for (render_primitive *prim = window().m_primlist->first(); prim != NULL; prim = prim->next())
{
- prim->bounds.x0 *= fw;
- prim->bounds.x1 *= fw;
- prim->bounds.y0 *= fh;
- prim->bounds.y1 *= fh;
+ prim->bounds.x0 = floor(fw * prim->bounds.x0 + 0.5f);
+ prim->bounds.x1 = floor(fw * prim->bounds.x1 + 0.5f);
+ prim->bounds.y0 = floor(fh * prim->bounds.y0 + 0.5f);
+ prim->bounds.y1 = floor(fh * prim->bounds.y1 + 0.5f);
}
// render to it
@@ -818,10 +784,10 @@ int sdl_info::draw(UINT32 dc, int update)
// unlock and flip
#if (!SDLMAME_SDL2)
- if (SDL_MUSTLOCK(window().m_sdlsurf)) SDL_UnlockSurface(window().m_sdlsurf);
+ if (SDL_MUSTLOCK(window().sdl_surface())) SDL_UnlockSurface(window().sdl_surface());
if (!sm->is_yuv)
{
- SDL_Flip(window().m_sdlsurf);
+ SDL_Flip(window().sdl_surface());
}
else
{
diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c
index 48a30c5d874..d04b3fd14af 100644
--- a/src/osd/sdl/input.c
+++ b/src/osd/sdl/input.c
@@ -1547,7 +1547,7 @@ INLINE sdl_window_info * window_from_id(Uint32 windowID)
for (w = sdl_window_list; w != NULL; w = w->m_next)
{
//printf("w->window_id: %d\n", w->window_id);
- if (w->m_sdl_window == window)
+ if (w->sdl_window() == window)
{
return w;
}
@@ -1760,9 +1760,9 @@ void sdlinput_poll(running_machine &machine)
devinfo->keyboard.state[OSD_SDL_INDEX_KEYSYM(&event.key.keysym)] = 0x80;
#if (SDLMAME_SDL2)
if (event.key.keysym.sym < 0x20)
- ui_input_push_char_event(machine, sdl_window_list->m_target, event.key.keysym.sym);
+ ui_input_push_char_event(machine, sdl_window_list->target(), event.key.keysym.sym);
#else
- ui_input_push_char_event(machine, sdl_window_list->m_target, (unicode_char) event.key.keysym.unicode);
+ ui_input_push_char_event(machine, sdl_window_list->target(), (unicode_char) event.key.keysym.unicode);
#endif
break;
case SDL_KEYUP:
@@ -1864,14 +1864,14 @@ void sdlinput_poll(running_machine &machine)
sdl_window_info *window = GET_FOCUS_WINDOW(&event.button);
if (window != NULL && window->xy_to_render_target(event.button.x,event.button.y, &cx, &cy) )
{
- ui_input_push_mouse_down_event(machine, window->m_target, cx, cy);
+ ui_input_push_mouse_down_event(machine, window->target(), cx, cy);
// FIXME Parameter ?
if ((click-last_click < 250)
&& (cx >= last_x - 4 && cx <= last_x + 4)
&& (cy >= last_y - 4 && cy <= last_y + 4) )
{
last_click = 0;
- ui_input_push_mouse_double_click_event(machine, window->m_target, cx, cy);
+ ui_input_push_mouse_double_click_event(machine, window->target(), cx, cy);
}
else
{
@@ -1898,7 +1898,7 @@ void sdlinput_poll(running_machine &machine)
if (window != NULL && window->xy_to_render_target(event.button.x,event.button.y, &cx, &cy) )
{
- ui_input_push_mouse_up_event(machine, window->m_target, cx, cy);
+ ui_input_push_mouse_up_event(machine, window->target(), cx, cy);
}
}
break;
@@ -1922,7 +1922,7 @@ void sdlinput_poll(running_machine &machine)
sdl_window_info *window = GET_FOCUS_WINDOW(&event.motion);
if (window != NULL && window->xy_to_render_target(event.motion.x, event.motion.y, &cx, &cy) )
- ui_input_push_mouse_move_event(machine, window->m_target, cx, cy);
+ ui_input_push_mouse_move_event(machine, window->target(), cx, cy);
}
break;
case SDL_JOYBALLMOTION:
@@ -1937,7 +1937,7 @@ void sdlinput_poll(running_machine &machine)
if (!event.active.gain)
{
sdl_window_info *window = GET_FOCUS_WINDOW(&event.motion);
- ui_input_push_mouse_leave_event(machine, window->m_target);
+ ui_input_push_mouse_leave_event(machine, window->target());
}
break;
case SDL_QUIT:
@@ -1956,7 +1956,7 @@ void sdlinput_poll(running_machine &machine)
if (window != NULL )
{
osd_uchar_from_osdchar(&result, event.text.text, 1);
- ui_input_push_char_event(machine, window->m_target, result);
+ ui_input_push_char_event(machine, window->target(), result);
}
}
break;
@@ -1973,7 +1973,7 @@ void sdlinput_poll(running_machine &machine)
machine.schedule_exit();
break;
case SDL_WINDOWEVENT_LEAVE:
- ui_input_push_mouse_leave_event(machine, window->m_target);
+ ui_input_push_mouse_leave_event(machine, window->target());
app_has_mouse_focus = 0;
break;
case SDL_WINDOWEVENT_MOVED:
@@ -1997,7 +1997,7 @@ void sdlinput_poll(running_machine &machine)
#endif
{
//printf("event data1,data2 %d x %d %ld\n", event.window.data1, event.window.data2, sizeof(SDL_Event));
- if (event.window.data1 != window->m_width || event.window.data2 != window->m_height)
+ if (event.window.data1 != window->width() || event.window.data2 != window->height())
window->window_resize(event.window.data1, event.window.data2);
}
}
diff --git a/src/osd/sdl/video.c b/src/osd/sdl/video.c
index 9b45ee2aae4..a7374845dc0 100644
--- a/src/osd/sdl/video.c
+++ b/src/osd/sdl/video.c
@@ -113,7 +113,11 @@ bool sdl_osd_interface::video_init()
sdl_window_config conf;
memset(&conf, 0, sizeof(conf));
get_resolution(options().resolution(), options().resolution(index), &conf, TRUE);
- if (sdlwindow_video_window_create(machine(), index, sdl_monitor_info::pick_monitor(options(), index), &conf))
+
+ // create window ...
+ sdl_window_info *win = global_alloc(sdl_window_info(machine(), index, sdl_monitor_info::pick_monitor(options(), index), &conf));
+
+ if (win->window_init())
return false;
}
diff --git a/src/osd/sdl/window.c b/src/osd/sdl/window.c
index 51670cdc311..463eb0d5ae6 100644
--- a/src/osd/sdl/window.c
+++ b/src/osd/sdl/window.c
@@ -142,8 +142,6 @@ private:
static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window);
static void sdlwindow_sync(void);
-static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view);
-
//============================================================
// execute_async
//============================================================
@@ -480,13 +478,30 @@ OSDWORK_CALLBACK( sdl_window_info::sdlwindow_resize_wt )
{
worker_param * wp = (worker_param *) param;
sdl_window_info * window = wp->window();
+ int width = wp->new_width();
+ int height = wp->new_height();
ASSERT_WINDOW_THREAD();
window->renderer().destroy_all_textures();
- window->renderer().resize(wp->new_width(), wp->new_height());
- window->blit_surface_size(wp->new_width(), wp->new_height());
+#if (SDLMAME_SDL2)
+ SDL_SetWindowSize(window->sdl_window(), width, height);
+ SDL_GetWindowSize(window->sdl_window(), &window->m_width, &window->m_height);
+#else
+ SDL_FreeSurface(window->m_sdlsurf);
+
+ window->m_sdlsurf = SDL_SetVideoMode(width, height, 0,
+ SDL_SWSURFACE | SDL_ANYFORMAT | window->m_extra_flags);
+
+ window->m_width = window->m_sdlsurf->w;
+ window->m_height = window->m_sdlsurf->h;
+#endif
+
+
+ window->renderer().resize(window->m_width, window->m_height);
+
+ window->blit_surface_size(window->m_width, window->m_height);
window->window_clear();
@@ -498,7 +513,7 @@ void sdl_window_info::window_resize(INT32 width, INT32 height)
{
ASSERT_MAIN_THREAD();
- if (width == this->m_width && height == this->m_height)
+ if (width == this->width() && height == this->height())
return;
execute_async_wait(&sdlwindow_resize_wt, worker_param(this, width, height));
@@ -554,11 +569,29 @@ OSDWORK_CALLBACK( sdl_window_info::sdlwindow_toggle_full_screen_wt )
// If we are going fullscreen (leaving windowed) remember our windowed size
if (!window->fullscreen())
{
- window->m_windowed_width = window->m_width;
- window->m_windowed_height = window->m_height;
+ window->m_windowed_width = window->width();
+ window->m_windowed_height = window->height();
}
window->renderer().destroy();
+
+#if (SDLMAME_SDL2)
+ if (window->fullscreen() && video_config.switchres)
+ {
+ SDL_SetWindowFullscreen(window->sdl_window(), 0); // Try to set mode
+ SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode); // Try to set mode
+ SDL_SetWindowFullscreen(window->sdl_window(), SDL_WINDOW_FULLSCREEN); // Try to set mode
+ }
+ SDL_DestroyWindow(window->sdl_window());
+#else
+ if (window->m_sdlsurf)
+ {
+ SDL_FreeSurface(window->m_sdlsurf);
+ window->m_sdlsurf = NULL;
+ }
+#endif
+
+
sdlinput_release_keys(wp->machine());
// toggle the window mode
@@ -591,14 +624,14 @@ OSDWORK_CALLBACK( sdl_window_info::destroy_all_textures_wt )
void sdl_window_info::modify_prescale(running_machine &machine, int dir)
{
worker_param wp = worker_param(machine, this);
- int new_prescale = m_prescale;
+ int new_prescale = prescale();
- if (dir > 0 && m_prescale < 3)
- new_prescale = m_prescale + 1;
- if (dir < 0 && m_prescale > 1)
- new_prescale = m_prescale - 1;
+ if (dir > 0 && prescale() < 3)
+ new_prescale = prescale() + 1;
+ if (dir < 0 && prescale() > 1)
+ new_prescale = prescale() - 1;
- if (new_prescale != m_prescale)
+ if (new_prescale != prescale())
{
if (m_fullscreen && video_config.switchres)
{
@@ -614,7 +647,7 @@ void sdl_window_info::modify_prescale(running_machine &machine, int dir)
execute_async_wait(destroy_all_textures_wt, wp);
m_prescale = new_prescale;
}
- machine.ui().popup_time(1, "Prescale %d", m_prescale);
+ machine.ui().popup_time(1, "Prescale %d", prescale());
}
}
@@ -645,15 +678,15 @@ static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_i
if (!window->fullscreen() && !sdlinput_should_hide_mouse(machine))
{
SDL_ShowCursor(SDL_ENABLE);
- if (SDL_GetWindowGrab(window->m_sdl_window ))
- SDL_SetWindowGrab(window->m_sdl_window, SDL_FALSE);
+ if (SDL_GetWindowGrab(window->sdl_window() ))
+ SDL_SetWindowGrab(window->sdl_window(), SDL_FALSE);
SDL_SetRelativeMouseMode(SDL_FALSE);
}
else
{
SDL_ShowCursor(SDL_DISABLE);
- if (!SDL_GetWindowGrab(window->m_sdl_window))
- SDL_SetWindowGrab(window->m_sdl_window, SDL_TRUE);
+ if (!SDL_GetWindowGrab(window->sdl_window()))
+ SDL_SetWindowGrab(window->sdl_window(), SDL_TRUE);
SDL_SetRelativeMouseMode(SDL_TRUE);
}
SDL_SetCursor(NULL); // Force an update in case the underlying driver has changed visibility
@@ -706,44 +739,40 @@ int sdl_window_info::xy_to_render_target(int x, int y, int *xt, int *yt)
// (main thread)
//============================================================
-int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config)
+int sdl_window_info::window_init()
{
- sdl_window_info *window;
worker_param *wp = (worker_param *) osd_malloc(sizeof(worker_param));
int result;
ASSERT_MAIN_THREAD();
- // allocate a new window object
- window = global_alloc(sdl_window_info(&machine, monitor, index, config));
-
// set the initial maximized state
// FIXME: Does not belong here
- sdl_options &options = downcast<sdl_options &>(machine.options());
- window->m_startmaximized = options.maximize();
+ sdl_options &options = downcast<sdl_options &>(m_machine.options());
+ m_startmaximized = options.maximize();
// add us to the list
- *last_window_ptr = window;
- last_window_ptr = &window->m_next;
+ *last_window_ptr = this;
+ last_window_ptr = &this->m_next;
- window->set_renderer(draw.create(window));
+ set_renderer(draw.create(this));
// create an event that we can use to skip blitting
- window->m_rendered_event = osd_event_alloc(FALSE, TRUE);
+ m_rendered_event = osd_event_alloc(FALSE, TRUE);
// load the layout
- window->m_target = machine.render().target_alloc();
+ m_target = m_machine.render().target_alloc();
// set the specific view
- set_starting_view(machine, index, window, options.view(), options.view(index));
+ set_starting_view(m_machine, m_index, options.view(), options.view(m_index));
// make the window title
if (video_config.numscreens == 1)
- sprintf(window->m_title, "%s: %s [%s]", emulator_info::get_appname(), machine.system().description, machine.system().name);
+ sprintf(m_title, "%s: %s [%s]", emulator_info::get_appname(), m_machine.system().description, m_machine.system().name);
else
- sprintf(window->m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index);
+ sprintf(m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), m_machine.system().description, m_machine.system().name, m_index);
- wp->set_window(window);
+ wp->set_window(this);
// FIXME: pass error back in a different way
if (multithreading_enabled)
@@ -765,9 +794,8 @@ int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monit
return 0;
error:
- window->video_window_destroy(machine);
+ video_window_destroy(m_machine);
// free the window itself
- global_free(window);
return 1;
}
@@ -787,6 +815,22 @@ OSDWORK_CALLBACK( sdl_window_info::sdlwindow_video_window_destroy_wt )
// free the textures etc
window->renderer().destroy();
+#if (SDLMAME_SDL2)
+ if (window->fullscreen() && video_config.switchres)
+ {
+ SDL_SetWindowFullscreen(window->sdl_window(), 0); // Try to set mode
+ SDL_SetWindowDisplayMode(window->sdl_window(), &window->m_original_mode); // Try to set mode
+ SDL_SetWindowFullscreen(window->sdl_window(), SDL_WINDOW_FULLSCREEN); // Try to set mode
+ }
+ SDL_DestroyWindow(window->sdl_window());
+#else
+ if (window->m_sdlsurf)
+ {
+ SDL_FreeSurface(window->m_sdlsurf);
+ window->m_sdlsurf = NULL;
+ }
+#endif
+
// release all keys ...
sdlinput_release_keys(wp->machine());
@@ -843,8 +887,8 @@ void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight)
m_target->compute_minimum_size(minimum_width, minimum_height);
// use those as the target for now
- target_width = minimum_width * MAX(1, m_prescale);
- target_height = minimum_height * MAX(1, m_prescale);
+ target_width = minimum_width * MAX(1, prescale());
+ target_height = minimum_height * MAX(1, prescale());
// if we're not stretching, allow some slop on the minimum since we can handle it
{
@@ -910,8 +954,8 @@ void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight)
m_target->compute_minimum_size(minimum_width, minimum_height);
// use those as the target for now
- target_width = minimum_width * MAX(1, m_prescale);
- target_height = minimum_height * MAX(1, m_prescale);
+ target_width = minimum_width * MAX(1, prescale());
+ target_height = minimum_height * MAX(1, prescale());
// if we're not stretching, allow some slop on the minimum since we can handle it
{
@@ -1003,7 +1047,7 @@ void sdl_window_info::video_window_update(running_machine &machine)
if (!this->m_fullscreen)
{
- blit_surface_size(m_width, m_height);
+ blit_surface_size(width(), height());
//Don't resize window without user interaction;
//window_resize(blitwidth, blitheight);
}
@@ -1049,7 +1093,7 @@ void sdl_window_info::video_window_update(running_machine &machine)
// (main thread)
//============================================================
-static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view)
+void sdl_window_info::set_starting_view(running_machine &machine, int index, const char *defview, const char *view)
{
int viewindex;
@@ -1060,11 +1104,11 @@ static void set_starting_view(running_machine &machine, int index, sdl_window_in
view = defview;
// query the video system to help us pick a view
- viewindex = window->m_target->configured_view(view, index, video_config.numscreens);
+ viewindex = target()->configured_view(view, index, video_config.numscreens);
// set the view
- window->m_target->set_view(viewindex);
- window->m_start_viewscreen=viewindex;
+ target()->set_view(viewindex);
+ m_start_viewscreen=viewindex;
}
@@ -1160,7 +1204,7 @@ OSDWORK_CALLBACK( sdl_window_info::complete_create_wt )
window->m_sdl_window = SDL_CreateWindow(window->m_title,
window->monitor()->position_size().x, window->monitor()->position_size().y,
tempwidth, tempheight, window->m_extra_flags);
- //window().m_sdl_window = SDL_CreateWindow(window().m_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
+ //window().sdl_window() = SDL_CreateWindow(window().m_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
// width, height, m_extra_flags);
if ( window->m_sdl_window == NULL )
@@ -1176,34 +1220,34 @@ OSDWORK_CALLBACK( sdl_window_info::complete_create_wt )
{
SDL_DisplayMode mode;
//SDL_GetCurrentDisplayMode(window().monitor()->handle, &mode);
- SDL_GetWindowDisplayMode(window->m_sdl_window, &mode);
+ SDL_GetWindowDisplayMode(window->sdl_window(), &mode);
window->m_original_mode = mode;
mode.w = tempwidth;
mode.h = tempheight;
if (window->m_refresh)
mode.refresh_rate = window->m_refresh;
- SDL_SetWindowDisplayMode(window->m_sdl_window, &mode); // Try to set mode
+ SDL_SetWindowDisplayMode(window->sdl_window(), &mode); // Try to set mode
#ifndef SDLMAME_WIN32
/* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution
* is in place after the mode switch - which will most likely be the case
* This is a hack to work around a deficiency in SDL2
*/
- SDL_WarpMouseInWindow(window->m_sdl_window, 1, 1);
+ SDL_WarpMouseInWindow(window->sdl_window(), 1, 1);
#endif
}
else
{
- //SDL_SetWindowDisplayMode(window().m_sdl_window, NULL); // Use desktop
+ //SDL_SetWindowDisplayMode(window().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_ShowWindow(window->sdl_window());
+ //SDL_SetWindowFullscreen(window().sdl_window(), window().fullscreen);
+ SDL_RaiseWindow(window->sdl_window());
- SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
+ SDL_GetWindowSize(window->sdl_window(), &window->m_width, &window->m_height);
#else
window->m_extra_flags = (window->fullscreen() ? SDL_FULLSCREEN : SDL_RESIZABLE);
@@ -1238,15 +1282,12 @@ OSDWORK_CALLBACK( sdl_window_info::complete_create_wt )
window->m_width = window->m_sdlsurf->w;
window->m_height = window->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
// initialize the drawing backend
- if (window->renderer().create(window->m_width, window->m_height))
+ if (window->renderer().create(window->width(), window->height()))
return (void *) &result[1];
// Make sure we have a consistent state
diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h
index 23e65022441..825f9eab234 100644
--- a/src/osd/sdl/window.h
+++ b/src/osd/sdl/window.h
@@ -75,21 +75,24 @@ private:
class sdl_window_info
{
public:
- sdl_window_info(running_machine *a_machine, sdl_monitor_info *a_monitor,
- int index, const sdl_window_config *config)
- : m_next(NULL), m_minwidth(0), m_minheight(0),
- m_startmaximized(0),
- m_rendered_event(0), m_target(0), m_primlist(NULL),
- m_width(0), m_height(0), m_blitwidth(0), m_blitheight(0),
+ sdl_window_info(running_machine &a_machine, int index, sdl_monitor_info *a_monitor,
+ const sdl_window_config *config)
+ : m_next(NULL), m_primlist(NULL),
m_start_viewscreen(0),
+ // Following three are used by input code to defer resizes
#if (SDLMAME_SDL2)
- m_sdl_window(NULL),
m_resize_width(0),
m_resize_height(0),
m_last_resize(0),
+#endif
+ m_minwidth(0), m_minheight(0),
+ m_rendered_event(0), m_target(0),
+ m_width(0), m_height(0), m_blitwidth(0), m_blitheight(0),
+#if (SDLMAME_SDL2)
+ m_sdl_window(NULL),
+
#else
m_sdlsurf(NULL),
- m_screen_width(0), m_screen_height(0),
#endif
m_machine(a_machine), m_monitor(a_monitor), m_fullscreen(0), m_index(0)
{
@@ -112,6 +115,8 @@ public:
global_free(m_renderer);
}
+ int window_init();
+
void video_window_update(running_machine &machine);
void toggle_full_screen(running_machine &machine);
void modify_prescale(running_machine &machine, int dir);
@@ -122,7 +127,7 @@ public:
void get_min_bounds(int *window_width, int *window_height, int constrain);
void get_max_bounds(int *window_width, int *window_height, int constrain);
- running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
+ running_machine &machine() const { return m_machine; }
sdl_monitor_info *monitor() const { return m_monitor; }
int fullscreen() const { return m_fullscreen; }
@@ -130,13 +135,40 @@ public:
void blit_surface_size(int window_width, int window_height);
void pick_best_mode(int *fswidth, int *fsheight);
+ void set_starting_view(running_machine &machine, int index, const char *defview, const char *view);
+
int index() const { return m_index; }
int xy_to_render_target(int x, int y, int *xt, int *yt);
+
+ render_target *target() { return m_target; }
+#if (SDLMAME_SDL2)
+ SDL_Window *sdl_window() { return m_sdl_window; }
+#else
+ SDL_Surface *sdl_surface() { return m_sdlsurf; }
+#endif
+ int width() const { return m_width; }
+ int height() const { return m_height; }
+
+ int blitwidth() const { return m_blitwidth; }
+ int blitheight() const { return m_blitheight; }
+ int prescale() const { return m_prescale; }
+
// Pointer to next window
sdl_window_info * m_next;
+ // FIXME: renderer should deal with this
+ render_primitive_list *m_primlist;
+ int m_start_viewscreen;
+#if (SDLMAME_SDL2)
+ // These are used in combine resizing events ... #if SDL13_COMBINE_RESIZE
+ int m_resize_width;
+ int m_resize_height;
+ osd_ticks_t m_last_resize;
+#endif
+
+private:
// window handle and info
char m_title[256];
@@ -152,19 +184,16 @@ public:
// rendering info
osd_event * m_rendered_event;
render_target * m_target;
- render_primitive_list *m_primlist;
- // cache of physical m_width and m_height
+ // cache of physical width() and height()
int m_width;
int m_height;
- // current m_blitwidth and m_height
+ // current m_blitwidth and height()
int m_blitwidth;
int m_blitheight;
- int m_start_viewscreen;
- // GL specific
int m_prescale;
#if (SDLMAME_SDL2)
@@ -172,17 +201,11 @@ public:
SDL_Window *m_sdl_window;
// Original display_mode
SDL_DisplayMode m_original_mode;
- // These are used in combine resizing events ... #if SDL13_COMBINE_RESIZE
- int m_resize_width;
- int m_resize_height;
- osd_ticks_t m_last_resize;
#else
// SDL surface
SDL_Surface *m_sdlsurf;
-
- int m_screen_width;
- int m_screen_height;
#endif
+
int m_extra_flags;
void set_renderer(osd_renderer *renderer)
@@ -197,7 +220,7 @@ private:
void constrain_to_aspect_ratio(int *window_width, int *window_height, int adjustment);
// Pointer to machine
- running_machine * m_machine;
+ running_machine & m_machine;
// monitor info
sdl_monitor_info * m_monitor;
int m_fullscreen;
@@ -234,9 +257,6 @@ extern sdl_window_info *sdl_window_list;
// PROTOTYPES
//============================================================
-// creation/deletion of windows
-int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config);
-
//============================================================
// PROTOTYPES - drawsdl.c
//============================================================