updated sdl os-core to compile against stock SDL-2.0 [couriersud].

- The SDL team has moved from 1.3 to 2.0. At the same time, changes were made to allow SDL1.2 and SDL2.0 to coexist. All SDL2.0 include files are now in /usr/include/SDL2.
- Added sdlinc.h to avoid having tons of #ifdef .. #include in the code.
- Scalemode is no longer a per-window setting
- Fixed a bug in YUV rendering.
- Use SDL_GetClipboard (SDL2.0)
- Updated README_SDL20.txt

Currently, SDL 2.0 is only supported on *nix. Volunteers welcome.
This commit is contained in:
Couriersud 2012-02-12 20:59:24 +00:00
parent d75dbab0de
commit 5344166555
29 changed files with 327 additions and 264 deletions

3
.gitattributes vendored
View File

@ -5110,7 +5110,7 @@ src/osd/osdmini/osdmini.h svneol=native#text/plain
src/osd/osdmini/osdmini.mak svneol=native#text/plain
src/osd/osdnet.c svneol=native#text/plain
src/osd/osdnet.h svneol=native#text/plain
src/osd/sdl/README_SDL13.txt svneol=native#text/plain
src/osd/sdl/README_SDL20.txt svneol=native#text/plain
src/osd/sdl/SDL1211_opengl.h svneol=native#text/plain
src/osd/sdl/SDLMain_tmpl.h svneol=native#text/plain
src/osd/sdl/SDLMain_tmpl.m svneol=native#text/plain
@ -5171,6 +5171,7 @@ src/osd/sdl/sdl.mak svneol=native#text/plain
src/osd/sdl/sdldir.c svneol=native#text/plain
src/osd/sdl/sdlfile.c svneol=native#text/plain
src/osd/sdl/sdlfile.h svneol=native#text/plain
src/osd/sdl/sdlinc.h svneol=native#text/plain
src/osd/sdl/sdlmain.c svneol=native#text/plain
src/osd/sdl/sdlmisc_macosx.c svneol=native#text/plain
src/osd/sdl/sdlmisc_os2.c svneol=native#text/plain

View File

@ -1,25 +1,12 @@
======================================================================================
SDLMAME only supports SDL hg revisions up to 4464
Every revision after 4464 has multi-mice/multi-keyboard ripped out.
Revisions >= 4465 will not work with SDLMAME.
To build a version suitable for SDLMAME, use ...
hg clone http://hg.libsdl.org/SDL
hg update 4464
sh autogen.sh
./configure --prefix=/usr/local/sdl13 --enable-maintainer-mode --disable-video-directfb --disable-fusionsound
Know caveats: DirectFB is broken (will not compile)
SDLMAME now supports SDL from version 2.0 on upwards.
=======================================================================================
Warning
=======
- SDL1.3 still is still under development, the following may or may not
- SDL2.0 still is still under development, the following may or may not
work.
- if you are using wine on unix be sure to disable wintab32.dll
@ -27,14 +14,14 @@ Known bugs:
===========
* SDL1.3/X11: Some compound keys, e.g. "'" are not supported by SDL driver
* SDL1.3: sdlvideofps does not take -numscreens>1 into account.
* SDL2.0: sdlvideofps does not take -numscreens>1 into account.
* SDL1.3/WIN32: crashes with -rd d3d
* SDL1.3/WIN32: resizing does not work
Build SDL 1.3 from SVN
Build SDL 2.0 from HG
======================
Pull 1.3 from svn. Than
Pull 2.0 from hg. Than
sh autogen.sh
./configure --prefix=/usr/local/sdl13/ --disable-video-svga --enable-video-directfb --enable-fusionsound
@ -53,6 +40,7 @@ Replace /usr/local/sdl13 above with a safe location, this may as well be a direc
Edit sdl.mak to have
SDL_LIBVER = sdl2
SDL_INSTALL_ROOT = /usr/local/sdl13
That's it.
@ -86,8 +74,7 @@ the same time performs any necessary rotation.
Basic usage examples:
X11/opengl: ./mamed -video sdl13 -rd opengl mario
DFB/DFB: ./mamed -video sdl13 -rd directfb mario
WIN32/opengl ./mamed -video sdl13 -rd opengl mario
DFB/DFB: ./mamed -video sdl13 -vd directfb -rd directfb mario
The performance of the directfb driver depends on the combined
support of the kernel framebuffer driver and the directfb driver.
@ -101,24 +88,20 @@ X11,DFB,WIN32 ./mamed -video sdl13 -rd software
Soft:
=====
./mamed -mt -video soft -ym none -numscreens 2 mario
./mamed -mt -video soft -sm none -numscreens 2 mario
OpenGL:
=======
Plain opengl does work. Anything more advanced like pbo, fbo or glsl will
most probably not.
most probably not work with more than one screen.
./mamed -mt -video opengl mario -ym none -nogl_pbo -numscreens 2
./mamed -mt -video opengl mario -nogl_pbo -nogl_vbo -nogl_glsl -numscreens 2
YUV - modes:
============
./mamed -mt -video soft -rd software -ym yuy2 -numscreens 2 mario
The "-rd" overwrites the default which is built-in opengl. This renderer
does not support yuv modes. The software driver does support them non-accelarated.
This has been left in for the time Xv is once again implemented in SDL.
./mamed -mt -video soft -sm yuy2 mario
Using DirectFB, the following should get you going
@ -142,10 +125,8 @@ yv12, yv12x2, yuy2, yuy2x2:
Rendering in software / scaling with hardware (if supported)
Whether these are actually hardware accelerated depends on the SDL driver
and the hardware. The current SDL X11 driver needs opengl for rendering but
does not support yuv textures. The "to-be-submitted" SDL directfb driver
supports all above if the hardware supports it. However, only one YUV-texture
per display is supported. The second window consequently will get "software"
YUV blitting.
and the hardware. The SDL directfb driver supports all above if the hardware
supports it. However, only one YUV-texture per display is supported.
The second window consequently will get "software" YUV blitting.

View File

@ -1276,8 +1276,7 @@ on_memoryview_key_press_event(GtkWidget *widget,
#else
#include <SDL/SDL.h>
#include <SDL/SDL_version.h>
#include "sdlinc.h"
#include "emu.h"
#include "osdepend.h"

View File

@ -18,7 +18,7 @@
#include "options.h"
// standard SDL headers
#include <SDL/SDL.h>
#include "sdlinc.h"
// OSD headers
#include "osdsdl.h"
@ -379,11 +379,11 @@ INLINE void render_quad(sdl_info *sdl, texture_info *texture, render_primitive *
#if 0
if ((PRIMFLAG_GET_SCREENTEX(prim->flags)) && video_config.filter)
{
SDL_SetTextureScaleMode(texture->texture_id, SDL_SCALEMODE_BEST);
SDL_SetTextureScaleMode(texture->texture_id, DRAW2_SCALEMODE_BEST);
}
else
{
SDL_SetTextureScaleMode(texture->texture_id, SDL_SCALEMODE_NONE);
SDL_SetTextureScaleMode(texture->texture_id, DRAW2_SCALEMODE_NEAREST);
}
#endif
SDL_SetTextureBlendMode(texture_id, texture->sdl_blendmode);
@ -497,7 +497,7 @@ int draw13_init(running_machine &machine, sdl_draw_info *callbacks)
callbacks->exit = draw13_exit;
callbacks->attach = draw13_attach;
mame_printf_verbose("Using SDL native texturing driver (SDL 1.3+)\n");
mame_printf_verbose("Using SDL native texturing driver (SDL 2.0+)\n");
expand_copy_info(blit_info_default);
//FIXME: -opengl16 should be -opengl -prefer16bpp
@ -577,6 +577,9 @@ static int draw13_window_create(sdl_window_info *window, int width, int height)
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
// create the SDL window
window->sdl_window = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED_DISPLAY(window->monitor->handle), SDL_WINDOWPOS_UNDEFINED,
width, height, sdl->extra_flags);
if (window->fullscreen && video_config.switchres)
{
SDL_DisplayMode mode;
@ -610,15 +613,12 @@ static int draw13_window_create(sdl_window_info *window, int width, int height)
else
SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
window->sdl_window = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED_DISPLAY(window->monitor->handle), SDL_WINDOWPOS_UNDEFINED,
width, height, sdl->extra_flags);
// create renderer
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->sdl_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
else
sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0);
sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, SDL_RENDERER_ACCELERATED);
if (!sdl->sdl_renderer)
{
@ -721,6 +721,7 @@ static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update)
SDL_SetWindowSize(window->sdl_window, sdl->resize_width, sdl->resize_height);
SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
sdl->resize_pending = 0;
SDL_RenderSetViewport(sdl->sdl_renderer, NULL);
}
//SDL_SelectRenderer(window->sdl_window);

