All private members for sdl_window_info now start with "m_". (nw)

This commit is contained in:
couriersud 2015-01-31 23:39:57 +01:00
parent 1e60dfa08d
commit d614721163
6 changed files with 332 additions and 306 deletions

View File

@ -584,7 +584,7 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height
osd_printf_verbose("Enter drawsdl2_window_create\n"); osd_printf_verbose("Enter drawsdl2_window_create\n");
window->dxdata = sdl; window->m_dxdata = sdl;
UINT32 extra_flags = (window->fullscreen() ? UINT32 extra_flags = (window->fullscreen() ?
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE); SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
@ -593,7 +593,7 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
#endif #endif
// create the SDL window // create the SDL window
window->sdl_window = SDL_CreateWindow(window->title, window->m_sdl_window = SDL_CreateWindow(window->m_title,
window->monitor()->position_size().x, window->monitor()->position_size().y, window->monitor()->position_size().x, window->monitor()->position_size().y,
width, height, extra_flags); width, height, extra_flags);
@ -601,12 +601,12 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height
{ {
SDL_DisplayMode mode; SDL_DisplayMode mode;
//SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode); //SDL_GetCurrentDisplayMode(window->monitor()->handle, &mode);
SDL_GetWindowDisplayMode(window->sdl_window, &mode); SDL_GetWindowDisplayMode(window->m_sdl_window, &mode);
sdl->m_original_mode = mode; sdl->m_original_mode = mode;
mode.w = width; mode.w = width;
mode.h = height; mode.h = height;
if (window->refresh) if (window->m_refresh)
mode.refresh_rate = window->refresh; mode.refresh_rate = window->m_refresh;
#if 0 #if 0
if (window->depth) if (window->depth)
{ {
@ -630,13 +630,13 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height
} }
#endif #endif
SDL_SetWindowDisplayMode(window->sdl_window, &mode); // Try to set mode SDL_SetWindowDisplayMode(window->m_sdl_window, &mode); // Try to set mode
#ifndef SDLMAME_WIN32 #ifndef SDLMAME_WIN32
/* FIXME: Warp the mouse to 0,0 in case a virtual desktop resolution /* 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 * 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 * This is a hack to work around a deficiency in SDL2
*/ */
SDL_WarpMouseInWindow(window->sdl_window, 1, 1); SDL_WarpMouseInWindow(window->m_sdl_window, 1, 1);
#endif #endif
} }
else else
@ -646,9 +646,9 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height
// create renderer // create renderer
if (video_config.waitvsync) if (video_config.waitvsync)
sdl->m_renderer = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); sdl->m_renderer = SDL_CreateRenderer(window->m_sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
else else
sdl->m_renderer = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_ACCELERATED); sdl->m_renderer = SDL_CreateRenderer(window->m_sdl_window, -1, SDL_RENDERER_ACCELERATED);
if (!sdl->m_renderer) if (!sdl->m_renderer)
{ {
@ -656,11 +656,11 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height
} }
//SDL_SelectRenderer(window->sdl_window); //SDL_SelectRenderer(window->sdl_window);
SDL_ShowWindow(window->sdl_window); SDL_ShowWindow(window->m_sdl_window);
//SDL_SetWindowFullscreen(window->window_id, window->fullscreen); //SDL_SetWindowFullscreen(window->window_id, window->fullscreen);
SDL_RaiseWindow(window->sdl_window); SDL_RaiseWindow(window->m_sdl_window);
SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
sdl->m_blittimer = 3; sdl->m_blittimer = 3;
@ -675,14 +675,14 @@ static int drawsdl2_window_create(sdl_window_info *window, int width, int height
static void drawsdl2_window_resize(sdl_window_info *window, int width, int height) static void drawsdl2_window_resize(sdl_window_info *window, int width, int height)
{ {
sdl_info13 *sdl = (sdl_info13 *) window->dxdata; sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
sdl->m_resize_pending = 1; sdl->m_resize_pending = 1;
sdl->m_resize_height = height; sdl->m_resize_height = height;
sdl->m_resize_width = width; sdl->m_resize_width = width;
window->width = width; window->m_width = width;
window->height = height; window->m_height = height;
sdl->m_blittimer = 3; sdl->m_blittimer = 3;
@ -694,13 +694,13 @@ static void drawsdl2_window_resize(sdl_window_info *window, int width, int heigh
static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt) static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
{ {
sdl_info13 *sdl = (sdl_info13 *) window->dxdata; sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
*xt = x - sdl->m_hofs; *xt = x - sdl->m_hofs;
*yt = y - sdl->m_vofs; *yt = y - sdl->m_vofs;
if (*xt<0 || *xt >= window->blitwidth) if (*xt<0 || *xt >= window->m_blitwidth)
return 0; return 0;
if (*yt<0 || *yt >= window->blitheight) if (*yt<0 || *yt >= window->m_blitheight)
return 0; return 0;
return 1; return 1;
} }
@ -711,7 +711,7 @@ static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, i
static void drawsdl2_set_target_bounds(sdl_window_info *window) static void drawsdl2_set_target_bounds(sdl_window_info *window)
{ {
window->target->set_bounds(window->blitwidth, window->blitheight, window->monitor()->aspect()); window->m_target->set_bounds(window->m_blitwidth, window->m_blitheight, window->monitor()->aspect());
} }
//============================================================ //============================================================
@ -720,7 +720,7 @@ static void drawsdl2_set_target_bounds(sdl_window_info *window)
static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update) static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
{ {
sdl_info13 *sdl = (sdl_info13 *) window->dxdata; sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
render_primitive *prim; render_primitive *prim;
texture_info *texture=NULL; texture_info *texture=NULL;
float vofs, hofs; float vofs, hofs;
@ -733,8 +733,8 @@ static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
if (sdl->m_resize_pending) if (sdl->m_resize_pending)
{ {
SDL_SetWindowSize(window->sdl_window, sdl->m_resize_width, sdl->m_resize_height); SDL_SetWindowSize(window->m_sdl_window, sdl->m_resize_width, sdl->m_resize_height);
SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
sdl->m_resize_pending = 0; sdl->m_resize_pending = 0;
SDL_RenderSetViewport(sdl->m_renderer, NULL); SDL_RenderSetViewport(sdl->m_renderer, NULL);
//sdlvideo_monitor_refresh(window->monitor()); //sdlvideo_monitor_refresh(window->monitor());
@ -767,27 +767,27 @@ static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
} }
else else
{ {
ch = window->height; ch = window->m_height;
cw = window->width; cw = window->m_width;
} }
if (video_config.centerv) if (video_config.centerv)
{ {
vofs = (ch - window->blitheight) / 2.0f; vofs = (ch - window->m_blitheight) / 2.0f;
} }
if (video_config.centerh) if (video_config.centerh)
{ {
hofs = (cw - window->blitwidth) / 2.0f; hofs = (cw - window->m_blitwidth) / 2.0f;
} }
} }
sdl->m_hofs = hofs; sdl->m_hofs = hofs;
sdl->m_vofs = vofs; sdl->m_vofs = vofs;
window->primlist->acquire_lock(); window->m_primlist->acquire_lock();
// now draw // now draw
for (prim = window->primlist->first(); prim != NULL; prim = prim->next()) for (prim = window->m_primlist->first(); prim != NULL; prim = prim->next())
{ {
Uint8 sr, sg, sb, sa; Uint8 sr, sg, sb, sa;
@ -817,7 +817,7 @@ static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
} }
} }
window->primlist->release_lock(); window->m_primlist->release_lock();
sdl->m_last_blit_pixels = blit_pixels; sdl->m_last_blit_pixels = blit_pixels;
sdl->m_last_blit_time = -osd_ticks(); sdl->m_last_blit_time = -osd_ticks();
@ -834,7 +834,7 @@ static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
static void drawsdl2_window_clear(sdl_window_info *window) static void drawsdl2_window_clear(sdl_window_info *window)
{ {
sdl_info13 *sdl = (sdl_info13 *) window->dxdata; sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
sdl->m_blittimer = 2; sdl->m_blittimer = 2;
} }
@ -846,7 +846,7 @@ static void drawsdl2_window_clear(sdl_window_info *window)
static void drawsdl2_window_destroy(sdl_window_info *window) static void drawsdl2_window_destroy(sdl_window_info *window)
{ {
sdl_info13 *sdl = (sdl_info13 *) window->dxdata; sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
// skip if nothing // skip if nothing
if (sdl == NULL) if (sdl == NULL)
@ -858,15 +858,15 @@ static void drawsdl2_window_destroy(sdl_window_info *window)
if (window->fullscreen() && video_config.switchres) if (window->fullscreen() && video_config.switchres)
{ {
SDL_SetWindowFullscreen(window->sdl_window, 0); // Try to set mode SDL_SetWindowFullscreen(window->m_sdl_window, 0); // Try to set mode
SDL_SetWindowDisplayMode(window->sdl_window, &sdl->m_original_mode); // Try to set mode SDL_SetWindowDisplayMode(window->m_sdl_window, &sdl->m_original_mode); // Try to set mode
SDL_SetWindowFullscreen(window->sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode SDL_SetWindowFullscreen(window->m_sdl_window, SDL_WINDOW_FULLSCREEN); // Try to set mode
} }
SDL_DestroyWindow(window->sdl_window); SDL_DestroyWindow(window->m_sdl_window);
global_free(sdl); global_free(sdl);
window->dxdata = NULL; window->m_dxdata = NULL;
} }
//============================================================ //============================================================
@ -1190,16 +1190,16 @@ texture_info * sdl_info13::texture_update(const render_primitive &prim)
static void drawsdl2_destroy_all_textures(sdl_window_info *window) static void drawsdl2_destroy_all_textures(sdl_window_info *window)
{ {
sdl_info13 *sdl = (sdl_info13 *) window->dxdata; sdl_info13 *sdl = (sdl_info13 *) window->m_dxdata;
if (sdl == NULL) if (sdl == NULL)
return; return;
if(window->primlist) if(window->m_primlist)
{ {
window->primlist->acquire_lock(); window->m_primlist->acquire_lock();
sdl->m_texlist.reset(); sdl->m_texlist.reset();
window->primlist->release_lock(); window->m_primlist->release_lock();
} }
else else
sdl->m_texlist.reset(); sdl->m_texlist.reset();

View File

@ -51,15 +51,15 @@ typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum);
typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei, const GLuint *); typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei, const GLuint *);
typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);
typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum m_target, GLuint framebuffer);
typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);
typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);
typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum m_target);
typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); 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 PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum m_target, GLuint renderbuffer);
typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum m_target, GLenum internalformat, GLsizei m_width, GLsizei m_height);
typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum m_target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
#endif #endif
@ -538,7 +538,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
// allocate memory for our structures // allocate memory for our structures
sdl = global_alloc(sdl_info); sdl = global_alloc(sdl_info);
window->dxdata = sdl; window->m_dxdata = sdl;
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
sdl->extra_flags = (window->fullscreen() ? sdl->extra_flags = (window->fullscreen() ?
@ -558,11 +558,11 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
//load_gl_lib(window->machine()); //load_gl_lib(window->machine());
// create the SDL window // create the SDL window
window->sdl_window = SDL_CreateWindow(window->title, window->m_sdl_window = SDL_CreateWindow(window->m_title,
window->monitor()->position_size().x, window->monitor()->position_size().y, window->monitor()->position_size().x, window->monitor()->position_size().y,
width, height, sdl->extra_flags); width, height, sdl->extra_flags);
if (!window->sdl_window ) if (!window->m_sdl_window )
{ {
osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError()); osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
return 1; return 1;
@ -574,19 +574,19 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
SDL_GetCurrentDisplayMode(window->monitor()->handle(), &mode); SDL_GetCurrentDisplayMode(window->monitor()->handle(), &mode);
mode.w = width; mode.w = width;
mode.h = height; mode.h = height;
if (window->refresh) if (window->m_refresh)
mode.refresh_rate = window->refresh; mode.refresh_rate = window->m_refresh;
SDL_SetWindowDisplayMode(window->sdl_window, &mode); // Try to set mode SDL_SetWindowDisplayMode(window->m_sdl_window, &mode); // Try to set mode
} }
else else
SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop SDL_SetWindowDisplayMode(window->m_sdl_window, NULL); // Use desktop
SDL_ShowWindow(window->sdl_window); SDL_ShowWindow(window->m_sdl_window);
//SDL_SetWindowFullscreen(window->sdl_window, window->fullscreen); //SDL_SetWindowFullscreen(window->sdl_window, window->fullscreen);
SDL_RaiseWindow(window->sdl_window); SDL_RaiseWindow(window->m_sdl_window);
SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
sdl->gl_context_id = SDL_GL_CreateContext(window->sdl_window); sdl->gl_context_id = SDL_GL_CreateContext(window->m_sdl_window);
if (!sdl->gl_context_id) if (!sdl->gl_context_id)
{ {
osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError()); osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
@ -607,14 +607,14 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
load_gl_lib(window->machine()); load_gl_lib(window->machine());
// create the SDL surface (which creates the window in windowed mode) // create the SDL surface (which creates the window in windowed mode)
sdl->sdlsurf = SDL_SetVideoMode(width, height, sdl->sdlsurf = SDL_SetVideoMode(m_width, m_height,
0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags); 0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);
if (!sdl->sdlsurf) if (!sdl->sdlsurf)
return 1; return 1;
window->width = sdl->sdlsurf->w; window->m_width = sdl->sdlsurf->w;
window->height = sdl->sdlsurf->h; window->m_height = sdl->sdlsurf->h;
window->screen_width = 0; window->screen_width = 0;
window->screen_height = 0; window->screen_height = 0;
@ -626,7 +626,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
} }
// set the window title // set the window title
SDL_WM_SetCaption(window->title, "SDLMAME"); SDL_WM_SetCaption(window->m_title, "SDLMAME");
#endif #endif
sdl->blittimer = 0; sdl->blittimer = 0;
@ -800,21 +800,21 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
static void drawogl_window_resize(sdl_window_info *window, int width, int height) static void drawogl_window_resize(sdl_window_info *window, int width, int height)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
//SDL_GL_MakeCurrent(window->sdl_window, sdl->gl_context_id); //SDL_GL_MakeCurrent(window->sdl_window, sdl->gl_context_id);
SDL_SetWindowSize(window->sdl_window, width, height); SDL_SetWindowSize(window->m_sdl_window, width, height);
SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
sdl->blittimer = 3; sdl->blittimer = 3;
#else #else
SDL_FreeSurface(sdl->sdlsurf); SDL_FreeSurface(sdl->sdlsurf);
sdl->sdlsurf = SDL_SetVideoMode(width, height, 0, sdl->sdlsurf = SDL_SetVideoMode(m_width, m_height, 0,
SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags); SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);
window->width = sdl->sdlsurf->w; window->m_width = sdl->sdlsurf->w;
window->height = sdl->sdlsurf->h; window->m_height = sdl->sdlsurf->h;
#endif #endif
sdl->init_context = 1; sdl->init_context = 1;
@ -826,13 +826,13 @@ static void drawogl_window_resize(sdl_window_info *window, int width, int height
static int drawogl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt) static int drawogl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
{ {
sdl_info *sdl =(sdl_info *) window->dxdata; sdl_info *sdl =(sdl_info *) window->m_dxdata;
*xt = x - sdl->last_hofs; *xt = x - sdl->last_hofs;
*yt = y - sdl->last_vofs; *yt = y - sdl->last_vofs;
if (*xt<0 || *xt >= window->blitwidth) if (*xt<0 || *xt >= window->m_blitwidth)
return 0; return 0;
if (*yt<0 || *yt >= window->blitheight) if (*yt<0 || *yt >= window->m_blitheight)
return 0; return 0;
return 1; return 1;
} }
@ -843,7 +843,7 @@ static int drawogl_xy_to_render_target(sdl_window_info *window, int x, int y, in
static void drawogl_set_target_bounds(sdl_window_info *window) static void drawogl_set_target_bounds(sdl_window_info *window)
{ {
window->target->set_bounds(window->blitwidth, window->blitheight, window->monitor()->aspect()); window->m_target->set_bounds(window->m_blitwidth, window->m_blitheight, window->monitor()->aspect());
} }
//============================================================ //============================================================
@ -852,7 +852,7 @@ static void drawogl_set_target_bounds(sdl_window_info *window)
static void loadGLExtensions(sdl_window_info *window) static void loadGLExtensions(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
static int _once = 1; static int _once = 1;
// sdl->usevbo=FALSE; // You may want to switch VBO and PBO off, by uncommenting this statement // sdl->usevbo=FALSE; // You may want to switch VBO and PBO off, by uncommenting this statement
@ -1065,7 +1065,7 @@ static void loadGLExtensions(sdl_window_info *window)
if ( sdl->useglsl ) if ( sdl->useglsl )
{ {
if ( window->prescale != 1 ) if ( window->m_prescale != 1 )
{ {
sdl->useglsl = 0; sdl->useglsl = 0;
if (_once) if (_once)
@ -1163,7 +1163,7 @@ static void loadGLExtensions(sdl_window_info *window)
static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update) static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
render_primitive *prim; render_primitive *prim;
texture_info *texture=NULL; texture_info *texture=NULL;
float vofs, hofs; float vofs, hofs;
@ -1176,7 +1176,7 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
} }
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
SDL_GL_MakeCurrent(window->sdl_window, sdl->gl_context_id); SDL_GL_MakeCurrent(window->m_sdl_window, sdl->gl_context_id);
#else #else
if (!sdl->init_context) if (!sdl->init_context)
{ {
@ -1185,10 +1185,10 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
{ {
if (window->index() == 0) if (window->index() == 0)
{ {
if ((screen->width() != window->screen_width) || (screen->height() != window->screen_height)) if ((screen->m_width() != window->screen_width) || (screen->m_height() != window->screen_height))
{ {
window->screen_width = screen->width(); window->screen_width = screen->m_width();
window->screen_height = screen->height(); window->screen_height = screen->m_height();
// force all textures to be regenerated // force all textures to be regenerated
drawogl_destroy_all_textures(window); drawogl_destroy_all_textures(window);
@ -1239,15 +1239,15 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
} }
if ( !sdl->initialized || if ( !sdl->initialized ||
window->width!= sdl->surf_w || window->height!= sdl->surf_h ) window->m_width!= sdl->surf_w || window->m_height!= sdl->surf_h )
{ {
if ( !sdl->initialized ) if ( !sdl->initialized )
{ {
loadGLExtensions(window); loadGLExtensions(window);
} }
sdl->surf_w=window->width; sdl->surf_w=window->m_width;
sdl->surf_h=window->height; sdl->surf_h=window->m_height;
// we're doing nothing 3d, so the Z-buffer is currently not interesting // we're doing nothing 3d, so the Z-buffer is currently not interesting
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
@ -1288,10 +1288,10 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
// |_________| // |_________|
// (0,h) (w,h) // (0,h) (w,h)
glViewport(0.0, 0.0, (GLsizei)window->width, (GLsizei)window->height); glViewport(0.0, 0.0, (GLsizei)window->m_width, (GLsizei)window->m_height);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glOrtho(0.0, (GLdouble)window->width, (GLdouble)window->height, 0.0, 0.0, -1.0); glOrtho(0.0, (GLdouble)window->m_width, (GLdouble)window->m_height, 0.0, 0.0, -1.0);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
@ -1318,27 +1318,27 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
} }
else else
{ {
ch = window->height; ch = window->m_height;
cw = window->width; cw = window->m_width;
} }
if (video_config.centerv) if (video_config.centerv)
{ {
vofs = (ch - window->blitheight) / 2.0f; vofs = (ch - window->m_blitheight) / 2.0f;
} }
if (video_config.centerh) if (video_config.centerh)
{ {
hofs = (cw - window->blitwidth) / 2.0f; hofs = (cw - window->m_blitwidth) / 2.0f;
} }
} }
sdl->last_hofs = hofs; sdl->last_hofs = hofs;
sdl->last_vofs = vofs; sdl->last_vofs = vofs;
window->primlist->acquire_lock(); window->m_primlist->acquire_lock();
// now draw // now draw
for (prim = window->primlist->first(); prim != NULL; prim = prim->next()) for (prim = window->m_primlist->first(); prim != NULL; prim = prim->next())
{ {
int i; int i;
@ -1404,7 +1404,7 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags)); set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags));
// compute the effective width based on the direction of the line // compute the effective width based on the direction of the line
effwidth = prim->width; effwidth = prim->m_width;
if (effwidth < 0.5f) if (effwidth < 0.5f)
effwidth = 0.5f; effwidth = 0.5f;
@ -1509,12 +1509,12 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
// 1:1 tex coord CCW (0/0) (1/0) (1/1) (0/1) on texture dimensions // 1:1 tex coord CCW (0/0) (1/0) (1/1) (0/1) on texture dimensions
sdl->texVerticex[0]=(GLfloat)0.0; sdl->texVerticex[0]=(GLfloat)0.0;
sdl->texVerticex[1]=(GLfloat)0.0; sdl->texVerticex[1]=(GLfloat)0.0;
sdl->texVerticex[2]=(GLfloat)window->width; sdl->texVerticex[2]=(GLfloat)window->m_width;
sdl->texVerticex[3]=(GLfloat)0.0; sdl->texVerticex[3]=(GLfloat)0.0;
sdl->texVerticex[4]=(GLfloat)window->width; sdl->texVerticex[4]=(GLfloat)window->m_width;
sdl->texVerticex[5]=(GLfloat)window->height; sdl->texVerticex[5]=(GLfloat)window->m_height;
sdl->texVerticex[6]=(GLfloat)0.0; sdl->texVerticex[6]=(GLfloat)0.0;
sdl->texVerticex[7]=(GLfloat)window->height; sdl->texVerticex[7]=(GLfloat)window->m_height;
} }
if(i>0) // first fetch already done if(i>0) // first fetch already done
@ -1554,13 +1554,13 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
pendingPrimitive=GL_NO_PRIMITIVE; pendingPrimitive=GL_NO_PRIMITIVE;
} }
window->primlist->release_lock(); window->m_primlist->release_lock();
sdl->init_context = 0; sdl->init_context = 0;
#if (!SDLMAME_SDL2) #if (!SDLMAME_SDL2)
SDL_GL_SwapBuffers(); SDL_GL_SwapBuffers();
#else #else
SDL_GL_SwapWindow(window->sdl_window); SDL_GL_SwapWindow(window->m_sdl_window);
#endif #endif
return 0; return 0;
} }
@ -1631,7 +1631,7 @@ static void drawogl_exit(void)
static void drawogl_window_destroy(sdl_window_info *window) static void drawogl_window_destroy(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
// skip if nothing // skip if nothing
if (sdl == NULL) if (sdl == NULL)
@ -1643,7 +1643,7 @@ static void drawogl_window_destroy(sdl_window_info *window)
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
SDL_GL_DeleteContext(sdl->gl_context_id); SDL_GL_DeleteContext(sdl->gl_context_id);
SDL_DestroyWindow(window->sdl_window); SDL_DestroyWindow(window->m_sdl_window);
#else #else
if (sdl->sdlsurf) if (sdl->sdlsurf)
{ {
@ -1653,7 +1653,7 @@ static void drawogl_window_destroy(sdl_window_info *window)
#endif #endif
global_free(sdl); global_free(sdl);
window->dxdata = NULL; window->m_dxdata = NULL;
} }
//============================================================ //============================================================
@ -1725,7 +1725,7 @@ static void texture_compute_size_subroutine(sdl_window_info *window, texture_inf
UINT32 width, UINT32 height, UINT32 width, UINT32 height,
int* p_width, int* p_height, int* p_width_create, int* p_height_create) int* p_width, int* p_height, int* p_width_create, int* p_height_create)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
int width_create; int width_create;
int height_create; int height_create;
@ -1750,8 +1750,8 @@ static void texture_compute_size_subroutine(sdl_window_info *window, texture_inf
texture->xprescale--; texture->xprescale--;
while (texture->yprescale > 1 && height_create * texture->yprescale > sdl->texture_max_height) while (texture->yprescale > 1 && height_create * texture->yprescale > sdl->texture_max_height)
texture->yprescale--; texture->yprescale--;
if (PRIMFLAG_GET_SCREENTEX(flags) && (texture->xprescale != window->prescale || texture->yprescale != window->prescale)) 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->prescale, window->prescale, texture->xprescale, texture->yprescale); osd_printf_warning("SDL: adjusting prescale from %dx%d to %dx%d\n", window->m_prescale, window->m_prescale, texture->xprescale, texture->yprescale);
width *= texture->xprescale; width *= texture->xprescale;
height *= texture->yprescale; height *= texture->yprescale;
@ -1775,7 +1775,7 @@ static void texture_compute_size_subroutine(sdl_window_info *window, texture_inf
static void texture_compute_size_type(sdl_window_info *window, const render_texinfo *texsource, texture_info *texture, UINT32 flags) static void texture_compute_size_type(sdl_window_info *window, const render_texinfo *texsource, texture_info *texture, UINT32 flags)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
int finalheight, finalwidth; int finalheight, finalwidth;
int finalheight_create, finalwidth_create; int finalheight_create, finalwidth_create;
@ -1930,11 +1930,11 @@ static int texture_fbo_create(UINT32 text_unit, UINT32 text_name, UINT32 fbo_nam
static int texture_shader_create(sdl_window_info *window, static int texture_shader_create(sdl_window_info *window,
const render_texinfo *texsource, texture_info *texture, UINT32 flags) const render_texinfo *texsource, texture_info *texture, UINT32 flags)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
int uniform_location; int uniform_location;
int i; int i;
int surf_w_pow2 = get_valid_pow2_value (window->blitwidth, texture->texpow2); int surf_w_pow2 = get_valid_pow2_value (window->m_blitwidth, texture->texpow2);
int surf_h_pow2 = get_valid_pow2_value (window->blitheight, texture->texpow2); int surf_h_pow2 = get_valid_pow2_value (window->m_blitheight, texture->texpow2);
assert ( texture->type==TEXTURE_TYPE_SHADER ); assert ( texture->type==TEXTURE_TYPE_SHADER );
@ -1981,7 +1981,7 @@ static int texture_shader_create(sdl_window_info *window,
pfn_glUniform2fvARB(uniform_location, 1, &(color_texture_pow2_sz[0])); pfn_glUniform2fvARB(uniform_location, 1, &(color_texture_pow2_sz[0]));
GL_CHECK_ERROR_NORMAL(); GL_CHECK_ERROR_NORMAL();
GLfloat screen_texture_sz[2] = { (GLfloat)window->blitwidth, (GLfloat)window->blitheight }; GLfloat screen_texture_sz[2] = { (GLfloat)window->m_blitwidth, (GLfloat)window->m_blitheight };
uniform_location = pfn_glGetUniformLocationARB(sdl->glsl_program[i], "screen_texture_sz"); uniform_location = pfn_glGetUniformLocationARB(sdl->glsl_program[i], "screen_texture_sz");
pfn_glUniform2fvARB(uniform_location, 1, &(screen_texture_sz[0])); pfn_glUniform2fvARB(uniform_location, 1, &(screen_texture_sz[0]));
GL_CHECK_ERROR_NORMAL(); GL_CHECK_ERROR_NORMAL();
@ -2037,7 +2037,7 @@ static int texture_shader_create(sdl_window_info *window,
} }
osd_printf_verbose("GL texture: mpass screen-bmp 2x %dx%d (pow2 %dx%d)\n", osd_printf_verbose("GL texture: mpass screen-bmp 2x %dx%d (pow2 %dx%d)\n",
window->width, window->height, surf_w_pow2, surf_h_pow2); window->m_width, window->m_height, surf_w_pow2, surf_h_pow2);
} }
// GL_TEXTURE0 // GL_TEXTURE0
@ -2104,7 +2104,7 @@ static int texture_shader_create(sdl_window_info *window,
static texture_info *texture_create(sdl_window_info *window, const render_texinfo *texsource, UINT32 flags) static texture_info *texture_create(sdl_window_info *window, const render_texinfo *texsource, UINT32 flags)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
texture_info *texture; texture_info *texture;
// allocate a new texture // allocate a new texture
@ -2117,8 +2117,8 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->texinfo.seqid = -1; // force set data texture->texinfo.seqid = -1; // force set data
if (PRIMFLAG_GET_SCREENTEX(flags)) if (PRIMFLAG_GET_SCREENTEX(flags))
{ {
texture->xprescale = window->prescale; texture->xprescale = window->m_prescale;
texture->yprescale = window->prescale; texture->yprescale = window->m_prescale;
} }
else else
{ {
@ -2483,7 +2483,7 @@ INLINE void copyline_yuy16_to_argb(UINT32 *dst, const UINT16 *src, int width, co
int x; int x;
assert(xborderpix == 0 || xborderpix == 2); assert(xborderpix == 0 || xborderpix == 2);
assert(width % 2 == 0); assert(m_width % 2 == 0);
// palette (really RGB map) case // palette (really RGB map) case
if (palette != NULL) if (palette != NULL)
@ -2724,7 +2724,7 @@ static texture_info *texture_find(sdl_info *sdl, const render_primitive *prim)
static void texture_coord_update(sdl_window_info *window, static void texture_coord_update(sdl_window_info *window,
texture_info *texture, const render_primitive *prim, int shaderIdx) texture_info *texture, const render_primitive *prim, int shaderIdx)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
float ustart = 0.0f, ustop = 0.0f; // beginning/ending U coordinates float ustart = 0.0f, ustop = 0.0f; // beginning/ending U coordinates
float vstart = 0.0f, vstop = 0.0f; // beginning/ending V coordinates float vstart = 0.0f, vstop = 0.0f; // beginning/ending V coordinates
float du, dv; float du, dv;
@ -2750,11 +2750,11 @@ static void texture_coord_update(sdl_window_info *window,
} }
else if ( texture->type == TEXTURE_TYPE_SHADER && shaderIdx>sdl->glsl_program_mb2sc ) else if ( texture->type == TEXTURE_TYPE_SHADER && shaderIdx>sdl->glsl_program_mb2sc )
{ {
int surf_w_pow2 = get_valid_pow2_value (window->width, texture->texpow2); int surf_w_pow2 = get_valid_pow2_value (window->m_width, texture->texpow2);
int surf_h_pow2 = get_valid_pow2_value (window->height, texture->texpow2); int surf_h_pow2 = get_valid_pow2_value (window->m_height, texture->texpow2);
ustop = (float)(window->width) / (float)surf_w_pow2; ustop = (float)(window->m_width) / (float)surf_w_pow2;
vstop = (float)(window->height) / (float)surf_h_pow2; vstop = (float)(window->m_height) / (float)surf_h_pow2;
} }
else else
{ {
@ -2872,7 +2872,7 @@ static void texture_mpass_flip(sdl_info *sdl, texture_info *texture, int shaderI
static void texture_shader_update(sdl_window_info *window, texture_info *texture, int shaderIdx) static void texture_shader_update(sdl_window_info *window, texture_info *texture, int shaderIdx)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
int uniform_location, scrnum; int uniform_location, scrnum;
render_container *container; render_container *container;
GLfloat vid_attributes[4]; GLfloat vid_attributes[4];
@ -2882,7 +2882,7 @@ static void texture_shader_update(sdl_window_info *window, texture_info *texture
screen_device_iterator iter(window->machine().root_device()); screen_device_iterator iter(window->machine().root_device());
for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next()) for (screen_device *screen = iter.first(); screen != NULL; screen = iter.next())
{ {
if (scrnum == window->start_viewscreen) if (scrnum == window->m_start_viewscreen)
{ {
container = &screen->container(); container = &screen->container();
} }
@ -2913,13 +2913,13 @@ static void texture_shader_update(sdl_window_info *window, texture_info *texture
} }
else else
{ {
osd_printf_verbose("GLSL: could not get render container for screen %d\n", window->start_viewscreen); osd_printf_verbose("GLSL: could not get render container for screen %d\n", window->m_start_viewscreen);
} }
} }
static texture_info * texture_update(sdl_window_info *window, const render_primitive *prim, int shaderIdx) static texture_info * texture_update(sdl_window_info *window, const render_primitive *prim, int shaderIdx)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
texture_info *texture = texture_find(sdl, prim); texture_info *texture = texture_find(sdl, prim);
int texBound = 0; int texBound = 0;
@ -3046,7 +3046,7 @@ static void texture_all_disable(sdl_info *sdl)
static void drawogl_destroy_all_textures(sdl_window_info *window) static void drawogl_destroy_all_textures(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
texture_info *texture = NULL; texture_info *texture = NULL;
int lock=FALSE; int lock=FALSE;
int i; int i;
@ -3058,13 +3058,13 @@ static void drawogl_destroy_all_textures(sdl_window_info *window)
return; return;
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
SDL_GL_MakeCurrent(window->sdl_window, sdl->gl_context_id); SDL_GL_MakeCurrent(window->m_sdl_window, sdl->gl_context_id);
#endif #endif
if(window->primlist) if(window->m_primlist)
{ {
lock=TRUE; lock=TRUE;
window->primlist->acquire_lock(); window->m_primlist->acquire_lock();
} }
glFinish(); glFinish();
@ -3126,7 +3126,7 @@ static void drawogl_destroy_all_textures(sdl_window_info *window)
sdl->initialized = 0; sdl->initialized = 0;
if (lock) if (lock)
window->primlist->release_lock(); window->m_primlist->release_lock();
} }
//============================================================ //============================================================
@ -3135,7 +3135,7 @@ static void drawogl_destroy_all_textures(sdl_window_info *window)
static void drawogl_window_clear(sdl_window_info *window) static void drawogl_window_clear(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
//FIXME: Handled in drawogl_window_draw as well //FIXME: Handled in drawogl_window_draw as well
sdl->blittimer = 3; sdl->blittimer = 3;

View File

@ -245,7 +245,7 @@ static void drawsdl_destroy_all_textures(sdl_window_info *window)
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight) static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode]; const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
SDL_DisplayMode mode; SDL_DisplayMode mode;
UINT32 fmt; UINT32 fmt;
@ -261,7 +261,7 @@ static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight
if (sdl_sm->is_scale) if (sdl_sm->is_scale)
{ {
window->target->compute_minimum_size(sdl->hw_scale_width, sdl->hw_scale_height); window->m_target->compute_minimum_size(sdl->hw_scale_width, sdl->hw_scale_height);
if (video_config.prescale) if (video_config.prescale)
{ {
sdl->hw_scale_width *= video_config.prescale; sdl->hw_scale_width *= video_config.prescale;
@ -300,11 +300,11 @@ static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight
#if (!SDLMAME_SDL2) #if (!SDLMAME_SDL2)
static void yuv_overlay_init(sdl_window_info *window) static void yuv_overlay_init(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode]; const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
int minimum_width, minimum_height; int minimum_width, minimum_height;
window->target->compute_minimum_size(minimum_width, minimum_height); window->m_target->compute_minimum_size(minimum_width, minimum_height);
if (video_config.prescale) if (video_config.prescale)
{ {
@ -394,7 +394,7 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
sdl = (sdl_info *) osd_malloc(sizeof(sdl_info)); sdl = (sdl_info *) osd_malloc(sizeof(sdl_info));
memset(sdl, 0, sizeof(sdl_info)); memset(sdl, 0, sizeof(sdl_info));
window->dxdata = sdl; window->m_dxdata = sdl;
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
@ -406,7 +406,7 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS
| SDL_WINDOW_INPUT_GRABBED : SDL_WINDOW_RESIZABLE); | SDL_WINDOW_INPUT_GRABBED : SDL_WINDOW_RESIZABLE);
window->sdl_window = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window->m_sdl_window = SDL_CreateWindow(window->m_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height, sdl->extra_flags); width, height, sdl->extra_flags);
if (window->fullscreen() && video_config.switchres) if (window->fullscreen() && video_config.switchres)
@ -415,29 +415,29 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
SDL_GetCurrentDisplayMode(window->monitor()->handle(), &mode); SDL_GetCurrentDisplayMode(window->monitor()->handle(), &mode);
mode.w = width; mode.w = width;
mode.h = height; mode.h = height;
if (window->refresh) if (window->m_refresh)
mode.refresh_rate = window->refresh; mode.refresh_rate = window->m_refresh;
SDL_SetWindowDisplayMode(window->sdl_window, &mode); // Try to set mode SDL_SetWindowDisplayMode(window->m_sdl_window, &mode); // Try to set mode
} }
else else
SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop SDL_SetWindowDisplayMode(window->m_sdl_window, NULL); // Use desktop
SDL_ShowWindow(window->sdl_window); SDL_ShowWindow(window->m_sdl_window);
SDL_SetWindowFullscreen(window->sdl_window, (SDL_bool) window->fullscreen()); SDL_SetWindowFullscreen(window->m_sdl_window, (SDL_bool) window->fullscreen());
SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
SDL_RaiseWindow(window->sdl_window); SDL_RaiseWindow(window->m_sdl_window);
/* FIXME: Bug in SDL 1.3 */ /* FIXME: Bug in SDL 1.3 */
if (window->fullscreen()) if (window->fullscreen())
SDL_SetWindowGrab(window->sdl_window, SDL_TRUE); SDL_SetWindowGrab(window->m_sdl_window, SDL_TRUE);
// create a texture // create a texture
if (video_config.waitvsync) if (video_config.waitvsync)
sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD |*/ SDL_RENDERER_PRESENTVSYNC); sdl->sdl_renderer = SDL_CreateRenderer(window->m_sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD |*/ SDL_RENDERER_PRESENTVSYNC);
else else
sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0); sdl->sdl_renderer = SDL_CreateRenderer(window->m_sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0);
//SDL_SelectRenderer(window->sdl_window); //SDL_SelectRenderer(window->sdl_window);
@ -471,20 +471,20 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
sdl->extra_flags |= sm->extra_flags; sdl->extra_flags |= sm->extra_flags;
sdl->sdlsurf = SDL_SetVideoMode(width, height, sdl->sdlsurf = SDL_SetVideoMode(m_width, m_height,
0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags); 0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);
if (!sdl->sdlsurf) if (!sdl->sdlsurf)
return 1; return 1;
window->width = sdl->sdlsurf->w; window->m_width = sdl->sdlsurf->w;
window->height = sdl->sdlsurf->h; window->m_height = sdl->sdlsurf->h;
if (sm->is_yuv) if (sm->is_yuv)
yuv_overlay_init(window); yuv_overlay_init(window);
// set the window title // set the window title
SDL_WM_SetCaption(window->title, "SDLMAME"); SDL_WM_SetCaption(window->m_title, "SDLMAME");
#endif #endif
sdl->yuv_lookup = NULL; sdl->yuv_lookup = NULL;
sdl->blittimer = 0; sdl->blittimer = 0;
@ -503,11 +503,11 @@ static void drawsdl_window_resize(sdl_window_info *window, int width, int height
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode]; const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
#endif #endif
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
SDL_SetWindowSize(window->sdl_window, width, height); SDL_SetWindowSize(window->m_sdl_window, width, height);
SDL_GetWindowSize(window->sdl_window, &window->width, &window->height); SDL_GetWindowSize(window->m_sdl_window, &window->m_width, &window->m_height);
#else #else
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
if (sdl->yuvsurf != NULL) if (sdl->yuvsurf != NULL)
{ {
@ -517,10 +517,10 @@ static void drawsdl_window_resize(sdl_window_info *window, int width, int height
SDL_FreeSurface(sdl->sdlsurf); SDL_FreeSurface(sdl->sdlsurf);
//printf("SetVideoMode %d %d\n", wp->resize_new_width, wp->resize_new_height); //printf("SetVideoMode %d %d\n", wp->resize_new_width, wp->resize_new_height);
sdl->sdlsurf = SDL_SetVideoMode(width, height, 0, sdl->sdlsurf = SDL_SetVideoMode(m_width, m_height, 0,
SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags); SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);
window->width = sdl->sdlsurf->w; window->m_width = sdl->sdlsurf->w;
window->height = sdl->sdlsurf->h; window->m_height = sdl->sdlsurf->h;
if (sdl_sm->is_yuv) if (sdl_sm->is_yuv)
{ {
@ -537,7 +537,7 @@ static void drawsdl_window_resize(sdl_window_info *window, int width, int height
static void drawsdl_window_destroy(sdl_window_info *window) static void drawsdl_window_destroy(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
// skip if nothing // skip if nothing
if (sdl == NULL) if (sdl == NULL)
@ -547,7 +547,7 @@ static void drawsdl_window_destroy(sdl_window_info *window)
//SDL_SelectRenderer(window->sdl_window); //SDL_SelectRenderer(window->sdl_window);
SDL_DestroyTexture(sdl->texture_id); SDL_DestroyTexture(sdl->texture_id);
//SDL_DestroyRenderer(window->sdl_window); //SDL_DestroyRenderer(window->sdl_window);
SDL_DestroyWindow(window->sdl_window); SDL_DestroyWindow(window->m_sdl_window);
#else #else
if (sdl->yuvsurf != NULL) if (sdl->yuvsurf != NULL)
{ {
@ -574,7 +574,7 @@ static void drawsdl_window_destroy(sdl_window_info *window)
sdl->yuv_bitmap = NULL; sdl->yuv_bitmap = NULL;
} }
osd_free(sdl); osd_free(sdl);
window->dxdata = NULL; window->m_dxdata = NULL;
} }
//============================================================ //============================================================
@ -583,7 +583,7 @@ static void drawsdl_window_destroy(sdl_window_info *window)
static void drawsdl_window_clear(sdl_window_info *window) static void drawsdl_window_clear(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
sdl->blittimer = 3; sdl->blittimer = 3;
} }
@ -594,22 +594,22 @@ static void drawsdl_window_clear(sdl_window_info *window)
static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt) static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
*xt = x - sdl->last_hofs; *xt = x - sdl->last_hofs;
*yt = y - sdl->last_vofs; *yt = y - sdl->last_vofs;
if (*xt<0 || *xt >= window->blitwidth) if (*xt<0 || *xt >= window->m_blitwidth)
return 0; return 0;
if (*yt<0 || *xt >= window->blitheight) if (*yt<0 || *xt >= window->m_blitheight)
return 0; return 0;
if (!sm->is_scale) if (!sm->is_scale)
{ {
return 1; return 1;
} }
/* Rescale */ /* Rescale */
*xt = (*xt * sdl->hw_scale_width) / window->blitwidth; *xt = (*xt * sdl->hw_scale_width) / window->m_blitwidth;
*yt = (*yt * sdl->hw_scale_height) / window->blitheight; *yt = (*yt * sdl->hw_scale_height) / window->m_blitheight;
return 1; return 1;
} }
@ -619,13 +619,13 @@ static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, in
static void drawsdl_set_target_bounds(sdl_window_info *window) static void drawsdl_set_target_bounds(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
if (!sm->is_scale) if (!sm->is_scale)
window->target->set_bounds(window->blitwidth, window->blitheight, window->monitor()->aspect()); window->m_target->set_bounds(window->m_blitwidth, window->m_blitheight, window->monitor()->aspect());
else else
window->target->set_bounds(sdl->hw_scale_width, sdl->hw_scale_height); window->m_target->set_bounds(sdl->hw_scale_width, sdl->hw_scale_height);
} }
//============================================================ //============================================================
@ -634,7 +634,7 @@ static void drawsdl_set_target_bounds(sdl_window_info *window)
static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update) static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->m_dxdata;
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode]; const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
UINT8 *surfptr; UINT8 *surfptr;
INT32 pitch; INT32 pitch;
@ -664,12 +664,12 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
bmask = sdl->sdlsurf->format->Bmask; bmask = sdl->sdlsurf->format->Bmask;
// amask = sdl->sdlsurf->format->Amask; // amask = sdl->sdlsurf->format->Amask;
if (window->blitwidth != sdl->old_blitwidth || window->blitheight != sdl->old_blitheight) if (window->m_blitwidth != sdl->old_blitwidth || window->m_blitheight != sdl->old_blitheight)
{ {
if (sm->is_yuv) if (sm->is_yuv)
yuv_overlay_init(window); yuv_overlay_init(window);
sdl->old_blitwidth = window->blitwidth; sdl->old_blitwidth = window->m_blitwidth;
sdl->old_blitheight = window->blitheight; sdl->old_blitheight = window->m_blitheight;
sdl->blittimer = 3; sdl->blittimer = 3;
} }
@ -678,7 +678,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
if (sdl->blittimer > 0) if (sdl->blittimer > 0)
{ {
memset(sdl->sdlsurf->pixels, 0, window->height * sdl->sdlsurf->pitch); memset(sdl->sdlsurf->pixels, 0, window->m_height * sdl->sdlsurf->pitch);
sdl->blittimer--; sdl->blittimer--;
} }
@ -694,14 +694,14 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
#else #else
//SDL_SelectRenderer(window->sdl_window); //SDL_SelectRenderer(window->sdl_window);
if (window->blitwidth != sdl->old_blitwidth || window->blitheight != sdl->old_blitheight) if (window->m_blitwidth != sdl->old_blitwidth || window->m_blitheight != sdl->old_blitheight)
{ {
SDL_RenderSetViewport(sdl->sdl_renderer, NULL); SDL_RenderSetViewport(sdl->sdl_renderer, NULL);
SDL_DestroyTexture(sdl->texture_id); SDL_DestroyTexture(sdl->texture_id);
setup_texture(window, window->blitwidth, window->blitheight); setup_texture(window, window->m_blitwidth, window->m_blitheight);
sdl->old_blitwidth = window->blitwidth; sdl->old_blitwidth = window->m_blitwidth;
sdl->old_blitheight = window->blitheight; sdl->old_blitheight = window->m_blitheight;
sdl->blittimer = 3; sdl->blittimer = 3;
} }
@ -729,8 +729,8 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
#endif #endif
// get ready to center the image // get ready to center the image
vofs = hofs = 0; vofs = hofs = 0;
blitwidth = window->blitwidth; blitwidth = window->m_blitwidth;
blitheight = window->blitheight; blitheight = window->m_blitheight;
// figure out what coordinate system to use for centering - in window mode it's always the // 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 // SDL surface size. in fullscreen the surface covers all monitors, so center according to
@ -742,8 +742,8 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
} }
else else
{ {
ch = window->height; ch = window->m_height;
cw = window->width; cw = window->m_width;
} }
// do not crash if the window's smaller than the blit area // do not crash if the window's smaller than the blit area
@ -753,7 +753,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
} }
else if (video_config.centerv) else if (video_config.centerv)
{ {
vofs = (ch - window->blitheight) / 2; vofs = (ch - window->m_blitheight) / 2;
} }
if (blitwidth > cw) if (blitwidth > cw)
@ -762,13 +762,13 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
} }
else if (video_config.centerh) else if (video_config.centerh)
{ {
hofs = (cw - window->blitwidth) / 2; hofs = (cw - window->m_blitwidth) / 2;
} }
sdl->last_hofs = hofs; sdl->last_hofs = hofs;
sdl->last_vofs = vofs; sdl->last_vofs = vofs;
window->primlist->acquire_lock(); window->m_primlist->acquire_lock();
// render to it // render to it
if (!sm->is_yuv) if (!sm->is_yuv)
@ -791,23 +791,23 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
switch (rmask) switch (rmask)
{ {
case 0x0000ff00: case 0x0000ff00:
software_renderer<UINT32, 0,0,0, 8,16,24>::draw_primitives(*window->primlist, surfptr, mamewidth, mameheight, pitch / 4); software_renderer<UINT32, 0,0,0, 8,16,24>::draw_primitives(*window->m_primlist, surfptr, mamewidth, mameheight, pitch / 4);
break; break;
case 0x00ff0000: case 0x00ff0000:
software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window->primlist, surfptr, mamewidth, mameheight, pitch / 4); software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window->m_primlist, surfptr, mamewidth, mameheight, pitch / 4);
break; break;
case 0x000000ff: case 0x000000ff:
software_renderer<UINT32, 0,0,0, 0,8,16>::draw_primitives(*window->primlist, surfptr, mamewidth, mameheight, pitch / 4); software_renderer<UINT32, 0,0,0, 0,8,16>::draw_primitives(*window->m_primlist, surfptr, mamewidth, mameheight, pitch / 4);
break; break;
case 0xf800: case 0xf800:
software_renderer<UINT16, 3,2,3, 11,5,0>::draw_primitives(*window->primlist, surfptr, mamewidth, mameheight, pitch / 2); software_renderer<UINT16, 3,2,3, 11,5,0>::draw_primitives(*window->m_primlist, surfptr, mamewidth, mameheight, pitch / 2);
break; break;
case 0x7c00: case 0x7c00:
software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window->primlist, surfptr, mamewidth, mameheight, pitch / 2); software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window->m_primlist, surfptr, mamewidth, mameheight, pitch / 2);
break; break;
default: default:
@ -819,11 +819,11 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
{ {
assert (sdl->yuv_bitmap != NULL); assert (sdl->yuv_bitmap != NULL);
assert (surfptr != NULL); assert (surfptr != NULL);
software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window->primlist, sdl->yuv_bitmap, sdl->hw_scale_width, sdl->hw_scale_height, sdl->hw_scale_width); software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window->m_primlist, sdl->yuv_bitmap, sdl->hw_scale_width, sdl->hw_scale_height, sdl->hw_scale_width);
sm->yuv_blit((UINT16 *)sdl->yuv_bitmap, sdl, surfptr, pitch); sm->yuv_blit((UINT16 *)sdl->yuv_bitmap, sdl, surfptr, pitch);
} }
window->primlist->release_lock(); window->m_primlist->release_lock();
// unlock and flip // unlock and flip
#if (!SDLMAME_SDL2) #if (!SDLMAME_SDL2)
@ -839,8 +839,8 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
SDL_UnlockYUVOverlay(sdl->yuvsurf); SDL_UnlockYUVOverlay(sdl->yuvsurf);
r.x=hofs; r.x=hofs;
r.y=vofs; r.y=vofs;
r.w=blitwidth; r.w=m_blitwidth;
r.h=blitheight; r.h=m_blitheight;
SDL_DisplayYUVOverlay(sdl->yuvsurf, &r); SDL_DisplayYUVOverlay(sdl->yuvsurf, &r);
} }
#else #else

