SDL: More cleanups. (nw)

This commit is contained in:
R. Belmont 2014-09-01 22:38:35 +00:00
parent f83325f1a0
commit 4631c02ca0
7 changed files with 62 additions and 70 deletions

View File

@ -1,8 +1,8 @@
//============================================================ //============================================================
// //
// draw13.c - SDL 1.3 drawing implementation // draw13.c - SDL 2.0 drawing implementation
// //
// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. // Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions. // Visit http://mamedev.org for licensing and usage restrictions.
// //
// SDLMAME by Olivier Galibert and R. Belmont // SDLMAME by Olivier Galibert and R. Belmont
@ -145,17 +145,17 @@ struct sdl_info
// core functions // core functions
static void draw13_exit(void); static void drawsdl2_exit(void);
static void draw13_attach(sdl_draw_info *info, sdl_window_info *window); static void drawsdl2_attach(sdl_draw_info *info, sdl_window_info *window);
static int draw13_window_create(sdl_window_info *window, int width, int height); static int drawsdl2_window_create(sdl_window_info *window, int width, int height);
static void draw13_window_resize(sdl_window_info *window, int width, int height); static void drawsdl2_window_resize(sdl_window_info *window, int width, int height);
static void draw13_window_destroy(sdl_window_info *window); static void drawsdl2_window_destroy(sdl_window_info *window);
static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update); static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update);
static render_primitive_list &draw13_window_get_primitives(sdl_window_info *window); static render_primitive_list &drawsdl2_window_get_primitives(sdl_window_info *window);
static void draw13_destroy_all_textures(sdl_window_info *window); static void drawsdl2_destroy_all_textures(sdl_window_info *window);
static void draw13_window_clear(sdl_window_info *window); static void drawsdl2_window_clear(sdl_window_info *window);
static int draw13_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);
static void draw13_destroy_texture(sdl_info *sdl, texture_info *texture); static void drawsdl2_destroy_texture(sdl_info *sdl, texture_info *texture);
//============================================================ //============================================================
// Textures // Textures
@ -455,7 +455,7 @@ static int RendererSupportsFormat(SDL_Renderer *renderer, Uint32 format, Uint32
#endif #endif
//============================================================ //============================================================
// draw13_init // drawsdl2_init
//============================================================ //============================================================
static void add_list(copy_info **head, copy_info *element, Uint32 bm) static void add_list(copy_info **head, copy_info *element, Uint32 bm)
@ -486,13 +486,13 @@ static void expand_copy_info(copy_info *list)
} }
} }
int draw13_init(running_machine &machine, sdl_draw_info *callbacks) int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks)
{ {
const char *stemp; const char *stemp;
// fill in the callbacks // fill in the callbacks
callbacks->exit = draw13_exit; callbacks->exit = drawsdl2_exit;
callbacks->attach = draw13_attach; callbacks->attach = drawsdl2_attach;
osd_printf_verbose("Using SDL native texturing driver (SDL 2.0+)\n"); osd_printf_verbose("Using SDL native texturing driver (SDL 2.0+)\n");
@ -518,10 +518,10 @@ int draw13_init(running_machine &machine, sdl_draw_info *callbacks)
//============================================================ //============================================================
// draw13_exit // drawsdl2_exit
//============================================================ //============================================================
static void draw13_exit(void) static void drawsdl2_exit(void)
{ {
int i; int i;
copy_info *bi, *freeme; copy_info *bi, *freeme;
@ -539,32 +539,32 @@ static void draw13_exit(void)
} }
//============================================================ //============================================================
// draw13_attach // drawsdl2_attach
//============================================================ //============================================================
static void draw13_attach(sdl_draw_info *info, sdl_window_info *window) static void drawsdl2_attach(sdl_draw_info *info, sdl_window_info *window)
{ {
// fill in the callbacks // fill in the callbacks
window->create = draw13_window_create; window->create = drawsdl2_window_create;
window->resize = draw13_window_resize; window->resize = drawsdl2_window_resize;
window->get_primitives = draw13_window_get_primitives; window->get_primitives = drawsdl2_window_get_primitives;
window->draw = draw13_window_draw; window->draw = drawsdl2_window_draw;
window->destroy = draw13_window_destroy; window->destroy = drawsdl2_window_destroy;
window->destroy_all_textures = draw13_destroy_all_textures; window->destroy_all_textures = drawsdl2_destroy_all_textures;
window->clear = draw13_window_clear; window->clear = drawsdl2_window_clear;
window->xy_to_render_target = draw13_xy_to_render_target; window->xy_to_render_target = drawsdl2_xy_to_render_target;
} }
//============================================================ //============================================================
// draw13_window_create // drawsdl2_window_create
//============================================================ //============================================================
static int draw13_window_create(sdl_window_info *window, int width, int height) static int drawsdl2_window_create(sdl_window_info *window, int width, int height)
{ {
// allocate memory for our structures // allocate memory for our structures
sdl_info *sdl = (sdl_info *) osd_malloc(sizeof(*sdl)); sdl_info *sdl = (sdl_info *) osd_malloc(sizeof(*sdl));
osd_printf_verbose("Enter draw13_window_create\n"); osd_printf_verbose("Enter drawsdl2_window_create\n");
memset(sdl, 0, sizeof(*sdl)); memset(sdl, 0, sizeof(*sdl));
@ -638,15 +638,15 @@ static int draw13_window_create(sdl_window_info *window, int width, int height)
sdl->texture_max_height = 64; sdl->texture_max_height = 64;
SDL_RenderPresent(sdl->sdl_renderer); SDL_RenderPresent(sdl->sdl_renderer);
osd_printf_verbose("Leave draw13_window_create\n"); osd_printf_verbose("Leave drawsdl2_window_create\n");
return 0; return 0;
} }
//============================================================ //============================================================
// draw13_window_resize // drawsdl2_window_resize
//============================================================ //============================================================
static void draw13_window_resize(sdl_window_info *window, int width, int height) static void drawsdl2_window_resize(sdl_window_info *window, int width, int height)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->dxdata;
@ -665,7 +665,7 @@ static void draw13_window_resize(sdl_window_info *window, int width, int height)
// drawsdl_xy_to_render_target // drawsdl_xy_to_render_target
//============================================================ //============================================================
static int draw13_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_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->dxdata;
@ -679,10 +679,10 @@ static int draw13_xy_to_render_target(sdl_window_info *window, int x, int y, int
} }
//============================================================ //============================================================
// draw13_window_get_primitives // drawsdl2_window_get_primitives
//============================================================ //============================================================
static render_primitive_list &draw13_window_get_primitives(sdl_window_info *window) static render_primitive_list &drawsdl2_window_get_primitives(sdl_window_info *window)
{ {
if ((!window->fullscreen) || (video_config.switchres)) if ((!window->fullscreen) || (video_config.switchres))
{ {
@ -697,10 +697,10 @@ static render_primitive_list &draw13_window_get_primitives(sdl_window_info *wind
} }
//============================================================ //============================================================
// draw13_window_draw // drawsdl2_window_draw
//============================================================ //============================================================
static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update) static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->dxdata;
render_primitive *prim; render_primitive *prim;
@ -809,10 +809,10 @@ static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update)
//============================================================ //============================================================
// draw13_window_clear // drawsdl2_window_clear
//============================================================ //============================================================
static void draw13_window_clear(sdl_window_info *window) static void drawsdl2_window_clear(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->dxdata;
@ -821,10 +821,10 @@ static void draw13_window_clear(sdl_window_info *window)
//============================================================ //============================================================
// draw13_window_destroy // drawsdl2_window_destroy
//============================================================ //============================================================
static void draw13_window_destroy(sdl_window_info *window) static void drawsdl2_window_destroy(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->dxdata;
@ -834,7 +834,7 @@ static void draw13_window_destroy(sdl_window_info *window)
// free the memory in the window // free the memory in the window
draw13_destroy_all_textures(window); drawsdl2_destroy_all_textures(window);
SDL_DestroyWindow(window->sdl_window); SDL_DestroyWindow(window->sdl_window);
@ -1107,7 +1107,7 @@ static texture_info *texture_find(sdl_info *sdl, const render_primitive *prim, q
texture_info *expire = texture; texture_info *expire = texture;
texture = texture->next; texture = texture->next;
if (now - expire->last_access > osd_ticks_per_second()) if (now - expire->last_access > osd_ticks_per_second())
draw13_destroy_texture(sdl, expire); drawsdl2_destroy_texture(sdl, expire);
} }
// nothing found // nothing found
@ -1147,7 +1147,7 @@ static texture_info * texture_update(sdl_window_info *window, const render_primi
return texture; return texture;
} }
static void draw13_destroy_texture(sdl_info *sdl, texture_info *texture) static void drawsdl2_destroy_texture(sdl_info *sdl, texture_info *texture)
{ {
texture_info *p; texture_info *p;
@ -1169,7 +1169,7 @@ static void draw13_destroy_texture(sdl_info *sdl, texture_info *texture)
osd_free(texture); osd_free(texture);
} }
static void draw13_destroy_all_textures(sdl_window_info *window) static void drawsdl2_destroy_all_textures(sdl_window_info *window)
{ {
sdl_info *sdl = (sdl_info *) window->dxdata; sdl_info *sdl = (sdl_info *) window->dxdata;
texture_info *next_texture=NULL, *texture = NULL; texture_info *next_texture=NULL, *texture = NULL;
@ -1189,7 +1189,7 @@ static void draw13_destroy_all_textures(sdl_window_info *window)
while (texture) while (texture)
{ {
next_texture = texture->next; next_texture = texture->next;
draw13_destroy_texture(sdl, texture); drawsdl2_destroy_texture(sdl, texture);
texture = next_texture; texture = next_texture;
} }

View File

@ -82,9 +82,8 @@
#define SDLOPTVAL_AUTO "auto" #define SDLOPTVAL_AUTO "auto"
#define SDLOPTVAL_OPENGL "opengl" #define SDLOPTVAL_OPENGL "opengl"
#define SDLOPTVAL_OPENGL16 "opengl16"
#define SDLOPTVAL_SOFT "soft" #define SDLOPTVAL_SOFT "soft"
#define SDLOPTVAL_SDL13 "sdl13" #define SDLOPTVAL_SDL2ACCEL "accel"
#define SDLMAME_LED(x) "led" #x #define SDLMAME_LED(x) "led" #x

View File

@ -59,7 +59,7 @@ USE_DISPATCH_GL = 1
# active development on sdlmame or SDL. # active development on sdlmame or SDL.
# uncomment the next line to compile and link against SDL2.0 # uncomment the next line to compile and link against SDL2.0
# SDL_LIBVER = sdl2 #SDL_LIBVER = sdl2
# uncomment the next line to use couriersud's multi-keyboard patch for SDL 2.1? (this API was removed prior to the 2.0 release) # uncomment the next line to use couriersud's multi-keyboard patch for SDL 2.1? (this API was removed prior to the 2.0 release)
# SDL2_MULTIAPI = 1 # SDL2_MULTIAPI = 1

View File

@ -2,7 +2,7 @@
// //
// video.c - SDL video handling // video.c - SDL video handling
// //
// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. // Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions. // Visit http://mamedev.org for licensing and usage restrictions.
// //
// SDLMAME by Olivier Galibert and R. Belmont // SDLMAME by Olivier Galibert and R. Belmont
@ -645,15 +645,9 @@ static void extract_video_config(running_machine &machine)
} }
else if (USE_OPENGL && (strcmp(stemp, SDLOPTVAL_OPENGL) == 0)) else if (USE_OPENGL && (strcmp(stemp, SDLOPTVAL_OPENGL) == 0))
video_config.mode = VIDEO_MODE_OPENGL; video_config.mode = VIDEO_MODE_OPENGL;
else if (USE_OPENGL && (strcmp(stemp, SDLOPTVAL_OPENGL16) == 0)) else if (SDLMAME_SDL2 && (strcmp(stemp, SDLOPTVAL_SDL2ACCEL) == 0))
{ {
video_config.mode = VIDEO_MODE_OPENGL; video_config.mode = VIDEO_MODE_SDL2ACCEL;
video_config.prefer16bpp_tex = 1;
}
else if (SDLMAME_SDL2 && (strcmp(stemp, SDLOPTVAL_SDL13) == 0))
{
video_config.mode = VIDEO_MODE_SDL13;
video_config.prefer16bpp_tex = 1;
} }
else else
{ {
@ -684,7 +678,6 @@ static void extract_video_config(running_machine &machine)
video_config.prescale = 1; video_config.prescale = 1;
} }
// default to working video please // default to working video please
video_config.prefer16bpp_tex = 0;
video_config.forcepow2texture = options.gl_force_pow2_texture(); video_config.forcepow2texture = options.gl_force_pow2_texture();
video_config.allowtexturerect = !(options.gl_no_texture_rect()); video_config.allowtexturerect = !(options.gl_no_texture_rect());
video_config.vbo = options.gl_vbo(); video_config.vbo = options.gl_vbo();

View File

@ -2,7 +2,7 @@
// //
// video.h - SDL implementation of MAME video routines // video.h - SDL implementation of MAME video routines
// //
// Copyright (c) 1996-2006, Nicola Salmoria and the MAME Team. // Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions. // Visit http://mamedev.org for licensing and usage restrictions.
// //
// SDLMAME by Olivier Galibert and R. Belmont // SDLMAME by Olivier Galibert and R. Belmont
@ -21,7 +21,7 @@
enum { enum {
VIDEO_MODE_SOFT = 0, VIDEO_MODE_SOFT = 0,
VIDEO_MODE_OPENGL, VIDEO_MODE_OPENGL,
VIDEO_MODE_SDL13 VIDEO_MODE_SDL2ACCEL
}; };
#define VIDEO_SCALE_MODE_NONE (0) #define VIDEO_SCALE_MODE_NONE (0)
@ -109,7 +109,6 @@ struct sdl_video_config
// OpenGL options // OpenGL options
int filter; // enable filtering, disabled if glsl_filter>0 int filter; // enable filtering, disabled if glsl_filter>0
int prefer16bpp_tex;
int glsl; int glsl;
int glsl_filter; // glsl filtering, >0 disables filter int glsl_filter; // glsl filtering, >0 disables filter
char * glsl_shader_mamebm[GLSL_SHADER_MAX]; // custom glsl shader set, mame bitmap char * glsl_shader_mamebm[GLSL_SHADER_MAX]; // custom glsl shader set, mame bitmap

View File

@ -2,7 +2,7 @@
// //
// window.c - SDL window handling // window.c - SDL window handling
// //
// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. // Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions. // Visit http://mamedev.org for licensing and usage restrictions.
// //
// SDLMAME by Olivier Galibert and R. Belmont // SDLMAME by Olivier Galibert and R. Belmont
@ -239,9 +239,9 @@ bool sdl_osd_interface::window_init()
} }
#endif #endif
#if SDLMAME_SDL2 #if SDLMAME_SDL2
if (video_config.mode == VIDEO_MODE_SDL13) if (video_config.mode == VIDEO_MODE_SDL2ACCEL)
{ {
if (draw13_init(machine(), &draw)) if (drawsdl2_init(machine(), &draw))
video_config.mode = VIDEO_MODE_SOFT; video_config.mode = VIDEO_MODE_SOFT;
} }
#endif #endif
@ -974,6 +974,7 @@ void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *wi
{ {
window->minwidth = tempwidth; window->minwidth = tempwidth;
window->minheight = tempheight; window->minheight = tempheight;
if (!window->fullscreen) if (!window->fullscreen)
{ {
sdlwindow_blit_surface_size(window, window->width, window->height); sdlwindow_blit_surface_size(window, window->width, window->height);

View File

@ -2,7 +2,7 @@
// //
// window.h - SDL window handling // window.h - SDL window handling
// //
// Copyright (c) 1996-2006, Nicola Salmoria and the MAME Team. // Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions. // Visit http://mamedev.org for licensing and usage restrictions.
// //
// SDLMAME by Olivier Galibert and R. Belmont // SDLMAME by Olivier Galibert and R. Belmont
@ -147,6 +147,6 @@ int drawogl_init(running_machine &machine, sdl_draw_info *callbacks);
// PROTOTYPES - draw13.c // PROTOTYPES - draw13.c
//============================================================ //============================================================
int draw13_init(running_machine &machine, sdl_draw_info *callbacks); int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks);
#endif /* __SDLWINDOW__ */ #endif /* __SDLWINDOW__ */