View File

@ -24,7 +24,7 @@
#include "emuopts.h"
// standard SDL headers
#include <SDL/SDL.h>
#include "sdlinc.h"
// OpenGL headers
#include "osd_opengl.h"
@ -219,7 +219,7 @@ struct _sdl_info
INT32 blittimer;
UINT32 extra_flags;
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
SDL_GLContext gl_context_id;
#else
// SDL surface
@ -437,15 +437,14 @@ int drawogl_init(running_machine &machine, sdl_draw_info *callbacks)
dll_loaded = 0;
if (SDL_VERSION_ATLEAST(1,3,0))
mame_printf_verbose("Using SDL multi-window OpenGL driver (SDL 1.3+)\n");
if (SDLMAME_SDL2)
{
mame_printf_verbose("Using SDL multi-window OpenGL driver (SDL 2.0+)\n");
load_gl_lib(machine);
}
else
mame_printf_verbose("Using SDL single-window OpenGL driver (SDL 1.2)\n");
#if (SDL_VERSION_ATLEAST(1,3,0))
load_gl_lib(machine);
#endif
return 0;
}
@ -546,7 +545,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
window->dxdata = sdl;
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
sdl->extra_flags = (window->fullscreen ?
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_FULLSCREEN : SDL_WINDOW_RESIZABLE);
sdl->extra_flags |= SDL_WINDOW_OPENGL;
@ -556,6 +555,14 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
//load_gl_lib(window->machine());
// create the SDL window
window->sdl_window = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED_DISPLAY(window->monitor->handle), SDL_WINDOWPOS_UNDEFINED,
width, height, sdl->extra_flags);
if (!window->sdl_window )
{
mame_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
return 1;
}
if (window->fullscreen && video_config.switchres)
{
@ -570,15 +577,6 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
else
SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
window->sdl_window = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED_DISPLAY(window->monitor->handle), SDL_WINDOWPOS_UNDEFINED,
width, height, sdl->extra_flags);
if (!window->sdl_window )
{
mame_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
return 1;
}
SDL_ShowWindow(window->sdl_window);
//SDL_SetWindowFullscreen(window->sdl_window, window->fullscreen);
SDL_RaiseWindow(window->sdl_window);
@ -798,7 +796,7 @@ static void drawogl_window_resize(sdl_window_info *window, int width, int height
{
sdl_info *sdl = (sdl_info *) window->dxdata;
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
//SDL_GL_MakeCurrent(window->sdl_window, sdl->gl_context_id);
SDL_SetWindowSize(window->sdl_window, width, height);
SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
@ -1190,7 +1188,7 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
return 0;
}
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
SDL_GL_MakeCurrent(window->sdl_window, sdl->gl_context_id);
#endif
if (sdl->init_context)
@ -1546,7 +1544,7 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update)
window->primlist->release_lock();
sdl->init_context = 0;
#if (!SDL_VERSION_ATLEAST(1,3,0))
#if (!SDLMAME_SDL2)
SDL_GL_SwapBuffers();
#else
SDL_GL_SwapWindow(window->sdl_window);
@ -1721,7 +1719,7 @@ static void drawogl_window_destroy(sdl_window_info *window)
drawogl_destroy_all_textures(window);
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
SDL_GL_DeleteContext(sdl->gl_context_id);
SDL_DestroyWindow(window->sdl_window);
#else
@ -3135,7 +3133,7 @@ static void drawogl_destroy_all_textures(sdl_window_info *window)
if ( !sdl->initialized )
return;
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
SDL_GL_MakeCurrent(window->sdl_window, sdl->gl_context_id);
#endif

View File