View File

@ -1547,7 +1547,7 @@ INLINE sdl_window_info * window_from_id(Uint32 windowID)
for (w = sdl_window_list; w != NULL; w = w->next) for (w = sdl_window_list; w != NULL; w = w->next)
{ {
//printf("w->window_id: %d\n", w->window_id); //printf("w->window_id: %d\n", w->window_id);
if (w->sdl_window == window) if (w->m_sdl_window == window)
{ {
return w; return w;
} }
@ -1564,11 +1564,11 @@ INLINE void resize_all_windows(void)
{ {
for (w = sdl_window_list; w != NULL; w = w->next) for (w = sdl_window_list; w != NULL; w = w->next)
{ {
if (w->resize_width && w->resize_height && ((now - w->last_resize) > osd_ticks_per_second() / 10)) if (w->m_resize_width && w->m_resize_height && ((now - w->m_last_resize) > osd_ticks_per_second() / 10))
{ {
w->window_resize(w->resize_width, w->resize_height); w->window_resize(w->m_resize_width, w->m_resize_height);
w->resize_width = 0; w->m_resize_width = 0;
w->resize_height = 0; w->m_resize_height = 0;
} }
} }
} }
@ -1759,7 +1759,7 @@ void sdlinput_poll(running_machine &machine)
#endif #endif
devinfo->keyboard.state[OSD_SDL_INDEX_KEYSYM(&event.key.keysym)] = 0x80; devinfo->keyboard.state[OSD_SDL_INDEX_KEYSYM(&event.key.keysym)] = 0x80;
#if (!SDLMAME_SDL2) #if (!SDLMAME_SDL2)
ui_input_push_char_event(machine, sdl_window_list->target, (unicode_char) event.key.keysym.unicode); ui_input_push_char_event(machine, sdl_window_list->m_target, (unicode_char) event.key.keysym.unicode);
#endif #endif
break; break;
case SDL_KEYUP: case SDL_KEYUP:
@ -1861,14 +1861,14 @@ void sdlinput_poll(running_machine &machine)
sdl_window_info *window = GET_FOCUS_WINDOW(&event.button); sdl_window_info *window = GET_FOCUS_WINDOW(&event.button);
if (window != NULL && window->xy_to_render_target(window, event.button.x,event.button.y, &cx, &cy) ) if (window != NULL && window->xy_to_render_target(window, event.button.x,event.button.y, &cx, &cy) )
{ {
ui_input_push_mouse_down_event(machine, window->target, cx, cy); ui_input_push_mouse_down_event(machine, window->m_target, cx, cy);
// FIXME Parameter ? // FIXME Parameter ?
if ((click-last_click < 250) if ((click-last_click < 250)
&& (cx >= last_x - 4 && cx <= last_x + 4) && (cx >= last_x - 4 && cx <= last_x + 4)
&& (cy >= last_y - 4 && cy <= last_y + 4) ) && (cy >= last_y - 4 && cy <= last_y + 4) )
{ {
last_click = 0; last_click = 0;
ui_input_push_mouse_double_click_event(machine, window->target, cx, cy); ui_input_push_mouse_double_click_event(machine, window->m_target, cx, cy);
} }
else else
{ {
@ -1895,7 +1895,7 @@ void sdlinput_poll(running_machine &machine)
if (window != NULL && window->xy_to_render_target(window, event.button.x,event.button.y, &cx, &cy) ) if (window != NULL && window->xy_to_render_target(window, event.button.x,event.button.y, &cx, &cy) )
{ {
ui_input_push_mouse_up_event(machine, window->target, cx, cy); ui_input_push_mouse_up_event(machine, window->m_target, cx, cy);
} }
} }
break; break;
@ -1919,7 +1919,7 @@ void sdlinput_poll(running_machine &machine)
sdl_window_info *window = GET_FOCUS_WINDOW(&event.motion); sdl_window_info *window = GET_FOCUS_WINDOW(&event.motion);
if (window != NULL && window->xy_to_render_target(window, event.motion.x, event.motion.y, &cx, &cy) ) if (window != NULL && window->xy_to_render_target(window, event.motion.x, event.motion.y, &cx, &cy) )
ui_input_push_mouse_move_event(machine, window->target, cx, cy); ui_input_push_mouse_move_event(machine, window->m_target, cx, cy);
} }
break; break;
case SDL_JOYBALLMOTION: case SDL_JOYBALLMOTION:
@ -1934,7 +1934,7 @@ void sdlinput_poll(running_machine &machine)
if (!event.active.gain) if (!event.active.gain)
{ {
sdl_window_info *window = GET_FOCUS_WINDOW(&event.motion); sdl_window_info *window = GET_FOCUS_WINDOW(&event.motion);
ui_input_push_mouse_leave_event(machine, window->target); ui_input_push_mouse_leave_event(machine, window->m_target);
} }
break; break;
case SDL_QUIT: case SDL_QUIT:
@ -1952,7 +1952,7 @@ void sdlinput_poll(running_machine &machine)
if (window != NULL ) if (window != NULL )
{ {
osd_uchar_from_osdchar(&result, event.text.text, 1); osd_uchar_from_osdchar(&result, event.text.text, 1);
ui_input_push_char_event(machine, window->target, result); ui_input_push_char_event(machine, window->m_target, result);
} }
} }
break; break;
@ -1969,7 +1969,7 @@ void sdlinput_poll(running_machine &machine)
machine.schedule_exit(); machine.schedule_exit();
break; break;
case SDL_WINDOWEVENT_LEAVE: case SDL_WINDOWEVENT_LEAVE:
ui_input_push_mouse_leave_event(machine, window->target); ui_input_push_mouse_leave_event(machine, window->m_target);
app_has_mouse_focus = 0; app_has_mouse_focus = 0;
break; break;
case SDL_WINDOWEVENT_MOVED: case SDL_WINDOWEVENT_MOVED:
@ -1979,9 +1979,9 @@ void sdlinput_poll(running_machine &machine)
case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_RESIZED:
if (SDL13_COMBINE_RESIZE) if (SDL13_COMBINE_RESIZE)
{ {
window->resize_width = event.window.data1; window->m_resize_width = event.window.data1;
window->resize_height = event.window.data2; window->m_resize_height = event.window.data2;
window->last_resize = osd_ticks(); window->m_last_resize = osd_ticks();
} }
else else
{ {
@ -1993,7 +1993,7 @@ void sdlinput_poll(running_machine &machine)
#endif #endif
{ {
//printf("event data1,data2 %d x %d %ld\n", event.window.data1, event.window.data2, sizeof(SDL_Event)); //printf("event data1,data2 %d x %d %ld\n", event.window.data1, event.window.data2, sizeof(SDL_Event));
if (event.window.data1 != window->width || event.window.data2 != window->height) if (event.window.data1 != window->m_width || event.window.data2 != window->m_height)
window->window_resize(event.window.data1, event.window.data2); window->window_resize(event.window.data1, event.window.data2);
} }
} }

