Previous 199869 Revisions Next

r35190 Sunday 22nd February, 2015 at 00:14:37 UTC by Couriersud
Make OpenGL renderer available in mainline build as well. This needs to
be explicitly enabled by specifying USE_OPENGL=1. More code alignment.
[Couriersud]
[src/osd/modules/lib]osdobj_common.h
[src/osd/sdl]draw13.c drawogl.c gl_shader_mgr.c gl_shader_tool.h input.c osdsdl.h sdlmain.c video.c video.h window.h
[src/osd/windows]drawd3d.c drawdd.c video.c video.h window.c window.h windows.mak winmain.c winmain.h

trunk/src/osd/modules/lib/osdobj_common.h
r243701r243702
5656#define OSDOPTION_AUDIO_LATENCY         "audio_latency"
5757
5858#define OSDOPTVAL_AUTO                  "auto"
59#define OSDOPTVAL_NONE                  "none"
5960
61
62
6063//============================================================
6164//  TYPE DEFINITIONS
6265//============================================================
trunk/src/osd/sdl/draw13.c
r243701r243702
525525#else
526526   stemp = NULL;
527527#endif
528   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) == 0)
528   if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) == 0)
529529      stemp = NULL;
530530
531531   // No fatalerror here since not all video drivers support GL !
trunk/src/osd/sdl/drawogl.c
r243701r243702
2323#include "options.h"
2424#include "emuopts.h"
2525
26#ifndef OSD_WINDOWS
2627// standard SDL headers
28#define TOBEMIGRATED 1
2729#include "sdlinc.h"
30#else
31#define SDLMAME_SDL2 1
32#include "GL/gl.h"
33#include "GL/glext.h"
34#include "GL/wglext.h"
2835
36typedef HGLRC SDL_GLContext;
37#endif
38
2939// OpenGL headers
40#ifndef OSD_WINDOWS
3041#include "osd_opengl.h"
42#endif
3143#include "modules/lib/osdlib.h"
3244
3345
r243701r243702
121133#define OVERFLOW_SIZE   (1<<10)
122134
123135// OSD headers
136#ifndef OSD_WINDOWS
124137#include "osdsdl.h"
125138#include "window.h"
139#else
140#include "../windows/window.h"
141typedef UINT64 HashT;
142#endif
126143
127144//============================================================
128145//  DEBUGGING
r243701r243702
149166//  MACROS
150167//============================================================
151168
169#ifdef OSD_WINDOWS
170// texture formats
171// This used to be an enum, but these are now defines so we can use them as
172// preprocessor conditionals
173#define SDL_TEXFORMAT_ARGB32            (0) // non-16-bit textures or specials
174#define SDL_TEXFORMAT_RGB32             (1)
175#define SDL_TEXFORMAT_RGB32_PALETTED    (2)
176#define SDL_TEXFORMAT_YUY16             (3)
177#define SDL_TEXFORMAT_YUY16_PALETTED    (4)
178#define SDL_TEXFORMAT_PALETTE16         (5)
179#define SDL_TEXFORMAT_RGB15             (6)
180#define SDL_TEXFORMAT_RGB15_PALETTED    (7)
181#define SDL_TEXFORMAT_PALETTE16A        (8)
182// special texture formats for 16bpp texture destination support, do not use
183// to address the tex properties / tex functions arrays!
184#define SDL_TEXFORMAT_PALETTE16_ARGB1555    (16)
185#define SDL_TEXFORMAT_RGB15_ARGB1555        (17)
186#define SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555   (18)
187#endif
188
152189#define FSWAP(var1, var2) do { float temp = var1; var1 = var2; var2 = temp; } while (0)
153190#define GL_NO_PRIMITIVE -1
154191
r243701r243702
253290   }
254291
255292   /* virtual */ int create();
293#ifdef OSD_WINDOWS
294   /* virtual */ int draw(const HDC dc, const int update);
295#else
256296   /* virtual */ int draw(const UINT32 dc, const int update);
297#endif
257298   /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt);
258299   /* virtual */ void destroy();
259300   /* virtual */ render_primitive_list *get_primitives()
260301   {
261302      int nw = 0; int nh = 0;
303#ifdef OSD_WINDOWS
304      window().get_size(nw, nh);
305#else
262306      window().blit_surface_size(nw, nh);
307#endif
263308      if (nw != m_blitwidth || nh != m_blitheight)
264309      {
265310         m_blitwidth = nw; m_blitheight = nh;
r243701r243702
269314      return &window().target()->get_primitives();
270315   }
271316
317   /* virtual */ void save() { }
318   /* virtual */ void record() { }
319   /* virtual */ void toggle_fsfx() { }
320
272321private:
273322   void destroy_all_textures();
274323
r243701r243702
298347
299348#if (SDLMAME_SDL2)
300349   SDL_GLContext   m_gl_context_id;
350#ifdef OSD_WINDOWS
351   HDC            m_hdc;
352#endif
301353#else
302354#endif
303355
r243701r243702
483535   return 0;
484536}
485537
538//============================================================
539// Windows Compatibility
540//============================================================
486541
542#ifdef OSD_WINDOWS
543PROC SDL_GL_GetProcAddress(const char *procname)
544{
545   return wglGetProcAddress(procname);
546}
547#endif
548
487549//============================================================
488550// Load the OGL function addresses
489551//============================================================
r243701r243702
530592      const char *stemp;
531593
532594      stemp = downcast<sdl_options &>(machine.options()).gl_lib();
533      if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) == 0)
595      if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) == 0)
534596         stemp = NULL;
535597
536598      if (SDL_GL_LoadLibrary(stemp) != 0) // Load library (default for e==NULL
r243701r243702
552614   char *extstr = (char *)glGetString(GL_EXTENSIONS);
553615   char *vendor = (char *)glGetString(GL_VENDOR);
554616
555   //printf("%s\n", extstr);
556
617   //printf("%p\n", extstr);
618#ifdef OSD_WINDOWS
619   if (!extstr)
620      extstr = (char *)"";
621#endif
557622   // print out the driver info for debugging
558623   if (!shown_video_info)
559624   {
r243701r243702
679744      }
680745   }
681746
747#ifdef TOBEMIGRATED
682748   if (osd_getenv(SDLENV_VMWARE) != NULL)
683749   {
684750      m_usetexturerect = 1;
685751      m_texpoweroftwo = 1;
686752   }
753#endif
687754   glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&m_texture_max_width);
688755   glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&m_texture_max_height);
689756   if (!shown_video_info)
r243701r243702
724791// a
725792//============================================================
726793
794#ifdef OSD_WINDOWS
795void
796setupPixelFormat(HDC hDC)
797{
798    PIXELFORMATDESCRIPTOR pfd = {
799        sizeof(PIXELFORMATDESCRIPTOR),  /* size */
800        1,                              /* version */
801        PFD_SUPPORT_OPENGL |
802        PFD_DRAW_TO_WINDOW |
803        PFD_DOUBLEBUFFER,               /* support double-buffering */
804        PFD_TYPE_RGBA,                  /* color type */
805        32,                             /* prefered color depth */
806        0, 0, 0, 0, 0, 0,               /* color bits (ignored) */
807        0,                              /* no alpha buffer */
808        0,                              /* alpha bits (ignored) */
809        0,                              /* no accumulation buffer */
810        0, 0, 0, 0,                     /* accum bits (ignored) */
811        16,                             /* depth buffer */
812        0,                              /* no stencil buffer */
813        0,                              /* no auxiliary buffers */
814        PFD_MAIN_PLANE,                 /* main layer */
815        0,                              /* reserved */
816        0, 0, 0,                        /* no layer, visible, damage masks */
817    };
818    int pixelFormat;
819
820    pixelFormat = ChoosePixelFormat(hDC, &pfd);
821    if (pixelFormat == 0) {
822        osd_printf_error("ChoosePixelFormat failed.\n");
823        exit(1);
824    }
825
826    if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE) {
827        osd_printf_error("SetPixelFormat failed.\n");
828        exit(1);
829    }
830}
831#endif
727832int sdl_info_ogl::create()
728833{
729834
730835#if (SDLMAME_SDL2)
731836   // create renderer
732
837#ifdef OSD_WINDOWS
838   m_hdc = GetDC(window().m_hwnd);
839   setupPixelFormat(m_hdc);
840   m_gl_context_id = wglCreateContext(m_hdc);
841   if  (!m_gl_context_id)
842   {
843      char errorStr[1024];
844      FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0, errorStr, 255, NULL);
845      osd_printf_error("OpenGL not supported on this driver %s\n", errorStr);
846      return 1;
847   }
848   wglMakeCurrent(m_hdc, m_gl_context_id);
849#else
733850   m_gl_context_id = SDL_GL_CreateContext(window().sdl_window());
734851   if  (!m_gl_context_id)
735852   {
736853      osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError());
737854      return 1;
738855   }
856#endif
739857
858#ifndef OSD_WINDOWS
740859   SDL_GL_SetSwapInterval(video_config.waitvsync ? 2 : 0);
741
860#endif
742861#else
743862#endif
744863
r243701r243702
779898   destroy_all_textures();
780899
781900#if (SDLMAME_SDL2)
901#ifdef OSD_WINDOWS
902   wglDeleteContext(m_gl_context_id);
903   ReleaseDC(window().m_hwnd, m_hdc);
904#else
782905   SDL_GL_DeleteContext(m_gl_context_id);
783906#endif
907#endif
784908
785909}
786910
r243701r243702
815939      return;
816940
817941#if (SDLMAME_SDL2)
942#ifdef OSD_WINDOWS
943   wglMakeCurrent(m_hdc, m_gl_context_id);
944#else
818945   SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id);
819946#endif
947#endif
820948
821949   if(window().m_primlist)
822950   {
r243701r243702
11991327//  sdl_info::draw
12001328//============================================================
12011329
1202int sdl_info_ogl::draw(UINT32 dc, int update)
1330#ifdef OSD_WINDOWS
1331int sdl_info_ogl::draw(const HDC dc, const int update)
1332#else
1333int sdl_info_ogl::draw(const UINT32 dc, const int update)
1334#endif
12031335{
12041336   render_primitive *prim;
12051337   texture_info *texture=NULL;
r243701r243702
12071339   int  pendingPrimitive=GL_NO_PRIMITIVE, curPrimitive=GL_NO_PRIMITIVE;
12081340   int width = 0; int height = 0;
12091341
1342#ifdef TOBEMIGRATED
12101343   if (video_config.novideo)
12111344   {
12121345      return 0;
12131346   }
1347#endif
12141348
12151349   window().get_size(width, height);
12161350
r243701r243702
12251359   }
12261360
12271361#if (SDLMAME_SDL2)
1362#ifdef OSD_WINDOWS
1363   wglMakeCurrent(m_hdc, m_gl_context_id);
1364#else
12281365   SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id);
12291366#endif
1367#endif
12301368
12311369   if (m_init_context)
12321370   {
r243701r243702
12941432      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
12951433      m_last_blendmode = BLENDMODE_ALPHA;
12961434
1435#ifdef TOBEMIGRATED
12971436      // set lines and points just barely above normal size to get proper results
12981437      glLineWidth(video_config.beamwidth);
12991438      glPointSize(video_config.beamwidth);
1439#endif
13001440
13011441      // set up a nice simple 2D coordinate system, so GL behaves exactly how we'd like.
13021442      //
r243701r243702
13271467   // compute centering parameters
13281468   vofs = hofs = 0.0f;
13291469
1470#ifdef TOBEMIGRATED
13301471   if (video_config.centerv || video_config.centerh)
13311472   {
13321473      int ch, cw;
r243701r243702
13431484         hofs = (cw - m_blitwidth) / 2.0f;
13441485      }
13451486   }
1487#else
1488#endif
13461489
13471490   m_last_hofs = hofs;
13481491   m_last_vofs = vofs;
r243701r243702
15721715#if (!SDLMAME_SDL2)
15731716   SDL_GL_SwapBuffers();
15741717#else
1718#ifdef OSD_WINDOWS
1719   SwapBuffers(m_hdc);
1720   //wglSwapLayerBuffers(GetDC(window().m_hwnd), WGL_SWAP_MAIN_PLANE);
1721#else
15751722   SDL_GL_SwapWindow(window().sdl_window());
15761723#endif
1724#endif
15771725   return 0;
15781726}
15791727
trunk/src/osd/sdl/gl_shader_mgr.c
r243701r243702
11#include <stdio.h>   /* snprintf */
22#include <stdlib.h>  /* malloc */
33
4#ifdef OSD_WINDOWS
5#include "GL/gl.h"
6#include "GL/glext.h"
7#else
48#include "sdlinc.h"
5
69#include "osd_opengl.h"
10#endif
711
812#include "gl_shader_mgr.h"
913#include "gl_shader_tool.h"
r243701r243702
120124{
121125   int i,j, err;
122126
123      err = gl_shader_loadExtention((PFNGLGETPROCADDRESSOS)SDL_GL_GetProcAddress);
127#ifdef OSD_WINDOWS
128   err = gl_shader_loadExtention((PFNGLGETPROCADDRESSOS)wglGetProcAddress);
129#else
130   err = gl_shader_loadExtention((PFNGLGETPROCADDRESSOS)SDL_GL_GetProcAddress);
131#endif
124132   if(err) return NULL;
125133
126134   for (i=0; !err && i<GLSL_VERTEX_SHADER_INT_NUMBER; i++)
trunk/src/osd/sdl/gl_shader_tool.h
r243701r243702
5151#define GL_GLEXT_PROTOTYPES 1
5252#endif
5353
54#ifdef OSD_WINDOWS
55#include "GL/gl.h"
56#include "GL/glext.h"
57#else
5458#include "osd_opengl.h"
59#endif
5560
5661#if defined(SDLMAME_MACOSX)
5762
trunk/src/osd/sdl/input.c
r243701r243702
665665      sprintf(defname, "%s%d", opt, dev + 1);
666666
667667      dev_name = machine.options().value(defname);
668      if (dev_name && *dev_name && strcmp(dev_name,SDLOPTVAL_AUTO))
668      if (dev_name && *dev_name && strcmp(dev_name,OSDOPTVAL_AUTO))
669669      {
670670         devmap->map[dev].name = remove_spaces(machine, dev_name);
671671         osd_printf_verbose("%s: Logical id %d: %s\n", label, dev + 1, devmap->map[dev].name);
trunk/src/osd/sdl/osdsdl.h
r243701r243702
8181#define SDLOPTION_RENDERDRIVER          "renderdriver"
8282#define SDLOPTION_GL_LIB                "gl_lib"
8383
84#define SDLOPTVAL_NONE                  "none"
85#define SDLOPTVAL_AUTO                  "auto"
86
8784#define SDLOPTVAL_OPENGL                "opengl"
8885#define SDLOPTVAL_SOFT                  "soft"
8986#define SDLOPTVAL_SDL2ACCEL             "accel"
r243701r243702
109106/* Vas Crabb: Default GL-lib for MACOSX */
110107#define SDLOPTVAL_GLLIB                 "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
111108#else
112#define SDLOPTVAL_GLLIB                 SDLOPTVAL_AUTO
109#define SDLOPTVAL_GLLIB                 OSDOPTVAL_AUTO
113110#endif
114111
115112
r243701r243702
209206private:
210207   virtual void osd_exit();
211208
212   // FIXME: remove machine usage
213   void extract_video_config(running_machine &machine);
209   void extract_video_config();
214210
215211   sdl_options &m_options;
216212
trunk/src/osd/sdl/sdlmain.c
r243701r243702
103103   { SDLOPTION_CENTERH,                      "1",        OPTION_BOOLEAN,    "center horizontally within the view area" },
104104   { SDLOPTION_CENTERV,                      "1",        OPTION_BOOLEAN,    "center vertically within the view area" },
105105#if (SDLMAME_SDL2)
106   { SDLOPTION_SCALEMODE ";sm",         SDLOPTVAL_NONE,  OPTION_STRING,     "Scale mode: none, hwblit, hwbest, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" },
106   { SDLOPTION_SCALEMODE ";sm",         OSDOPTVAL_NONE,  OPTION_STRING,     "Scale mode: none, hwblit, hwbest, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" },
107107#else
108   { SDLOPTION_SCALEMODE ";sm",         SDLOPTVAL_NONE,  OPTION_STRING,     "Scale mode: none, async, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" },
108   { SDLOPTION_SCALEMODE ";sm",         OSDOPTVAL_NONE,  OPTION_STRING,     "Scale mode: none, async, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" },
109109#endif
110110#if USE_OPENGL
111111   // OpenGL specific options
r243701r243702
118118   { SDLOPTION_GL_PBO,                       "1",    OPTION_BOOLEAN, "enable OpenGL PBO,  if available (default on)" },
119119   { SDLOPTION_GL_GLSL,                      "0",    OPTION_BOOLEAN, "enable OpenGL GLSL, if available (default off)" },
120120   { SDLOPTION_GLSL_FILTER,                  "1",    OPTION_STRING,  "enable OpenGL GLSL filtering instead of FF filtering 0-plain, 1-bilinear (default)" },
121   { SDLOPTION_SHADER_MAME "0",     SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 0" },
122   { SDLOPTION_SHADER_MAME "1",     SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 1" },
123   { SDLOPTION_SHADER_MAME "2",     SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 2" },
124   { SDLOPTION_SHADER_MAME "3",     SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 3" },
125   { SDLOPTION_SHADER_MAME "4",     SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 4" },
126   { SDLOPTION_SHADER_MAME "5",     SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 5" },
127   { SDLOPTION_SHADER_MAME "6",     SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 6" },
128   { SDLOPTION_SHADER_MAME "7",     SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 7" },
129   { SDLOPTION_SHADER_MAME "8",     SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 8" },
130   { SDLOPTION_SHADER_MAME "9",     SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 9" },
131   { SDLOPTION_SHADER_SCREEN "0",   SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 0" },
132   { SDLOPTION_SHADER_SCREEN "1",   SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 1" },
133   { SDLOPTION_SHADER_SCREEN "2",   SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 2" },
134   { SDLOPTION_SHADER_SCREEN "3",   SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 3" },
135   { SDLOPTION_SHADER_SCREEN "4",   SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 4" },
136   { SDLOPTION_SHADER_SCREEN "5",   SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 5" },
137   { SDLOPTION_SHADER_SCREEN "6",   SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 6" },
138   { SDLOPTION_SHADER_SCREEN "7",   SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 7" },
139   { SDLOPTION_SHADER_SCREEN "8",   SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 8" },
140   { SDLOPTION_SHADER_SCREEN "9",   SDLOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 9" },
121   { SDLOPTION_SHADER_MAME "0",     OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 0" },
122   { SDLOPTION_SHADER_MAME "1",     OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 1" },
123   { SDLOPTION_SHADER_MAME "2",     OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 2" },
124   { SDLOPTION_SHADER_MAME "3",     OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 3" },
125   { SDLOPTION_SHADER_MAME "4",     OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 4" },
126   { SDLOPTION_SHADER_MAME "5",     OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 5" },
127   { SDLOPTION_SHADER_MAME "6",     OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 6" },
128   { SDLOPTION_SHADER_MAME "7",     OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 7" },
129   { SDLOPTION_SHADER_MAME "8",     OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 8" },
130   { SDLOPTION_SHADER_MAME "9",     OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader set mame bitmap 9" },
131   { SDLOPTION_SHADER_SCREEN "0",   OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 0" },
132   { SDLOPTION_SHADER_SCREEN "1",   OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 1" },
133   { SDLOPTION_SHADER_SCREEN "2",   OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 2" },
134   { SDLOPTION_SHADER_SCREEN "3",   OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 3" },
135   { SDLOPTION_SHADER_SCREEN "4",   OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 4" },
136   { SDLOPTION_SHADER_SCREEN "5",   OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 5" },
137   { SDLOPTION_SHADER_SCREEN "6",   OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 6" },
138   { SDLOPTION_SHADER_SCREEN "7",   OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 7" },
139   { SDLOPTION_SHADER_SCREEN "8",   OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 8" },
140   { SDLOPTION_SHADER_SCREEN "9",   OSDOPTVAL_NONE,  OPTION_STRING,  "custom OpenGL GLSL shader screen bitmap 9" },
141141#endif
142142
143143   // full screen options
r243701r243702
158158
159159   // joystick mapping
160160   { NULL,                                  NULL,   OPTION_HEADER,     "SDL JOYSTICK MAPPING" },
161   { SDLOPTION_JOYINDEX "1",                SDLOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #1" },
162   { SDLOPTION_JOYINDEX "2",                SDLOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #2" },
163   { SDLOPTION_JOYINDEX "3",                SDLOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #3" },
164   { SDLOPTION_JOYINDEX "4",                SDLOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #4" },
165   { SDLOPTION_JOYINDEX "5",                SDLOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #5" },
166   { SDLOPTION_JOYINDEX "6",                SDLOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #6" },
167   { SDLOPTION_JOYINDEX "7",                SDLOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #7" },
168   { SDLOPTION_JOYINDEX "8",                SDLOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #8" },
161   { SDLOPTION_JOYINDEX "1",                OSDOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #1" },
162   { SDLOPTION_JOYINDEX "2",                OSDOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #2" },
163   { SDLOPTION_JOYINDEX "3",                OSDOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #3" },
164   { SDLOPTION_JOYINDEX "4",                OSDOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #4" },
165   { SDLOPTION_JOYINDEX "5",                OSDOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #5" },
166   { SDLOPTION_JOYINDEX "6",                OSDOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #6" },
167   { SDLOPTION_JOYINDEX "7",                OSDOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #7" },
168   { SDLOPTION_JOYINDEX "8",                OSDOPTVAL_AUTO, OPTION_STRING,         "name of joystick mapped to joystick #8" },
169169   { SDLOPTION_SIXAXIS,                     "0",    OPTION_BOOLEAN,    "Use special handling for PS3 Sixaxis controllers" },
170170
171171#if (USE_XINPUT)
172172   // lightgun mapping
173173   { NULL,                                  NULL,   OPTION_HEADER,     "SDL LIGHTGUN MAPPING" },
174   { SDLOPTION_LIGHTGUNINDEX "1",           SDLOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #1" },
175   { SDLOPTION_LIGHTGUNINDEX "2",           SDLOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #2" },
176   { SDLOPTION_LIGHTGUNINDEX "3",           SDLOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #3" },
177   { SDLOPTION_LIGHTGUNINDEX "4",           SDLOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #4" },
178   { SDLOPTION_LIGHTGUNINDEX "5",           SDLOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #5" },
179   { SDLOPTION_LIGHTGUNINDEX "6",           SDLOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #6" },
180   { SDLOPTION_LIGHTGUNINDEX "7",           SDLOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #7" },
181   { SDLOPTION_LIGHTGUNINDEX "8",           SDLOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #8" },
174   { SDLOPTION_LIGHTGUNINDEX "1",           OSDOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #1" },
175   { SDLOPTION_LIGHTGUNINDEX "2",           OSDOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #2" },
176   { SDLOPTION_LIGHTGUNINDEX "3",           OSDOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #3" },
177   { SDLOPTION_LIGHTGUNINDEX "4",           OSDOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #4" },
178   { SDLOPTION_LIGHTGUNINDEX "5",           OSDOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #5" },
179   { SDLOPTION_LIGHTGUNINDEX "6",           OSDOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #6" },
180   { SDLOPTION_LIGHTGUNINDEX "7",           OSDOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #7" },
181   { SDLOPTION_LIGHTGUNINDEX "8",           OSDOPTVAL_AUTO, OPTION_STRING,         "name of lightgun mapped to lightgun #8" },
182182#endif
183183
184184#if (SDLMAME_SDL2)
185185   { NULL,                                  NULL,   OPTION_HEADER,     "SDL MOUSE MAPPING" },
186   { SDLOPTION_MOUSEINDEX "1",              SDLOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #1" },
187   { SDLOPTION_MOUSEINDEX "2",              SDLOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #2" },
188   { SDLOPTION_MOUSEINDEX "3",              SDLOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #3" },
189   { SDLOPTION_MOUSEINDEX "4",              SDLOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #4" },
190   { SDLOPTION_MOUSEINDEX "5",              SDLOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #5" },
191   { SDLOPTION_MOUSEINDEX "6",              SDLOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #6" },
192   { SDLOPTION_MOUSEINDEX "7",              SDLOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #7" },
193   { SDLOPTION_MOUSEINDEX "8",              SDLOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #8" },
186   { SDLOPTION_MOUSEINDEX "1",              OSDOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #1" },
187   { SDLOPTION_MOUSEINDEX "2",              OSDOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #2" },
188   { SDLOPTION_MOUSEINDEX "3",              OSDOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #3" },
189   { SDLOPTION_MOUSEINDEX "4",              OSDOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #4" },
190   { SDLOPTION_MOUSEINDEX "5",              OSDOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #5" },
191   { SDLOPTION_MOUSEINDEX "6",              OSDOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #6" },
192   { SDLOPTION_MOUSEINDEX "7",              OSDOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #7" },
193   { SDLOPTION_MOUSEINDEX "8",              OSDOPTVAL_AUTO, OPTION_STRING,         "name of mouse mapped to mouse #8" },
194194
195195   { NULL,                                  NULL,   OPTION_HEADER,     "SDL KEYBOARD MAPPING" },
196   { SDLOPTION_KEYBINDEX "1",               SDLOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #1" },
197   { SDLOPTION_KEYBINDEX "2",               SDLOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #2" },
198   { SDLOPTION_KEYBINDEX "3",               SDLOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #3" },
199   { SDLOPTION_KEYBINDEX "4",               SDLOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #4" },
200   { SDLOPTION_KEYBINDEX "5",               SDLOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #5" },
201   { SDLOPTION_KEYBINDEX "6",               SDLOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #6" },
202   { SDLOPTION_KEYBINDEX "7",               SDLOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #7" },
203   { SDLOPTION_KEYBINDEX "8",               SDLOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #8" },
196   { SDLOPTION_KEYBINDEX "1",               OSDOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #1" },
197   { SDLOPTION_KEYBINDEX "2",               OSDOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #2" },
198   { SDLOPTION_KEYBINDEX "3",               OSDOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #3" },
199   { SDLOPTION_KEYBINDEX "4",               OSDOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #4" },
200   { SDLOPTION_KEYBINDEX "5",               OSDOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #5" },
201   { SDLOPTION_KEYBINDEX "6",               OSDOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #6" },
202   { SDLOPTION_KEYBINDEX "7",               OSDOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #7" },
203   { SDLOPTION_KEYBINDEX "8",               OSDOPTVAL_AUTO, OPTION_STRING,         "name of keyboard mapped to keyboard #8" },
204204#endif
205205   // SDL low level driver options
206206   { NULL,                                  NULL,   OPTION_HEADER,     "SDL LOWLEVEL DRIVER OPTIONS" },
207   { SDLOPTION_VIDEODRIVER ";vd",           SDLOPTVAL_AUTO,  OPTION_STRING,        "sdl video driver to use ('x11', 'directfb', ... or 'auto' for SDL default" },
207   { SDLOPTION_VIDEODRIVER ";vd",           OSDOPTVAL_AUTO,  OPTION_STRING,        "sdl video driver to use ('x11', 'directfb', ... or 'auto' for SDL default" },
208208#if (SDLMAME_SDL2)
209   { SDLOPTION_RENDERDRIVER ";rd",          SDLOPTVAL_AUTO,  OPTION_STRING,        "sdl render driver to use ('software', 'opengl', 'directfb' ... or 'auto' for SDL default" },
209   { SDLOPTION_RENDERDRIVER ";rd",          OSDOPTVAL_AUTO,  OPTION_STRING,        "sdl render driver to use ('software', 'opengl', 'directfb' ... or 'auto' for SDL default" },
210210#endif
211   { SDLOPTION_AUDIODRIVER ";ad",           SDLOPTVAL_AUTO,  OPTION_STRING,        "sdl audio driver to use ('alsa', 'arts', ... or 'auto' for SDL default" },
211   { SDLOPTION_AUDIODRIVER ";ad",           OSDOPTVAL_AUTO,  OPTION_STRING,        "sdl audio driver to use ('alsa', 'arts', ... or 'auto' for SDL default" },
212212#if USE_OPENGL
213213   { SDLOPTION_GL_LIB,                      SDLOPTVAL_GLLIB, OPTION_STRING,        "alternative libGL.so to use; 'auto' for system default" },
214214#endif
r243701r243702
542542
543543   // Some driver options - must be before audio init!
544544   stemp = options().audio_driver();
545   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
545   if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0)
546546   {
547547      osd_printf_verbose("Setting SDL audiodriver '%s' ...\n", stemp);
548548      osd_setenv(SDLENV_AUDIODRIVER, stemp, 1);
549549   }
550550
551551   stemp = options().video_driver();
552   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
552   if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0)
553553   {
554554      osd_printf_verbose("Setting SDL videodriver '%s' ...\n", stemp);
555555      osd_setenv(SDLENV_VIDEODRIVER, stemp, 1);
r243701r243702
559559      stemp = options().render_driver();
560560      if (stemp != NULL)
561561      {
562         if (strcmp(stemp, SDLOPTVAL_AUTO) != 0)
562         if (strcmp(stemp, OSDOPTVAL_AUTO) != 0)
563563         {
564564            osd_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp);
565565            //osd_setenv(SDLENV_RENDERDRIVER, stemp, 1);
r243701r243702
584584   /* FIXME: move lib loading code from drawogl.c here */
585585
586586   stemp = options().gl_lib();
587   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
587   if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0)
588588   {
589589      osd_setenv("SDL_VIDEO_GL_DRIVER", stemp, 1);
590590      osd_printf_verbose("Setting SDL_VIDEO_GL_DRIVER = '%s' ...\n", stemp);
trunk/src/osd/sdl/video.c
r243701r243702
9595   int index;
9696
9797   // extract data from the options
98   extract_video_config(machine());
98   extract_video_config();
9999
100100   // set up monitors first
101101   sdl_monitor_info::init();
r243701r243702
418418         monitor = global_alloc_clear(sdl_monitor_info);
419419         monitor->m_handle = i;
420420
421         snprintf(monitor->m_monitor_device, sizeof(monitor->m_monitor_device)-1, "%s%d", OSDOPTION_SCREEN,i);
421         snprintf(monitor->m_name, sizeof(monitor->m_name)-1, "%s%d", OSDOPTION_SCREEN,i);
422422
423423         SDL_GetDesktopDisplayMode(i, &dmode);
424424         SDL_GetDisplayBounds(i, &monitor->m_dimensions);
r243701r243702
426426         // guess the aspect ratio assuming square pixels
427427         monitor->m_aspect = (float)(dmode.w) / (float)(dmode.h);
428428
429         osd_printf_verbose("Adding monitor %s (%d x %d)\n", monitor->m_monitor_device, dmode.w, dmode.h);
429         osd_printf_verbose("Adding monitor %s (%d x %d)\n", monitor->m_name, dmode.w, dmode.h);
430430
431431         monx += dmode.w;
432432
r243701r243702
488488      for (monitor = sdl_monitor_info::list; monitor != NULL; monitor = monitor->next())
489489      {
490490         moncount++;
491         if (strcmp(scrname, monitor->device()) == 0)
491         if (strcmp(scrname, monitor->devicename()) == 0)
492492            goto finishit;
493493      }
494494   }
r243701r243702
584584//  extract_video_config
585585//============================================================
586586
587void sdl_osd_interface::extract_video_config(running_machine &machine)
587void sdl_osd_interface::extract_video_config()
588588{
589589   const char *stemp;
590590
r243701r243702
592592
593593   // global options: extract the data
594594   video_config.windowed      = options().window();
595   video_config.prescale      = options().prescale();
595596   video_config.keepaspect    = options().keep_aspect();
596597   video_config.numscreens    = options().numscreens();
597598   video_config.fullstretch   = options().uneven_stretch();
r243701r243702
599600   video_config.restrictonemonitor = !options().use_all_heads();
600601   #endif
601602
602
603   if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)
603   // if we are in debug mode, never go full screen
604   if (machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)
604605      video_config.windowed = TRUE;
605606
606607   // default to working video please
r243701r243702
618619   }
619620   if (strcmp(stemp, SDLOPTVAL_SOFT) == 0)
620621      video_config.mode = VIDEO_MODE_SOFT;
621   else if (strcmp(stemp, SDLOPTVAL_NONE) == 0)
622   else if (strcmp(stemp, OSDOPTVAL_NONE) == 0)
622623   {
623624      video_config.mode = VIDEO_MODE_SOFT;
624625      video_config.novideo = 1;
r243701r243702
656657   }
657658
658659   #if (USE_OPENGL || SDLMAME_SDL2)
659      video_config.filter        = options().filter();
660   video_config.filter        = options().filter();
660661   #endif
661662
662663   #if (USE_OPENGL)
663      video_config.prescale      = options().prescale();
664664      if (video_config.prescale < 1 || video_config.prescale > 3)
665665      {
666666         osd_printf_warning("Invalid prescale option, reverting to '1'\n");
r243701r243702
683683         for(i=0; i<GLSL_SHADER_MAX; i++)
684684         {
685685            stemp = options().shader_mame(i);
686            if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
686            if (stemp && strcmp(stemp, OSDOPTVAL_NONE) != 0 && strlen(stemp)>0)
687687            {
688688               video_config.glsl_shader_mamebm[i] = (char *) malloc(strlen(stemp)+1);
689689               strcpy(video_config.glsl_shader_mamebm[i], stemp);
r243701r243702
698698         for(i=0; i<GLSL_SHADER_MAX; i++)
699699         {
700700            stemp = options().shader_screen(i);
701            if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
701            if (stemp && strcmp(stemp, OSDOPTVAL_NONE) != 0 && strlen(stemp)>0)
702702            {
703703               video_config.glsl_shader_scrn[i] = (char *) malloc(strlen(stemp)+1);
704704               strcpy(video_config.glsl_shader_scrn[i], stemp);
r243701r243702
763763{
764764   int num = 0, den = 1;
765765
766   if (strcmp(data, SDLOPTVAL_AUTO) == 0)
766   if (strcmp(data, OSDOPTVAL_AUTO) == 0)
767767   {
768      if (strcmp(defdata,SDLOPTVAL_AUTO) == 0)
768      if (strcmp(defdata,OSDOPTVAL_AUTO) == 0)
769769         return 0;
770770      data = defdata;
771771   }
r243701r243702
782782static void get_resolution(const char *defdata, const char *data, sdl_window_config *config, int report_error)
783783{
784784   config->width = config->height = config->depth = config->refresh = 0;
785   if (strcmp(data, SDLOPTVAL_AUTO) == 0)
785   if (strcmp(data, OSDOPTVAL_AUTO) == 0)
786786   {
787      if (strcmp(defdata, SDLOPTVAL_AUTO) == 0)
788      {
787      if (strcmp(defdata, OSDOPTVAL_AUTO) == 0)
789788         return;
790      }
791
792789      data = defdata;
793790   }
794791
trunk/src/osd/sdl/video.h
r243701r243702
7070   sdl_monitor_info(const UINT64 handle, const char *monitor_device, float aspect)
7171   : m_next(NULL), m_handle(handle), m_aspect(aspect)
7272   {
73      strncpy(m_monitor_device, monitor_device, 64);
73      strncpy(m_name, monitor_device, 64);
7474      refresh();
7575   }
7676
7777   const UINT64 handle() { return m_handle; }
7878   const SDL_Rect &position_size() { refresh(); return m_dimensions; }
7979
80   const char *device() { return m_monitor_device; }
80   const char *devicename() { refresh(); return (m_name != NULL) ? m_name : "UNKNOWN"; }
8181
8282   float aspect();
8383
r243701r243702
9797   static sdl_monitor_info *primary_monitor;
9898   static sdl_monitor_info *list;
9999
100   // FIXME: shouldn't be here - see windows enumeration callback
101100   sdl_monitor_info     * m_next;                   // pointer to next monitor in list
102101private:
103102   void refresh();
104103
105104   UINT64              m_handle;                 // handle to the monitor
106105   SDL_Rect         m_dimensions;
107   char                m_monitor_device[64];
106   char                m_name[64];
108107   float               m_aspect;                 // computed/configured aspect ratio of the physical device
109108};
110109
r243701r243702
126125
127126   // global configuration
128127   int                 windowed;               // start windowed?
129   int                 prescale;               // prescale factor (supported by accel driver)
130   int                 keepaspect;             // keep aspect ratio?
128   int                 prescale;                   // prescale factor
129   int                 keepaspect;                 // keep aspect ratio
131130   int                 numscreens;             // number of screens
132131   int                 centerh;
133132   int                 centerv;
trunk/src/osd/sdl/window.h
r243701r243702
6666
6767   float aspect() const { return monitor()->aspect(); }
6868
69   virtual void get_size(int &w, int &h) = 0;
70
6971#ifdef OSD_SDL
7072   virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
7173   virtual sdl_monitor_info *monitor() const = 0;
72   virtual void get_size(int &w, int &h) = 0;
7374#if (SDLMAME_SDL2)
7475   virtual SDL_Window *sdl_window() = 0;
7576#else
trunk/src/osd/windows/drawd3d.c
r243701r243702
12661266      HMONITOR curmonitor = (*d3dintf->d3d.get_adapter_monitor)(d3dintf, adapternum);
12671267
12681268      // if we match the proposed monitor, this is it
1269      if (curmonitor == window().monitor()->handle)
1269      if (curmonitor == window().monitor()->handle())
12701270      {
12711271         return adapternum;
12721272      }
trunk/src/osd/windows/drawdd.c
r243701r243702
964964      ClientToScreen(window().m_hwnd, &((LPPOINT)&outer)[1]);
965965
966966      // adjust to be relative to the monitor
967      outer.left -= monitor->info.rcMonitor.left;
968      outer.right -= monitor->info.rcMonitor.left;
969      outer.top -= monitor->info.rcMonitor.top;
970      outer.bottom -= monitor->info.rcMonitor.top;
967      RECT pos = monitor->position_size();
968      outer.left -= pos.left;
969      outer.right -= pos.left;
970      outer.top -= pos.top;
971      outer.bottom -= pos.top;
971972   }
972973
973974   // compute outer rect -- full screen version
r243701r243702
11601161   monitor_enum_info *einfo = (monitor_enum_info *)context;
11611162
11621163   // do we match the desired monitor?
1163   if (hmonitor == einfo->monitor->handle || (hmonitor == NULL && (einfo->monitor->info.dwFlags & MONITORINFOF_PRIMARY) != 0))
1164   if (hmonitor == einfo->monitor->handle() || (hmonitor == NULL && einfo->monitor->is_primary()))
11641165   {
11651166      einfo->guid_ptr = (guid != NULL) ? &einfo->guid : NULL;
11661167      if (guid != NULL)
trunk/src/osd/windows/video.c
r243701r243702
5151//============================================================
5252
5353static void init_monitors(void);
54static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data);
5554static win_monitor_info *pick_monitor(windows_options &options, int index);
5655
5756static void check_osd_inputs(running_machine &machine);
5857
59static void extract_video_config(running_machine &machine);
6058static float get_aspect(const char *defdata, const char *data, int report_error);
6159static void get_resolution(const char *defdata, const char *data, win_window_config *config, int report_error);
6260
r243701r243702
7169   int index;
7270
7371   // extract data from the options
74   extract_video_config(machine());
72   extract_video_config();
7573
7674   // set up monitors first
7775   init_monitors();
r243701r243702
102100   while (win_monitor_list != NULL)
103101   {
104102      win_monitor_info *temp = win_monitor_list;
105      win_monitor_list = temp->next;
103      win_monitor_list = temp->m_next;
106104      global_free(temp);
107105   }
108106}
r243701r243702
110108
111109
112110win_monitor_info::win_monitor_info()
113   : next(NULL),
114      handle(NULL),
111   : m_next(NULL),
112      m_handle(NULL),
115113      m_aspect(0.0f),
116      reqwidth(0),
117      reqheight(0),
118114      m_name(NULL)
119115{
120116}
r243701r243702
134130   BOOL result;
135131
136132   // fetch the latest info about the monitor
137   info.cbSize = sizeof(info);
138   result = GetMonitorInfo(handle, (LPMONITORINFO)&info);
133   m_info.cbSize = sizeof(m_info);
134   result = GetMonitorInfo(m_handle, (LPMONITORINFO)&m_info);
139135   assert(result);
140136   if (m_name != NULL)
141137      osd_free(m_name);
142   m_name = utf8_from_tstring(info.szDevice);
138   m_name = utf8_from_tstring(m_info.szDevice);
143139   (void)result; // to silence gcc 4.6
144140}
145141
r243701r243702
152148float win_monitor_info::aspect()
153149{
154150   // refresh the monitor information and compute the aspect
151   refresh();
152   // FIXME: returning 0 looks odd, video_config is bad
155153   if (video_config.keepaspect)
156154   {
157155      int width, height;
158156      refresh();
159      width = rect_width(&info.rcMonitor);
160      height = rect_height(&info.rcMonitor);
157      width = rect_width(&m_info.rcMonitor);
158      height = rect_height(&m_info.rcMonitor);
161159      return m_aspect / ((float)width / (float)height);
162160   }
163161   return 0.0f;
r243701r243702
174172   win_monitor_info *monitor;
175173
176174   // find the matching monitor
177   for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next)
178      if (monitor->handle == hmonitor)
175   for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
176      if (monitor->handle() == hmonitor)
179177         return monitor;
180178   return NULL;
181179}
r243701r243702
218216   // make a list of monitors
219217   win_monitor_list = NULL;
220218   tailptr = &win_monitor_list;
221   EnumDisplayMonitors(NULL, NULL, monitor_enum_callback, (LPARAM)&tailptr);
219   EnumDisplayMonitors(NULL, NULL, win_monitor_info::monitor_enum_callback, (LPARAM)&tailptr);
222220
223221   // if we're verbose, print the list of monitors
224222   {
225223      win_monitor_info *monitor;
226      for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next)
224      for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
227225      {
228         osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle, monitor->devicename(), (monitor == primary_monitor) ? "(primary)" : "");
226         osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle(), monitor->devicename(), (monitor == primary_monitor) ? "(primary)" : "");
229227      }
230228   }
231229}
r243701r243702
236234//  monitor_enum_callback
237235//============================================================
238236
239static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data)
237BOOL CALLBACK win_monitor_info::monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data)
240238{
241239   win_monitor_info ***tailptr = (win_monitor_info ***)data;
242240   win_monitor_info *monitor;
r243701r243702
253251   monitor = global_alloc(win_monitor_info);
254252
255253   // copy in the data
256   monitor->handle = handle;
257   monitor->info = info;
254   monitor->m_handle = handle;
255   monitor->m_info = info;
258256
259257   // guess the aspect ratio assuming square pixels
260258   monitor->set_aspect((float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top));
261259
262260   // save the primary monitor handle
263   if (monitor->info.dwFlags & MONITORINFOF_PRIMARY)
261   if (monitor->m_info.dwFlags & MONITORINFOF_PRIMARY)
264262      primary_monitor = monitor;
265263
266264   // hook us into the list
267265   **tailptr = monitor;
268   *tailptr = &monitor->next;
266   *tailptr = &monitor->m_next;
269267
270268   // enumerate all the available monitors so to list their names in verbose mode
271269   return TRUE;
r243701r243702
297295
298296   // look for a match in the name first
299297   if (scrname[0] != 0)
300      for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next)
298      for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
301299      {
302300         int rc = 1;
303301
r243701r243702
311309
312310   // didn't find it; alternate monitors until we hit the jackpot
313311   index %= moncount;
314   for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->next)
312   for (monitor = win_monitor_list; monitor != NULL; monitor = monitor->m_next)
315313      if (index-- == 0)
316314         goto finishit;
317315
r243701r243702
320318
321319finishit:
322320   if (aspect != 0)
321   {
323322      monitor->set_aspect(aspect);
323   }
324324   return monitor;
325325}
326326
r243701r243702
355355//  extract_video_config
356356//============================================================
357357
358static void extract_video_config(running_machine &machine)
358void windows_osd_interface::extract_video_config()
359359{
360   windows_options &options = downcast<windows_options &>(machine.options());
361360   const char *stemp;
362361
363362   // global options: extract the data
364   video_config.windowed      = options.window();
365   video_config.prescale      = options.prescale();
366   video_config.keepaspect    = options.keep_aspect();
367   video_config.numscreens    = options.numscreens();
363   video_config.windowed      = options().window();
364   video_config.prescale      = options().prescale();
365   video_config.keepaspect    = options().keep_aspect();
366   video_config.numscreens    = options().numscreens();
368367
369368   // if we are in debug mode, never go full screen
370   if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)
369   if (machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)
371370      video_config.windowed = TRUE;
372371
373372   // per-window options: extract the data
374   const char *default_resolution = options.resolution();
375   get_resolution(default_resolution, options.resolution(0), &video_config.window[0], TRUE);
376   get_resolution(default_resolution, options.resolution(1), &video_config.window[1], TRUE);
377   get_resolution(default_resolution, options.resolution(2), &video_config.window[2], TRUE);
378   get_resolution(default_resolution, options.resolution(3), &video_config.window[3], TRUE);
373   const char *default_resolution = options().resolution();
374   get_resolution(default_resolution, options().resolution(0), &video_config.window[0], TRUE);
375   get_resolution(default_resolution, options().resolution(1), &video_config.window[1], TRUE);
376   get_resolution(default_resolution, options().resolution(2), &video_config.window[2], TRUE);
377   get_resolution(default_resolution, options().resolution(3), &video_config.window[3], TRUE);
379378
380379   // video options: extract the data
381   stemp = options.video();
380   stemp = options().video();
382381   if (strcmp(stemp, "d3d") == 0)
383382      video_config.mode = VIDEO_MODE_D3D;
384383   else if (strcmp(stemp, "auto") == 0)
r243701r243702
392391   else if (strcmp(stemp, "none") == 0)
393392   {
394393      video_config.mode = VIDEO_MODE_NONE;
395      if (options.seconds_to_run() == 0)
394      if (options().seconds_to_run() == 0)
396395         osd_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n");
397396   }
397#if (USE_OPENGL)
398   else if (strcmp(stemp, "opengl") == 0)
399      video_config.mode = VIDEO_MODE_OPENGL;
400#endif
398401   else
399402   {
400403      osd_printf_warning("Invalid video value %s; reverting to gdi\n", stemp);
401404      video_config.mode = VIDEO_MODE_GDI;
402405   }
403   video_config.waitvsync     = options.wait_vsync();
404   video_config.syncrefresh   = options.sync_refresh();
405   video_config.triplebuf     = options.triple_buffer();
406   video_config.switchres     = options.switch_res();
406   video_config.waitvsync     = options().wait_vsync();
407   video_config.syncrefresh   = options().sync_refresh();
408   video_config.triplebuf     = options().triple_buffer();
409   video_config.switchres     = options().switch_res();
407410
408411   // ddraw options: extract the data
409   video_config.hwstretch     = options.hwstretch();
412   video_config.hwstretch     = options().hwstretch();
410413
411414   // d3d options: extract the data
412   video_config.filter        = options.filter();
415   video_config.filter        = options().filter();
413416   if (video_config.prescale == 0)
414417      video_config.prescale = 1;
415418}
r243701r243702
424427{
425428   int num = 0, den = 1;
426429
427   if (strcmp(data, "auto") == 0)
430   if (strcmp(data, OSDOPTVAL_AUTO) == 0)
428431   {
429      if (strcmp(defdata, "auto") == 0)
432      if (strcmp(defdata,OSDOPTVAL_AUTO) == 0)
430433         return 0;
431434      data = defdata;
432435   }
r243701r243702
436439}
437440
438441
439
440442//============================================================
441443//  get_resolution
442444//============================================================
r243701r243702
444446static void get_resolution(const char *defdata, const char *data, win_window_config *config, int report_error)
445447{
446448   config->width = config->height = config->refresh = 0;
447   if (strcmp(data, "auto") == 0)
449   if (strcmp(data, OSDOPTVAL_AUTO) == 0)
448450   {
449      if (strcmp(defdata, "auto") == 0)
451      if (strcmp(defdata, OSDOPTVAL_AUTO) == 0)
450452         return;
451453      data = defdata;
452454   }
trunk/src/osd/windows/video.h
r243701r243702
1818
1919#define MAX_WINDOWS         4
2020
21#define VIDEO_MODE_NONE     0
22#define VIDEO_MODE_GDI      1
23#define VIDEO_MODE_DDRAW    2
24#define VIDEO_MODE_D3D      3
25#define VIDEO_MODE_BGFX     4
21enum {
22   VIDEO_MODE_NONE,
23   VIDEO_MODE_GDI,
24   VIDEO_MODE_DDRAW,
25   VIDEO_MODE_D3D,
26   VIDEO_MODE_BGFX,
27#if (USE_OPENGL)
28   VIDEO_MODE_OPENGL,
29#endif
30};
2631
32#define GLSL_SHADER_MAX 10
2733
28
2934//============================================================
3035//  TYPE DEFINITIONS
3136//============================================================
r243701r243702
3742   virtual ~win_monitor_info();
3843
3944   void refresh();
40   float aspect();
41   void set_aspect(float a) { m_aspect = a; }
45
46   const HMONITOR handle() { return m_handle; }
47   const RECT &position_size() { refresh(); return m_info.rcMonitor; }
48   const RECT &usuable_position_size() { refresh(); return m_info.rcWork; }
49   bool is_primary() { return (m_info.dwFlags & MONITORINFOF_PRIMARY) != 0; }
4250   const char *devicename() { refresh(); return (m_name != NULL) ? m_name : "UNKNOWN"; }
4351
44   win_monitor_info  * next;                   // pointer to next monitor in list
45   HMONITOR            handle;                 // handle to the monitor
46   MONITORINFOEX       info;                   // most recently retrieved info
52   float aspect();
53
54   void set_aspect(const float a) { m_aspect = a; }
55
56   win_monitor_info  * m_next;                   // pointer to next monitor in list
57
58   // static
59
60   static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data);
61
4762private:
63   HMONITOR            m_handle;                 // handle to the monitor
64   MONITORINFOEX       m_info;                   // most recently retrieved info
65
4866   float               m_aspect;               // computed/configured aspect ratio of the physical device
49   int                 reqwidth;               // requested width for this monitor
50   int                 reqheight;              // requested height for this monitor
5167   char *             m_name;
5268};
5369
r243701r243702
85101
86102   // d3d options
87103   int                 filter;                     // enable filtering
104
105   // OpenGL options
106   //int                 filter;         // enable filtering, disabled if glsl_filter>0
107   int                 glsl;
108   int                 glsl_filter;        // glsl filtering, >0 disables filter
109   char *              glsl_shader_mamebm[GLSL_SHADER_MAX]; // custom glsl shader set, mame bitmap
110   int                 glsl_shader_mamebm_num; // custom glsl shader set number, mame bitmap
111   char *              glsl_shader_scrn[GLSL_SHADER_MAX]; // custom glsl shader set, screen bitmap
112   int                 glsl_shader_scrn_num; // custom glsl shader number, screen bitmap
113   int                 pbo;
114   int                 vbo;
115   int                 allowtexturerect;   // allow GL_ARB_texture_rectangle, default: no
116   int                 forcepow2texture;   // force power of two textures, default: no
88117};
89118
90119
trunk/src/osd/windows/window.c
r243701r243702
4040extern int drawdd_init(running_machine &machine, osd_draw_callbacks *callbacks);
4141extern int drawd3d_init(running_machine &machine, osd_draw_callbacks *callbacks);
4242extern int drawbgfx_init(running_machine &machine, osd_draw_callbacks *callbacks);
43#if (USE_OPENGL)
44extern int drawogl_init(running_machine &machine, osd_draw_callbacks *callbacks);
45#endif
4346
44
4547//============================================================
4648//  PARAMETERS
4749//============================================================
r243701r243702
245247      drawbgfx_init(machine(), &draw);
246248   if (video_config.mode == VIDEO_MODE_NONE)
247249      drawnone_init(machine(), &draw);
248
250#if (USE_OPENGL)
251   if (video_config.mode == VIDEO_MODE_OPENGL)
252      drawogl_init(machine(), &draw);
253#endif
249254   // set up the window list
250255   last_window_ptr = &win_window_list;
251256
r243701r243702
11731178   assert(GetCurrentThreadId() == window_threadid);
11741179
11751180   // get the monitor bounds
1176   monitorbounds = window->m_monitor->info.rcMonitor;
1181   monitorbounds = window->m_monitor->position_size();
11771182
11781183   // create the window menu if needed
11791184   if (downcast<windows_options &>(window->machine().options()).menu())
r243701r243702
15611566   // clamp against the maximum (fit on one screen for full screen mode)
15621567   if (window->m_fullscreen)
15631568   {
1564      maxwidth = rect_width(&monitor->info.rcMonitor) - extrawidth;
1565      maxheight = rect_height(&monitor->info.rcMonitor) - extraheight;
1569      maxwidth = rect_width(&monitor->position_size()) - extrawidth;
1570      maxheight = rect_height(&monitor->position_size()) - extraheight;
15661571   }
15671572   else
15681573   {
1569      maxwidth = rect_width(&monitor->info.rcWork) - extrawidth;
1570      maxheight = rect_height(&monitor->info.rcWork) - extraheight;
1574      maxwidth = rect_width(&monitor->usuable_position_size()) - extrawidth;
1575      maxheight = rect_height(&monitor->usuable_position_size()) - extraheight;
15711576
15721577      // further clamp to the maximum width/height in the window
15731578      if (window->m_maxwidth != 0)
r243701r243702
16951700
16961701   // compute the maximum client area
16971702   window->m_monitor->refresh();
1698   maximum = window->m_monitor->info.rcWork;
1703   maximum = window->m_monitor->usuable_position_size();
16991704
17001705   // clamp to the window's max
17011706   if (window->m_maxwidth != 0)
r243701r243702
17211726   }
17221727
17231728   // center within the work area
1724   bounds->left = window->m_monitor->info.rcWork.left + (rect_width(&window->m_monitor->info.rcWork) - rect_width(&maximum)) / 2;
1725   bounds->top = window->m_monitor->info.rcWork.top + (rect_height(&window->m_monitor->info.rcWork) - rect_height(&maximum)) / 2;
1729   RECT work = window->m_monitor->usuable_position_size();
1730   bounds->left = work.left + (rect_width(&work) - rect_width(&maximum)) / 2;
1731   bounds->top = work.top + (rect_height(&work) - rect_height(&maximum)) / 2;
17261732   bounds->right = bounds->left + rect_width(&maximum);
17271733   bounds->bottom = bounds->top + rect_height(&maximum);
17281734}
r243701r243702
18231829   else
18241830   {
18251831      win_monitor_info *monitor = window->winwindow_video_window_monitor(NULL);
1826      newrect = monitor->info.rcMonitor;
1832      newrect = monitor->position_size();
18271833   }
18281834
18291835   // adjust the position if different
trunk/src/osd/windows/window.h
r243701r243702
6666
6767   float aspect() const { return monitor()->aspect(); }
6868
69   virtual void get_size(int &w, int &h) = 0;
70
6971#ifdef OSD_SDL
7072   virtual void blit_surface_size(int &blitwidth, int &blitheight) = 0;
7173   virtual sdl_monitor_info *monitor() const = 0;
72   virtual void get_size(int &w, int &h) = 0;
7374#if (SDLMAME_SDL2)
7475   virtual SDL_Window *sdl_window() = 0;
7576#else
r243701r243702
169170      return GetMenu(m_hwnd) ? true : false;
170171   }
171172
173   /* virtual */ void get_size(int &w, int &h)
174   {
175      RECT client;
176      GetClientRect(m_hwnd, &client);
177      w = client.right - client.left;
178      h = client.bottom - client.top;
179   }
180
172181   win_monitor_info *monitor() const { return m_monitor; }
173182
174183   win_window_info *   m_next;
trunk/src/osd/windows/windows.mak
r243701r243702
6666# uncomment next line to use SDL library for sound and video output
6767# USE_SDL = 1
6868
69# uncomment next line to compile OpenGL video renderer
70# USE_OPENGL = 1
71
6972# uncomment next line to use QT debugger
7073# USE_QTDEBUG = 1
7174
r243701r243702
395398   $(OSDOBJ)/modules/netdev/taptun.o \
396399   $(OSDOBJ)/modules/netdev/none.o \
397400
401ifdef USE_OPENGL
402OSDOBJS +=    $(WINOBJ)/../sdl/drawogl.o $(WINOBJ)/../sdl/gl_shader_tool.o $(WINOBJ)/../sdl/gl_shader_mgr.o
403OBJDIRS += $(WINOBJ)/../sdl
404
405DEFS += -DUSE_OPENGL=1
406LIBS += -lopengl32
407
408else
409DEFS += -DUSE_OPENGL=0
410endif
411
398412ifdef USE_SDL
399413DEFS += -DUSE_SDL_SOUND
400414endif
trunk/src/osd/windows/winmain.c
r243701r243702
503503//============================================================
504504
505505windows_osd_interface::windows_osd_interface(windows_options &options)
506: osd_common_t(options)
506: osd_common_t(options), m_options(options)
507507{
508508}
509509
trunk/src/osd/windows/winmain.h
r243701r243702
269269   virtual void input_exit();
270270   virtual void output_exit();
271271
272   void extract_video_config();
273
274   windows_options &options() { return m_options; }
275
272276private:
273277   void osd_exit();
278   windows_options &m_options;
274279
275280   static const int DEFAULT_FONT_HEIGHT = 200;
276281};
r243701r243702
296301void winmain_watchdog_ping(void);
297302void winmain_dump_stack();
298303
299#endif
No newline at end of file
304#endif


Previous 199869 Revisions Next


© 1997-2024 The MAME Team