@ -18,7 +18,7 @@
#include "ui.h"
// standard SDL headers
#include <SDL/SDL.h>
#include "sdlinc.h"
// OSD headers
#include "osdsdl.h"
@ -38,11 +38,10 @@
typedef struct _sdl_scale_mode sdl_scale_mode;
// FIXME: Only until there is a final decision from SAM on scalemodes
#if (SDL_VERSION_ATLEAST(1,3,0))
#define SDL_SCALEMODE_NONE (0)
#define SDL_SCALEMODE_FAST (0)
#define SDL_SCALEMODE_BEST (0)
#if (SDLMAME_SDL2)
#define DRAW2_SCALEMODE_NEAREST "0"
#define DRAW2_SCALEMODE_LINEAR "1"
#define DRAW2_SCALEMODE_BEST "2"
#endif
/* sdl_info is the information about SDL for the current screen */
@ -52,7 +51,8 @@ struct _sdl_info
INT32 blittimer;
UINT32 extra_flags;
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
SDL_Renderer *sdl_renderer;
SDL_Texture *texture_id;
#else
// SDL surface
@ -73,10 +73,6 @@ struct _sdl_info
int last_vofs;
int old_blitwidth;
int old_blitheight;
// shortcut to scale mode info
const sdl_scale_mode *scale_mode;
};
struct _sdl_scale_mode
@ -86,11 +82,10 @@ struct _sdl_scale_mode
int is_yuv; /* Yuv mode? */
int mult_w; /* Width multiplier */
int mult_h; /* Height multiplier */
#if (!SDL_VERSION_ATLEAST(1,3,0))
#if (!SDLMAME_SDL2)
int extra_flags; /* Texture/surface flags */
#else
//SDL_ScaleMode sdl_scale_mode; /* sdl 1.3 scale mode */
int sdl_scale_mode; /* got removed recently - trying to get it in again */
const char *sdl_scale_mode; /* what to use as a hint ? */
#endif
int pixel_format; /* Pixel/Overlay format */
void (*yuv_blit)(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pitch);
@ -116,7 +111,7 @@ static void drawsdl_destroy_all_textures(sdl_window_info *window);
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);
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight);
#endif
@ -137,7 +132,7 @@ static void yuv_RGB_to_YUY2X2(UINT16 *bitmap, sdl_info *sdl, UINT8 *ptr, int pit
// Static declarations
#if (!SDL_VERSION_ATLEAST(1,3,0))
#if (!SDLMAME_SDL2)
static int shown_video_info = 0;
static const sdl_scale_mode scale_modes[] =
@ -153,13 +148,13 @@ static const sdl_scale_mode scale_modes[] =
#else
static const sdl_scale_mode scale_modes[] =
{
{ "none", 0, 0, 0, 0, SDL_SCALEMODE_NONE, 0, 0 },
{ "hwblit", 1, 0, 1, 1, SDL_SCALEMODE_FAST, 0, 0 },
{ "hwbest", 1, 0, 1, 1, SDL_SCALEMODE_BEST, 0, 0 },
{ "yv12", 1, 1, 1, 1, SDL_SCALEMODE_NONE, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12 },
{ "yv12x2", 1, 1, 2, 2, SDL_SCALEMODE_NONE, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12X2 },
{ "yuy2", 1, 1, 1, 1, SDL_SCALEMODE_NONE, SDL_PIXELFORMAT_YUY2, yuv_RGB_to_YUY2 },
{ "yuy2x2", 1, 1, 2, 1, SDL_SCALEMODE_NONE, SDL_PIXELFORMAT_YUY2, yuv_RGB_to_YUY2X2 },
{ "none", 0, 0, 0, 0, DRAW2_SCALEMODE_NEAREST, 0, 0 },
{ "hwblit", 1, 0, 1, 1, DRAW2_SCALEMODE_LINEAR, 0, 0 },
{ "hwbest", 1, 0, 1, 1, DRAW2_SCALEMODE_BEST, 0, 0 },
{ "yv12", 1, 1, 1, 1, DRAW2_SCALEMODE_NEAREST, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12 },
{ "yv12x2", 1, 1, 2, 2, DRAW2_SCALEMODE_NEAREST, SDL_PIXELFORMAT_YV12, yuv_RGB_to_YV12X2 },
{ "yuy2", 1, 1, 1, 1, DRAW2_SCALEMODE_NEAREST, SDL_PIXELFORMAT_YUY2, yuv_RGB_to_YUY2 },
{ "yuy2x2", 1, 1, 2, 1, DRAW2_SCALEMODE_NEAREST, SDL_PIXELFORMAT_YUY2, yuv_RGB_to_YUY2X2 },
{ NULL }
};
#endif
@ -208,8 +203,8 @@ int drawsdl_init(sdl_draw_info *callbacks)
callbacks->exit = drawsdl_exit;
callbacks->attach = drawsdl_attach;
if (SDL_VERSION_ATLEAST(1,3,0))
mame_printf_verbose("Using SDL multi-window soft driver (SDL 1.3+)\n");
if (SDLMAME_SDL2)
mame_printf_verbose("Using SDL multi-window soft driver (SDL 2.0+)\n");
else
mame_printf_verbose("Using SDL single-window soft driver (SDL 1.2)\n");
@ -254,11 +249,11 @@ static void drawsdl_destroy_all_textures(sdl_window_info *window)
// setup_texture for window
//============================================================
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight)
{
sdl_info *sdl = (sdl_info *) window->dxdata;
const sdl_scale_mode *sdl_sm = sdl->scale_mode;
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
SDL_DisplayMode mode;
UINT32 fmt;
@ -278,6 +273,9 @@ static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight
{
sdl->hw_scale_width *= video_config.prescale;
sdl->hw_scale_height *= video_config.prescale;
/* This must be a multiple of 2 */
sdl->hw_scale_width = (sdl->hw_scale_width + 1) & ~1;
}
}
@ -291,17 +289,14 @@ static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight
int w = sdl->hw_scale_width * sdl_sm->mult_w;
int h = sdl->hw_scale_height * sdl_sm->mult_h;
sdl->texture_id = SDL_CreateTexture(window->sdl_renderer, fmt, SDL_TEXTUREACCESS_STREAMING, w, h);
sdl->texture_id = SDL_CreateTexture(sdl->sdl_renderer, fmt, SDL_TEXTUREACCESS_STREAMING, w, h);
}
else
{
sdl->texture_id = SDL_CreateTexture(window->sdl_renderer,fmt, SDL_TEXTUREACCESS_STREAMING,
sdl->texture_id = SDL_CreateTexture(sdl->sdl_renderer,fmt, SDL_TEXTUREACCESS_STREAMING,
tempwidth, tempheight);
}
//SDL_SetTextureScaleMode(window->sdl_renderer,sdl->texture_id, sdl_sm->sdl_scale_mode);
}
#endif
@ -309,11 +304,11 @@ static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight
// yuv_overlay_init
//============================================================
#if (!SDL_VERSION_ATLEAST(1,3,0))
#if (!SDLMAME_SDL2)
static void yuv_overlay_init(sdl_window_info *window)
{
sdl_info *sdl = (sdl_info *) window->dxdata;
const sdl_scale_mode *sdl_sm = sdl->scale_mode;
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
int minimum_width, minimum_height;
window->target->compute_minimum_size(minimum_width, minimum_height);
@ -364,7 +359,7 @@ static void yuv_overlay_init(sdl_window_info *window)
// drawsdl_show_info
//============================================================
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
static void drawsdl_show_info(sdl_window_info *window, struct SDL_RendererInfo *render_info)
{
#define RF_ENTRY(x) {x, #x }
@ -400,6 +395,7 @@ static void drawsdl_show_info(sdl_window_info *window, struct SDL_RendererInfo *
static int drawsdl_window_create(sdl_window_info *window, int width, int height)
{
sdl_info *sdl;
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
// allocate memory for our structures
sdl = (sdl_info *) osd_malloc(sizeof(sdl_info));
@ -407,13 +403,19 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
window->dxdata = sdl;
sdl->scale_mode = &scale_modes[window->scale_mode];
#if (SDLMAME_SDL2)
/* set hints ... */
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, sm->sdl_scale_mode);
#if (SDL_VERSION_ATLEAST(1,3,0))
sdl->extra_flags = (window->fullscreen ?
SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS
| SDL_WINDOW_INPUT_GRABBED : SDL_WINDOW_RESIZABLE);
window->sdl_window = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height, sdl->extra_flags);
if (window->fullscreen && video_config.switchres)
{
SDL_DisplayMode mode;
@ -427,8 +429,6 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
else
SDL_SetWindowDisplayMode(window->sdl_window, NULL); // Use desktop
window->sdl_window = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height, sdl->extra_flags);
SDL_ShowWindow(window->sdl_window);
SDL_SetWindowFullscreen(window->sdl_window, (SDL_bool) window->fullscreen);
@ -442,34 +442,33 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
// create a texture
if (video_config.waitvsync)
window->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD |*/ SDL_RENDERER_PRESENTVSYNC);
sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD |*/ SDL_RENDERER_PRESENTVSYNC);
else
window->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0);
sdl->sdl_renderer = SDL_CreateRenderer(window->sdl_window, -1, /*SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD*/ 0);
//SDL_SelectRenderer(window->sdl_window);
{
struct SDL_RendererInfo render_info;
SDL_GetRendererInfo(window->sdl_renderer, &render_info);
SDL_GetRendererInfo(sdl->sdl_renderer, &render_info);
drawsdl_show_info(window, &render_info);
// Check scale mode
if (sdl->scale_mode->pixel_format)
if (sm->pixel_format)
{
int i;
int found = 0;
for (i=0; i < render_info.num_texture_formats; i++)
if (sdl->scale_mode->pixel_format == render_info.texture_formats[i])
if (sm->pixel_format == render_info.texture_formats[i])
found = 1;
if (!found)
{
mame_printf_verbose("window: Scale mode %s not supported! Using default.\n", sdl->scale_mode->name);
ui_popup_time(3, "Scale mode %s not supported! Using default.", sdl->scale_mode->name);
sdl->scale_mode = &scale_modes[0];
mame_printf_verbose("window: Scale mode %s not supported!\n", sm->name);
ui_popup_time(3, "Scale mode %s not supported!", sm->name);
}
}
}
@ -478,7 +477,7 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
#else
sdl->extra_flags = (window->fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE);
sdl->extra_flags |= sdl->scale_mode->extra_flags;
sdl->extra_flags |= sm->extra_flags;
sdl->sdlsurf = SDL_SetVideoMode(width, height,
0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);
@ -489,7 +488,7 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
window->width = sdl->sdlsurf->w;
window->height = sdl->sdlsurf->h;
if (sdl->scale_mode->is_yuv)
if (sm->is_yuv)
yuv_overlay_init(window);
// set the window title
@ -508,8 +507,10 @@ static int drawsdl_window_create(sdl_window_info *window, int width, int height)
static void drawsdl_window_resize(sdl_window_info *window, int width, int height)
{
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (!SDLMAME_SDL2)
const sdl_scale_mode *sdl_sm = &scale_modes[video_config.scale_mode];
#endif
#if (SDLMAME_SDL2)
SDL_SetWindowSize(window->sdl_window, width, height);
SDL_GetWindowSize(window->sdl_window, &window->width, &window->height);
@ -529,7 +530,7 @@ static void drawsdl_window_resize(sdl_window_info *window, int width, int height
window->width = sdl->sdlsurf->w;
window->height = sdl->sdlsurf->h;
if (sdl->scale_mode->is_yuv)
if (sdl_sm->is_yuv)
{
yuv_overlay_init(window);
}
@ -550,7 +551,7 @@ static void drawsdl_window_destroy(sdl_window_info *window)
if (sdl == NULL)
return;
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
//SDL_SelectRenderer(window->sdl_window);
SDL_DestroyTexture(sdl->texture_id);
//SDL_DestroyRenderer(window->sdl_window);
@ -602,6 +603,7 @@ 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)
{
sdl_info *sdl = (sdl_info *) window->dxdata;
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
*xt = x - sdl->last_hofs;
*yt = y - sdl->last_vofs;
@ -609,7 +611,7 @@ static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, in
return 0;
if (*yt<0 || *xt >= window->blitheight)
return 0;
if (!sdl->scale_mode->is_scale)
if (!sm->is_scale)
{
return 1;
}
@ -626,6 +628,7 @@ static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, in
static render_primitive_list &drawsdl_window_get_primitives(sdl_window_info *window)
{
sdl_info *sdl = (sdl_info *) window->dxdata;
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
if ((!window->fullscreen) || (video_config.switchres))
{
@ -636,7 +639,7 @@ static render_primitive_list &drawsdl_window_get_primitives(sdl_window_info *win
sdlwindow_blit_surface_size(window, window->monitor->center_width, window->monitor->center_height);
}
if (!sdl->scale_mode->is_scale)
if (!sm->is_scale)
window->target->set_bounds(window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor));
else
window->target->set_bounds(sdl->hw_scale_width, sdl->hw_scale_height);
@ -651,11 +654,12 @@ static render_primitive_list &drawsdl_window_get_primitives(sdl_window_info *win
static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
{
sdl_info *sdl = (sdl_info *) window->dxdata;
const sdl_scale_mode *sm = &scale_modes[video_config.scale_mode];
UINT8 *surfptr;
INT32 pitch;
int bpp;
Uint32 rmask, gmask, bmask;
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
Uint32 amask;
#endif
INT32 vofs, hofs, blitwidth, blitheight, ch, cw;
@ -670,7 +674,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
return 1;
// lock it if we need it
#if (!SDL_VERSION_ATLEAST(1,3,0))
#if (!SDLMAME_SDL2)
pitch = sdl->sdlsurf->pitch;
bpp = sdl->sdlsurf->format->BytesPerPixel;
@ -681,7 +685,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
if (window->blitwidth != sdl->old_blitwidth || window->blitheight != sdl->old_blitheight)
{
if (sdl->scale_mode->is_yuv)
if (sm->is_yuv)
yuv_overlay_init(window);
sdl->old_blitwidth = window->blitwidth;
sdl->old_blitheight = window->blitheight;
@ -698,7 +702,7 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
}
if (sdl->scale_mode->is_yuv)
if (sm->is_yuv)
{
SDL_LockYUVOverlay(sdl->yuvsurf);
surfptr = sdl->yuvsurf->pixels[0]; // (UINT8 *) sdl->yuv_bitmap;
@ -711,6 +715,8 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
if (window->blitwidth != sdl->old_blitwidth || window->blitheight != sdl->old_blitheight)
{
SDL_RenderSetViewport(sdl->sdl_renderer, NULL);
SDL_DestroyTexture(sdl->texture_id);
setup_texture(window, window->blitwidth, window->blitheight);
sdl->old_blitwidth = window->blitwidth;
@ -731,8 +737,8 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
if (sdl->blittimer > 0)
{
/* SDL Underlays need alpha = 0 ! */
SDL_SetRenderDrawColor(window->sdl_renderer,0,0,0,0);
SDL_RenderFillRect(window->sdl_renderer,NULL);
SDL_SetRenderDrawColor(sdl->sdl_renderer,0,0,0,0);
SDL_RenderFillRect(sdl->sdl_renderer,NULL);
//SDL_RenderFill(0,0,0,0 /*255*/,NULL);
sdl->blittimer--;
}
@ -784,15 +790,15 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
window->primlist->acquire_lock();
// render to it
if (!sdl->scale_mode->is_yuv)
if (!sm->is_yuv)
{
int mamewidth, mameheight;
if (!sdl->scale_mode->is_scale)
if (!sm->is_scale)
{
mamewidth = blitwidth;
mameheight = blitheight;
#if !SDL_VERSION_ATLEAST(1,3,0)
#if !SDLMAME_SDL2
surfptr += ((vofs * pitch) + (hofs * bpp));
#endif
}
@ -833,15 +839,15 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
assert (sdl->yuv_bitmap != NULL);
assert (surfptr != NULL);
drawsdl_rgb555_draw_primitives(*window->primlist, sdl->yuv_bitmap, sdl->hw_scale_width, sdl->hw_scale_height, sdl->hw_scale_width);
sdl->scale_mode->yuv_blit((UINT16 *)sdl->yuv_bitmap, sdl, surfptr, pitch);
sm->yuv_blit((UINT16 *)sdl->yuv_bitmap, sdl, surfptr, pitch);
}
window->primlist->release_lock();
// unlock and flip
#if (!SDL_VERSION_ATLEAST(1,3,0))
#if (!SDLMAME_SDL2)
if (SDL_MUSTLOCK(sdl->sdlsurf)) SDL_UnlockSurface(sdl->sdlsurf);
if (!sdl->scale_mode->is_yuv)
if (!sm->is_yuv)
{
SDL_Flip(sdl->sdlsurf);
}
@ -867,8 +873,8 @@ static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
r.h=blitheight;
//printf("blitwidth %d %d - %d %d\n", blitwidth, blitheight, window->width, window->height);
//SDL_UpdateTexture(sdl->sdltex, NULL, sdl->sdlsurf->pixels, pitch);
SDL_RenderCopy(window->sdl_renderer,sdl->texture_id, NULL, &r);
SDL_RenderPresent(window->sdl_renderer);
SDL_RenderCopy(sdl->sdl_renderer,sdl->texture_id, NULL, &r);
SDL_RenderPresent(sdl->sdl_renderer);
}
#endif
return 0;

View File

@ -1,5 +1,5 @@
#include <SDL/SDL.h>
#include "sdlinc.h"
#include "osd_opengl.h"

View File

@ -13,7 +13,7 @@
//============================================================
// standard sdl header
#include <SDL/SDL.h>
#include "sdlinc.h"
#include <ctype.h>
#include <stddef.h>
@ -206,7 +206,7 @@ struct _kt_table {
char * ui_name;
};
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
#define OSD_SDL_INDEX(x) (x)
#define OSD_SDL_INDEX_KEYSYM(keysym) ((keysym)->scancode)
@ -470,7 +470,7 @@ struct _key_lookup_table
const char *name;
};
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
#define KE(x) { SDL_SCANCODE_ ## x, "SDL_SCANCODE_" #x },
#define KE8(A, B, C, D, E, F, G, H) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) KE(H)
#define KE7(A, B, C, D, E, F, G) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G)
@ -790,7 +790,7 @@ static void sdlinput_deregister_joysticks(running_machine &machine)
// sdlinput_register_mice
//============================================================
#if (!SDL13_POST_HG4464 && SDL_VERSION_ATLEAST(1,3,0))
#if defined(SDL2_MULTIAPI) && 0
static void sdlinput_register_mice(running_machine &machine)
{
int index, physical_mouse;
@ -1002,7 +1002,7 @@ static kt_table * sdlinput_read_keymap(running_machine &machine)
// sdlinput_register_keyboards
//============================================================
#if ((1 ||!SDL13_POST_HG4464) && SDL_VERSION_ATLEAST(1,3,0))
#ifdef SDL2_MULTIAPI
static void sdlinput_register_keyboards(running_machine &machine)
{
int physical_keyboard;
@ -1193,7 +1193,7 @@ sdl_window_info *sdlinput_get_focus_window(running_machine &machine)
// sdlinput_poll
//============================================================
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
INLINE sdl_window_info * window_from_id(Uint32 windowID)
{
sdl_window_info *w;
@ -1238,7 +1238,7 @@ void sdlinput_process_events_buf(running_machine &machine)
if (SDLMAME_EVENTS_IN_WORKER_THREAD)
{
osd_lock_acquire(input_lock);
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
/* Make sure we get all pending events */
SDL_PumpEvents();
#endif
@ -1306,15 +1306,24 @@ void sdlinput_poll(running_machine &machine)
}
switch(event.type) {
case SDL_KEYDOWN:
#ifdef SDL2_MULTIAPI
devinfo = generic_device_find_index( keyboard_list, keyboard_map.logical[event.key.which]);
//printf("Key down %d %d %s => %d %s (scrlock keycode is %d)\n", event.key.which, event.key.keysym.scancode, devinfo->name, OSD_SDL_INDEX_KEYSYM(&event.key.keysym), sdl_key_trans_table[event.key.keysym.scancode].mame_key_name, KEYCODE_SCRLOCK);
#else
devinfo = generic_device_find_index( keyboard_list, keyboard_map.logical[0]);
#endif
devinfo->keyboard.state[OSD_SDL_INDEX_KEYSYM(&event.key.keysym)] = 0x80;
#if (!SDL_VERSION_ATLEAST(1,3,0))
#if (!SDLMAME_SDL2)
ui_input_push_char_event(machine, sdl_window_list->target, (unicode_char) event.key.keysym.unicode);
#endif
break;
case SDL_KEYUP:
#ifdef SDL2_MULTIAPI
devinfo = generic_device_find_index( keyboard_list, keyboard_map.logical[event.key.which]);
//printf("Key up: %d %d\n", OSD_SDL_INDEX_KEYSYM(&event.key.keysym), event.key.which);
#else
devinfo = generic_device_find_index( keyboard_list, keyboard_map.logical[0]);
#endif
devinfo->keyboard.state[OSD_SDL_INDEX_KEYSYM(&event.key.keysym)] = 0x00;
break;
case SDL_JOYAXISMOTION:
@ -1389,7 +1398,11 @@ void sdlinput_poll(running_machine &machine)
}
break;
case SDL_MOUSEBUTTONDOWN:
#ifdef SDL2_MULTIAPI
devinfo = generic_device_find_index(mouse_list, mouse_map.logical[event.button.which]);
#else
devinfo = generic_device_find_index(mouse_list, mouse_map.logical[0]);
#endif
devinfo->mouse.buttons[event.button.button-1] = 0x80;
//printf("But down %d %d %d %d %s\n", event.button.which, event.button.button, event.button.x, event.button.y, devinfo->name);
if (event.button.button == 1)
@ -1422,7 +1435,11 @@ void sdlinput_poll(running_machine &machine)
}
break;
case SDL_MOUSEBUTTONUP:
#ifdef SDL2_MULTIAPI
devinfo = generic_device_find_index(mouse_list, mouse_map.logical[event.button.which]);
#else
devinfo = generic_device_find_index(mouse_list, mouse_map.logical[0]);
#endif
devinfo->mouse.buttons[event.button.button-1] = 0;
//printf("But up %d %d %d %d\n", event.button.which, event.button.button, event.button.x, event.button.y);
@ -1438,8 +1455,12 @@ void sdlinput_poll(running_machine &machine)
}
break;
case SDL_MOUSEMOTION:
#ifdef SDL2_MULTIAPI
devinfo = generic_device_find_index(mouse_list, mouse_map.logical[event.motion.which]);
#if (SDL_VERSION_ATLEAST(1,3,0))
#else
devinfo = generic_device_find_index(mouse_list, mouse_map.logical[0]);
#endif
#if (SDLMAME_SDL2)
// FIXME: may apply to 1.2 as well ...
//printf("Motion %d %d %d %s\n", event.motion.which, event.motion.x, event.motion.y, devinfo->name);
devinfo->mouse.lX += event.motion.xrel * INPUT_RELATIVE_PER_PIXEL;
@ -1456,7 +1477,7 @@ void sdlinput_poll(running_machine &machine)
ui_input_push_mouse_move_event(machine, window->target, cx, cy);
}
break;
#if (!SDL_VERSION_ATLEAST(1,3,0))
#if (!SDLMAME_SDL2)
case SDL_APPMOUSEFOCUS:
app_has_mouse_focus = event.active.gain;
if (!event.active.gain)
@ -1533,7 +1554,7 @@ void sdlinput_poll(running_machine &machine)
#endif
}
}
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
resize_all_windows();
#endif
}
@ -1549,7 +1570,7 @@ void sdlinput_release_keys(running_machine &machine)
// FIXME: SDL >= 1.3 will nuke the window event buffer when
// a window is closed. This will leave keys in a pressed
// state when a window is destroyed and recreated.
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
device_info *devinfo;
int index;

View File

@ -15,14 +15,22 @@
/* equivalent to #include <GL/gl.h>
* #include <GL/glext.h>
*/
#if (SDLMAME_SDL2)
#include <SDL2/SDL_version.h>
#else
#include <SDL/SDL_version.h>
#endif
#if (SDL_VERSION_ATLEAST(1,2,10))
#if defined(SDLMAME_WIN32)
// Avoid that winnt.h (included via sdl_opengl.h, windows.h, windef.h includes intrin.h
#define __INTRIN_H_
#endif
#if (SDLMAME_SDL2)
#include <SDL2/SDL_opengl.h>
#else
#include <SDL/SDL_opengl.h>
#endif
#else
/*
* SDL 1.2.9 does not provide everything we need

View File

@ -1,33 +1,24 @@
#ifndef _osdsdl_h_
#define _osdsdl_h_
#include <SDL/SDL.h>
#include "sdlinc.h"
#include "watchdog.h"
#include "clifront.h"
//============================================================
// Temporary SDL 1.3 defines
//============================================================
// set this to 0 if compiling against a "hg update 4464"
// checkout of SDL 1.3
#define SDL13_POST_HG4464 (1)
//============================================================
// System dependent defines
//============================================================
// Process events in worker thread
#if defined(SDLMAME_WIN32) || (SDL_VERSION_ATLEAST(1,3,0))
#if defined(SDLMAME_WIN32) || (SDLMAME_SDL2)
#define SDLMAME_EVENTS_IN_WORKER_THREAD (1)
#else
#define SDLMAME_EVENTS_IN_WORKER_THREAD (0)
#endif
#if defined(SDLMAME_WIN32)
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
#define SDLMAME_INIT_IN_WORKER_THREAD (0) //FIXME: breaks mt
#define SDL13_COMBINE_RESIZE (1)
#else
@ -215,7 +206,7 @@ public:
const char *joy_index(int index) const { astring temp; return value(temp.format("%s%d", SDLOPTION_JOYINDEX, index)); }
bool sixaxis() const { return bool_value(SDLOPTION_SIXAXIS); }
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
const char *mouse_index(int index) const { astring temp; return value(temp.format("%s%d", SDLOPTION_MOUSEINDEX, index)); }
const char *keyboard_index(int index) const { astring temp; return value(temp.format("%s%d", SDLOPTION_KEYBINDEX, index)); }
#endif

View File

@ -21,7 +21,6 @@
# for details
#-------------------------------------------------
# uncomment and edit next line to specify a distribution
# supported debian-stable, ubuntu-intrepid
@ -48,17 +47,20 @@
USE_DISPATCH_GL = 1
# uncomment and change the next line to compile and link to specific
# SDL library. This is currently supported for unix and win32.
# The following settings are currently supported for unix only.
# There is no need to play with this option unless you are doing
# active development on sdlmame or SDL.
ifeq ($(TARGETOS),win32)
#SDL_INSTALL_ROOT = /usr/local/sdl13w32
else
#SDL_INSTALL_ROOT = /usr/local/sdl13
#SDL_INSTALL_ROOT = /usr/local/test
endif
# uncomment the next line to compile and link against SDL2.0
# SDL_LIBVER = sdl2
# uncomment the next line to use couriersud's multi-keyboard patch for sdl2.0
# SDL2_MULTIAPI = 1
# uncomment the next line to specify where you have installed
# SDL. Equivalent to the ./configure --prefix=<path>
# SDL_INSTALL_ROOT = /usr/local/sdl13
# uncomment and change the next line to build the gtk debugger for win32
# Get what you need here: http://www.gtk.org/download-windows.html
@ -70,6 +72,25 @@ endif
################## END USER-CONFIGURABLE OPTIONS ######################
###########################################################################
ifndef SDL_LIBVER
SDL_LIBVER = sdl
endif
ifdef SDL_INSTALL_ROOT
SDL_CONFIG = $(SDL_INSTALL_ROOT)/bin/$(SDL_LIBVER)-config
else
SDL_CONFIG = $(SDL_LIBVER)-config
endif
ifeq ($(SDL_LIBVER),sdl2)
DEFS += -DSDLMAME_SDL2=1
ifeq ($(SDL2_MULTIAPI),1)
DEFS += -DSDL2_MULTIAPI
endif
else
DEFS += -DSDLMAME_SDL2=0
endif
ifdef NOASM
DEFS += -DSDLMAME_NOASM
endif
@ -288,8 +309,9 @@ OSDOBJS = \
$(SDLOBJ)/output.o \
$(SDLOBJ)/watchdog.o
# Add SDL1.3 support
ifdef SDL_INSTALL_ROOT
# Add SDL2.0 support
ifeq ($(SDL_LIBVER),sdl2)
OSDOBJS += $(SDLOBJ)/draw13.o
endif
@ -350,31 +372,27 @@ LDFLAGS += -m32
endif
endif
ifndef SDL_INSTALL_ROOT
INCPATH += `sdl-config --cflags | sed -e 's:/SDL::' -e 's:\(-D[^ ]*\)::g'`
CCOMFLAGS += `sdl-config --cflags | sed -e 's:/SDL::' -e 's:\(-I[^ ]*\)::g'`
LIBS += -lm `sdl-config --libs`
else
# The commented out statements document what sdl-config returns when build from svn.
# sdl-config --libs on ubuntu returns "-L/usr/lib -lSDL" which is not what we really
# want in a multi-version SDL environment. Should the svn sdl-config at some point
# return the same output, we need the commented out section again.
INCPATH += `$(SDL_CONFIG) --cflags | sed -e 's:/SDL[2]*::' -e 's:\(-D[^ ]*\)::g'`
CCOMFLAGS += `$(SDL_CONFIG) --cflags | sed -e 's:/SDL[2]*::' -e 's:\(-I[^ ]*\)::g'`
LIBS += -lm `$(SDL_CONFIG) --libs`
#INCPATH += -I$(SDL_INSTALL_ROOT)/include
#CCOMFLAGS += -D_GNU_SOURCE=1
#LIBS += -lm -L$(SDL_INSTALL_ROOT)/lib -Wl,-rpath,$(SDL_INSTALL_ROOT)/lib -lSDL
# FIXME: remove the directfb ref. later. This is just there for now to work around an issue with SDL1.3.
ifeq ($(SDL_LIBVER),sdl2)
ifdef SDL_INSTALL_ROOT
# FIXME: remove the directfb ref. later. This is just there for now to work around an issue with SDL1.3 and SDL2.0
INCPATH += -I$(SDL_INSTALL_ROOT)/include/directfb
INCPATH += `$(SDL_INSTALL_ROOT)/bin/sdl-config --cflags | sed -e 's:/SDL::' -e 's:\(-D[^ ]*\)::g'`
CCOMFLAGS += `$(SDL_INSTALL_ROOT)/bin/sdl-config --cflags | sed -e 's:/SDL::' -e 's:\(-I[^ ]*\)::g'`
LIBS += -lm `$(SDL_INSTALL_ROOT)/bin/sdl-config --libs`
endif
endif
INCPATH += `pkg-config --cflags fontconfig`
LIBS += `pkg-config --libs fontconfig`
ifeq ($(SDL_LIBVER),sdl2)
LIBS += -lSDL2_ttf -lutil
else
LIBS += -lSDL_ttf -lutil
endif
endif # Unix
@ -591,9 +609,10 @@ $(OSDCLEAN):
#-------------------------------------------------
testlib:
-echo LIBS: $(LIBS)
-echo DEFS: $(DEFS)
-echo CORE: $(OSDCOREOBJS)
@echo LIBS: $(LIBS)
@echo INCPATH: $(INCPATH)
@echo DEFS: $(DEFS)
@echo CORE: $(OSDCOREOBJS)
ifneq ($(TARGETOS),win32)
BUILD_VERSION = $(shell grep 'build_version\[\] =' src/version.c | sed -e "s/.*= \"//g" -e "s/ .*//g")

20
src/osd/sdl/sdlinc.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef _sdlinc_h_
#define _sdlinc_h_
#if (SDLMAME_SDL2)
#include <SDL2/SDL.h>
#include <SDL2/SDL_version.h>
// on win32 this includes windows.h by itself and breaks us!
#ifndef SDLMAME_WIN32
#include <SDL2/SDL_syswm.h>
#endif
#else
#include <SDL/SDL.h>
#include <SDL/SDL_version.h>
// on win32 this includes windows.h by itself and breaks us!
#ifndef SDLMAME_WIN32
#include <SDL/SDL_syswm.h>
#endif
#endif
#endif

View File

@ -10,12 +10,15 @@
//============================================================
// standard sdl header
#include <SDL/SDL.h>
#include <SDL/SDL_version.h>
#include "sdlinc.h"
#ifdef SDLMAME_UNIX
#ifndef SDLMAME_MACOSX
#if (SDLMAME_SDL2)
#include <SDL2/SDL_ttf.h>
#else
#include <SDL/SDL_ttf.h>
#endif
#include <fontconfig/fontconfig.h>
#endif
#ifdef SDLMAME_MACOSX
@ -112,7 +115,7 @@ const options_entry sdl_options::s_option_entries[] =
{ SDLOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" },
{ SDLOPTION_SYNCREFRESH ";sr", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" },
#endif
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
{ SDLOPTION_SCALEMODE ";sm", SDLOPTVAL_NONE, OPTION_STRING, "Scale mode: none, hwblit, hwbest, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" },
#else
{ SDLOPTION_SCALEMODE ";sm", SDLOPTVAL_NONE, OPTION_STRING, "Scale mode: none, async, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" },
@ -211,7 +214,7 @@ const options_entry sdl_options::s_option_entries[] =
{ SDLOPTION_JOYINDEX "8", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #8" },
{ SDLOPTION_SIXAXIS, "0", OPTION_BOOLEAN, "Use special handling for PS3 Sixaxis controllers" },
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
{ NULL, NULL, OPTION_HEADER, "SDL MOUSE MAPPING" },
{ SDLOPTION_MOUSEINDEX "1", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #1" },
{ SDLOPTION_MOUSEINDEX "2", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #2" },
@ -235,7 +238,7 @@ const options_entry sdl_options::s_option_entries[] =
// SDL low level driver options
{ NULL, NULL, OPTION_HEADER, "SDL LOWLEVEL DRIVER OPTIONS" },
{ SDLOPTION_VIDEODRIVER ";vd", SDLOPTVAL_AUTO, OPTION_STRING, "sdl video driver to use ('x11', 'directfb', ... or 'auto' for SDL default" },
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
{ SDLOPTION_RENDERDRIVER ";rd", SDLOPTVAL_AUTO, OPTION_STRING, "sdl render driver to use ('software', 'opengl', 'directfb' ... or 'auto' for SDL default" },
#endif
{ SDLOPTION_AUDIODRIVER ";ad", SDLOPTVAL_AUTO, OPTION_STRING, "sdl audio driver to use ('alsa', 'arts', ... or 'auto' for SDL default" },
@ -298,7 +301,7 @@ int main(int argc, char *argv[])
{
int res = 0;
#if !(SDL_VERSION_ATLEAST(1,3,0))
#if !(SDLMAME_SDL2)
/* Load SDL dynamic link library */
if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) {
fprintf(stderr, "WinMain() error: %s", SDL_GetError());
@ -416,7 +419,14 @@ void sdl_osd_interface::osd_exit(running_machine &machine)
#endif
if (!SDLMAME_INIT_IN_WORKER_THREAD)
{
/* FixMe: Bug in SDL2.0, Quitting joystick will cause SIGSEGV */
#if SDLMAME_SDL2
SDL_QuitSubSystem(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO /*| SDL_INIT_JOYSTICK */);
#else
SDL_Quit();
#endif
}
}
//============================================================
@ -492,7 +502,7 @@ static void defines_verbose(void)
static void osd_sdl_info(void)
{
#if SDL_VERSION_ATLEAST(1,3,0)
#if SDLMAME_SDL2
int i, num = SDL_GetNumVideoDrivers();
mame_printf_verbose("Available videodrivers: ");
@ -572,15 +582,15 @@ void sdl_osd_interface::init(running_machine &machine)
osd_setenv(SDLENV_VIDEODRIVER, stemp, 1);
}
if (SDL_VERSION_ATLEAST(1,3,0))
{
#if (SDLMAME_SDL2)
stemp = options.render_driver();
if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
{
mame_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp);
osd_setenv(SDLENV_RENDERDRIVER, stemp, 1);
//osd_setenv(SDLENV_RENDERDRIVER, stemp, 1);
SDL_SetHint(SDL_HINT_RENDER_DRIVER, stemp);
}
}
#endif
/* Set the SDL environment variable for drivers wanting to load the
* lib at startup.
@ -615,7 +625,7 @@ void sdl_osd_interface::init(running_machine &machine)
if (!SDLMAME_INIT_IN_WORKER_THREAD)
{
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
if (SDL_InitSubSystem(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) {
#else
if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) {
@ -670,7 +680,7 @@ void sdl_osd_interface::init(running_machine &machine)
m_watchdog->setTimeout(watchdog_timeout);
}
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
SDL_EventState(SDL_TEXTINPUT, SDL_TRUE);
#else
SDL_EnableUNICODE(SDL_TRUE);

View File

@ -10,7 +10,7 @@
//============================================================
// standard sdl header
#include <SDL/SDL.h>
#include "sdlinc.h"
#include <sys/types.h>
#include <sys/mman.h>
#include <signal.h>

View File

@ -10,7 +10,7 @@
//============================================================
// standard sdl header
#include <SDL/SDL.h>
#include "sdlinc.h"
#include <unistd.h>
#include <stdio.h>
#include <string.h>

View File

@ -10,7 +10,7 @@
//============================================================
// standard sdl header
#include <SDL/SDL.h>
#include "sdlinc.h"
#define WIN32_LEAN_AND_MEAN

View File

@ -10,7 +10,7 @@
//============================================================
// standard sdl header
#include <SDL/SDL.h>
#include "sdlinc.h"
#include <sys/stat.h>
#include <unistd.h>

View File

@ -10,7 +10,7 @@
//============================================================
// standard sdl header
#include <SDL/SDL.h>
#include "sdlinc.h"
#include <unistd.h>
#include <stdio.h>
#include <string.h>

View File

@ -16,8 +16,7 @@
#include <sys/time.h>
#include <sys/stat.h>
#include <SDL/SDL.h>
#include <SDL/SDL_syswm.h>
#include "sdlinc.h"
// MAME headers
#include "osdcore.h"
@ -138,7 +137,27 @@ int osd_setenv(const char *name, const char *value, int overwrite)
return setenv(name, value, overwrite);
}
#if defined(SDL_VIDEO_DRIVER_X11) && defined(SDLMAME_X11)
#if (SDLMAME_SDL2)
//============================================================
// osd_get_clipboard_text
//============================================================
char *osd_get_clipboard_text(void)
{
char *result = NULL;
if (SDL_HasClipboardText())
{
char *temp = SDL_GetClipboardText();
result = (char *) osd_malloc_array(strlen(temp) + 1);
strcpy(result, temp);
SDL_free(temp);
}
return result;
}
#elif defined(SDL_VIDEO_DRIVER_X11) && defined(SDLMAME_X11)
//============================================================
// osd_get_clipboard_text
@ -167,17 +186,11 @@ char *osd_get_clipboard_text(void)
return NULL;
if ( info.subsystem != SDL_SYSWM_X11 )
return NULL;
#if (SDL_VERSION_ATLEAST(1,3,0))
if ( (display = info.info.x11.display) == NULL )
return NULL;
if ( (our_win = info.info.x11.window) == None )
return NULL;
#else
if ( (display = info.info.x11.display) == NULL )
return NULL;
if ( (our_win = info.info.x11.window) == None )
return NULL;
#endif
/* request data to owner */
selection_win = XGetSelectionOwner( display, XA_PRIMARY );
if ( selection_win == None )

View File

@ -10,7 +10,7 @@
//============================================================
// standard sdl header
#include <SDL/SDL.h>
#include "sdlinc.h"
#define WIN32_LEAN_AND_MEAN

View File

@ -13,7 +13,7 @@
#define _GNU_SOURCE // for PTHREAD_MUTEX_RECURSIVE; needs to be here before other glibc headers are included
#endif
#include "SDL/SDL.h"
#include "sdlinc.h"
#ifdef SDLMAME_MACOSX
#include <mach/mach.h>

View File

@ -13,7 +13,7 @@
#define _GNU_SOURCE // for PTHREAD_MUTEX_RECURSIVE; needs to be here before other glibc headers are included
#endif
#include "SDL/SDL.h"
#include "sdlinc.h"
// standard C headers
#include <math.h>

View File

@ -9,7 +9,7 @@
//
//============================================================
#include "SDL/SDL.h"
#include "sdlinc.h"
// standard C headers
#include <unistd.h>

View File

@ -13,7 +13,7 @@
#define _GNU_SOURCE // for PTHREAD_MUTEX_RECURSIVE; needs to be here before other glibc headers are included
#endif
#include "SDL/SDL.h"
#include "sdlinc.h"
#ifdef SDLMAME_MACOSX
#include <mach/mach.h>

View File

@ -10,7 +10,7 @@
//============================================================
// standard sdl header
#include <SDL/SDL.h>
#include "sdlinc.h"
// MAME headers
#include "emu.h"
@ -432,7 +432,7 @@ static int sdl_init(running_machine &machine)
}
mame_printf_verbose("Audio: Start initialization\n");
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
strncpy(audio_driver, SDL_GetCurrentAudioDriver(), sizeof(audio_driver));
#else
SDL_AudioDriverName(audio_driver, sizeof(audio_driver));

View File

@ -15,12 +15,12 @@
#include <string.h>
#include <wchar.h>
#include <SDL/SDL.h>
#include "sdlinc.h"
#include "unicode.h"
// Check whether SDL has compat interface
#if defined(SDL_AllocSurface) || (!SDL_VERSION_ATLEAST(1,3,0))
#if defined(SDL_AllocSurface) || (!SDLMAME_SDL2)
#define SDL_HAS_COMPAT 1
#else
#define SDL_HAS_COMPAT 0
@ -35,7 +35,7 @@ struct _key_lookup_table
};
#if SDL_HAS_COMPAT
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
#define KE(x) { SDL_SCANCODE_ ## x, "SDL_SCANCODE_" #x },
#define KE8(A, B, C, D, E, F, G, H) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G) KE(H)
#define KE7(A, B, C, D, E, F, G) KE(A) KE(B) KE(C) KE(D) KE(E) KE(F) KE(G)
@ -149,7 +149,7 @@ int main(int argc, char *argv[])
memset(buf, 0, ARRAY_LENGTH(buf));
utf8_from_uchar(buf, sizeof(buf), event.key.keysym.unicode);
printf("ITEM_ID_XY %s 0x%x 0x%x %s \n",
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
lookup_key_name(sdl_lookup, event.key.keysym.scancode),
#else
lookup_key_name(sdl_lookup, event.key.keysym.sym),
@ -163,7 +163,7 @@ int main(int argc, char *argv[])
memset(buf, 0, 19);
utf8_from_uchar(buf, sizeof(buf), event.key.keysym.unicode);
printf("ITEM_ID_XY %s 0x%x 0x%x %s \n",
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
lookup_key_name(sdl_lookup, event.key.keysym.scancode),
#else
lookup_key_name(sdl_lookup, event.key.keysym.sym),

View File

@ -9,11 +9,7 @@
//
//============================================================
#include <SDL/SDL.h>
// on win32 this includes windows.h by itself and breaks us!
#ifndef SDLMAME_WIN32
#include <SDL/SDL_syswm.h>
#endif
#include "sdlinc.h"
#ifdef SDLMAME_X11
#include <X11/extensions/Xinerama.h>
@ -163,7 +159,7 @@ static void video_exit(running_machine &machine)
void sdlvideo_monitor_refresh(sdl_monitor_info *monitor)
{
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
SDL_DisplayMode dmode;
SDL_GetDesktopDisplayMode(monitor->handle, &dmode);
@ -283,7 +279,7 @@ void sdlvideo_monitor_refresh(sdl_monitor_info *monitor)
info_shown = 1;
}
}
#endif // (SDL_VERSION_ATLEAST(1,3,0))
#endif // (SDLMAME_SDL2)
}
@ -354,7 +350,7 @@ void sdl_osd_interface::update(bool skip_redraw)
// add_primary_monitor
//============================================================
#if !defined(SDLMAME_WIN32) && !(SDL_VERSION_ATLEAST(1,3,0))
#if !defined(SDLMAME_WIN32) && !(SDLMAME_SDL2)
static void add_primary_monitor(void *data)
{
sdl_monitor_info ***tailptr = (sdl_monitor_info ***)data;
@ -385,7 +381,7 @@ static void add_primary_monitor(void *data)
// monitor_enum_callback
//============================================================
#if defined(SDLMAME_WIN32) && !(SDL_VERSION_ATLEAST(1,3,0))
#if defined(SDLMAME_WIN32) && !(SDLMAME_SDL2)
static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data)
{
sdl_monitor_info ***tailptr = (sdl_monitor_info ***)data;
@ -446,7 +442,7 @@ static void init_monitors(void)
sdl_monitor_list = NULL;
tailptr = &sdl_monitor_list;
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
{
int i;
@ -494,7 +490,7 @@ static void init_monitors(void)
// pick_monitor
//============================================================
#if (SDL_VERSION_ATLEAST(1,3,0)) || defined(SDLMAME_WIN32)
#if (SDLMAME_SDL2) || defined(SDLMAME_WIN32)
static sdl_monitor_info *pick_monitor(sdl_options &options, int index)
{
sdl_monitor_info *monitor;
@ -580,7 +576,7 @@ static void check_osd_inputs(running_machine &machine)
ui_popup_time(1, "Keepaspect %s", video_config.keepaspect? "enabled":"disabled");
}
if (USE_OPENGL || SDL_VERSION_ATLEAST(1,3,0))
if (USE_OPENGL || SDLMAME_SDL2)
{
//FIXME: on a per window basis
if (ui_input_pressed(machine, IPT_OSD_5))
@ -654,7 +650,7 @@ static void extract_video_config(running_machine &machine)
video_config.mode = VIDEO_MODE_OPENGL;
video_config.prefer16bpp_tex = 1;
}
else if (SDL_VERSION_ATLEAST(1,3,0) && (strcmp(stemp, SDLOPTVAL_SDL13) == 0))
else if (SDLMAME_SDL2 && (strcmp(stemp, SDLOPTVAL_SDL13) == 0))
{
video_config.mode = VIDEO_MODE_SDL13;
video_config.prefer16bpp_tex = 1;
@ -676,7 +672,7 @@ static void extract_video_config(running_machine &machine)
video_config.syncrefresh = 0;
}
if (USE_OPENGL || SDL_VERSION_ATLEAST(1,3,0))
if (USE_OPENGL || SDLMAME_SDL2)
{
video_config.filter = options.filter();
}
@ -765,7 +761,7 @@ static void extract_video_config(running_machine &machine)
// misc options: sanity check values
// global options: sanity check values
#if (!SDL_VERSION_ATLEAST(1,3,0))
#if (!SDLMAME_SDL2)
if (video_config.numscreens < 1 || video_config.numscreens > 1) //MAX_VIDEO_WINDOWS)
{
mame_printf_warning("Invalid numscreens value %d; reverting to 1\n", video_config.numscreens);

View File

@ -10,9 +10,13 @@
//============================================================
// standard SDL headers
#include <SDL/SDL.h>
#include <SDL/SDL_syswm.h>
#include "sdlinc.h"
#if (SDLMAME_SDL2)
#include <SDL2/SDL_thread.h>
#else
#include <SDL/SDL_thread.h>
#endif
// standard C headers
#include <math.h>
@ -84,7 +88,7 @@ static sdl_window_info **last_window_ptr;
static int multithreading_enabled;
static osd_work_queue *work_queue;
#if !(SDL_VERSION_ATLEAST(1,3,0))
#if !(SDLMAME_SDL2)
typedef int SDL_threadID;
#endif
@ -184,7 +188,7 @@ static OSDWORK_CALLBACK(sdlwindow_thread_id)
if (SDLMAME_INIT_IN_WORKER_THREAD)
{
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
if (SDL_InitSubSystem(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE))
#else
if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE))
@ -239,7 +243,7 @@ int sdlwindow_init(running_machine &machine)
video_config.mode = VIDEO_MODE_SOFT;
}
#endif
#if SDL_VERSION_ATLEAST(1,3,0)
#if SDLMAME_SDL2
if (video_config.mode == VIDEO_MODE_SDL13)
{
if (draw13_init(machine, &draw))
@ -408,7 +412,7 @@ void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int
//FIXME: really necessary to distinguish for yuv_modes ?
if (window->target->zoom_to_screen()
&& (window->scale_mode == VIDEO_SCALE_MODE_NONE ))
&& (video_config.scale_mode == VIDEO_SCALE_MODE_NONE ))
newwidth = window_width;
if ((window->blitwidth != newwidth) || (window->blitheight != newheight))
@ -595,7 +599,7 @@ void sdlwindow_modify_prescale(running_machine &machine, sdl_window_info *window
static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window)
{
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
// do not do mouse capture if the debugger's enabled to avoid
// the possibility of losing control
if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED))
@ -672,7 +676,6 @@ int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monit
//FIXME: these should be per_window in config-> or even better a bit set
window->fullscreen = !video_config.windowed;
window->prescale = video_config.prescale;
window->scale_mode = video_config.scale_mode;
// set the initial maximized state
// FIXME: Does not belong here
@ -798,7 +801,7 @@ static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_
// pick_best_mode
//============================================================
#if SDL_VERSION_ATLEAST(1,3,0)
#if SDLMAME_SDL2
static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
{
int minimum_width, minimum_height, target_width, target_height;

View File

@ -12,7 +12,7 @@
#ifndef __SDLWINDOW__
#define __SDLWINDOW__
#include <SDL/SDL.h>
#include "sdlinc.h"
#include "video.h"
#include "render.h"
#include "sdlsync.h"
@ -88,16 +88,12 @@ struct _sdl_window_info
int totalColors; // total colors from machine/sdl_window_config
int start_viewscreen;
// per window modes ...
int scale_mode;
// GL specific
int prescale;
#if (SDL_VERSION_ATLEAST(1,3,0))
#if (SDLMAME_SDL2)
// Needs to be here as well so we can identify window
SDL_Window *sdl_window;
SDL_Renderer *sdl_renderer;
// These are used in combine resizing events ... #if SDL13_COMBINE_RESIZE
int resize_width;
int resize_height;