View File

@ -401,13 +401,13 @@ void sdl_window_info::blit_surface_size(int window_width, int window_height)
INT32 target_height = window_height; INT32 target_height = window_height;
// start with the minimum size // start with the minimum size
target->compute_minimum_size(newwidth, newheight); m_target->compute_minimum_size(newwidth, newheight);
// compute the appropriate visible area if we're trying to keepaspect // compute the appropriate visible area if we're trying to keepaspect
if (video_config.keepaspect) if (video_config.keepaspect)
{ {
// make sure the monitor is up-to-date // make sure the monitor is up-to-date
target->compute_visible_area(target_width, target_height, m_monitor->aspect(), target->orientation(), target_width, target_height); m_target->compute_visible_area(target_width, target_height, m_monitor->aspect(), m_target->orientation(), target_width, target_height);
desired_aspect = (float)target_width / (float)target_height; desired_aspect = (float)target_width / (float)target_height;
} }
@ -459,15 +459,15 @@ void sdl_window_info::blit_surface_size(int window_width, int window_height)
} }
//FIXME: really necessary to distinguish for yuv_modes ? //FIXME: really necessary to distinguish for yuv_modes ?
if (target->zoom_to_screen() if (m_target->zoom_to_screen()
&& (video_config.scale_mode == VIDEO_SCALE_MODE_NONE )) && (video_config.scale_mode == VIDEO_SCALE_MODE_NONE ))
newwidth = window_width; newwidth = window_width;
if ((blitwidth != newwidth) || (blitheight != newheight)) if ((m_blitwidth != newwidth) || (m_blitheight != newheight))
window_clear(); window_clear();
blitwidth = newwidth; m_blitwidth = newwidth;
blitheight = newheight; m_blitheight = newheight;
} }
@ -498,7 +498,7 @@ void sdl_window_info::window_resize(INT32 width, INT32 height)
{ {
ASSERT_MAIN_THREAD(); ASSERT_MAIN_THREAD();
if (width == this->width && height == this->height) if (width == this->m_width && height == this->m_height)
return; return;
execute_async_wait(&sdlwindow_resize_wt, worker_param(this, width, height)); execute_async_wait(&sdlwindow_resize_wt, worker_param(this, width, height));
@ -554,8 +554,8 @@ static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt )
// If we are going fullscreen (leaving windowed) remember our windowed size // If we are going fullscreen (leaving windowed) remember our windowed size
if (!window->fullscreen()) if (!window->fullscreen())
{ {
window->windowed_width = window->width; window->m_windowed_width = window->m_width;
window->windowed_height = window->height; window->m_windowed_height = window->m_height;
} }
window->destroy(window); window->destroy(window);
@ -591,20 +591,20 @@ static OSDWORK_CALLBACK( destroy_all_textures_wt )
void sdl_window_info::modify_prescale(running_machine &machine, int dir) void sdl_window_info::modify_prescale(running_machine &machine, int dir)
{ {
worker_param wp = worker_param(machine, this); worker_param wp = worker_param(machine, this);
int new_prescale = prescale; int new_prescale = m_prescale;
if (dir > 0 && prescale < 3) if (dir > 0 && m_prescale < 3)
new_prescale = prescale + 1; new_prescale = m_prescale + 1;
if (dir < 0 && prescale > 1) if (dir < 0 && m_prescale > 1)
new_prescale = prescale - 1; new_prescale = m_prescale - 1;
if (new_prescale != prescale) if (new_prescale != m_prescale)
{ {
if (m_fullscreen && video_config.switchres) if (m_fullscreen && video_config.switchres)
{ {
execute_async_wait(&sdlwindow_video_window_destroy_wt, wp); execute_async_wait(&sdlwindow_video_window_destroy_wt, wp);
prescale = new_prescale; m_prescale = new_prescale;
execute_async_wait(&complete_create_wt, wp); execute_async_wait(&complete_create_wt, wp);
@ -612,9 +612,9 @@ void sdl_window_info::modify_prescale(running_machine &machine, int dir)
else else
{ {
execute_async_wait(destroy_all_textures_wt, wp); execute_async_wait(destroy_all_textures_wt, wp);
prescale = new_prescale; m_prescale = new_prescale;
} }
machine.ui().popup_time(1, "Prescale %d", prescale); machine.ui().popup_time(1, "Prescale %d", m_prescale);
} }
} }
@ -645,15 +645,15 @@ static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_i
if (!window->fullscreen() && !sdlinput_should_hide_mouse(machine)) if (!window->fullscreen() && !sdlinput_should_hide_mouse(machine))
{ {
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
if (SDL_GetWindowGrab(window->sdl_window )) if (SDL_GetWindowGrab(window->m_sdl_window ))
SDL_SetWindowGrab(window->sdl_window, SDL_FALSE); SDL_SetWindowGrab(window->m_sdl_window, SDL_FALSE);
SDL_SetRelativeMouseMode(SDL_FALSE); SDL_SetRelativeMouseMode(SDL_FALSE);
} }
else else
{ {
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
if (!SDL_GetWindowGrab(window->sdl_window)) if (!SDL_GetWindowGrab(window->m_sdl_window))
SDL_SetWindowGrab(window->sdl_window, SDL_TRUE); SDL_SetWindowGrab(window->m_sdl_window, SDL_TRUE);
SDL_SetRelativeMouseMode(SDL_TRUE); SDL_SetRelativeMouseMode(SDL_TRUE);
} }
SDL_SetCursor(NULL); // Force an update in case the underlying driver has changed visibility SDL_SetCursor(NULL); // Force an update in case the underlying driver has changed visibility
@ -716,7 +716,7 @@ int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monit
// set the initial maximized state // set the initial maximized state
// FIXME: Does not belong here // FIXME: Does not belong here
sdl_options &options = downcast<sdl_options &>(machine.options()); sdl_options &options = downcast<sdl_options &>(machine.options());
window->startmaximized = options.maximize(); window->m_startmaximized = options.maximize();
// add us to the list // add us to the list
*last_window_ptr = window; *last_window_ptr = window;
@ -725,19 +725,19 @@ int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monit
draw.attach(&draw, window); draw.attach(&draw, window);
// create an event that we can use to skip blitting // create an event that we can use to skip blitting
window->rendered_event = osd_event_alloc(FALSE, TRUE); window->m_rendered_event = osd_event_alloc(FALSE, TRUE);
// load the layout // load the layout
window->target = machine.render().target_alloc(); window->m_target = machine.render().target_alloc();
// set the specific view // set the specific view
set_starting_view(machine, index, window, options.view(), options.view(index)); set_starting_view(machine, index, window, options.view(), options.view(index));
// make the window title // make the window title
if (video_config.numscreens == 1) if (video_config.numscreens == 1)
sprintf(window->title, "%s: %s [%s]", emulator_info::get_appname(), machine.system().description, machine.system().name); sprintf(window->m_title, "%s: %s [%s]", emulator_info::get_appname(), machine.system().description, machine.system().name);
else else
sprintf(window->title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index); sprintf(window->m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index);
wp->set_window(window); wp->set_window(window);
@ -815,10 +815,10 @@ void sdl_window_info::video_window_destroy(running_machine &machine)
execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(machine, this)); execute_async_wait(&sdlwindow_video_window_destroy_wt, worker_param(machine, this));
// free the render target, after the textures! // free the render target, after the textures!
this->machine().render().target_free(target); this->machine().render().target_free(m_target);
// free the event // free the event
osd_event_free(rendered_event); osd_event_free(m_rendered_event);
} }
@ -836,11 +836,11 @@ void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight)
float size_score, best_score = 0.0f; float size_score, best_score = 0.0f;
// determine the minimum width/height for the selected target // determine the minimum width/height for the selected target
target->compute_minimum_size(minimum_width, minimum_height); m_target->compute_minimum_size(minimum_width, minimum_height);
// use those as the target for now // use those as the target for now
target_width = minimum_width * MAX(1, prescale); target_width = minimum_width * MAX(1, m_prescale);
target_height = minimum_height * MAX(1, prescale); target_height = minimum_height * MAX(1, m_prescale);
// if we're not stretching, allow some slop on the minimum since we can handle it // if we're not stretching, allow some slop on the minimum since we can handle it
{ {
@ -878,8 +878,8 @@ void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight)
size_score = 2.0f; size_score = 2.0f;
// refresh adds some points // refresh adds some points
if (refresh) if (m_refresh)
size_score *= 1.0f / (1.0f + fabsf(refresh - mode.refresh_rate) / 10.0f); size_score *= 1.0f / (1.0f + fabsf(m_refresh - mode.refresh_rate) / 10.0f);
osd_printf_verbose("%4dx%4d@%2d -> %f\n", (int)mode.w, (int)mode.h, (int) mode.refresh_rate, size_score); osd_printf_verbose("%4dx%4d@%2d -> %f\n", (int)mode.w, (int)mode.h, (int) mode.refresh_rate, size_score);
@ -903,11 +903,11 @@ void sdl_window_info::pick_best_mode(int *fswidth, int *fsheight)
SDL_Rect **modes; SDL_Rect **modes;
// determine the minimum width/height for the selected target // determine the minimum width/height for the selected target
target->compute_minimum_size(minimum_width, minimum_height); m_target->compute_minimum_size(minimum_width, minimum_height);
// use those as the target for now // use those as the target for now
target_width = minimum_width * MAX(1, prescale); target_width = minimum_width * MAX(1, m_prescale);
target_height = minimum_height * MAX(1, prescale); target_height = minimum_height * MAX(1, m_prescale);
// if we're not stretching, allow some slop on the minimum since we can handle it // if we're not stretching, allow some slop on the minimum since we can handle it
{ {
@ -986,12 +986,12 @@ void sdl_window_info::video_window_update(running_machine &machine)
execute_async(&sdlwindow_update_cursor_state_wt, worker_param(machine, this)); execute_async(&sdlwindow_update_cursor_state_wt, worker_param(machine, this));
// if we're visible and running and not in the middle of a resize, draw // if we're visible and running and not in the middle of a resize, draw
if (target != NULL) if (m_target != NULL)
{ {
int tempwidth, tempheight; int tempwidth, tempheight;
// see if the games video mode has changed // see if the games video mode has changed
target->compute_minimum_size(tempwidth, tempheight); m_target->compute_minimum_size(tempwidth, tempheight);
if (tempwidth != m_minwidth || tempheight != m_minheight) if (tempwidth != m_minwidth || tempheight != m_minheight)
{ {
m_minwidth = tempwidth; m_minwidth = tempwidth;
@ -999,7 +999,7 @@ void sdl_window_info::video_window_update(running_machine &machine)
if (!this->m_fullscreen) if (!this->m_fullscreen)
{ {
blit_surface_size(width, height); blit_surface_size(m_width, m_height);
//Don't resize window without user interaction; //Don't resize window without user interaction;
//window_resize(blitwidth, blitheight); //window_resize(blitwidth, blitheight);
} }
@ -1015,11 +1015,11 @@ void sdl_window_info::video_window_update(running_machine &machine)
else else
event_wait_ticks = 0; event_wait_ticks = 0;
if (osd_event_wait(rendered_event, event_wait_ticks)) if (osd_event_wait(m_rendered_event, event_wait_ticks))
{ {
if ((!fullscreen()) || (video_config.switchres)) if ((!fullscreen()) || (video_config.switchres))
{ {
blit_surface_size(width, height); blit_surface_size(m_width, m_height);
} }
else else
{ {
@ -1029,7 +1029,7 @@ void sdl_window_info::video_window_update(running_machine &machine)
// ensure the target bounds are up-to-date, and then get the primitives // ensure the target bounds are up-to-date, and then get the primitives
set_target_bounds(this); set_target_bounds(this);
render_primitive_list &primlist = target->get_primitives(); render_primitive_list &primlist = m_target->get_primitives();
// and redraw now // and redraw now
@ -1055,11 +1055,11 @@ static void set_starting_view(running_machine &machine, int index, sdl_window_in
view = defview; view = defview;
// query the video system to help us pick a view // query the video system to help us pick a view
viewindex = window->target->configured_view(view, index, video_config.numscreens); viewindex = window->m_target->configured_view(view, index, video_config.numscreens);
// set the view // set the view
window->target->set_view(viewindex); window->m_target->set_view(viewindex);
window->start_viewscreen=viewindex; window->m_start_viewscreen=viewindex;
} }
@ -1089,15 +1089,15 @@ static OSDWORK_CALLBACK( complete_create_wt )
if (video_config.switchres) if (video_config.switchres)
window->pick_best_mode(&tempwidth, &tempheight); window->pick_best_mode(&tempwidth, &tempheight);
} }
else if (window->windowed_width) else if (window->m_windowed_width)
{ {
// if we have a remembered size force the new window size to it // if we have a remembered size force the new window size to it
tempwidth = window->windowed_width; tempwidth = window->m_windowed_width;
tempheight = window->windowed_height; tempheight = window->m_windowed_height;
} }
else else
{ {
if (window->startmaximized) if (window->m_startmaximized)
{ {
tempwidth = tempheight = 0; tempwidth = tempheight = 0;
window->get_max_bounds(&tempwidth, &tempheight, video_config.keepaspect ); window->get_max_bounds(&tempwidth, &tempheight, video_config.keepaspect );
@ -1186,10 +1186,10 @@ static OSDWORK_CALLBACK( draw_video_contents_wt )
// Some configurations require events to be polled in the worker thread // Some configurations require events to be polled in the worker thread
sdlinput_process_events_buf(wp->machine()); sdlinput_process_events_buf(wp->machine());
window->primlist = wp->list(); window->m_primlist = wp->list();
// if no bitmap, just fill // if no bitmap, just fill
if (window->primlist == NULL) if (window->m_primlist == NULL)
{ {
} }
// otherwise, render with our drawing system // otherwise, render with our drawing system
@ -1202,7 +1202,7 @@ static OSDWORK_CALLBACK( draw_video_contents_wt )
} }
/* all done, ready for next */ /* all done, ready for next */
osd_event_set(window->rendered_event); osd_event_set(window->m_rendered_event);
osd_free(wp); osd_free(wp);
return NULL; return NULL;
@ -1237,21 +1237,21 @@ void sdl_window_info::constrain_to_aspect_ratio(int *window_width, int *window_h
{ {
case WMSZ_BOTTOM: case WMSZ_BOTTOM:
case WMSZ_TOP: case WMSZ_TOP:
target->compute_visible_area(10000, propheight, pixel_aspect, target->orientation(), propwidth, propheight); m_target->compute_visible_area(10000, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
break; break;
case WMSZ_LEFT: case WMSZ_LEFT:
case WMSZ_RIGHT: case WMSZ_RIGHT:
target->compute_visible_area(propwidth, 10000, pixel_aspect, target->orientation(), propwidth, propheight); m_target->compute_visible_area(propwidth, 10000, pixel_aspect, m_target->orientation(), propwidth, propheight);
break; break;
default: default:
target->compute_visible_area(propwidth, propheight, pixel_aspect, target->orientation(), propwidth, propheight); m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), propwidth, propheight);
break; break;
} }
// get the minimum width/height for the current layout // get the minimum width/height for the current layout
target->compute_minimum_size(minwidth, minheight); m_target->compute_minimum_size(minwidth, minheight);
// clamp against the absolute minimum // clamp against the absolute minimum
propwidth = MAX(propwidth, MIN_WINDOW_DIM); propwidth = MAX(propwidth, MIN_WINDOW_DIM);
@ -1284,7 +1284,7 @@ void sdl_window_info::constrain_to_aspect_ratio(int *window_width, int *window_h
propheight = MIN(propheight, maxheight); propheight = MIN(propheight, maxheight);
// compute the visible area based on the proposed rectangle // compute the visible area based on the proposed rectangle
target->compute_visible_area(propwidth, propheight, pixel_aspect, target->orientation(), viswidth, visheight); m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), viswidth, visheight);
*window_width = viswidth; *window_width = viswidth;
*window_height = visheight; *window_height = visheight;
@ -1301,7 +1301,7 @@ void sdl_window_info::get_min_bounds(int *window_width, int *window_height, int
INT32 minwidth, minheight; INT32 minwidth, minheight;
// get the minimum target size // get the minimum target size
this->target->compute_minimum_size(minwidth, minheight); this->m_target->compute_minimum_size(minwidth, minheight);
// expand to our minimum dimensions // expand to our minimum dimensions
if (minwidth < MIN_WINDOW_DIM) if (minwidth < MIN_WINDOW_DIM)

View File

@ -32,20 +32,43 @@ typedef UINT32 HashT;
// TYPE DEFINITIONS // TYPE DEFINITIONS
//============================================================ //============================================================
struct sdl_window_info;
class osd_renderer
{
public:
osd_renderer(sdl_window_info *window)
: m_window(window) { }
sdl_window_info &window() { return *m_window; }
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 y_to_render_target(int x, 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;
};
struct sdl_window_info struct sdl_window_info
{ {
sdl_window_info(running_machine *a_machine, sdl_monitor_info *a_monitor, sdl_window_info(running_machine *a_machine, sdl_monitor_info *a_monitor,
int index, const sdl_window_config *config) int index, const sdl_window_config *config)
: next(NULL), m_minwidth(0), m_minheight(0), : next(NULL), m_minwidth(0), m_minheight(0),
startmaximized(0), m_startmaximized(0),
rendered_event(0), target(0), primlist(NULL), dxdata(NULL), m_rendered_event(0), m_target(0), m_primlist(NULL), m_dxdata(NULL),
width(0), height(0), blitwidth(0), blitheight(0), m_width(0), m_height(0), m_blitwidth(0), m_blitheight(0),
start_viewscreen(0), m_start_viewscreen(0),
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
sdl_window(NULL), m_sdl_window(NULL),
resize_width(0), m_resize_width(0),
resize_height(0), m_resize_height(0),
last_resize(0), m_last_resize(0),
#else #else
screen_width(0), screen_height(0), screen_width(0), screen_height(0),
#endif #endif
@ -53,16 +76,16 @@ struct sdl_window_info
{ {
m_maxwidth = config->width; m_maxwidth = config->width;
m_maxheight = config->height; m_maxheight = config->height;
depth = config->depth; m_depth = config->depth;
refresh = config->refresh; m_refresh = config->refresh;
m_index = index; m_index = index;
//FIXME: these should be per_window in config-> or even better a bit set //FIXME: these should be per_window in config-> or even better a bit set
m_fullscreen = !video_config.windowed; m_fullscreen = !video_config.windowed;
prescale = video_config.prescale; m_prescale = video_config.prescale;
windowed_width = config->width; m_windowed_width = config->width;
windowed_height = config->height; m_windowed_height = config->height;
} }
void video_window_update(running_machine &machine); void video_window_update(running_machine &machine);
@ -87,59 +110,61 @@ struct sdl_window_info
void set_fullscreen(int afullscreen) { m_fullscreen = afullscreen; } void set_fullscreen(int afullscreen) { m_fullscreen = afullscreen; }
#if 1
// Draw Callbacks // Draw Callbacks
int (*create)(sdl_window_info *window, int width, int height); int (*create)(sdl_window_info *window, int m_width, int m_height);
void (*resize)(sdl_window_info *window, int width, int height); void (*resize)(sdl_window_info *window, int m_width, int m_height);
int (*draw)(sdl_window_info *window, UINT32 dc, int update); int (*draw)(sdl_window_info *window, UINT32 dc, int update);
void (*set_target_bounds)(sdl_window_info *window); void (*set_target_bounds)(sdl_window_info *window);
int (*xy_to_render_target)(sdl_window_info *window, int x, int y, int *xt, int *yt); int (*xy_to_render_target)(sdl_window_info *window, int x, int y, int *xt, int *yt);
void (*destroy_all_textures)(sdl_window_info *window); void (*destroy_all_textures)(sdl_window_info *window);
void (*destroy)(sdl_window_info *window); void (*destroy)(sdl_window_info *window);
void (*clear)(sdl_window_info *window); void (*clear)(sdl_window_info *window);
#endif
// window handle and info // window handle and info
char title[256]; char m_title[256];
// diverse flags // diverse flags
int m_minwidth, m_minheight; int m_minwidth, m_minheight;
int m_maxwidth, m_maxheight; int m_maxwidth, m_maxheight;
int depth; int m_depth;
int refresh; int m_refresh;
int windowed_width; int m_windowed_width;
int windowed_height; int m_windowed_height;
int startmaximized; int m_startmaximized;
// rendering info // rendering info
osd_event * rendered_event; osd_event * m_rendered_event;
render_target * target; render_target * m_target;
render_primitive_list *primlist; render_primitive_list *m_primlist;
// drawing data // drawing data
void * dxdata; void * m_dxdata;
// cache of physical width and height // cache of physical m_width and m_height
int width; int m_width;
int height; int m_height;
// current blitwidth and height // current m_blitwidth and m_height
int blitwidth; int m_blitwidth;
int blitheight; int m_blitheight;
int start_viewscreen; int m_start_viewscreen;
// GL specific // GL specific
int prescale; int m_prescale;
#if (SDLMAME_SDL2) #if (SDLMAME_SDL2)
// Needs to be here as well so we can identify window // Needs to be here as well so we can identify window
SDL_Window *sdl_window; SDL_Window *m_sdl_window;
// These are used in combine resizing events ... #if SDL13_COMBINE_RESIZE // These are used in combine resizing events ... #if SDL13_COMBINE_RESIZE
int resize_width; int m_resize_width;
int resize_height; int m_resize_height;
osd_ticks_t last_resize; osd_ticks_t m_last_resize;
#else #else
int screen_width; int m_screen_width;
int screen_height; int m_screen_height;
#endif #endif
private: private:
@ -151,6 +176,7 @@ private:
sdl_monitor_info * m_monitor; sdl_monitor_info * m_monitor;
int m_fullscreen; int m_fullscreen;
int m_index; int m_index;
osd_renderer * m_renderer;
}; };