Make OpenGL renderer available in mainline build as well. This needs to

be explicitly enabled by specifying USE_OPENGL=1. More code alignment.
[Couriersud]
This commit is contained in:
couriersud 2015-02-22 01:14:37 +01:00
parent 9151c0a9e2
commit d2ea4df4ad
20 changed files with 409 additions and 186 deletions

View File

@ -56,6 +56,9 @@
#define OSDOPTION_AUDIO_LATENCY "audio_latency"
#define OSDOPTVAL_AUTO "auto"
#define OSDOPTVAL_NONE "none"
//============================================================
// TYPE DEFINITIONS

View File

@ -525,7 +525,7 @@ int drawsdl2_init(running_machine &machine, osd_draw_callbacks *callbacks)
#else
stemp = NULL;
#endif
if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) == 0)
if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) == 0)
stemp = NULL;
// No fatalerror here since not all video drivers support GL !

View File

@ -23,11 +23,23 @@
#include "options.h"
#include "emuopts.h"
#ifndef OSD_WINDOWS
// standard SDL headers
#define TOBEMIGRATED 1
#include "sdlinc.h"
#else
#define SDLMAME_SDL2 1
#include "GL/gl.h"
#include "GL/glext.h"
#include "GL/wglext.h"
typedef HGLRC SDL_GLContext;
#endif
// OpenGL headers
#ifndef OSD_WINDOWS
#include "osd_opengl.h"
#endif
#include "modules/lib/osdlib.h"
@ -121,8 +133,13 @@ typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuin
#define OVERFLOW_SIZE (1<<10)
// OSD headers
#ifndef OSD_WINDOWS
#include "osdsdl.h"
#include "window.h"
#else
#include "../windows/window.h"
typedef UINT64 HashT;
#endif
//============================================================
// DEBUGGING
@ -149,6 +166,26 @@ enum
// MACROS
//============================================================
#ifdef OSD_WINDOWS
// texture formats
// This used to be an enum, but these are now defines so we can use them as
// preprocessor conditionals
#define SDL_TEXFORMAT_ARGB32 (0) // non-16-bit textures or specials
#define SDL_TEXFORMAT_RGB32 (1)
#define SDL_TEXFORMAT_RGB32_PALETTED (2)
#define SDL_TEXFORMAT_YUY16 (3)
#define SDL_TEXFORMAT_YUY16_PALETTED (4)
#define SDL_TEXFORMAT_PALETTE16 (5)
#define SDL_TEXFORMAT_RGB15 (6)
#define SDL_TEXFORMAT_RGB15_PALETTED (7)
#define SDL_TEXFORMAT_PALETTE16A (8)
// special texture formats for 16bpp texture destination support, do not use
// to address the tex properties / tex functions arrays!
#define SDL_TEXFORMAT_PALETTE16_ARGB1555 (16)
#define SDL_TEXFORMAT_RGB15_ARGB1555 (17)
#define SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555 (18)
#endif
#define FSWAP(var1, var2) do { float temp = var1; var1 = var2; var2 = temp; } while (0)
#define GL_NO_PRIMITIVE -1
@ -253,13 +290,21 @@ public:
}
/* virtual */ int create();
#ifdef OSD_WINDOWS
/* virtual */ int draw(const HDC dc, const int update);
#else
/* virtual */ int draw(const UINT32 dc, const int update);
#endif
/* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt);
/* virtual */ void destroy();
/* virtual */ render_primitive_list *get_primitives()
{
int nw = 0; int nh = 0;
#ifdef OSD_WINDOWS
window().get_size(nw, nh);
#else
window().blit_surface_size(nw, nh);
#endif
if (nw != m_blitwidth || nh != m_blitheight)
{
m_blitwidth = nw; m_blitheight = nh;
@ -269,6 +314,10 @@ public:
return &window().target()->get_primitives();
}
/* virtual */ void save() { }
/* virtual */ void record() { }
/* virtual */ void toggle_fsfx() { }
private:
void destroy_all_textures();
@ -298,6 +347,9 @@ private:
#if (SDLMAME_SDL2)
SDL_GLContext m_gl_context_id;
#ifdef OSD_WINDOWS
HDC m_hdc;
#endif
#else
#endif
@ -483,6 +535,16 @@ int drawogl_init(running_machine &machine, osd_draw_callbacks *callbacks)
return 0;
}
//============================================================
// Windows Compatibility
//============================================================
#ifdef OSD_WINDOWS
PROC SDL_GL_GetProcAddress(const char *procname)
{
return wglGetProcAddress(procname);
}
#endif
//============================================================
// Load the OGL function addresses
@ -530,7 +592,7 @@ static void load_gl_lib(running_machine &machine)
const char *stemp;
stemp = downcast<sdl_options &>(machine.options()).gl_lib();
if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) == 0)
if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) == 0)
stemp = NULL;
if (SDL_GL_LoadLibrary(stemp) != 0) // Load library (default for e==NULL
@ -552,8 +614,11 @@ void sdl_info_ogl::initialize_gl()
char *extstr = (char *)glGetString(GL_EXTENSIONS);
char *vendor = (char *)glGetString(GL_VENDOR);
//printf("%s\n", extstr);
//printf("%p\n", extstr);
#ifdef OSD_WINDOWS
if (!extstr)
extstr = (char *)"";
#endif
// print out the driver info for debugging
if (!shown_video_info)
{
@ -679,11 +744,13 @@ void sdl_info_ogl::initialize_gl()
}
}
#ifdef TOBEMIGRATED
if (osd_getenv(SDLENV_VMWARE) != NULL)
{
m_usetexturerect = 1;
m_texpoweroftwo = 1;
}
#endif
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&m_texture_max_width);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&m_texture_max_height);
if (!shown_video_info)
@ -724,21 +791,73 @@ void sdl_info_ogl::initialize_gl()
// a
//============================================================
#ifdef OSD_WINDOWS
void
setupPixelFormat(HDC hDC)
{
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), /* size */
1, /* version */
PFD_SUPPORT_OPENGL |
PFD_DRAW_TO_WINDOW |
PFD_DOUBLEBUFFER, /* support double-buffering */
PFD_TYPE_RGBA, /* color type */
32, /* prefered color depth */
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
0, /* no alpha buffer */
0, /* alpha bits (ignored) */
0, /* no accumulation buffer */
0, 0, 0, 0, /* accum bits (ignored) */
16, /* depth buffer */
0, /* no stencil buffer */
0, /* no auxiliary buffers */
PFD_MAIN_PLANE, /* main layer */
0, /* reserved */
0, 0, 0, /* no layer, visible, damage masks */
};
int pixelFormat;
pixelFormat = ChoosePixelFormat(hDC, &pfd);
if (pixelFormat == 0) {
osd_printf_error("ChoosePixelFormat failed.\n");
exit(1);
}
if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE) {
osd_printf_error("SetPixelFormat failed.\n");
exit(1);
}
}
#endif
int sdl_info_ogl::create()
{
#if (SDLMAME_SDL2)
// create renderer
#ifdef OSD_WINDOWS
m_hdc = GetDC(window().m_hwnd);
setupPixelFormat(m_hdc);
m_gl_context_id = wglCreateContext(m_hdc);
if (!m_gl_context_id)
{
char errorStr[1024];
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, errorStr, 255, NULL);
osd_printf_error("OpenGL not supported on this driver %s\n", errorStr);
return 1;
}
wglMakeCurrent(m_hdc, m_gl_context_id);
#else
m_gl_context_id = SDL_GL_CreateContext(window().sdl_window());
if (!m_gl_context_id)
{
osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
return 1;
}
#endif
#ifndef OSD_WINDOWS
SDL_GL_SetSwapInterval(video_config.waitvsync ? 2 : 0);
#endif
#else
#endif
@ -779,8 +898,13 @@ void sdl_info_ogl::destroy()
destroy_all_textures();
#if (SDLMAME_SDL2)
#ifdef OSD_WINDOWS
wglDeleteContext(m_gl_context_id);
ReleaseDC(window().m_hwnd, m_hdc);
#else
SDL_GL_DeleteContext(m_gl_context_id);
#endif
#endif
}
@ -815,7 +939,11 @@ void sdl_info_ogl::destroy_all_textures()
return;
#if (SDLMAME_SDL2)
#ifdef OSD_WINDOWS
wglMakeCurrent(m_hdc, m_gl_context_id);
#else
SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id);
#endif
#endif
if(window().m_primlist)
@ -1199,7 +1327,11 @@ void sdl_info_ogl::loadGLExtensions()
// sdl_info::draw
//============================================================
int sdl_info_ogl::draw(UINT32 dc, int update)
#ifdef OSD_WINDOWS
int sdl_info_ogl::draw(const HDC dc, const int update)
#else
int sdl_info_ogl::draw(const UINT32 dc, const int update)
#endif
{
render_primitive *prim;
texture_info *texture=NULL;
@ -1207,10 +1339,12 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
int pendingPrimitive=GL_NO_PRIMITIVE, curPrimitive=GL_NO_PRIMITIVE;
int width = 0; int height = 0;
#ifdef TOBEMIGRATED
if (video_config.novideo)
{
return 0;
}
#endif
window().get_size(width, height);
@ -1225,7 +1359,11 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
}
#if (SDLMAME_SDL2)
#ifdef OSD_WINDOWS
wglMakeCurrent(m_hdc, m_gl_context_id);
#else
SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id);
#endif
#endif
if (m_init_context)
@ -1294,9 +1432,11 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
m_last_blendmode = BLENDMODE_ALPHA;
#ifdef TOBEMIGRATED
// set lines and points just barely above normal size to get proper results
glLineWidth(video_config.beamwidth);
glPointSize(video_config.beamwidth);
#endif
// set up a nice simple 2D coordinate system, so GL behaves exactly how we'd like.
//
@ -1327,6 +1467,7 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
// compute centering parameters
vofs = hofs = 0.0f;
#ifdef TOBEMIGRATED
if (video_config.centerv || video_config.centerh)
{
int ch, cw;
@ -1343,6 +1484,8 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
hofs = (cw - m_blitwidth) / 2.0f;
}
}
#else
#endif
m_last_hofs = hofs;
m_last_vofs = vofs;
@ -1571,8 +1714,13 @@ int sdl_info_ogl::draw(UINT32 dc, int update)
#if (!SDLMAME_SDL2)
SDL_GL_SwapBuffers();
#else
#ifdef OSD_WINDOWS
SwapBuffers(m_hdc);
//wglSwapLayerBuffers(GetDC(window().m_hwnd), WGL_SWAP_MAIN_PLANE);
#else
SDL_GL_SwapWindow(window().sdl_window());
#endif
#endif
return 0;
}

