trunk/src/osd/sdl/drawogl.c
| r243701 | r243702 | |
| 23 | 23 | #include "options.h" |
| 24 | 24 | #include "emuopts.h" |
| 25 | 25 | |
| 26 | #ifndef OSD_WINDOWS |
| 26 | 27 | // standard SDL headers |
| 28 | #define TOBEMIGRATED 1 |
| 27 | 29 | #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" |
| 28 | 35 | |
| 36 | typedef HGLRC SDL_GLContext; |
| 37 | #endif |
| 38 | |
| 29 | 39 | // OpenGL headers |
| 40 | #ifndef OSD_WINDOWS |
| 30 | 41 | #include "osd_opengl.h" |
| 42 | #endif |
| 31 | 43 | #include "modules/lib/osdlib.h" |
| 32 | 44 | |
| 33 | 45 | |
| r243701 | r243702 | |
| 121 | 133 | #define OVERFLOW_SIZE (1<<10) |
| 122 | 134 | |
| 123 | 135 | // OSD headers |
| 136 | #ifndef OSD_WINDOWS |
| 124 | 137 | #include "osdsdl.h" |
| 125 | 138 | #include "window.h" |
| 139 | #else |
| 140 | #include "../windows/window.h" |
| 141 | typedef UINT64 HashT; |
| 142 | #endif |
| 126 | 143 | |
| 127 | 144 | //============================================================ |
| 128 | 145 | // DEBUGGING |
| r243701 | r243702 | |
| 149 | 166 | // MACROS |
| 150 | 167 | //============================================================ |
| 151 | 168 | |
| 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 | |
| 152 | 189 | #define FSWAP(var1, var2) do { float temp = var1; var1 = var2; var2 = temp; } while (0) |
| 153 | 190 | #define GL_NO_PRIMITIVE -1 |
| 154 | 191 | |
| r243701 | r243702 | |
| 253 | 290 | } |
| 254 | 291 | |
| 255 | 292 | /* virtual */ int create(); |
| 293 | #ifdef OSD_WINDOWS |
| 294 | /* virtual */ int draw(const HDC dc, const int update); |
| 295 | #else |
| 256 | 296 | /* virtual */ int draw(const UINT32 dc, const int update); |
| 297 | #endif |
| 257 | 298 | /* virtual */ int xy_to_render_target(const int x, const int y, int *xt, int *yt); |
| 258 | 299 | /* virtual */ void destroy(); |
| 259 | 300 | /* virtual */ render_primitive_list *get_primitives() |
| 260 | 301 | { |
| 261 | 302 | int nw = 0; int nh = 0; |
| 303 | #ifdef OSD_WINDOWS |
| 304 | window().get_size(nw, nh); |
| 305 | #else |
| 262 | 306 | window().blit_surface_size(nw, nh); |
| 307 | #endif |
| 263 | 308 | if (nw != m_blitwidth || nh != m_blitheight) |
| 264 | 309 | { |
| 265 | 310 | m_blitwidth = nw; m_blitheight = nh; |
| r243701 | r243702 | |
| 269 | 314 | return &window().target()->get_primitives(); |
| 270 | 315 | } |
| 271 | 316 | |
| 317 | /* virtual */ void save() { } |
| 318 | /* virtual */ void record() { } |
| 319 | /* virtual */ void toggle_fsfx() { } |
| 320 | |
| 272 | 321 | private: |
| 273 | 322 | void destroy_all_textures(); |
| 274 | 323 | |
| r243701 | r243702 | |
| 298 | 347 | |
| 299 | 348 | #if (SDLMAME_SDL2) |
| 300 | 349 | SDL_GLContext m_gl_context_id; |
| 350 | #ifdef OSD_WINDOWS |
| 351 | HDC m_hdc; |
| 352 | #endif |
| 301 | 353 | #else |
| 302 | 354 | #endif |
| 303 | 355 | |
| r243701 | r243702 | |
| 483 | 535 | return 0; |
| 484 | 536 | } |
| 485 | 537 | |
| 538 | //============================================================ |
| 539 | // Windows Compatibility |
| 540 | //============================================================ |
| 486 | 541 | |
| 542 | #ifdef OSD_WINDOWS |
| 543 | PROC SDL_GL_GetProcAddress(const char *procname) |
| 544 | { |
| 545 | return wglGetProcAddress(procname); |
| 546 | } |
| 547 | #endif |
| 548 | |
| 487 | 549 | //============================================================ |
| 488 | 550 | // Load the OGL function addresses |
| 489 | 551 | //============================================================ |
| r243701 | r243702 | |
| 530 | 592 | const char *stemp; |
| 531 | 593 | |
| 532 | 594 | 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) |
| 534 | 596 | stemp = NULL; |
| 535 | 597 | |
| 536 | 598 | if (SDL_GL_LoadLibrary(stemp) != 0) // Load library (default for e==NULL |
| r243701 | r243702 | |
| 552 | 614 | char *extstr = (char *)glGetString(GL_EXTENSIONS); |
| 553 | 615 | char *vendor = (char *)glGetString(GL_VENDOR); |
| 554 | 616 | |
| 555 | | //printf("%s\n", extstr); |
| 556 | | |
| 617 | //printf("%p\n", extstr); |
| 618 | #ifdef OSD_WINDOWS |
| 619 | if (!extstr) |
| 620 | extstr = (char *)""; |
| 621 | #endif |
| 557 | 622 | // print out the driver info for debugging |
| 558 | 623 | if (!shown_video_info) |
| 559 | 624 | { |
| r243701 | r243702 | |
| 679 | 744 | } |
| 680 | 745 | } |
| 681 | 746 | |
| 747 | #ifdef TOBEMIGRATED |
| 682 | 748 | if (osd_getenv(SDLENV_VMWARE) != NULL) |
| 683 | 749 | { |
| 684 | 750 | m_usetexturerect = 1; |
| 685 | 751 | m_texpoweroftwo = 1; |
| 686 | 752 | } |
| 753 | #endif |
| 687 | 754 | glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&m_texture_max_width); |
| 688 | 755 | glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&m_texture_max_height); |
| 689 | 756 | if (!shown_video_info) |
| r243701 | r243702 | |
| 724 | 791 | // a |
| 725 | 792 | //============================================================ |
| 726 | 793 | |
| 794 | #ifdef OSD_WINDOWS |
| 795 | void |
| 796 | setupPixelFormat(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 |
| 727 | 832 | int sdl_info_ogl::create() |
| 728 | 833 | { |
| 729 | 834 | |
| 730 | 835 | #if (SDLMAME_SDL2) |
| 731 | 836 | // 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 |
| 733 | 850 | m_gl_context_id = SDL_GL_CreateContext(window().sdl_window()); |
| 734 | 851 | if (!m_gl_context_id) |
| 735 | 852 | { |
| 736 | 853 | osd_printf_error("OpenGL not supported on this driver: %s\n", SDL_GetError()); |
| 737 | 854 | return 1; |
| 738 | 855 | } |
| 856 | #endif |
| 739 | 857 | |
| 858 | #ifndef OSD_WINDOWS |
| 740 | 859 | SDL_GL_SetSwapInterval(video_config.waitvsync ? 2 : 0); |
| 741 | | |
| 860 | #endif |
| 742 | 861 | #else |
| 743 | 862 | #endif |
| 744 | 863 | |
| r243701 | r243702 | |
| 779 | 898 | destroy_all_textures(); |
| 780 | 899 | |
| 781 | 900 | #if (SDLMAME_SDL2) |
| 901 | #ifdef OSD_WINDOWS |
| 902 | wglDeleteContext(m_gl_context_id); |
| 903 | ReleaseDC(window().m_hwnd, m_hdc); |
| 904 | #else |
| 782 | 905 | SDL_GL_DeleteContext(m_gl_context_id); |
| 783 | 906 | #endif |
| 907 | #endif |
| 784 | 908 | |
| 785 | 909 | } |
| 786 | 910 | |
| r243701 | r243702 | |
| 815 | 939 | return; |
| 816 | 940 | |
| 817 | 941 | #if (SDLMAME_SDL2) |
| 942 | #ifdef OSD_WINDOWS |
| 943 | wglMakeCurrent(m_hdc, m_gl_context_id); |
| 944 | #else |
| 818 | 945 | SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id); |
| 819 | 946 | #endif |
| 947 | #endif |
| 820 | 948 | |
| 821 | 949 | if(window().m_primlist) |
| 822 | 950 | { |
| r243701 | r243702 | |
| 1199 | 1327 | // sdl_info::draw |
| 1200 | 1328 | //============================================================ |
| 1201 | 1329 | |
| 1202 | | int sdl_info_ogl::draw(UINT32 dc, int update) |
| 1330 | #ifdef OSD_WINDOWS |
| 1331 | int sdl_info_ogl::draw(const HDC dc, const int update) |
| 1332 | #else |
| 1333 | int sdl_info_ogl::draw(const UINT32 dc, const int update) |
| 1334 | #endif |
| 1203 | 1335 | { |
| 1204 | 1336 | render_primitive *prim; |
| 1205 | 1337 | texture_info *texture=NULL; |
| r243701 | r243702 | |
| 1207 | 1339 | int pendingPrimitive=GL_NO_PRIMITIVE, curPrimitive=GL_NO_PRIMITIVE; |
| 1208 | 1340 | int width = 0; int height = 0; |
| 1209 | 1341 | |
| 1342 | #ifdef TOBEMIGRATED |
| 1210 | 1343 | if (video_config.novideo) |
| 1211 | 1344 | { |
| 1212 | 1345 | return 0; |
| 1213 | 1346 | } |
| 1347 | #endif |
| 1214 | 1348 | |
| 1215 | 1349 | window().get_size(width, height); |
| 1216 | 1350 | |
| r243701 | r243702 | |
| 1225 | 1359 | } |
| 1226 | 1360 | |
| 1227 | 1361 | #if (SDLMAME_SDL2) |
| 1362 | #ifdef OSD_WINDOWS |
| 1363 | wglMakeCurrent(m_hdc, m_gl_context_id); |
| 1364 | #else |
| 1228 | 1365 | SDL_GL_MakeCurrent(window().sdl_window(), m_gl_context_id); |
| 1229 | 1366 | #endif |
| 1367 | #endif |
| 1230 | 1368 | |
| 1231 | 1369 | if (m_init_context) |
| 1232 | 1370 | { |
| r243701 | r243702 | |
| 1294 | 1432 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 1295 | 1433 | m_last_blendmode = BLENDMODE_ALPHA; |
| 1296 | 1434 | |
| 1435 | #ifdef TOBEMIGRATED |
| 1297 | 1436 | // set lines and points just barely above normal size to get proper results |
| 1298 | 1437 | glLineWidth(video_config.beamwidth); |
| 1299 | 1438 | glPointSize(video_config.beamwidth); |
| 1439 | #endif |
| 1300 | 1440 | |
| 1301 | 1441 | // set up a nice simple 2D coordinate system, so GL behaves exactly how we'd like. |
| 1302 | 1442 | // |
| r243701 | r243702 | |
| 1327 | 1467 | // compute centering parameters |
| 1328 | 1468 | vofs = hofs = 0.0f; |
| 1329 | 1469 | |
| 1470 | #ifdef TOBEMIGRATED |
| 1330 | 1471 | if (video_config.centerv || video_config.centerh) |
| 1331 | 1472 | { |
| 1332 | 1473 | int ch, cw; |
| r243701 | r243702 | |
| 1343 | 1484 | hofs = (cw - m_blitwidth) / 2.0f; |
| 1344 | 1485 | } |
| 1345 | 1486 | } |
| 1487 | #else |
| 1488 | #endif |
| 1346 | 1489 | |
| 1347 | 1490 | m_last_hofs = hofs; |
| 1348 | 1491 | m_last_vofs = vofs; |
| r243701 | r243702 | |
| 1572 | 1715 | #if (!SDLMAME_SDL2) |
| 1573 | 1716 | SDL_GL_SwapBuffers(); |
| 1574 | 1717 | #else |
| 1718 | #ifdef OSD_WINDOWS |
| 1719 | SwapBuffers(m_hdc); |
| 1720 | //wglSwapLayerBuffers(GetDC(window().m_hwnd), WGL_SWAP_MAIN_PLANE); |
| 1721 | #else |
| 1575 | 1722 | SDL_GL_SwapWindow(window().sdl_window()); |
| 1576 | 1723 | #endif |
| 1724 | #endif |
| 1577 | 1725 | return 0; |
| 1578 | 1726 | } |
| 1579 | 1727 | |
trunk/src/osd/sdl/sdlmain.c
| r243701 | r243702 | |
| 103 | 103 | { SDLOPTION_CENTERH, "1", OPTION_BOOLEAN, "center horizontally within the view area" }, |
| 104 | 104 | { SDLOPTION_CENTERV, "1", OPTION_BOOLEAN, "center vertically within the view area" }, |
| 105 | 105 | #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)" }, |
| 107 | 107 | #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)" }, |
| 109 | 109 | #endif |
| 110 | 110 | #if USE_OPENGL |
| 111 | 111 | // OpenGL specific options |
| r243701 | r243702 | |
| 118 | 118 | { SDLOPTION_GL_PBO, "1", OPTION_BOOLEAN, "enable OpenGL PBO, if available (default on)" }, |
| 119 | 119 | { SDLOPTION_GL_GLSL, "0", OPTION_BOOLEAN, "enable OpenGL GLSL, if available (default off)" }, |
| 120 | 120 | { 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" }, |
| 141 | 141 | #endif |
| 142 | 142 | |
| 143 | 143 | // full screen options |
| r243701 | r243702 | |
| 158 | 158 | |
| 159 | 159 | // joystick mapping |
| 160 | 160 | { 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" }, |
| 169 | 169 | { SDLOPTION_SIXAXIS, "0", OPTION_BOOLEAN, "Use special handling for PS3 Sixaxis controllers" }, |
| 170 | 170 | |
| 171 | 171 | #if (USE_XINPUT) |
| 172 | 172 | // lightgun mapping |
| 173 | 173 | { 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" }, |
| 182 | 182 | #endif |
| 183 | 183 | |
| 184 | 184 | #if (SDLMAME_SDL2) |
| 185 | 185 | { 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" }, |
| 194 | 194 | |
| 195 | 195 | { 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" }, |
| 204 | 204 | #endif |
| 205 | 205 | // SDL low level driver options |
| 206 | 206 | { 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" }, |
| 208 | 208 | #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" }, |
| 210 | 210 | #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" }, |
| 212 | 212 | #if USE_OPENGL |
| 213 | 213 | { SDLOPTION_GL_LIB, SDLOPTVAL_GLLIB, OPTION_STRING, "alternative libGL.so to use; 'auto' for system default" }, |
| 214 | 214 | #endif |
| r243701 | r243702 | |
| 542 | 542 | |
| 543 | 543 | // Some driver options - must be before audio init! |
| 544 | 544 | stemp = options().audio_driver(); |
| 545 | | if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) |
| 545 | if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0) |
| 546 | 546 | { |
| 547 | 547 | osd_printf_verbose("Setting SDL audiodriver '%s' ...\n", stemp); |
| 548 | 548 | osd_setenv(SDLENV_AUDIODRIVER, stemp, 1); |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | stemp = options().video_driver(); |
| 552 | | if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) |
| 552 | if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0) |
| 553 | 553 | { |
| 554 | 554 | osd_printf_verbose("Setting SDL videodriver '%s' ...\n", stemp); |
| 555 | 555 | osd_setenv(SDLENV_VIDEODRIVER, stemp, 1); |
| r243701 | r243702 | |
| 559 | 559 | stemp = options().render_driver(); |
| 560 | 560 | if (stemp != NULL) |
| 561 | 561 | { |
| 562 | | if (strcmp(stemp, SDLOPTVAL_AUTO) != 0) |
| 562 | if (strcmp(stemp, OSDOPTVAL_AUTO) != 0) |
| 563 | 563 | { |
| 564 | 564 | osd_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp); |
| 565 | 565 | //osd_setenv(SDLENV_RENDERDRIVER, stemp, 1); |
| r243701 | r243702 | |
| 584 | 584 | /* FIXME: move lib loading code from drawogl.c here */ |
| 585 | 585 | |
| 586 | 586 | stemp = options().gl_lib(); |
| 587 | | if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) |
| 587 | if (stemp != NULL && strcmp(stemp, OSDOPTVAL_AUTO) != 0) |
| 588 | 588 | { |
| 589 | 589 | osd_setenv("SDL_VIDEO_GL_DRIVER", stemp, 1); |
| 590 | 590 | osd_printf_verbose("Setting SDL_VIDEO_GL_DRIVER = '%s' ...\n", stemp); |
trunk/src/osd/windows/video.c
| r243701 | r243702 | |
| 51 | 51 | //============================================================ |
| 52 | 52 | |
| 53 | 53 | static void init_monitors(void); |
| 54 | | static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data); |
| 55 | 54 | static win_monitor_info *pick_monitor(windows_options &options, int index); |
| 56 | 55 | |
| 57 | 56 | static void check_osd_inputs(running_machine &machine); |
| 58 | 57 | |
| 59 | | static void extract_video_config(running_machine &machine); |
| 60 | 58 | static float get_aspect(const char *defdata, const char *data, int report_error); |
| 61 | 59 | static void get_resolution(const char *defdata, const char *data, win_window_config *config, int report_error); |
| 62 | 60 | |
| r243701 | r243702 | |
| 71 | 69 | int index; |
| 72 | 70 | |
| 73 | 71 | // extract data from the options |
| 74 | | extract_video_config(machine()); |
| 72 | extract_video_config(); |
| 75 | 73 | |
| 76 | 74 | // set up monitors first |
| 77 | 75 | init_monitors(); |
| r243701 | r243702 | |
| 102 | 100 | while (win_monitor_list != NULL) |
| 103 | 101 | { |
| 104 | 102 | win_monitor_info *temp = win_monitor_list; |
| 105 | | win_monitor_list = temp->next; |
| 103 | win_monitor_list = temp->m_next; |
| 106 | 104 | global_free(temp); |
| 107 | 105 | } |
| 108 | 106 | } |
| r243701 | r243702 | |
| 110 | 108 | |
| 111 | 109 | |
| 112 | 110 | win_monitor_info::win_monitor_info() |
| 113 | | : next(NULL), |
| 114 | | handle(NULL), |
| 111 | : m_next(NULL), |
| 112 | m_handle(NULL), |
| 115 | 113 | m_aspect(0.0f), |
| 116 | | reqwidth(0), |
| 117 | | reqheight(0), |
| 118 | 114 | m_name(NULL) |
| 119 | 115 | { |
| 120 | 116 | } |
| r243701 | r243702 | |
| 134 | 130 | BOOL result; |
| 135 | 131 | |
| 136 | 132 | // 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); |
| 139 | 135 | assert(result); |
| 140 | 136 | if (m_name != NULL) |
| 141 | 137 | osd_free(m_name); |
| 142 | | m_name = utf8_from_tstring(info.szDevice); |
| 138 | m_name = utf8_from_tstring(m_info.szDevice); |
| 143 | 139 | (void)result; // to silence gcc 4.6 |
| 144 | 140 | } |
| 145 | 141 | |
| r243701 | r243702 | |
| 152 | 148 | float win_monitor_info::aspect() |
| 153 | 149 | { |
| 154 | 150 | // refresh the monitor information and compute the aspect |
| 151 | refresh(); |
| 152 | // FIXME: returning 0 looks odd, video_config is bad |
| 155 | 153 | if (video_config.keepaspect) |
| 156 | 154 | { |
| 157 | 155 | int width, height; |
| 158 | 156 | 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); |
| 161 | 159 | return m_aspect / ((float)width / (float)height); |
| 162 | 160 | } |
| 163 | 161 | return 0.0f; |
| r243701 | r243702 | |
| 174 | 172 | win_monitor_info *monitor; |
| 175 | 173 | |
| 176 | 174 | // 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) |
| 179 | 177 | return monitor; |
| 180 | 178 | return NULL; |
| 181 | 179 | } |
| r243701 | r243702 | |
| 218 | 216 | // make a list of monitors |
| 219 | 217 | win_monitor_list = NULL; |
| 220 | 218 | 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); |
| 222 | 220 | |
| 223 | 221 | // if we're verbose, print the list of monitors |
| 224 | 222 | { |
| 225 | 223 | 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) |
| 227 | 225 | { |
| 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)" : ""); |
| 229 | 227 | } |
| 230 | 228 | } |
| 231 | 229 | } |
| r243701 | r243702 | |
| 236 | 234 | // monitor_enum_callback |
| 237 | 235 | //============================================================ |
| 238 | 236 | |
| 239 | | static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data) |
| 237 | BOOL CALLBACK win_monitor_info::monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data) |
| 240 | 238 | { |
| 241 | 239 | win_monitor_info ***tailptr = (win_monitor_info ***)data; |
| 242 | 240 | win_monitor_info *monitor; |
| r243701 | r243702 | |
| 253 | 251 | monitor = global_alloc(win_monitor_info); |
| 254 | 252 | |
| 255 | 253 | // copy in the data |
| 256 | | monitor->handle = handle; |
| 257 | | monitor->info = info; |
| 254 | monitor->m_handle = handle; |
| 255 | monitor->m_info = info; |
| 258 | 256 | |
| 259 | 257 | // guess the aspect ratio assuming square pixels |
| 260 | 258 | monitor->set_aspect((float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top)); |
| 261 | 259 | |
| 262 | 260 | // save the primary monitor handle |
| 263 | | if (monitor->info.dwFlags & MONITORINFOF_PRIMARY) |
| 261 | if (monitor->m_info.dwFlags & MONITORINFOF_PRIMARY) |
| 264 | 262 | primary_monitor = monitor; |
| 265 | 263 | |
| 266 | 264 | // hook us into the list |
| 267 | 265 | **tailptr = monitor; |
| 268 | | *tailptr = &monitor->next; |
| 266 | *tailptr = &monitor->m_next; |
| 269 | 267 | |
| 270 | 268 | // enumerate all the available monitors so to list their names in verbose mode |
| 271 | 269 | return TRUE; |
| r243701 | r243702 | |
| 297 | 295 | |
| 298 | 296 | // look for a match in the name first |
| 299 | 297 | 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) |
| 301 | 299 | { |
| 302 | 300 | int rc = 1; |
| 303 | 301 | |
| r243701 | r243702 | |
| 311 | 309 | |
| 312 | 310 | // didn't find it; alternate monitors until we hit the jackpot |
| 313 | 311 | 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) |
| 315 | 313 | if (index-- == 0) |
| 316 | 314 | goto finishit; |
| 317 | 315 | |
| r243701 | r243702 | |
| 320 | 318 | |
| 321 | 319 | finishit: |
| 322 | 320 | if (aspect != 0) |
| 321 | { |
| 323 | 322 | monitor->set_aspect(aspect); |
| 323 | } |
| 324 | 324 | return monitor; |
| 325 | 325 | } |
| 326 | 326 | |
| r243701 | r243702 | |
| 355 | 355 | // extract_video_config |
| 356 | 356 | //============================================================ |
| 357 | 357 | |
| 358 | | static void extract_video_config(running_machine &machine) |
| 358 | void windows_osd_interface::extract_video_config() |
| 359 | 359 | { |
| 360 | | windows_options &options = downcast<windows_options &>(machine.options()); |
| 361 | 360 | const char *stemp; |
| 362 | 361 | |
| 363 | 362 | // 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(); |
| 368 | 367 | |
| 369 | 368 | // 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) |
| 371 | 370 | video_config.windowed = TRUE; |
| 372 | 371 | |
| 373 | 372 | // 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); |
| 379 | 378 | |
| 380 | 379 | // video options: extract the data |
| 381 | | stemp = options.video(); |
| 380 | stemp = options().video(); |
| 382 | 381 | if (strcmp(stemp, "d3d") == 0) |
| 383 | 382 | video_config.mode = VIDEO_MODE_D3D; |
| 384 | 383 | else if (strcmp(stemp, "auto") == 0) |
| r243701 | r243702 | |
| 392 | 391 | else if (strcmp(stemp, "none") == 0) |
| 393 | 392 | { |
| 394 | 393 | video_config.mode = VIDEO_MODE_NONE; |
| 395 | | if (options.seconds_to_run() == 0) |
| 394 | if (options().seconds_to_run() == 0) |
| 396 | 395 | osd_printf_warning("Warning: -video none doesn't make much sense without -seconds_to_run\n"); |
| 397 | 396 | } |
| 397 | #if (USE_OPENGL) |
| 398 | else if (strcmp(stemp, "opengl") == 0) |
| 399 | video_config.mode = VIDEO_MODE_OPENGL; |
| 400 | #endif |
| 398 | 401 | else |
| 399 | 402 | { |
| 400 | 403 | osd_printf_warning("Invalid video value %s; reverting to gdi\n", stemp); |
| 401 | 404 | video_config.mode = VIDEO_MODE_GDI; |
| 402 | 405 | } |
| 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(); |
| 407 | 410 | |
| 408 | 411 | // ddraw options: extract the data |
| 409 | | video_config.hwstretch = options.hwstretch(); |
| 412 | video_config.hwstretch = options().hwstretch(); |
| 410 | 413 | |
| 411 | 414 | // d3d options: extract the data |
| 412 | | video_config.filter = options.filter(); |
| 415 | video_config.filter = options().filter(); |
| 413 | 416 | if (video_config.prescale == 0) |
| 414 | 417 | video_config.prescale = 1; |
| 415 | 418 | } |
| r243701 | r243702 | |
| 424 | 427 | { |
| 425 | 428 | int num = 0, den = 1; |
| 426 | 429 | |
| 427 | | if (strcmp(data, "auto") == 0) |
| 430 | if (strcmp(data, OSDOPTVAL_AUTO) == 0) |
| 428 | 431 | { |
| 429 | | if (strcmp(defdata, "auto") == 0) |
| 432 | if (strcmp(defdata,OSDOPTVAL_AUTO) == 0) |
| 430 | 433 | return 0; |
| 431 | 434 | data = defdata; |
| 432 | 435 | } |
| r243701 | r243702 | |
| 436 | 439 | } |
| 437 | 440 | |
| 438 | 441 | |
| 439 | | |
| 440 | 442 | //============================================================ |
| 441 | 443 | // get_resolution |
| 442 | 444 | //============================================================ |
| r243701 | r243702 | |
| 444 | 446 | static void get_resolution(const char *defdata, const char *data, win_window_config *config, int report_error) |
| 445 | 447 | { |
| 446 | 448 | config->width = config->height = config->refresh = 0; |
| 447 | | if (strcmp(data, "auto") == 0) |
| 449 | if (strcmp(data, OSDOPTVAL_AUTO) == 0) |
| 448 | 450 | { |
| 449 | | if (strcmp(defdata, "auto") == 0) |
| 451 | if (strcmp(defdata, OSDOPTVAL_AUTO) == 0) |
| 450 | 452 | return; |
| 451 | 453 | data = defdata; |
| 452 | 454 | } |