Previous 15994 Revisions Next

r845 Saturday 18th August, 2007 at 17:03:13 UTC by R. Belmont
[SDLMESS] Many updates/cleanups from couriersud including preliminary SDL 1.3 support.
[src/osd/sdl]drawsdl.c input.c osd_opengl.h osdsdl.h sdl.mak sdlmain.c testkeys.c video.c window.c window.h yuv_blit.c

src/osd/sdl/osd_opengl.h
r844r845
1212   
1313   #if USE_OPENGL
1414   
15   #if 0
16   // OpenGL headers - which to use ?
17   #ifdef SDLMAME_MACOSX
18   #include <OpenGL/gl.h>
19   #include <OpenGL/glext.h>
20   #else
21   #include <GL/gl.h>
22   #include <GL/glext.h>
23   #endif
24   #else
15   /* equivalent to #include <GL/gl.h>
16    * #include <GL/glext.h>
17    */
2518   #include <SDL/SDL_opengl.h>
26   #endif
2719   
2820   #ifdef USE_DISPATCH_GL
2921   
src/osd/sdl/sdl.mak
r844r845
3939
4040USE_DISPATCH_GL = 1
4141
42# uncomment and chang the next line to compile and link to specific
43# SDL library. This is currently ony supported for unix!
44# There is no need to play with this option unless you are doing
45# active development on sdlmame or SDL.
4246
47# SDL_INSTALL_ROOT = /usr/local/sdl13
48
4349###########################################################################
4450##################   END USER-CONFIGURABLE OPTIONS   ######################
4551###########################################################################
r844r845
179185else
180186OSDOBJS += $(SDLOBJ)/gl_shader_tool.o $(SDLOBJ)/gl_shader_mgr.o
181187DEFS += -DUSE_OPENGL=1
182ifdef USE_DISPATCH_GL
183188ifeq ($(TARGETOS),win32)
184189LIBGL=-lGL
185190else
191ifdef USE_DISPATCH_GL
186192DEFS += -DUSE_DISPATCH_GL=1
187endif
188193else
189194LIBGL=-lGL
190195endif
191196endif
197endif
192198
199#-------------------------------------------------
200# specific configurations
201#-------------------------------------------------
202
193203# Unix: add the necessary libraries
194204ifeq ($(TARGETOS),unix)
195CFLAGS += `sdl-config --cflags`
196205
197206ifndef USE_DISPATCH_GL
198207ifdef MESA_INSTALL_ROOT
r844r845
202211endif
203212endif
204213
214ifndef SDL_INSTALL_ROOT
215CFLAGS += `sdl-config --cflags`
205216LIBS += -lm `sdl-config --libs` $(LIBGL)
217else
218CFLAGS += -I$(SDL_INSTALL_ROOT)/include
219LIBS += -lm -L$(SDL_INSTALL_ROOT)/lib -Wl,-rpath,$(SDL_INSTALL_ROOT)/lib -lSDL $(LIBGL)
220endif
206221
207222ifndef NO_X11
208223LIBS += -lX11 -lXinerama
r844r845
286301   @echo Linking $@...
287302   $(LD) $(LDFLAGS) $^ $(SDLMAIN) $(SDLOBJ)/strconv.o $(LIBS) -o $@
288303   
304testlib:
305   -echo LIBS: $(LIBS)
306   -echo DEFS: $(DEFS)
src/osd/sdl/input.c
r844r845
338338   KE8(c,         d,         e,            f,         g,         h,         i,         j         )
339339   KE8(k,         l,         m,            n,         o,         p,         q,         r         )
340340   KE8(s,         t,         u,            v,         w,         x,         y,         z         )
341   { SDLK_DELETE, "SDLK_DELETE" }, KE(WORLD_0) KE(WORLD_1) KE(WORLD_2) KE(WORLD_3) KE(WORLD_4) KE(WORLD_5) KE(WORLD_6)
342   KE8(WORLD_7,   WORLD_8,   WORLD_9,      WORLD_10,   WORLD_11,   WORLD_12,   WORLD_13,   WORLD_14   )
343   KE8(WORLD_15,   WORLD_16,   WORLD_17,      WORLD_18,   WORLD_19,   WORLD_20,   WORLD_21,   WORLD_22   )
344   KE8(WORLD_23,   WORLD_24,   WORLD_25,      WORLD_26,   WORLD_27,   WORLD_28,   WORLD_29,   WORLD_30   )
345   KE8(WORLD_31,   WORLD_32,   WORLD_33,      WORLD_34,   WORLD_35,   WORLD_36,   WORLD_37,   WORLD_38   )
346   KE8(WORLD_39,   WORLD_40,   WORLD_41,      WORLD_42,   WORLD_43,   WORLD_44,   WORLD_45,   WORLD_46   )
347   KE8(WORLD_47,   WORLD_48,   WORLD_49,      WORLD_50,   WORLD_51,   WORLD_52,   WORLD_53,   WORLD_54   )
348   KE8(WORLD_55,   WORLD_56,   WORLD_57,      WORLD_58,   WORLD_59,   WORLD_60,   WORLD_61,   WORLD_62   )
349   KE8(WORLD_63,   WORLD_64,   WORLD_65,      WORLD_66,   WORLD_67,   WORLD_68,   WORLD_69,   WORLD_70   )
350   KE8(WORLD_71,   WORLD_72,   WORLD_73,      WORLD_74,   WORLD_75,   WORLD_76,   WORLD_77,   WORLD_78   )
351   KE8(WORLD_79,   WORLD_80,   WORLD_81,      WORLD_82,   WORLD_83,   WORLD_84,   WORLD_85,   WORLD_86   )
352   KE8(WORLD_87,   WORLD_88,   WORLD_89,      WORLD_90,   WORLD_91,   WORLD_92,   WORLD_93,   WORLD_94   )
353   KE8(WORLD_95,   KP0,      KP1,         KP2,      KP3,      KP4,      KP5,      KP6         )
354   KE8(KP7,      KP8,      KP9,         KP_PERIOD,   KP_DIVIDE,   KP_MULTIPLY,KP_MINUS,   KP_PLUS      )
355   KE8(KP_ENTER,   KP_EQUALS,   UP,            DOWN,      RIGHT,      LEFT,      INSERT,      HOME      )
356   KE8(END,      PAGEUP,      PAGEDOWN,      F1,         F2,         F3,         F4,         F5         )
357   KE8(F6,         F7,         F8,            F9,         F10,      F11,      F12,      F13         )
358   KE8(F14,      F15,      NUMLOCK,      CAPSLOCK,   SCROLLOCK,   RSHIFT,      LSHIFT,      RCTRL      )
359   KE8(LCTRL,      RALT,      LALT,         RMETA,      LMETA,      LSUPER,      RSUPER,      MODE      )
360   KE8(COMPOSE,   HELP,      PRINT,         SYSREQ,      BREAK,      MENU,      POWER,      EURO      )
361   KE(UNDO)
341   { SDLK_DELETE, "SDLK_DELETE" },
342   //FIXME:Proper check for version
343#if (SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) < 1300)
344   KE8(WORLD_0,   WORLD_1,   WORLD_2,   WORLD_3,   WORLD_4,   WORLD_5,   WORLD_6,   WORLD_7      )
345   KE8(WORLD_8,   WORLD_9,   WORLD_10,   WORLD_11,   WORLD_12,   WORLD_13,   WORLD_14,   WORLD_15   )
346   KE8(WORLD_16,   WORLD_17,   WORLD_18,   WORLD_19,   WORLD_20,   WORLD_21,   WORLD_22,   WORLD_23   )
347   KE8(WORLD_24,   WORLD_25,   WORLD_26,   WORLD_27,   WORLD_28,   WORLD_29,   WORLD_30,   WORLD_31   )
348   KE8(WORLD_32,   WORLD_33,   WORLD_34,   WORLD_35,   WORLD_36,   WORLD_37,   WORLD_38,   WORLD_39   )
349   KE8(WORLD_40,   WORLD_41,   WORLD_42,   WORLD_43,   WORLD_44,   WORLD_45,   WORLD_46,   WORLD_47   )
350   KE8(WORLD_48,   WORLD_49,   WORLD_50,   WORLD_51,   WORLD_52,   WORLD_53,   WORLD_54,   WORLD_55   )
351   KE8(WORLD_56,   WORLD_57,   WORLD_58,   WORLD_59,   WORLD_60,   WORLD_61,   WORLD_62,   WORLD_63   )
352   KE8(WORLD_64,   WORLD_65,   WORLD_66,   WORLD_67,   WORLD_68,   WORLD_69,   WORLD_70,   WORLD_71   )
353   KE8(WORLD_72,   WORLD_73,   WORLD_74,   WORLD_75,   WORLD_76,   WORLD_77,   WORLD_78,   WORLD_79   )
354   KE8(WORLD_80,   WORLD_81,   WORLD_82,   WORLD_83,   WORLD_84,   WORLD_85,   WORLD_86,   WORLD_87   )
355   KE8(WORLD_88,   WORLD_89,   WORLD_90,   WORLD_91,   WORLD_92,   WORLD_93,   WORLD_94,   WORLD_95   )
356#endif
357   KE8(KP0,      KP1,      KP2,      KP3,      KP4,      KP5,      KP6,      KP7         )
358   KE8(KP8,      KP9,      KP_PERIOD,   KP_DIVIDE,   KP_MULTIPLY,KP_MINUS,   KP_PLUS,    KP_ENTER   )
359   KE8(UP,         DOWN,      RIGHT,      LEFT,      INSERT,      HOME,      KP_EQUALS,   END         )
360   KE8(PAGEUP,      PAGEDOWN,   F1,         F2,         F3,         F4,         F5,         F6         )
361   KE8(F7,         F8,         F9,         F10,      F11,      F12,      F13,      F14         )
362   KE8(F15,      NUMLOCK,   CAPSLOCK,   SCROLLOCK,   RSHIFT,      LSHIFT,      RCTRL,      LCTRL      )
363   KE8(RALT,      LALT,      RMETA,      LMETA,      LSUPER,      RSUPER,      MODE,      COMPOSE      )
364   KE8(HELP,      PRINT,      SYSREQ,      BREAK,      MENU,      POWER,      EURO,      UNDO      )
362365   KE(LAST)     
363366   {-1, ""}
364367};
src/osd/sdl/drawsdl.c
r844r845
284284
285285// YUV overlays
286286
287void yuv_lookup_init(sdl_window_info *window);
288287static void yuv_RGB_to_YV12(UINT16 *bitmap, int bw, sdl_window_info *window);
289288static void yuv_RGB_to_YV12X2(UINT16 *bitmap, int bw, sdl_window_info *window);
290289static void yuv_RGB_to_YUY2(UINT16 *bitmap, int bw, sdl_window_info *window);
r844r845
448447//  drawsdl_window_draw
449448//============================================================
450449
451static void clear_surface(sdl_window_info *window)
452{
453   if (SDL_MUSTLOCK(window->sdlsurf)) SDL_LockSurface(window->sdlsurf);
454
455   memset(window->sdlsurf->pixels, 0, window->sdlsurf->h * window->sdlsurf->pitch);
456   if (SDL_MUSTLOCK(window->sdlsurf)) SDL_UnlockSurface(window->sdlsurf);
457
458   SDL_Flip(window->sdlsurf);
459}
460
461450static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update)
462451{
463452   sdl_info *sdl = window->dxdata;
r844r845
12601249
12611250   if (((sdl->blitwidth != newwidth) || (sdl->blitheight != newheight)) && !(window->opengl) && (window->sdlsurf))
12621251   {
1263      clear_surface(window);
1264      clear_surface(window);
1265      clear_surface(window);
1252      sdlwindow_clear_surface(window, 3);
12661253   }
12671254
12681255   sdl->blitwidth = newwidth;
src/osd/sdl/video.c
r844r845
145145
146146   // extract data from the options
147147   extract_video_config();
148
149#ifndef NO_OPENGL
150#ifdef USE_DISPATCH_GL
151   /*
152    *  directfb and and x11 use this env var
153    */
154   gl_dispatch = auto_malloc(sizeof(osd_gl_dispatch));
155   if (video_config.mode == VIDEO_MODE_OPENGL)
156   {
157      const char *e;
158      //e=getenv("SDL_VIDEO_GL_DRIVER");
159      e=getenv("SDLMAME_GL_LIB");
160#ifdef SDLMAME_MACOSX
161      /* Vas Crabb: Default GL-lib for MACOSX */
162      if (!e)
163         e = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib";
164#endif
165      if (SDL_GL_LoadLibrary(e) != 0) // Load library (default for e==NULL
166      {
167         fatalerror("Unable to load default library: %s\n", e);
168      }
169      mame_printf_verbose("Loaded opengl shared library: %s\n", e ? e : "<default>");
170   }
171#endif
172#endif
173148   
174149   // ensure we get called on the way out
175150   add_exit_callback(machine, video_exit);
r844r845
321296            char *dimstr = getenv("SDLMAME_DESKTOPDIM");
322297            const SDL_VideoInfo *sdl_vi;
323298           
324            #if 0
325            // Code disabled since directfb may support *software* opengl
326            // Unfortunately there is no way to tell wheter the driver
327            // supports opengl at all. Added code to video.c to check
328            // whether actually opengl was activated during setvideomode
329            if ( (video_config.mode == VIDEO_MODE_OPENGL) &&
330                (/*!strcmp(monitor->mo nitor_device,"directfb")*/ 0
331                 || !strcmp(monitor->monitor_device,"fbcon") ) )
332            {
333               mame_printf_warning("WARNING: OpenGL not supported for driver <%s>\n",monitor->monitor_device);
334               mame_printf_warning("         Falling back to soft mode\n");
335               video_config.mode = VIDEO_MODE_SOFT;
336            }
337            #endif
338           
339299            sdl_vi = SDL_GetVideoInfo();
340300            #if (SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) >= 1210)
301            //FIXME: File a bug for SDL 1.3
302            #if (SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) < 1300)
341303            cw = sdl_vi->current_w;
342304            ch = sdl_vi->current_h;
343305            #endif
306            #endif
344307            first_call=1;
345308            if ((cw==0) || (ch==0))
346309            {
r844r845
551514
552515   // get the screen option
553516   #if SDL_MULTIMON || defined(SDLMAME_WIN32)
554   sprintf(option, SDLOPTION_FMT_SCREEN, index);
517   sprintf(option, SDLOPTION_SCREEN("%d"), index);
555518   scrname = options_get_string(mame_options(), option);
556519   #endif
557520
558521   // get the aspect ratio
559   sprintf(option, SDLOPTION_FMT_ASPECT, index);
522   sprintf(option, SDLOPTION_ASPECT("%d"), index);
560523   aspect = get_aspect(option, TRUE);
561524
562525   // look for a match in the name first
r844r845
665628      load_effect_overlay(stemp);
666629
667630   // per-window options: extract the data
668   get_resolution("resolution0", &video_config.window[0], TRUE);
669   get_resolution("resolution1", &video_config.window[1], TRUE);
670   get_resolution("resolution2", &video_config.window[2], TRUE);
671   get_resolution("resolution3", &video_config.window[3], TRUE);
631   get_resolution(SDLOPTION_RESOLUTION("0"), &video_config.window[0], TRUE);
632   get_resolution(SDLOPTION_RESOLUTION("1"), &video_config.window[1], TRUE);
633   get_resolution(SDLOPTION_RESOLUTION("2"), &video_config.window[2], TRUE);
634   get_resolution(SDLOPTION_RESOLUTION("3"), &video_config.window[3], TRUE);
672635
673636   // default to working video please
674637   video_config.novideo = 0;
r844r845
710673      video_config.prescale = 1;
711674   }
712675
713   video_config.forcepow2texture = options_get_bool(mame_options(), "gl_forcepow2texture")==1;
714   video_config.allowtexturerect = options_get_bool(mame_options(), "gl_notexturerect")==0;
715   video_config.vbo         = options_get_bool(mame_options(), "gl_vbo");
716   video_config.pbo         = options_get_bool(mame_options(), "gl_pbo");
717   video_config.glsl        = options_get_bool(mame_options(), "gl_glsl");
676   video_config.forcepow2texture = options_get_bool(mame_options(), SDLOPTION_GL_FORCEPOW2TEXTURE)==1;
677   video_config.allowtexturerect = options_get_bool(mame_options(), SDLOPTION_GL_NOTEXTURERECT)==0;
678   video_config.vbo         = options_get_bool(mame_options(), SDLOPTION_GL_VBO);
679   video_config.pbo         = options_get_bool(mame_options(), SDLOPTION_GL_PBO);
680   video_config.glsl        = options_get_bool(mame_options(), SDLOPTION_GL_GLSL);
718681   if ( video_config.glsl )
719682   {
720683      int i;
721684      static char buffer[20]; // gl_glsl_filter[0..9]?
722685
723      video_config.glsl_filter = options_get_int (mame_options(), "gl_glsl_filter");
686      video_config.glsl_filter = options_get_int (mame_options(), SDLOPTION_GLSL_FILTER);
724687
725688      video_config.glsl_shader_mamebm_num=0;
726689
727690      for(i=0; i<GLSL_SHADER_MAX; i++)
728691      {
729         snprintf(buffer, 18, "glsl_shader_mame%d", i); buffer[17]=0;
692         snprintf(buffer, 18, SDLOPTION_SHADER_MAME("%d"), i); buffer[17]=0;
730693
731694         stemp = options_get_string(mame_options(), buffer);
732695         if (stemp && strcmp(stemp, "none") != 0 && strlen(stemp)>0)
r844r845
743706
744707      for(i=0; i<GLSL_SHADER_MAX; i++)
745708      {
746         snprintf(buffer, 20, "glsl_shader_screen%d", i); buffer[19]=0;
709         snprintf(buffer, 20, SDLOPTION_SHADER_SCREEN("%d"), i); buffer[19]=0;
747710
748711         stemp = options_get_string(mame_options(), buffer);
749712         if (stemp && strcmp(stemp, "none") != 0 && strlen(stemp)>0)
r844r845
756719         }
757720      }
758721
759      video_config.glsl_vid_attributes = options_get_int (mame_options(), "gl_glsl_vid_attr");
722      video_config.glsl_vid_attributes = options_get_int (mame_options(), SDLOPTION_GL_GLSL_VID_ATTR);
760723      {
761724         // Disable feature: glsl_vid_attributes, as long we have the gamma calculation
762725         // disabled within the direct shaders .. -> too slow.
r844r845
865828
866829static float get_aspect(const char *name, int report_error)
867830{
868   const char *defdata = options_get_string(mame_options(), SDLOPTION_ASPECT);
831   const char *defdata = options_get_string(mame_options(), SDLOPTION_ASPECT(""));
869832   const char *data = options_get_string(mame_options(), name);
870833   int num = 0, den = 1;
871834
src/osd/sdl/window.c
r844r845
8787static osd_work_queue *work_queue;
8888static int main_threadid;
8989static int window_threadid;
90static int dll_loaded;
9091
92
9193static UINT32 last_update_time;
9294
9395static const char *yuv_mode_names[] = { "none", "yv12", "yv12x2", "yuy2", "yuy2x2" };
r844r845
108110   const render_primitive_list *list;
109111   int resize_new_width;
110112   int resize_new_height;
113   int times;
111114};
112115
113116
r844r845
129132static void *complete_create_wt(void *param);
130133static void set_starting_view(int index, sdl_window_info *window, const char *view);
131134
132/* in drawsdl.c */
133void yuv_lookup_init(sdl_window_info *window);
134
135135//============================================================
136136//  clear the worker_param structure, inline - faster than memset
137137//============================================================
r844r845
142142   wp->list=NULL;
143143   wp->resize_new_width=0;
144144   wp->resize_new_height=0;
145   wp->times=0;
145146}
146147
147148//============================================================
r844r845
242243
243244   // set up the window list
244245   last_window_ptr = &sdl_window_list;
246   dll_loaded = 0;
245247   return 0;
246248}
247249
r844r845
285287{
286288   ASSERT_MAIN_THREAD();
287289
288   // if we're multithreaded, clean up the window thread
289   if (multithreading_enabled)
290   {
291      sdlwindow_sync();
292   }
293
294290   // free all the windows
295291   while (sdl_window_list != NULL)
296292   {
r844r845
298294      sdl_window_list = temp->next;
299295      sdlwindow_video_window_destroy(temp);
300296   }
297   
298   // if we're multithreaded, clean up the window thread
299   if (multithreading_enabled)
300   {
301      sdlwindow_sync();
302   }
301303
302304   // kill the drawers
303305   (*draw.exit)();
r844r845
382384#if USE_OPENGL
383385   drawsdl_destroy_all_textures(window);
384386#endif
387#if (SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) < 1300)
385388   SDL_FreeSurface(window->sdlsurf);
389#endif
390   //printf("SetVideoMode %d %d\n", wp->resize_new_width, wp->resize_new_height);
386391   if (video_config.yuv_mode == VIDEO_YUV_MODE_NONE)
387392      window->sdlsurf = SDL_SetVideoMode(wp->resize_new_width, wp->resize_new_height, 0, SDL_SWSURFACE |
388393         SDL_DOUBLEBUF | SDL_ANYFORMAT | window->extra_flags);
r844r845
419424}
420425
421426//============================================================
427//  sdlwindow_clear_surface
428//  (window thread)
429//============================================================
430
431static void *sdlwindow_clear_surface_wt(void *param)
432{
433   sdl_window_info *window = sdl_window_list;
434   worker_param *wp = (worker_param *) param;
435   int i;
436
437   ASSERT_WINDOW_THREAD();
438
439   for (i=0;i < wp->times; i++)
440   {
441      if (SDL_MUSTLOCK(window->sdlsurf)) SDL_LockSurface(window->sdlsurf);
442
443      memset(window->sdlsurf->pixels, 0, window->sdlsurf->h * window->sdlsurf->pitch);
444      if (SDL_MUSTLOCK(window->sdlsurf)) SDL_UnlockSurface(window->sdlsurf);
445
446      SDL_Flip(window->sdlsurf);
447   }
448
449   free(wp);
450   return NULL;
451}
452
453void sdlwindow_clear_surface(sdl_window_info *window, int times)
454{
455   worker_param wp;
456
457   ASSERT_MAIN_THREAD();
458
459   clear_worker_param(&wp);
460   wp.window = window;
461   wp.times = times;
462   
463   execute_async_wait(&sdlwindow_clear_surface_wt, &wp);
464}
465
466//============================================================
422467//  sdlwindow_toggle_full_screen
423468//  (main thread)
424469//============================================================
r844r845
687732      goto error;
688733
689734   // set the specific view
690   sprintf(option, "view%d", index);
735   sprintf(option, SDLOPTION_VIEW("%d"), index);
691736   set_starting_view(index, window, options_get_string(mame_options(), option));
692737
693738   // make the window title
r844r845
734779
735780   if (window->sdlsurf)
736781   {
782#if (SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) < 1300)
783      // Will be done by SDL on next call to SetVideoMode
737784      SDL_FreeSurface(window->sdlsurf);
785#endif
738786      window->sdlsurf = NULL;
739787   }
740788
r844r845
10941142       SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
10951143     
10961144      #if (SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) >= 1210)
1145      #if (SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) < 1300)
10971146      if (options_get_bool(mame_options(), SDLOPTION_WAITVSYNC))
10981147      {
10991148         SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
r844r845
11031152         SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
11041153      }
11051154      #endif
1155      #endif
11061156   }
11071157
1158#ifndef NO_OPENGL
1159#ifdef USE_DISPATCH_GL
1160   if (window->opengl && !dll_loaded)
1161   {
1162      /*
1163       *  directfb and and x11 use this env var
1164       *   SDL_VIDEO_GL_DRIVER
1165       */
1166      const char *e;
1167      e=getenv("SDLMAME_GL_LIB");
1168#ifdef SDLMAME_MACOSX
1169      /* Vas Crabb: Default GL-lib for MACOSX */
1170      if (!e)
1171         e = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib";
1172#endif
1173      if (SDL_GL_LoadLibrary(e) != 0) // Load library (default for e==NULL
1174      {
1175         fatalerror("Unable to load default library: %s\n", e);
1176      }
1177          mame_printf_verbose("Loaded opengl shared library: %s\n", e ? e : "<default>");
1178       gl_dispatch = auto_malloc(sizeof(osd_gl_dispatch));
1179        dll_loaded=1;
1180   }
1181#endif
1182#endif
11081183   // create the SDL surface (which creates the window in windowed mode)
11091184   if (video_config.yuv_mode == VIDEO_YUV_MODE_NONE)
11101185      window->sdlsurf = SDL_SetVideoMode(tempwidth, tempheight,
r844r845
12831358#endif
12841359   if (video_config.yuv_mode != VIDEO_YUV_MODE_NONE)
12851360   {
1286      yuv_lookup_init(window);
1361      drawsdl_yuv_init(window);
12871362      yuv_overlay_init(window);
12881363   }
12891364
src/osd/sdl/testkeys.c
r844r845
4242   KE8(c,         d,         e,            f,         g,         h,         i,         j         )
4343   KE8(k,         l,         m,            n,         o,         p,         q,         r         )
4444   KE8(s,         t,         u,            v,         w,         x,         y,         z         )
45//FIXME: SDL 1.3 Definitions are gone
46#if (SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) < 1300)
4547   KE8(DELETE,      WORLD_0,   WORLD_1,      WORLD_2,   WORLD_3,   WORLD_4,   WORLD_5,   WORLD_6      )
4648   KE8(WORLD_7,   WORLD_8,   WORLD_9,      WORLD_10,   WORLD_11,   WORLD_12,   WORLD_13,   WORLD_14   )
4749   KE8(WORLD_15,   WORLD_16,   WORLD_17,      WORLD_18,   WORLD_19,   WORLD_20,   WORLD_21,   WORLD_22   )
r844r845
5557   KE8(WORLD_79,   WORLD_80,   WORLD_81,      WORLD_82,   WORLD_83,   WORLD_84,   WORLD_85,   WORLD_86   )
5658   KE8(WORLD_87,   WORLD_88,   WORLD_89,      WORLD_90,   WORLD_91,   WORLD_92,   WORLD_93,   WORLD_94   )
5759   KE8(WORLD_95,   KP0,      KP1,         KP2,      KP3,      KP4,      KP5,      KP6         )
60#else
61   KE8(DELETE,      KP0,      KP1,         KP2,      KP3,      KP4,      KP5,      KP6         )
62   
63#endif
5864   KE8(KP7,      KP8,      KP9,         KP_PERIOD,   KP_DIVIDE,   KP_MULTIPLY,KP_MINUS,   KP_PLUS      )
5965   KE8(KP_ENTER,   KP_EQUALS,   UP,            DOWN,      RIGHT,      LEFT,      INSERT,      HOME      )
6066   KE8(END,      PAGEUP,      PAGEDOWN,      F1,         F2,         F3,         F4,         F5         )
src/osd/sdl/window.h
r844r845
145145{
146146   INT32            blitwidth, blitheight;   // current blit width/height values
147147
148#if USE_OPENGL
148149   // 3D info (GL mode only)
149150   texture_info *         texlist;      // list of active textures
150151   int            last_blendmode;      // previous blendmode
r844r845
165166                        // as output, otherwise the mame bitmap.
166167   int            glsl_vid_attributes;   // glsl brightness, contrast and gamma for RGB bitmaps
167168   int            usetexturerect;      // use ARB_texture_rectangle for non-power-of-2, general use
169#endif
168170
169171   int            totalColors;      // total colors from machine/sdl_window_config/sdl_window_info
170172};
r844r845
200202void sdlwindow_update_cursor_state(void);
201203void sdlwindow_video_window_update(sdl_window_info *window);
202204
205void sdlwindow_clear_surface(sdl_window_info *window, int times);
203206void sdlwindow_toggle_full_screen(void);
204207void sdlwindow_modify_prescale(int dir);
205208void sdlwindow_modify_effect(int dir);
r844r845
216219
217220int drawsdl_init(sdl_draw_callbacks *callbacks);
218221int drawogl_init(sdl_draw_callbacks *callbacks);
222void drawsdl_yuv_init(sdl_window_info *window);
219223
220224//============================================================
221225//  multitasking
src/osd/sdl/sdlmain.c
r844r845
9292   // performance options
9393   { NULL,                                   NULL,       OPTION_HEADER,     "PERFORMANCE OPTIONS" },
9494   { SDLOPTION_MULTITHREADING ";mt",         "0",        OPTION_BOOLEAN,    "enable multithreading; this enables rendering and blitting on a separate thread" },
95   { "sdlvideofps",                          "0",        OPTION_BOOLEAN,    "show sdl video performance" },
95   { SDLOPTION_SDLVIDEOFPS,                  "0",        OPTION_BOOLEAN,    "show sdl video performance" },
9696
9797   // video options
9898   { NULL,                                   NULL,       OPTION_HEADER,     "VIDEO OPTIONS" },
r844r845
113113
114114   // OpenGL specific options
115115   { NULL,                                   NULL,   OPTION_HEADER,  "OpenGL-SPECIFIC OPTIONS" },
116   { "filter;glfilter;flt",                  "1",    OPTION_BOOLEAN, "enable bilinear filtering on screen output" },
117   { "prescale",                             "1",        0,                 "scale screen rendering by this amount in software" },
118   { "gl_forcepow2texture",                  "0",    OPTION_BOOLEAN, "force power of two textures  (default no)" },
119   { "gl_notexturerect",                     "0",    OPTION_BOOLEAN, "don't use OpenGL GL_ARB_texture_rectangle (default on)" },
120   { "gl_vbo",                               "1",    OPTION_BOOLEAN, "enable OpenGL VBO,  if available (default on)" },
121   { "gl_pbo",                               "1",    OPTION_BOOLEAN, "enable OpenGL PBO,  if available (default on)" },
122   { "gl_glsl",                              "0",    OPTION_BOOLEAN, "enable OpenGL GLSL, if available (default off)" },
123    { "gl_glsl_filter",           "1",       0,          "enable OpenGL GLSL filtering instead of FF filtering 0-plain, 1-bilinear (default)" },
124    { "glsl_shader_mame0",         "none",      0,          "custom OpenGL GLSL shader set mame bitmap 0" },
125    { "glsl_shader_mame1",         "none",      0,          "custom OpenGL GLSL shader set mame bitmap 1" },
126    { "glsl_shader_mame2",         "none",      0,          "custom OpenGL GLSL shader set mame bitmap 2" },
127    { "glsl_shader_mame3",         "none",      0,          "custom OpenGL GLSL shader set mame bitmap 3" },
128    { "glsl_shader_mame4",         "none",      0,          "custom OpenGL GLSL shader set mame bitmap 4" },
129    { "glsl_shader_mame5",         "none",      0,          "custom OpenGL GLSL shader set mame bitmap 5" },
130    { "glsl_shader_mame6",         "none",      0,          "custom OpenGL GLSL shader set mame bitmap 6" },
131    { "glsl_shader_mame7",         "none",      0,          "custom OpenGL GLSL shader set mame bitmap 7" },
132    { "glsl_shader_mame8",         "none",      0,          "custom OpenGL GLSL shader set mame bitmap 8" },
133    { "glsl_shader_mame9",         "none",      0,          "custom OpenGL GLSL shader set mame bitmap 9" },
134    { "glsl_shader_screen0",      "none",      0,          "custom OpenGL GLSL shader screen bitmap 0" },
135    { "glsl_shader_screen1",      "none",      0,          "custom OpenGL GLSL shader screen bitmap 1" },
136    { "glsl_shader_screen2",      "none",      0,          "custom OpenGL GLSL shader screen bitmap 2" },
137    { "glsl_shader_screen3",      "none",      0,          "custom OpenGL GLSL shader screen bitmap 3" },
138    { "glsl_shader_screen4",      "none",      0,          "custom OpenGL GLSL shader screen bitmap 4" },
139    { "glsl_shader_screen5",      "none",      0,          "custom OpenGL GLSL shader screen bitmap 5" },
140    { "glsl_shader_screen6",      "none",      0,          "custom OpenGL GLSL shader screen bitmap 6" },
141    { "glsl_shader_screen7",      "none",      0,          "custom OpenGL GLSL shader screen bitmap 7" },
142    { "glsl_shader_screen8",      "none",      0,          "custom OpenGL GLSL shader screen bitmap 8" },
143    { "glsl_shader_screen9",      "none",      0,          "custom OpenGL GLSL shader screen bitmap 9" },
144    { "gl_glsl_vid_attr",          "1",    OPTION_BOOLEAN, "enable OpenGL GLSL handling of brightness and contrast. Better RGB game performance for free. (default)" },
116   { SDLOPTION_FILTER ";glfilter;flt",       "1",    OPTION_BOOLEAN, "enable bilinear filtering on screen output" },
117   { SDLOPTION_PRESCALE,                     "1",        0,                 "scale screen rendering by this amount in software" },
118   { SDLOPTION_GL_FORCEPOW2TEXTURE,          "0",    OPTION_BOOLEAN, "force power of two textures  (default no)" },
119   { SDLOPTION_GL_NOTEXTURERECT,             "0",    OPTION_BOOLEAN, "don't use OpenGL GL_ARB_texture_rectangle (default on)" },
120   { SDLOPTION_GL_VBO,                       "1",    OPTION_BOOLEAN, "enable OpenGL VBO,  if available (default on)" },
121   { SDLOPTION_GL_PBO,                       "1",    OPTION_BOOLEAN, "enable OpenGL PBO,  if available (default on)" },
122   { SDLOPTION_GL_GLSL,                      "0",    OPTION_BOOLEAN, "enable OpenGL GLSL, if available (default off)" },
123    { SDLOPTION_GLSL_FILTER,              "1",       0,          "enable OpenGL GLSL filtering instead of FF filtering 0-plain, 1-bilinear (default)" },
124    { SDLOPTION_SHADER_MAME("0"),           "none",      0,          "custom OpenGL GLSL shader set mame bitmap 0" },
125    { SDLOPTION_SHADER_MAME("1"),           "none",      0,          "custom OpenGL GLSL shader set mame bitmap 1" },
126    { SDLOPTION_SHADER_MAME("2"),           "none",      0,          "custom OpenGL GLSL shader set mame bitmap 2" },
127    { SDLOPTION_SHADER_MAME("3"),           "none",      0,          "custom OpenGL GLSL shader set mame bitmap 3" },
128    { SDLOPTION_SHADER_MAME("4"),           "none",      0,          "custom OpenGL GLSL shader set mame bitmap 4" },
129    { SDLOPTION_SHADER_MAME("5"),           "none",      0,          "custom OpenGL GLSL shader set mame bitmap 5" },
130    { SDLOPTION_SHADER_MAME("6"),           "none",      0,          "custom OpenGL GLSL shader set mame bitmap 6" },
131    { SDLOPTION_SHADER_MAME("7"),           "none",      0,          "custom OpenGL GLSL shader set mame bitmap 7" },
132    { SDLOPTION_SHADER_MAME("8"),           "none",      0,          "custom OpenGL GLSL shader set mame bitmap 8" },
133    { SDLOPTION_SHADER_MAME("9"),           "none",      0,          "custom OpenGL GLSL shader set mame bitmap 9" },
134    { SDLOPTION_SHADER_SCREEN("0"),          "none",      0,          "custom OpenGL GLSL shader screen bitmap 0" },
135    { SDLOPTION_SHADER_SCREEN("1"),          "none",      0,          "custom OpenGL GLSL shader screen bitmap 1" },
136    { SDLOPTION_SHADER_SCREEN("2"),          "none",      0,          "custom OpenGL GLSL shader screen bitmap 2" },
137    { SDLOPTION_SHADER_SCREEN("3"),          "none",      0,          "custom OpenGL GLSL shader screen bitmap 3" },
138    { SDLOPTION_SHADER_SCREEN("4"),          "none",      0,          "custom OpenGL GLSL shader screen bitmap 4" },
139    { SDLOPTION_SHADER_SCREEN("5"),          "none",      0,          "custom OpenGL GLSL shader screen bitmap 5" },
140    { SDLOPTION_SHADER_SCREEN("6"),          "none",      0,          "custom OpenGL GLSL shader screen bitmap 6" },
141    { SDLOPTION_SHADER_SCREEN("7"),          "none",      0,          "custom OpenGL GLSL shader screen bitmap 7" },
142    { SDLOPTION_SHADER_SCREEN("8"),          "none",      0,          "custom OpenGL GLSL shader screen bitmap 8" },
143    { SDLOPTION_SHADER_SCREEN("9"),          "none",      0,          "custom OpenGL GLSL shader screen bitmap 9" },
144    { SDLOPTION_GL_GLSL_VID_ATTR,          "1",    OPTION_BOOLEAN, "enable OpenGL GLSL handling of brightness and contrast. Better RGB game performance for free. (default)" },
145145
146146   // per-window options
147147   { NULL,                                   NULL,       OPTION_HEADER,     "PER-WINDOW VIDEO OPTIONS" },
148   { "screen",                               "auto",     0,                 "explicit name of the first screen; 'auto' here will try to make a best guess" },
149   { SDLOPTION_ASPECT ";screen_aspect",      "auto",     0,                 "aspect ratio for all screens; 'auto' here will try to make a best guess" },
150   { "resolution;r",                         "auto",     0,                 "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" },
151   { "view",                                 "auto",     0,                 "preferred view for all screens" },
148   { SDLOPTION_SCREEN(""),                   "auto",     0,                 "explicit name of the first screen; 'auto' here will try to make a best guess" },
149   { SDLOPTION_ASPECT("") ";screen_aspect",  "auto",     0,                 "aspect ratio for all screens; 'auto' here will try to make a best guess" },
150   { SDLOPTION_RESOLUTION("") ";r",          "auto",     0,                 "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" },
151   { SDLOPTION_VIEW(""),                     "auto",     0,                 "preferred view for all screens" },
152152
153   { "screen0",                              "auto",     0,                 "explicit name of the first screen; 'auto' here will try to make a best guess" },
154   { "aspect0",                              "auto",     0,                 "aspect ratio of the first screen; 'auto' here will try to make a best guess" },
155   { "resolution0;r0",                       "auto",     0,                 "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
156   { "view0",                                "auto",     0,                 "preferred view for the first screen" },
153   { SDLOPTION_SCREEN("0"),                  "auto",     0,                 "explicit name of the first screen; 'auto' here will try to make a best guess" },
154   { SDLOPTION_ASPECT("0"),                  "auto",     0,                 "aspect ratio of the first screen; 'auto' here will try to make a best guess" },
155   { SDLOPTION_RESOLUTION("0") ";r0",        "auto",     0,                 "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
156   { SDLOPTION_VIEW("0"),                    "auto",     0,                 "preferred view for the first screen" },
157157
158   { "screen1",                              "auto",     0,                 "explicit name of the second screen; 'auto' here will try to make a best guess" },
159   { "aspect1",                              "auto",     0,                 "aspect ratio of the second screen; 'auto' here will try to make a best guess" },
160   { "resolution1;r1",                       "auto",     0,                 "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
161   { "view1",                                "auto",     0,                 "preferred view for the second screen" },
158   { SDLOPTION_SCREEN("1"),                  "auto",     0,                 "explicit name of the second screen; 'auto' here will try to make a best guess" },
159   { SDLOPTION_ASPECT("1"),                  "auto",     0,                 "aspect ratio of the second screen; 'auto' here will try to make a best guess" },
160   { SDLOPTION_RESOLUTION("1") ";r1",        "auto",     0,                 "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
161   { SDLOPTION_VIEW("1"),                    "auto",     0,                 "preferred view for the second screen" },
162162
163   { "screen2",                              "auto",     0,                 "explicit name of the third screen; 'auto' here will try to make a best guess" },
164   { "aspect2",                              "auto",     0,                 "aspect ratio of the third screen; 'auto' here will try to make a best guess" },
165   { "resolution2;r2",                       "auto",     0,                 "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
166   { "view2",                                "auto",     0,                 "preferred view for the third screen" },
163   { SDLOPTION_SCREEN("2"),                  "auto",     0,                 "explicit name of the third screen; 'auto' here will try to make a best guess" },
164   { SDLOPTION_ASPECT("2"),                  "auto",     0,                 "aspect ratio of the third screen; 'auto' here will try to make a best guess" },
165   { SDLOPTION_RESOLUTION("2") ";r2",        "auto",     0,                 "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
166   { SDLOPTION_VIEW("2"),                    "auto",     0,                 "preferred view for the third screen" },
167167
168   { "screen3",                              "auto",     0,                 "explicit name of the fourth screen; 'auto' here will try to make a best guess" },
169   { "aspect3",                              "auto",     0,                 "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" },
170   { "resolution3;r3",                       "auto",     0,                 "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
171   { "view3",                                "auto",     0,                 "preferred view for the fourth screen" },
168   { SDLOPTION_SCREEN("3"),                  "auto",     0,                 "explicit name of the fourth screen; 'auto' here will try to make a best guess" },
169   { SDLOPTION_ASPECT("3"),                  "auto",     0,                 "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" },
170   { SDLOPTION_RESOLUTION("3") ";r3",        "auto",     0,                 "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
171   { SDLOPTION_VIEW("3"),                    "auto",     0,                 "preferred view for the fourth screen" },
172172
173173   // full screen options
174174   { NULL,                                   NULL,       OPTION_HEADER,     "FULL SCREEN OPTIONS" },
r844r845
187187   { SDLOPTION_JOYSTICK ";joy",              "0",        OPTION_BOOLEAN,    "enable joystick input" },
188188   { SDLOPTION_STEADYKEY ";steady",          "0",        OPTION_BOOLEAN,    "enable steadykey support" },
189189   { SDLOPTION_A2D_DEADZONE ";a2d",          "0.3",      0,                 "minimal analog value for digital input" },
190   { "digital",                              "none",     0,                 "mark certain joysticks or axes as digital (none|all|j<N>*|j<N>a<M>[,...])" },
191190
192   { NULL,                                   NULL,       OPTION_HEADER,     "AUTOMATIC DEVICE SELECTION OPTIONS" },
193   { "paddle_device;paddle",                 "keyboard", 0,                 "enable (keyboard|mouse|joystick) if a paddle control is present" },
194   { "adstick_device;adstick",               "keyboard", 0,                 "enable (keyboard|mouse|joystick) if an analog joystick control is present" },
195   { "pedal_device;pedal",                   "keyboard", 0,                 "enable (keyboard|mouse|joystick) if a pedal control is present" },
196   { "dial_device;dial",                     "keyboard", 0,                 "enable (keyboard|mouse|joystick) if a dial control is present" },
197   { "trackball_device;trackball",           "keyboard", 0,                "enable (keyboard|mouse|joystick) if a trackball control is present" },
198   { "lightgun_device",                      "keyboard", 0,                 "enable (keyboard|mouse|joystick) if a lightgun control is present" },
199   { "positional_device",                    "keyboard", 0,                 "enable (keyboard|mouse|joystick) if a positional control is present" },
200191#ifdef MESS
201192   { "mouse_device",                         "mouse",    0,                 "enable (keyboard|mouse|joystick) if a mouse control is present" },
202193#endif
src/osd/sdl/osdsdl.h
r844r845
3232   - moved pick_best_mode to window.c   
3333   - removed pause_brightness option
3434   - added more SDLOPTION_ defines
35
36   - renamed void yuv_lookup_init to drawsdl_yuv_init (global namespace)
37   - rmoved some obsolete code
38   - add SDL1.3 compatibility
39   
40   - fixed some compile issues
41   - moved clear_surface into window thread
42   - got SDL1.3 -mt working - still crashing on exit
43   
44   - removed "digital" option
45   - removed device selection options
46   - added more SDLOPTION defines
3547*/
3648
3749//============================================================
r844r845
3951//============================================================
4052
4153#define SDLOPTION_AUDIO_LATENCY         "audio_latency"
42#define SDLOPTION_FMT_SCREEN         "screen%d"
43#define SDLOPTION_FMT_ASPECT         "aspect%d"
44#define SDLOPTION_ASPECT            "aspect"
54#define SDLOPTION_SCREEN(x)            "screen" x
55#define SDLOPTION_ASPECT(x)            "aspect" x
56#define SDLOPTION_RESOLUTION(x)         "resolution" x
57#define SDLOPTION_VIEW(x)            "view" x
4558#define SDLOPTION_SDLVIDEOFPS         "sdlvideofps"
4659#define SDLOPTION_KEEPASPECT         "keepaspect"
4760#define SDLOPTION_WINDOW            "window"
r844r845
6174#define SDLOPTION_WAITVSYNC            "waitvsync"
6275#define SDLOPTION_KEYMAP            "keymap"
6376#define SDLOPTION_KEYMAP_FILE         "keymap_file"
64#define SDLOPTION_JOYMAP         "remapjoys"
77#define SDLOPTION_JOYMAP            "remapjoys"
6578#define SDLOPTION_JOYMAP_FILE         "remapjoyfile"
6679#define SDLOPTION_UIMODEKEY            "uimodekey"
6780#define SDLOPTION_MOUSE               "mouse"
r844r845
6982#define SDLOPTION_STEADYKEY            "steadykey"
7083#define SDLOPTION_A2D_DEADZONE         "a2d_deadzone"
7184
85#define SDLOPTION_SHADER_MAME(x)      "glsl_shader_mame" x
86#define SDLOPTION_SHADER_SCREEN(x)      "glsl_shader_screen" x
87#define SDLOPTION_GLSL_FILTER         "gl_glsl_filter"
88#define SDLOPTION_GL_GLSL            "gl_glsl"
89#define SDLOPTION_GL_PBO            "gl_pbo"
90#define SDLOPTION_GL_VBO            "gl_vbo"
91#define SDLOPTION_GL_NOTEXTURERECT      "gl_notexturerect"
92#define SDLOPTION_GL_FORCEPOW2TEXTURE   "gl_forcepow2texture"
93#define SDLOPTION_GL_GLSL_VID_ATTR      "gl_glsl_vid_attr"
94
7295//============================================================
7396//   sound.c
7497//============================================================
src/osd/sdl/yuv_blit.c
r844r845
5454   window->yuv_lookup[pen]=(y<<Y1SHIFT)|(u<<USHIFT)|(y<<Y2SHIFT)|(v<<VSHIFT);
5555}
5656
57void yuv_lookup_init(sdl_window_info *window)
57void drawsdl_yuv_init(sdl_window_info *window)
5858{
5959   unsigned char r,g,b;
6060   if (window->yuv_lookup == NULL)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team