View File

@ -1,9 +1,13 @@
#include <stdio.h> /* snprintf */
#include <stdlib.h> /* malloc */
#ifdef OSD_WINDOWS
#include "GL/gl.h"
#include "GL/glext.h"
#else
#include "sdlinc.h"
#include "osd_opengl.h"
#endif
#include "gl_shader_mgr.h"
#include "gl_shader_tool.h"
@ -120,7 +124,11 @@ glsl_shader_info *glsl_shader_init(void)
{
int i,j, err;
err = gl_shader_loadExtention((PFNGLGETPROCADDRESSOS)SDL_GL_GetProcAddress);
#ifdef OSD_WINDOWS
err = gl_shader_loadExtention((PFNGLGETPROCADDRESSOS)wglGetProcAddress);
#else
err = gl_shader_loadExtention((PFNGLGETPROCADDRESSOS)SDL_GL_GetProcAddress);
#endif
if(err) return NULL;
for (i=0; !err && i<GLSL_VERTEX_SHADER_INT_NUMBER; i++)

View File

@ -51,7 +51,12 @@ extern "C" {
#define GL_GLEXT_PROTOTYPES 1
#endif
#ifdef OSD_WINDOWS
#include "GL/gl.h"
#include "GL/glext.h"
#else
#include "osd_opengl.h"
#endif
#if defined(SDLMAME_MACOSX)

View File

@ -665,7 +665,7 @@ static void devmap_init(running_machine &machine, device_map_t *devmap, const ch
sprintf(defname, "%s%d", opt, dev + 1);
dev_name = machine.options().value(defname);
if (dev_name && *dev_name && strcmp(dev_name,SDLOPTVAL_AUTO))
if (dev_name && *dev_name && strcmp(dev_name,OSDOPTVAL_AUTO))
{
devmap->map[dev].name = remove_spaces(machine, dev_name);
osd_printf_verbose("%s: Logical id %d: %s\n", label, dev + 1, devmap->map[dev].name);

View File

@ -81,9 +81,6 @@
#define SDLOPTION_RENDERDRIVER "renderdriver"
#define SDLOPTION_GL_LIB "gl_lib"
#define SDLOPTVAL_NONE "none"
#define SDLOPTVAL_AUTO "auto"
#define SDLOPTVAL_OPENGL "opengl"
#define SDLOPTVAL_SOFT "soft"
#define SDLOPTVAL_SDL2ACCEL "accel"
@ -109,7 +106,7 @@
/* Vas Crabb: Default GL-lib for MACOSX */
#define SDLOPTVAL_GLLIB "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
#else
#define SDLOPTVAL_GLLIB SDLOPTVAL_AUTO
#define SDLOPTVAL_GLLIB OSDOPTVAL_AUTO
#endif
@ -209,8 +206,7 @@ public:
private:
virtual void osd_exit();
// FIXME: remove machine usage
void extract_video_config(running_machine &machine);
void extract_video_config();
sdl_options &m_options;

View File

@ -103,9 +103,9 @@ const options_entry sdl_options::s_option_entries[] =
{ SDLOPTION_CENTERH, "1", OPTION_BOOLEAN, "center horizontally within the view area" },
{ SDLOPTION_CENTERV, "1", OPTION_BOOLEAN, "center vertically within the view area" },
#if (SDLMAME_SDL2)
{ SDLOPTION_SCALEMODE ";sm", SDLOPTVAL_NONE, OPTION_STRING, "Scale mode: none, hwblit, hwbest, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" },
{ SDLOPTION_SCALEMODE ";sm", OSDOPTVAL_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)" },
{ SDLOPTION_SCALEMODE ";sm", OSDOPTVAL_NONE, OPTION_STRING, "Scale mode: none, async, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" },
#endif
#if USE_OPENGL
// OpenGL specific options
@ -118,26 +118,26 @@ const options_entry sdl_options::s_option_entries[] =
{ SDLOPTION_GL_PBO, "1", OPTION_BOOLEAN, "enable OpenGL PBO, if available (default on)" },
{ SDLOPTION_GL_GLSL, "0", OPTION_BOOLEAN, "enable OpenGL GLSL, if available (default off)" },
{ SDLOPTION_GLSL_FILTER, "1", OPTION_STRING, "enable OpenGL GLSL filtering instead of FF filtering 0-plain, 1-bilinear (default)" },
{ SDLOPTION_SHADER_MAME "0", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 0" },
{ SDLOPTION_SHADER_MAME "1", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 1" },
{ SDLOPTION_SHADER_MAME "2", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 2" },
{ SDLOPTION_SHADER_MAME "3", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 3" },
{ SDLOPTION_SHADER_MAME "4", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 4" },
{ SDLOPTION_SHADER_MAME "5", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 5" },
{ SDLOPTION_SHADER_MAME "6", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 6" },
{ SDLOPTION_SHADER_MAME "7", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 7" },
{ SDLOPTION_SHADER_MAME "8", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 8" },
{ SDLOPTION_SHADER_MAME "9", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 9" },
{ SDLOPTION_SHADER_SCREEN "0", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 0" },
{ SDLOPTION_SHADER_SCREEN "1", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 1" },
{ SDLOPTION_SHADER_SCREEN "2", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 2" },
{ SDLOPTION_SHADER_SCREEN "3", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 3" },
{ SDLOPTION_SHADER_SCREEN "4", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 4" },
{ SDLOPTION_SHADER_SCREEN "5", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 5" },
{ SDLOPTION_SHADER_SCREEN "6", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 6" },
{ SDLOPTION_SHADER_SCREEN "7", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 7" },
{ SDLOPTION_SHADER_SCREEN "8", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 8" },
{ SDLOPTION_SHADER_SCREEN "9", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 9" },
{ SDLOPTION_SHADER_MAME "0", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 0" },
{ SDLOPTION_SHADER_MAME "1", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 1" },
{ SDLOPTION_SHADER_MAME "2", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 2" },
{ SDLOPTION_SHADER_MAME "3", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 3" },
{ SDLOPTION_SHADER_MAME "4", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 4" },
{ SDLOPTION_SHADER_MAME "5", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 5" },
{ SDLOPTION_SHADER_MAME "6", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 6" },
{ SDLOPTION_SHADER_MAME "7", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 7" },
{ SDLOPTION_SHADER_MAME "8", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 8" },
{ SDLOPTION_SHADER_MAME "9", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader set mame bitmap 9" },
{ SDLOPTION_SHADER_SCREEN "0", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 0" },
{ SDLOPTION_SHADER_SCREEN "1", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 1" },
{ SDLOPTION_SHADER_SCREEN "2", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 2" },
{ SDLOPTION_SHADER_SCREEN "3", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 3" },
{ SDLOPTION_SHADER_SCREEN "4", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 4" },
{ SDLOPTION_SHADER_SCREEN "5", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 5" },
{ SDLOPTION_SHADER_SCREEN "6", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 6" },
{ SDLOPTION_SHADER_SCREEN "7", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 7" },
{ SDLOPTION_SHADER_SCREEN "8", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 8" },
{ SDLOPTION_SHADER_SCREEN "9", OSDOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 9" },
#endif
// full screen options
@ -158,57 +158,57 @@ const options_entry sdl_options::s_option_entries[] =
// joystick mapping
{ NULL, NULL, OPTION_HEADER, "SDL JOYSTICK MAPPING" },
{ SDLOPTION_JOYINDEX "1", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #1" },
{ SDLOPTION_JOYINDEX "2", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #2" },
{ SDLOPTION_JOYINDEX "3", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #3" },
{ SDLOPTION_JOYINDEX "4", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #4" },
{ SDLOPTION_JOYINDEX "5", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #5" },
{ SDLOPTION_JOYINDEX "6", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #6" },
{ SDLOPTION_JOYINDEX "7", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #7" },
{ SDLOPTION_JOYINDEX "8", SDLOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #8" },
{ SDLOPTION_JOYINDEX "1", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #1" },
{ SDLOPTION_JOYINDEX "2", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #2" },
{ SDLOPTION_JOYINDEX "3", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #3" },
{ SDLOPTION_JOYINDEX "4", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #4" },
{ SDLOPTION_JOYINDEX "5", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #5" },
{ SDLOPTION_JOYINDEX "6", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #6" },
{ SDLOPTION_JOYINDEX "7", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #7" },
{ SDLOPTION_JOYINDEX "8", OSDOPTVAL_AUTO, OPTION_STRING, "name of joystick mapped to joystick #8" },
{ SDLOPTION_SIXAXIS, "0", OPTION_BOOLEAN, "Use special handling for PS3 Sixaxis controllers" },
#if (USE_XINPUT)
// lightgun mapping
{ NULL, NULL, OPTION_HEADER, "SDL LIGHTGUN MAPPING" },
{ SDLOPTION_LIGHTGUNINDEX "1", SDLOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #1" },
{ SDLOPTION_LIGHTGUNINDEX "2", SDLOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #2" },
{ SDLOPTION_LIGHTGUNINDEX "3", SDLOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #3" },
{ SDLOPTION_LIGHTGUNINDEX "4", SDLOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #4" },
{ SDLOPTION_LIGHTGUNINDEX "5", SDLOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #5" },
{ SDLOPTION_LIGHTGUNINDEX "6", SDLOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #6" },
{ SDLOPTION_LIGHTGUNINDEX "7", SDLOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #7" },
{ SDLOPTION_LIGHTGUNINDEX "8", SDLOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #8" },
{ SDLOPTION_LIGHTGUNINDEX "1", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #1" },
{ SDLOPTION_LIGHTGUNINDEX "2", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #2" },
{ SDLOPTION_LIGHTGUNINDEX "3", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #3" },
{ SDLOPTION_LIGHTGUNINDEX "4", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #4" },
{ SDLOPTION_LIGHTGUNINDEX "5", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #5" },
{ SDLOPTION_LIGHTGUNINDEX "6", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #6" },
{ SDLOPTION_LIGHTGUNINDEX "7", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #7" },
{ SDLOPTION_LIGHTGUNINDEX "8", OSDOPTVAL_AUTO, OPTION_STRING, "name of lightgun mapped to lightgun #8" },
#endif
#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" },
{ SDLOPTION_MOUSEINDEX "3", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #3" },
{ SDLOPTION_MOUSEINDEX "4", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #4" },
{ SDLOPTION_MOUSEINDEX "5", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #5" },
{ SDLOPTION_MOUSEINDEX "6", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #6" },
{ SDLOPTION_MOUSEINDEX "7", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #7" },
{ SDLOPTION_MOUSEINDEX "8", SDLOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #8" },
{ SDLOPTION_MOUSEINDEX "1", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #1" },
{ SDLOPTION_MOUSEINDEX "2", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #2" },
{ SDLOPTION_MOUSEINDEX "3", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #3" },
{ SDLOPTION_MOUSEINDEX "4", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #4" },
{ SDLOPTION_MOUSEINDEX "5", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #5" },
{ SDLOPTION_MOUSEINDEX "6", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #6" },
{ SDLOPTION_MOUSEINDEX "7", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #7" },
{ SDLOPTION_MOUSEINDEX "8", OSDOPTVAL_AUTO, OPTION_STRING, "name of mouse mapped to mouse #8" },
{ NULL, NULL, OPTION_HEADER, "SDL KEYBOARD MAPPING" },
{ SDLOPTION_KEYBINDEX "1", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #1" },
{ SDLOPTION_KEYBINDEX "2", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #2" },
{ SDLOPTION_KEYBINDEX "3", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #3" },
{ SDLOPTION_KEYBINDEX "4", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #4" },
{ SDLOPTION_KEYBINDEX "5", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #5" },
{ SDLOPTION_KEYBINDEX "6", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #6" },
{ SDLOPTION_KEYBINDEX "7", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #7" },
{ SDLOPTION_KEYBINDEX "8", SDLOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #8" },
{ SDLOPTION_KEYBINDEX "1", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #1" },
{ SDLOPTION_KEYBINDEX "2", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #2" },
{ SDLOPTION_KEYBINDEX "3", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #3" },
{ SDLOPTION_KEYBINDEX "4", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #4" },
{ SDLOPTION_KEYBINDEX "5", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #5" },
{ SDLOPTION_KEYBINDEX "6", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #6" },
{ SDLOPTION_KEYBINDEX "7", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #7" },
{ SDLOPTION_KEYBINDEX "8", OSDOPTVAL_AUTO, OPTION_STRING, "name of keyboard mapped to keyboard #8" },
#endif
// 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" },
{ SDLOPTION_VIDEODRIVER ";vd", OSDOPTVAL_AUTO, OPTION_STRING, "sdl video driver to use ('x11', 'directfb', ... or 'auto' for SDL default" },
#if (SDLMAME_SDL2)
{ SDLOPTION_RENDERDRIVER ";rd", SDLOPTVAL_AUTO, OPTION_STRING, "sdl render driver to use ('software', 'opengl', 'directfb' ... or 'auto' for SDL default" },
{ SDLOPTION_RENDERDRIVER ";rd", OSDOPTVAL_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" },
{ SDLOPTION_AUDIODRIVER ";ad", OSDOPTVAL_AUTO, OPTION_STRING, "sdl audio driver to use ('alsa', 'arts', ... or 'auto' for SDL default" },
#if USE_OPENGL
{ SDLOPTION_GL_LIB, SDLOPTVAL_GLLIB, OPTION_STRING, "alternative libGL.so to use; 'auto' for system default" },
#endif
@ -542,14 +542,14 @@ void sdl_osd_interface::init(running_machine &machine)
// Some driver options - must be before audio init!
stemp = options().audio_driver();
if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0)
{
osd_printf_verbose("Setting SDL audiodriver '%s' ...\n", stemp);
osd_setenv(SDLENV_AUDIODRIVER, stemp, 1);
}
stemp = options().video_driver();
if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0)
{
osd_printf_verbose("Setting SDL videodriver '%s' ...\n", stemp);
osd_setenv(SDLENV_VIDEODRIVER, stemp, 1);
@ -559,7 +559,7 @@ void sdl_osd_interface::init(running_machine &machine)
stemp = options().render_driver();
if (stemp != NULL)
{
if (strcmp(stemp, SDLOPTVAL_AUTO) != 0)
if (strcmp(stemp, OSDOPTVAL_AUTO) != 0)
{
osd_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp);
//osd_setenv(SDLENV_RENDERDRIVER, stemp, 1);
@ -584,7 +584,7 @@ void sdl_osd_interface::init(running_machine &machine)
/* FIXME: move lib loading code from drawogl.c here */
stemp = options().gl_lib();
if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0)
{
osd_setenv("SDL_VIDEO_GL_DRIVER", stemp, 1);
osd_printf_verbose("Setting SDL_VIDEO_GL_DRIVER = '%s' ...\n", stemp);

View File

@ -95,7 +95,7 @@ bool sdl_osd_interface::video_init()
int index;
// extract data from the options
extract_video_config(machine());
extract_video_config();
// set up monitors first
sdl_monitor_info::init();
@ -418,7 +418,7 @@ void sdl_monitor_info::init()
monitor = global_alloc_clear(sdl_monitor_info);
monitor->m_handle = i;
snprintf(monitor->m_monitor_device, sizeof(monitor->m_monitor_device)-1, "%s%d", OSDOPTION_SCREEN,i);
snprintf(monitor->m_name, sizeof(monitor->m_name)-1, "%s%d", OSDOPTION_SCREEN,i);
SDL_GetDesktopDisplayMode(i, &dmode);
SDL_GetDisplayBounds(i, &monitor->m_dimensions);
@ -426,7 +426,7 @@ void sdl_monitor_info::init()
// guess the aspect ratio assuming square pixels
monitor->m_aspect = (float)(dmode.w) / (float)(dmode.h);
osd_printf_verbose("Adding monitor %s (%d x %d)\n", monitor->m_monitor_device, dmode.w, dmode.h);
osd_printf_verbose("Adding monitor %s (%d x %d)\n", monitor->m_name, dmode.w, dmode.h);
monx += dmode.w;
@ -488,7 +488,7 @@ sdl_monitor_info *sdl_monitor_info::pick_monitor(sdl_options &options, int index
for (monitor = sdl_monitor_info::list; monitor != NULL; monitor = monitor->next())
{
moncount++;
if (strcmp(scrname, monitor->device()) == 0)
if (strcmp(scrname, monitor->devicename()) == 0)
goto finishit;
}
}
@ -584,7 +584,7 @@ static void check_osd_inputs(running_machine &machine)
// extract_video_config
//============================================================
void sdl_osd_interface::extract_video_config(running_machine &machine)
void sdl_osd_interface::extract_video_config()
{
const char *stemp;
@ -592,6 +592,7 @@ void sdl_osd_interface::extract_video_config(running_machine &machine)
// global options: extract the data
video_config.windowed = options().window();
video_config.prescale = options().prescale();
video_config.keepaspect = options().keep_aspect();
video_config.numscreens = options().numscreens();
video_config.fullstretch = options().uneven_stretch();
@ -599,8 +600,8 @@ void sdl_osd_interface::extract_video_config(running_machine &machine)
video_config.restrictonemonitor = !options().use_all_heads();
#endif
if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)
// if we are in debug mode, never go full screen
if (machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)
video_config.windowed = TRUE;
// default to working video please
@ -618,7 +619,7 @@ void sdl_osd_interface::extract_video_config(running_machine &machine)
}
if (strcmp(stemp, SDLOPTVAL_SOFT) == 0)
video_config.mode = VIDEO_MODE_SOFT;
else if (strcmp(stemp, SDLOPTVAL_NONE) == 0)
else if (strcmp(stemp, OSDOPTVAL_NONE) == 0)
{
video_config.mode = VIDEO_MODE_SOFT;
video_config.novideo = 1;
@ -656,11 +657,10 @@ void sdl_osd_interface::extract_video_config(running_machine &machine)
}
#if (USE_OPENGL || SDLMAME_SDL2)
video_config.filter = options().filter();
video_config.filter = options().filter();
#endif
#if (USE_OPENGL)
video_config.prescale = options().prescale();
if (video_config.prescale < 1 || video_config.prescale > 3)
{
osd_printf_warning("Invalid prescale option, reverting to '1'\n");
@ -683,7 +683,7 @@ void sdl_osd_interface::extract_video_config(running_machine &machine)
for(i=0; i<GLSL_SHADER_MAX; i++)
{
stemp = options().shader_mame(i);
if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
if (stemp && strcmp(stemp, OSDOPTVAL_NONE) != 0 && strlen(stemp)>0)
{
video_config.glsl_shader_mamebm[i] = (char *) malloc(strlen(stemp)+1);
strcpy(video_config.glsl_shader_mamebm[i], stemp);
@ -698,7 +698,7 @@ void sdl_osd_interface::extract_video_config(running_machine &machine)
for(i=0; i<GLSL_SHADER_MAX; i++)
{
stemp = options().shader_screen(i);
if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
if (stemp && strcmp(stemp, OSDOPTVAL_NONE) != 0 && strlen(stemp)>0)
{
video_config.glsl_shader_scrn[i] = (char *) malloc(strlen(stemp)+1);
strcpy(video_config.glsl_shader_scrn[i], stemp);
@ -763,9 +763,9 @@ static float get_aspect(const char *defdata, const char *data, int report_error)
{
int num = 0, den = 1;
if (strcmp(data, SDLOPTVAL_AUTO) == 0)
if (strcmp(data, OSDOPTVAL_AUTO) == 0)
{
if (strcmp(defdata,SDLOPTVAL_AUTO) == 0)
if (strcmp(defdata,OSDOPTVAL_AUTO) == 0)
return 0;
data = defdata;
}
@ -782,13 +782,10 @@ static float get_aspect(const char *defdata, const char *data, int report_error)
static void get_resolution(const char *defdata, const char *data, sdl_window_config *config, int report_error)
{
config->width = config->height = config->depth = config->refresh = 0;
if (strcmp(data, SDLOPTVAL_AUTO) == 0)
if (strcmp(data, OSDOPTVAL_AUTO) == 0)
{
if (strcmp(defdata, SDLOPTVAL_AUTO) == 0)
{
if (strcmp(defdata, OSDOPTVAL_AUTO) == 0)
return;
}
data = defdata;
}

View File

@ -70,14 +70,14 @@ public:
sdl_monitor_info(const UINT64 handle, const char *monitor_device, float aspect)
: m_next(NULL), m_handle(handle), m_aspect(aspect)
{
strncpy(m_monitor_device, monitor_device, 64);
strncpy(m_name, monitor_device, 64);
refresh();
}
const UINT64 handle() { return m_handle; }
const SDL_Rect &position_size() { refresh(); return m_dimensions; }
const char *device() { return m_monitor_device; }
const char *devicename() { refresh(); return (m_name != NULL) ? m_name : "UNKNOWN"; }
float aspect();
@ -97,14 +97,13 @@ public:
static sdl_monitor_info *primary_monitor;
static sdl_monitor_info *list;
// FIXME: shouldn't be here - see windows enumeration callback
sdl_monitor_info * m_next; // pointer to next monitor in list
private:
void refresh();
UINT64 m_handle; // handle to the monitor
SDL_Rect m_dimensions;
char m_monitor_device[64];
char m_name[64];
float m_aspect; // computed/configured aspect ratio of the physical device
};
@ -126,8 +125,8 @@ struct sdl_video_config
// global configuration
int windowed; // start windowed?
int prescale; // prescale factor (supported by accel driver)
int keepaspect; // keep aspect ratio?
int prescale; // prescale factor
int keepaspect; // keep aspect ratio
int numscreens; // number of screens
int centerh;
int centerv;

View File

@ -66,10 +66,11 @@ public:
float aspect() const { return monitor()->aspect(); }
virtual void get_size(int &w, int &h) = 0;
#ifdef OSD_SDL
virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
virtual sdl_monitor_info *monitor() const = 0;
virtual void get_size(int &w, int &h) = 0;
#if (SDLMAME_SDL2)
virtual SDL_Window *sdl_window() = 0;
#else

View File

@ -1266,7 +1266,7 @@ int renderer::get_adapter_for_monitor()
HMONITOR curmonitor = (*d3dintf->d3d.get_adapter_monitor)(d3dintf, adapternum);
// if we match the proposed monitor, this is it
if (curmonitor == window().monitor()->handle)
if (curmonitor == window().monitor()->handle())
{
return adapternum;
}

View File

@ -964,10 +964,11 @@ void renderer_dd::blit_to_primary(int srcwidth, int srcheight)
ClientToScreen(window().m_hwnd, &((LPPOINT)&outer)[1]);
// adjust to be relative to the monitor
outer.left -= monitor->info.rcMonitor.left;
outer.right -= monitor->info.rcMonitor.left;
outer.top -= monitor->info.rcMonitor.top;
outer.bottom -= monitor->info.rcMonitor.top;
RECT pos = monitor->position_size();
outer.left -= pos.left;
outer.right -= pos.left;
outer.top -= pos.top;
outer.bottom -= pos.top;
}
// compute outer rect -- full screen version
@ -1160,7 +1161,7 @@ static BOOL WINAPI monitor_enum_callback(GUID FAR *guid, LPSTR description, LPST
monitor_enum_info *einfo = (monitor_enum_info *)context;
// do we match the desired monitor?
if (hmonitor == einfo->monitor->handle || (hmonitor == NULL && (einfo->monitor->info.dwFlags & MONITORINFOF_PRIMARY) != 0))
if (hmonitor == einfo->monitor->handle() || (hmonitor == NULL && einfo->monitor->is_primary()))
{
einfo->guid_ptr = (guid != NULL) ? &einfo->guid : NULL;
if (guid != NULL)

View File

@ -51,12 +51,10 @@ static win_monitor_info *primary_monitor;
//============================================================
static void init_monitors(void);
static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data);
static win_monitor_info *pick_monitor(windows_options &options, int index);
static void check_osd_inputs(running_machine &machine);
static void extract_video_config(running_machine &machine);
static float get_aspect(const char *defdata, const char *data, int report_error);
static void get_resolution(const char *defdata, const char *data, win_window_config *config, int report_error);
@ -71,7 +69,7 @@ bool windows_osd_interface::video_init()
int index;
// extract data from the options
extract_video_config(machine());
extract_video_config();
// set up monitors first
init_monitors();
@ -102,7 +100,7 @@ void windows_osd_interface::video_exit()
while (win_monitor_list != NULL)
{
win_monitor_info *temp = win_monitor_list;
win_monitor_list = temp->next;
win_monitor_list = temp->m_next;
global_free(temp);
}
}
@ -110,11 +108,9 @@ void windows_osd_interface::video_exit()
win_monitor_info::win_monitor_info()
: next(NULL),
handle(NULL),
: m_next(NULL),
m_handle(NULL),
m_aspect(0.0f),
reqwidth(0),
reqheight(0),
m_name(NULL)
{
}
@ -134,12 +130,12 @@ void win_monitor_info::refresh()
BOOL result;
// fetch the latest info about the monitor
info.cbSize = sizeof(info);
result = GetMonitorInfo(handle, (LPMONITORINFO)&info);
m_info.cbSize = sizeof(m_info);
result = GetMonitorInfo(m_handle, (LPMONITORINFO)&m_info);
assert(result);
if (m_name != NULL)
osd_free(m_name);
m_name = utf8_from_tstring(info.szDevice);
m_name = utf8_from_tstring(m_info.szDevice);
(void)result; // to silence gcc 4.6
}
@ -152,12 +148,14 @@ void win_monitor_info::refresh()
float win_monitor_info::aspect()
{
// refresh the monitor information and compute the aspect
refresh();
// FIXME: returning 0 looks odd, video_config is bad
if (video_config.keepaspect)
{
int width, height;
refresh();
width = rect_width(&info.rcMonitor);
height = rect_height(&info.rcMonitor);
width = rect_width(&m_info.rcMonitor);
height = rect_height(&m_info.rcMonitor);
return m_aspect / ((float)width / (float)height);
}
return 0.0f;
@ -174,8 +172,8 @@ win_monitor_info *winvideo_monitor_from_handle(HMONITOR hmonitor)
win_monitor_info *monitor;
// find the matching monitor
for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next)
if (monitor->handle == hmonitor)
for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
if (monitor->handle() == hmonitor)
return monitor;
return NULL;
}
@ -218,14 +216,14 @@ static void init_monitors(void)
// make a list of monitors
win_monitor_list = NULL;
tailptr = &win_monitor_list;
EnumDisplayMonitors(NULL, NULL, monitor_enum_callback, (LPARAM)&tailptr);
EnumDisplayMonitors(NULL, NULL, win_monitor_info::monitor_enum_callback, (LPARAM)&tailptr);
// if we're verbose, print the list of monitors
{
win_monitor_info *monitor;
for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next)
for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
{
osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle, monitor->devicename(), (monitor == primary_monitor) ? "(primary)" : "");
osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle(), monitor->devicename(), (monitor == primary_monitor) ? "(primary)" : "");
}
}
}
@ -236,7 +234,7 @@ static void init_monitors(void)
// monitor_enum_callback
//============================================================
static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data)
BOOL CALLBACK win_monitor_info::monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data)
{
win_monitor_info ***tailptr = (win_monitor_info ***)data;
win_monitor_info *monitor;
@ -253,19 +251,19 @@ static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect,
monitor = global_alloc(win_monitor_info);
// copy in the data
monitor->handle = handle;
monitor->info = info;
monitor->m_handle = handle;
monitor->m_info = info;
// guess the aspect ratio assuming square pixels
monitor->set_aspect((float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top));
// save the primary monitor handle
if (monitor->info.dwFlags & MONITORINFOF_PRIMARY)
if (monitor->m_info.dwFlags & MONITORINFOF_PRIMARY)
primary_monitor = monitor;
// hook us into the list
**tailptr = monitor;
*tailptr = &monitor->next;
*tailptr = &monitor->m_next;
// enumerate all the available monitors so to list their names in verbose mode
return TRUE;
@ -297,7 +295,7 @@ static win_monitor_info *pick_monitor(windows_options &options, int index)
// look for a match in the name first
if (scrname[0] != 0)
for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next)
for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
{
int rc = 1;
@ -311,7 +309,7 @@ static win_monitor_info *pick_monitor(windows_options &options, int index)
// didn't find it; alternate monitors until we hit the jackpot
index %= moncount;
for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next)
for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
if (index-- == 0)
goto finishit;
@ -320,7 +318,9 @@ static win_monitor_info *pick_monitor(windows_options &options, int index)
finishit:
if (aspect != 0)
{
monitor->set_aspect(aspect);
}
return monitor;
}
@ -355,30 +355,29 @@ static void check_osd_inputs(running_machine &machine)
// extract_video_config
//============================================================
static void extract_video_config(running_machine &machine)
void windows_osd_interface::extract_video_config()
{
windows_options &options = downcast<windows_options &>(machine.options());
const char *stemp;
// global options: extract the data
video_config.windowed = options.window();
video_config.prescale = options.prescale();
video_config.keepaspect = options.keep_aspect();
video_config.numscreens = options.numscreens();
video_config.windowed = options().window();
video_config.prescale = options().prescale();
video_config.keepaspect = options().keep_aspect();
video_config.numscreens = options().numscreens();
// if we are in debug mode, never go full screen
if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)
if (machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)
video_config.windowed = TRUE;
// per-window options: extract the data
const char *default_resolution = options.resolution();
get_resolution(default_resolution, options.resolution(0), &video_config.window[0], TRUE);
get_resolution(default_resolution, options.resolution(1), &video_config.window[1], TRUE);
get_resolution(default_resolution, options.resolution(2), &video_config.window[2], TRUE);
get_resolution(default_resolution, options.resolution(3), &video_config.window[3], TRUE);
const char *default_resolution = options().resolution();
get_resolution(default_resolution, options().resolution(0), &video_config.window[0], TRUE);
get_resolution(default_resolution, options().resolution(1), &video_config.window[1], TRUE);
get_resolution(default_resolution, options().resolution(2), &video_config.window[2], TRUE);
get_resolution(default_resolution, options().resolution(3), &video_config.window[3], TRUE);
// video options: extract the data
stemp = options.video();
stemp = options().video();
if (strcmp(stemp, "d3d") == 0)
video_config.mode = VIDEO_MODE_D3D;
else if (strcmp(stemp, "auto") == 0)
@ -392,24 +391,28 @@ static void extract_video_config(running_machine &machine)
else if (strcmp(stemp, "none") == 0)
{
video_config.mode = VIDEO_MODE_NONE;
if (options.seconds_to_run() == 0)
if (options().seconds_to_run() == 0)
osd_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n");
}
#if (USE_OPENGL)
else if (strcmp(stemp, "opengl") == 0)
video_config.mode = VIDEO_MODE_OPENGL;
#endif
else
{
osd_printf_warning("Invalid video value %s; reverting to gdi\n", stemp);
video_config.mode = VIDEO_MODE_GDI;
}
video_config.waitvsync = options.wait_vsync();
video_config.syncrefresh = options.sync_refresh();
video_config.triplebuf = options.triple_buffer();
video_config.switchres = options.switch_res();
video_config.waitvsync = options().wait_vsync();
video_config.syncrefresh = options().sync_refresh();
video_config.triplebuf = options().triple_buffer();
video_config.switchres = options().switch_res();
// ddraw options: extract the data
video_config.hwstretch = options.hwstretch();
video_config.hwstretch = options().hwstretch();
// d3d options: extract the data
video_config.filter = options.filter();
video_config.filter = options().filter();
if (video_config.prescale == 0)
video_config.prescale = 1;
}
@ -424,9 +427,9 @@ static float get_aspect(const char *defdata, const char *data, int report_error)
{
int num = 0, den = 1;
if (strcmp(data, "auto") == 0)
if (strcmp(data, OSDOPTVAL_AUTO) == 0)
{
if (strcmp(defdata, "auto") == 0)
if (strcmp(defdata,OSDOPTVAL_AUTO) == 0)
return 0;
data = defdata;
}
@ -436,7 +439,6 @@ static float get_aspect(const char *defdata, const char *data, int report_error)
}
//============================================================
// get_resolution
//============================================================
@ -444,9 +446,9 @@ static float get_aspect(const char *defdata, const char *data, int report_error)
static void get_resolution(const char *defdata, const char *data, win_window_config *config, int report_error)
{
config->width = config->height = config->refresh = 0;
if (strcmp(data, "auto") == 0)
if (strcmp(data, OSDOPTVAL_AUTO) == 0)
{
if (strcmp(defdata, "auto") == 0)
if (strcmp(defdata, OSDOPTVAL_AUTO) == 0)
return;
data = defdata;
}

View File

@ -18,13 +18,18 @@
#define MAX_WINDOWS 4
#define VIDEO_MODE_NONE 0
#define VIDEO_MODE_GDI 1
#define VIDEO_MODE_DDRAW 2
#define VIDEO_MODE_D3D 3
#define VIDEO_MODE_BGFX 4
enum {
VIDEO_MODE_NONE,
VIDEO_MODE_GDI,
VIDEO_MODE_DDRAW,
VIDEO_MODE_D3D,
VIDEO_MODE_BGFX,
#if (USE_OPENGL)
VIDEO_MODE_OPENGL,
#endif
};
#define GLSL_SHADER_MAX 10
//============================================================
// TYPE DEFINITIONS
@ -37,17 +42,28 @@ public:
virtual ~win_monitor_info();
void refresh();
float aspect();
void set_aspect(float a) { m_aspect = a; }
const HMONITOR handle() { return m_handle; }
const RECT &position_size() { refresh(); return m_info.rcMonitor; }
const RECT &usuable_position_size() { refresh(); return m_info.rcWork; }
bool is_primary() { return (m_info.dwFlags & MONITORINFOF_PRIMARY) != 0; }
const char *devicename() { refresh(); return (m_name != NULL) ? m_name : "UNKNOWN"; }
win_monitor_info * next; // pointer to next monitor in list
HMONITOR handle; // handle to the monitor
MONITORINFOEX info; // most recently retrieved info
float aspect();
void set_aspect(const float a) { m_aspect = a; }
win_monitor_info * m_next; // pointer to next monitor in list
// static
static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data);
private:
HMONITOR m_handle; // handle to the monitor
MONITORINFOEX m_info; // most recently retrieved info
float m_aspect; // computed/configured aspect ratio of the physical device
int reqwidth; // requested width for this monitor
int reqheight; // requested height for this monitor
char * m_name;
};
@ -85,6 +101,19 @@ struct win_video_config
// d3d options
int filter; // enable filtering
// OpenGL options
//int filter; // enable filtering, disabled if glsl_filter>0
int glsl;
int glsl_filter; // glsl filtering, >0 disables filter
char * glsl_shader_mamebm[GLSL_SHADER_MAX]; // custom glsl shader set, mame bitmap
int glsl_shader_mamebm_num; // custom glsl shader set number, mame bitmap
char * glsl_shader_scrn[GLSL_SHADER_MAX]; // custom glsl shader set, screen bitmap
int glsl_shader_scrn_num; // custom glsl shader number, screen bitmap
int pbo;
int vbo;
int allowtexturerect; // allow GL_ARB_texture_rectangle, default: no
int forcepow2texture; // force power of two textures, default: no
};

View File

@ -40,7 +40,9 @@ extern int drawgdi_init(running_machine &machine, osd_draw_callbacks *callbacks)
extern int drawdd_init(running_machine &machine, osd_draw_callbacks *callbacks);
extern int drawd3d_init(running_machine &machine, osd_draw_callbacks *callbacks);
extern int drawbgfx_init(running_machine &machine, osd_draw_callbacks *callbacks);
#if (USE_OPENGL)
extern int drawogl_init(running_machine &machine, osd_draw_callbacks *callbacks);
#endif
//============================================================
// PARAMETERS
@ -245,7 +247,10 @@ bool windows_osd_interface::window_init()
drawbgfx_init(machine(), &draw);
if (video_config.mode == VIDEO_MODE_NONE)
drawnone_init(machine(), &draw);
#if (USE_OPENGL)
if (video_config.mode == VIDEO_MODE_OPENGL)
drawogl_init(machine(), &draw);
#endif
// set up the window list
last_window_ptr = &win_window_list;
@ -1173,7 +1178,7 @@ static int complete_create(win_window_info *window)
assert(GetCurrentThreadId() == window_threadid);
// get the monitor bounds
monitorbounds = window->m_monitor->info.rcMonitor;
monitorbounds = window->m_monitor->position_size();
// create the window menu if needed
if (downcast<windows_options &>(window->machine().options()).menu())
@ -1561,13 +1566,13 @@ static void constrain_to_aspect_ratio(win_window_info *window, RECT *rect, int a
// clamp against the maximum (fit on one screen for full screen mode)
if (window->m_fullscreen)
{
maxwidth = rect_width(&monitor->info.rcMonitor) - extrawidth;
maxheight = rect_height(&monitor->info.rcMonitor) - extraheight;
maxwidth = rect_width(&monitor->position_size()) - extrawidth;
maxheight = rect_height(&monitor->position_size()) - extraheight;
}
else
{
maxwidth = rect_width(&monitor->info.rcWork) - extrawidth;
maxheight = rect_height(&monitor->info.rcWork) - extraheight;
maxwidth = rect_width(&monitor->usuable_position_size()) - extrawidth;
maxheight = rect_height(&monitor->usuable_position_size()) - extraheight;
// further clamp to the maximum width/height in the window
if (window->m_maxwidth != 0)
@ -1695,7 +1700,7 @@ static void get_max_bounds(win_window_info *window, RECT *bounds, int constrain)
// compute the maximum client area
window->m_monitor->refresh();
maximum = window->m_monitor->info.rcWork;
maximum = window->m_monitor->usuable_position_size();
// clamp to the window's max
if (window->m_maxwidth != 0)
@ -1721,8 +1726,9 @@ static void get_max_bounds(win_window_info *window, RECT *bounds, int constrain)
}
// center within the work area
bounds->left = window->m_monitor->info.rcWork.left + (rect_width(&window->m_monitor->info.rcWork) - rect_width(&maximum)) / 2;
bounds->top = window->m_monitor->info.rcWork.top + (rect_height(&window->m_monitor->info.rcWork) - rect_height(&maximum)) / 2;
RECT work = window->m_monitor->usuable_position_size();
bounds->left = work.left + (rect_width(&work) - rect_width(&maximum)) / 2;
bounds->top = work.top + (rect_height(&work) - rect_height(&maximum)) / 2;
bounds->right = bounds->left + rect_width(&maximum);
bounds->bottom = bounds->top + rect_height(&maximum);
}
@ -1823,7 +1829,7 @@ static void adjust_window_position_after_major_change(win_window_info *window)
else
{
win_monitor_info *monitor = window->winwindow_video_window_monitor(NULL);
newrect = monitor->info.rcMonitor;
newrect = monitor->position_size();
}
// adjust the position if different

View File

@ -66,10 +66,11 @@ public:
float aspect() const { return monitor()->aspect(); }
virtual void get_size(int &w, int &h) = 0;
#ifdef OSD_SDL
virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
virtual sdl_monitor_info *monitor() const = 0;
virtual void get_size(int &w, int &h) = 0;
#if (SDLMAME_SDL2)
virtual SDL_Window *sdl_window() = 0;
#else
@ -169,6 +170,14 @@ public:
return GetMenu(m_hwnd) ? true : false;
}
/* virtual */ void get_size(int &w, int &h)
{
RECT client;
GetClientRect(m_hwnd, &client);
w = client.right - client.left;
h = client.bottom - client.top;
}
win_monitor_info *monitor() const { return m_monitor; }
win_window_info * m_next;

View File

@ -66,6 +66,9 @@
# uncomment next line to use SDL library for sound and video output
# USE_SDL = 1
# uncomment next line to compile OpenGL video renderer
# USE_OPENGL = 1
# uncomment next line to use QT debugger
# USE_QTDEBUG = 1
@ -395,6 +398,17 @@ OSDOBJS = \
$(OSDOBJ)/modules/netdev/taptun.o \
$(OSDOBJ)/modules/netdev/none.o \
ifdef USE_OPENGL
OSDOBJS += $(WINOBJ)/../sdl/drawogl.o $(WINOBJ)/../sdl/gl_shader_tool.o $(WINOBJ)/../sdl/gl_shader_mgr.o
OBJDIRS += $(WINOBJ)/../sdl
DEFS += -DUSE_OPENGL=1
LIBS += -lopengl32
else
DEFS += -DUSE_OPENGL=0
endif
ifdef USE_SDL
DEFS += -DUSE_SDL_SOUND
endif

View File

@ -503,7 +503,7 @@ static void output_oslog(running_machine &machine, const char *buffer)
//============================================================
windows_osd_interface::windows_osd_interface(windows_options &options)
: osd_common_t(options)
: osd_common_t(options), m_options(options)
{
}

View File

@ -269,8 +269,13 @@ public:
virtual void input_exit();
virtual void output_exit();
void extract_video_config();
windows_options &options() { return m_options; }
private:
void osd_exit();
windows_options &m_options;
static const int DEFAULT_FONT_HEIGHT = 200;
};
@ -296,4 +301,4 @@ extern int osd_num_processors;
void winmain_watchdog_ping(void);
void winmain_dump_stack();
#endif
#endif