Previous 199869 Revisions Next

r31862 Monday 1st September, 2014 at 22:38:35 UTC by R. Belmont
SDL: More cleanups. (nw)
[src/osd/sdl]draw13.c osdsdl.h sdl.mak video.c video.h window.c window.h

trunk/src/osd/sdl/window.c
r31861r31862
22//
33//  window.c - SDL window handling
44//
5//  Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
5//  Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
66//  Visit http://mamedev.org for licensing and usage restrictions.
77//
88//  SDLMAME by Olivier Galibert and R. Belmont
r31861r31862
239239   }
240240#endif
241241#if SDLMAME_SDL2
242   if (video_config.mode == VIDEO_MODE_SDL13)
242   if (video_config.mode == VIDEO_MODE_SDL2ACCEL)
243243   {
244      if (draw13_init(machine(), &draw))
244      if (drawsdl2_init(machine(), &draw))
245245         video_config.mode = VIDEO_MODE_SOFT;
246246   }
247247#endif
r31861r31862
974974      {
975975         window->minwidth = tempwidth;
976976         window->minheight = tempheight;
977
977978         if (!window->fullscreen)
978979         {
979980            sdlwindow_blit_surface_size(window, window->width, window->height);
trunk/src/osd/sdl/sdl.mak
r31861r31862
5959# active development on sdlmame or SDL.
6060
6161# uncomment the next line to compile and link against SDL2.0
62# SDL_LIBVER = sdl2
62#SDL_LIBVER = sdl2
6363
6464# uncomment the next line to use couriersud's multi-keyboard patch for SDL 2.1? (this API was removed prior to the 2.0 release)
6565# SDL2_MULTIAPI = 1
trunk/src/osd/sdl/window.h
r31861r31862
22//
33//  window.h - SDL window handling
44//
5//  Copyright (c) 1996-2006, Nicola Salmoria and the MAME Team.
5//  Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
66//  Visit http://mamedev.org for licensing and usage restrictions.
77//
88//  SDLMAME by Olivier Galibert and R. Belmont
r31861r31862
147147// PROTOTYPES - draw13.c
148148//============================================================
149149
150int draw13_init(running_machine &machine, sdl_draw_info *callbacks);
150int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks);
151151
152152#endif /* __SDLWINDOW__ */
trunk/src/osd/sdl/video.c
r31861r31862
22//
33//  video.c - SDL video handling
44//
5//  Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
5//  Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
66//  Visit http://mamedev.org for licensing and usage restrictions.
77//
88//  SDLMAME by Olivier Galibert and R. Belmont
r31861r31862
645645   }
646646   else if (USE_OPENGL && (strcmp(stemp, SDLOPTVAL_OPENGL) == 0))
647647      video_config.mode = VIDEO_MODE_OPENGL;
648   else if (USE_OPENGL && (strcmp(stemp, SDLOPTVAL_OPENGL16) == 0))
648   else if (SDLMAME_SDL2 && (strcmp(stemp, SDLOPTVAL_SDL2ACCEL) == 0))
649649   {
650      video_config.mode = VIDEO_MODE_OPENGL;
651      video_config.prefer16bpp_tex = 1;
650      video_config.mode = VIDEO_MODE_SDL2ACCEL;
652651   }
653   else if (SDLMAME_SDL2 && (strcmp(stemp, SDLOPTVAL_SDL13) == 0))
654   {
655      video_config.mode = VIDEO_MODE_SDL13;
656      video_config.prefer16bpp_tex = 1;
657   }
658652   else
659653   {
660654      osd_printf_warning("Invalid video value %s; reverting to software\n", stemp);
r31861r31862
684678         video_config.prescale = 1;
685679      }
686680      // default to working video please
687      video_config.prefer16bpp_tex = 0;
688681      video_config.forcepow2texture = options.gl_force_pow2_texture();
689682      video_config.allowtexturerect = !(options.gl_no_texture_rect());
690683      video_config.vbo         = options.gl_vbo();
trunk/src/osd/sdl/video.h
r31861r31862
22//
33//  video.h - SDL implementation of MAME video routines
44//
5//  Copyright (c) 1996-2006, Nicola Salmoria and the MAME Team.
5//  Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
66//  Visit http://mamedev.org for licensing and usage restrictions.
77//
88//  SDLMAME by Olivier Galibert and R. Belmont
r31861r31862
2121enum {
2222   VIDEO_MODE_SOFT = 0,
2323   VIDEO_MODE_OPENGL,
24   VIDEO_MODE_SDL13
24   VIDEO_MODE_SDL2ACCEL
2525};
2626
2727#define VIDEO_SCALE_MODE_NONE       (0)
r31861r31862
109109
110110   // OpenGL options
111111   int                 filter;         // enable filtering, disabled if glsl_filter>0
112   int                 prefer16bpp_tex;
113112   int                 glsl;
114113   int                 glsl_filter;        // glsl filtering, >0 disables filter
115114   char *              glsl_shader_mamebm[GLSL_SHADER_MAX]; // custom glsl shader set, mame bitmap
trunk/src/osd/sdl/draw13.c
r31861r31862
11//============================================================
22//
3//  draw13.c - SDL 1.3 drawing implementation
3//  draw13.c - SDL 2.0 drawing implementation
44//
5//  Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
5//  Copyright (c) 1996-2014, Nicola Salmoria and the MAME Team.
66//  Visit http://mamedev.org for licensing and usage restrictions.
77//
88//  SDLMAME by Olivier Galibert and R. Belmont
r31861r31862
145145
146146// core functions
147147
148static void draw13_exit(void);
149static void draw13_attach(sdl_draw_info *info, sdl_window_info *window);
150static int draw13_window_create(sdl_window_info *window, int width, int height);
151static void draw13_window_resize(sdl_window_info *window, int width, int height);
152static void draw13_window_destroy(sdl_window_info *window);
153static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update);
154static render_primitive_list &draw13_window_get_primitives(sdl_window_info *window);
155static void draw13_destroy_all_textures(sdl_window_info *window);
156static void draw13_window_clear(sdl_window_info *window);
157static int draw13_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt);
158static void draw13_destroy_texture(sdl_info *sdl, texture_info *texture);
148static void drawsdl2_exit(void);
149static void drawsdl2_attach(sdl_draw_info *info, sdl_window_info *window);
150static int drawsdl2_window_create(sdl_window_info *window, int width, int height);
151static void drawsdl2_window_resize(sdl_window_info *window, int width, int height);
152static void drawsdl2_window_destroy(sdl_window_info *window);
153static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update);
154static render_primitive_list &drawsdl2_window_get_primitives(sdl_window_info *window);
155static void drawsdl2_destroy_all_textures(sdl_window_info *window);
156static void drawsdl2_window_clear(sdl_window_info *window);
157static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt);
158static void drawsdl2_destroy_texture(sdl_info *sdl, texture_info *texture);
159159
160160//============================================================
161161//  Textures
r31861r31862
455455#endif
456456
457457//============================================================
458//  draw13_init
458//  drawsdl2_init
459459//============================================================
460460
461461static void add_list(copy_info **head, copy_info *element, Uint32 bm)
r31861r31862
486486   }
487487}
488488
489int draw13_init(running_machine &machine, sdl_draw_info *callbacks)
489int drawsdl2_init(running_machine &machine, sdl_draw_info *callbacks)
490490{
491491   const char *stemp;
492492
493493   // fill in the callbacks
494   callbacks->exit = draw13_exit;
495   callbacks->attach = draw13_attach;
494   callbacks->exit = drawsdl2_exit;
495   callbacks->attach = drawsdl2_attach;
496496
497497   osd_printf_verbose("Using SDL native texturing driver (SDL 2.0+)\n");
498498
r31861r31862
518518
519519
520520//============================================================
521//  draw13_exit
521//  drawsdl2_exit
522522//============================================================
523523
524static void draw13_exit(void)
524static void drawsdl2_exit(void)
525525{
526526   int i;
527527   copy_info *bi, *freeme;
r31861r31862
539539}
540540
541541//============================================================
542//  draw13_attach
542//  drawsdl2_attach
543543//============================================================
544544
545static void draw13_attach(sdl_draw_info *info, sdl_window_info *window)
545static void drawsdl2_attach(sdl_draw_info *info, sdl_window_info *window)
546546{
547547   // fill in the callbacks
548   window->create = draw13_window_create;
549   window->resize = draw13_window_resize;
550   window->get_primitives = draw13_window_get_primitives;
551   window->draw = draw13_window_draw;
552   window->destroy = draw13_window_destroy;
553   window->destroy_all_textures = draw13_destroy_all_textures;
554   window->clear = draw13_window_clear;
555   window->xy_to_render_target = draw13_xy_to_render_target;
548   window->create = drawsdl2_window_create;
549   window->resize = drawsdl2_window_resize;
550   window->get_primitives = drawsdl2_window_get_primitives;
551   window->draw = drawsdl2_window_draw;
552   window->destroy = drawsdl2_window_destroy;
553   window->destroy_all_textures = drawsdl2_destroy_all_textures;
554   window->clear = drawsdl2_window_clear;
555   window->xy_to_render_target = drawsdl2_xy_to_render_target;
556556}
557557
558558//============================================================
559//  draw13_window_create
559//  drawsdl2_window_create
560560//============================================================
561561
562static int draw13_window_create(sdl_window_info *window, int width, int height)
562static int drawsdl2_window_create(sdl_window_info *window, int width, int height)
563563{
564564   // allocate memory for our structures
565565   sdl_info *sdl = (sdl_info *) osd_malloc(sizeof(*sdl));
566566
567   osd_printf_verbose("Enter draw13_window_create\n");
567   osd_printf_verbose("Enter drawsdl2_window_create\n");
568568
569569   memset(sdl, 0, sizeof(*sdl));
570570
r31861r31862
638638   sdl->texture_max_height = 64;
639639
640640   SDL_RenderPresent(sdl->sdl_renderer);
641   osd_printf_verbose("Leave draw13_window_create\n");
641   osd_printf_verbose("Leave drawsdl2_window_create\n");
642642   return 0;
643643}
644644
645645//============================================================
646//  draw13_window_resize
646//  drawsdl2_window_resize
647647//============================================================
648648
649static void draw13_window_resize(sdl_window_info *window, int width, int height)
649static void drawsdl2_window_resize(sdl_window_info *window, int width, int height)
650650{
651651   sdl_info *sdl = (sdl_info *) window->dxdata;
652652
r31861r31862
665665//  drawsdl_xy_to_render_target
666666//============================================================
667667
668static int draw13_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
668static int drawsdl2_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
669669{
670670   sdl_info *sdl = (sdl_info *) window->dxdata;
671671
r31861r31862
679679}
680680
681681//============================================================
682//  draw13_window_get_primitives
682//  drawsdl2_window_get_primitives
683683//============================================================
684684
685static render_primitive_list &draw13_window_get_primitives(sdl_window_info *window)
685static render_primitive_list &drawsdl2_window_get_primitives(sdl_window_info *window)
686686{
687687   if ((!window->fullscreen) || (video_config.switchres))
688688   {
r31861r31862
697697}
698698
699699//============================================================
700//  draw13_window_draw
700//  drawsdl2_window_draw
701701//============================================================
702702
703static int draw13_window_draw(sdl_window_info *window, UINT32 dc, int update)
703static int drawsdl2_window_draw(sdl_window_info *window, UINT32 dc, int update)
704704{
705705   sdl_info *sdl = (sdl_info *) window->dxdata;
706706   render_primitive *prim;
r31861r31862
809809
810810
811811//============================================================
812//  draw13_window_clear
812//  drawsdl2_window_clear
813813//============================================================
814814
815static void draw13_window_clear(sdl_window_info *window)
815static void drawsdl2_window_clear(sdl_window_info *window)
816816{
817817   sdl_info *sdl = (sdl_info *) window->dxdata;
818818
r31861r31862
821821
822822
823823//============================================================
824//  draw13_window_destroy
824//  drawsdl2_window_destroy
825825//============================================================
826826
827static void draw13_window_destroy(sdl_window_info *window)
827static void drawsdl2_window_destroy(sdl_window_info *window)
828828{
829829   sdl_info *sdl = (sdl_info *) window->dxdata;
830830
r31861r31862
834834
835835   // free the memory in the window
836836
837   draw13_destroy_all_textures(window);
837   drawsdl2_destroy_all_textures(window);
838838
839839   SDL_DestroyWindow(window->sdl_window);
840840
r31861r31862
11071107         texture_info *expire = texture;
11081108         texture = texture->next;
11091109         if (now - expire->last_access > osd_ticks_per_second())
1110            draw13_destroy_texture(sdl, expire);
1110            drawsdl2_destroy_texture(sdl, expire);
11111111      }
11121112
11131113   // nothing found
r31861r31862
11471147   return texture;
11481148}
11491149
1150static void draw13_destroy_texture(sdl_info *sdl, texture_info *texture)
1150static void drawsdl2_destroy_texture(sdl_info *sdl, texture_info *texture)
11511151{
11521152   texture_info *p;
11531153
r31861r31862
11691169   osd_free(texture);
11701170}
11711171
1172static void draw13_destroy_all_textures(sdl_window_info *window)
1172static void drawsdl2_destroy_all_textures(sdl_window_info *window)
11731173{
11741174   sdl_info *sdl = (sdl_info *) window->dxdata;
11751175   texture_info *next_texture=NULL, *texture = NULL;
r31861r31862
11891189   while (texture)
11901190   {
11911191      next_texture = texture->next;
1192      draw13_destroy_texture(sdl, texture);
1192      drawsdl2_destroy_texture(sdl, texture);
11931193      texture = next_texture;
11941194   }
11951195
trunk/src/osd/sdl/osdsdl.h
r31861r31862
8282#define SDLOPTVAL_AUTO                  "auto"
8383
8484#define SDLOPTVAL_OPENGL                "opengl"
85#define SDLOPTVAL_OPENGL16              "opengl16"
8685#define SDLOPTVAL_SOFT                  "soft"
87#define SDLOPTVAL_SDL13                 "sdl13"
86#define SDLOPTVAL_SDL2ACCEL            "accel"
8887
8988#define SDLMAME_LED(x)                  "led" #x
9089

Previous 199869 Revisions Next


© 1997-2024 The MAME Team