summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/sdl/window.h
blob: b5f9e07d2ab876b0d87f22ab63eeb63bf193e79b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//============================================================
//
//  window.h - SDL window handling
//
//  Copyright (c) 1996-2006, Nicola Salmoria and the MAME Team.
//  Visit http://mamedev.org for licensing and usage restrictions.
//
//  SDLMAME by Olivier Galibert and R. Belmont
//
//============================================================

#ifndef __SDLWINDOW__
#define __SDLWINDOW__

#include "sdlinc.h"
#include "video.h"
#include "render.h"
#include "sdlsync.h"

#include "osd_opengl.h"
#include "osdsdl.h"

// I don't like this, but we're going to get spurious "cast to integer of different size" warnings on
// at least one architecture without doing it this way.
#ifdef PTR64
typedef UINT64 HashT;
#else
typedef UINT32 HashT;
#endif

//============================================================
//  TYPE DEFINITIONS
//============================================================

struct sdl_window_info
{
	// Pointer to next window
	sdl_window_info *   next;

	// Pointer to machine
	running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
	running_machine *   m_machine;

	// Draw Callbacks
	int (*create)(sdl_window_info *window, int width, int height);
	void (*resize)(sdl_window_info *window, int width, int height);
	int (*draw)(sdl_window_info *window, UINT32 dc, int update);
	render_primitive_list &(*get_primitives)(sdl_window_info *window);
	int (*xy_to_render_target)(sdl_window_info *window, int x, int y, int *xt, int *yt);
	void (*destroy_all_textures)(sdl_window_info *window);
	void (*destroy)(sdl_window_info *window);
	void (*clear)(sdl_window_info *window);

	// window handle and info
	char                title[256];

	// monitor info
	sdl_monitor_info *  monitor;
	int                 fullscreen;
	int         index;

	// diverse flags
	int                 minwidth, minheight;
	int                 maxwidth, maxheight;
	int                 depth;
	int                 refresh;
	int                 windowed_width;
	int                 windowed_height;
	int                 startmaximized;

	// rendering info
	osd_event *         rendered_event;
	render_target *     target;
	render_primitive_list *primlist;

	// drawing data
	void *              dxdata;

	// cache of physical width and height
	int                 width;
	int                 height;

	// current blitwidth and height
	int                 blitwidth;
	int                 blitheight;

	int                 totalColors;        // total colors from machine/sdl_window_config
	int                 start_viewscreen;

	// GL specific
	int                 prescale;

#if (SDLMAME_SDL2)
	// Needs to be here as well so we can identify window
	SDL_Window          *sdl_window;
	// These are used in combine resizing events ... #if SDL13_COMBINE_RESIZE
	int                 resize_width;
	int                 resize_height;
	osd_ticks_t         last_resize;
#endif
};

struct sdl_draw_info
{
	void (*exit)(void);
	void (*attach)(sdl_draw_info *info, sdl_window_info *window);
};

//============================================================
//  GLOBAL VARIABLES
//============================================================

// window - list
extern sdl_window_info *sdl_window_list;

//============================================================
//  PROTOTYPES
//============================================================

// core initialization
int sdlwindow_init(running_machine &machine);

// creation/deletion of windows
int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config);
void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *window);
void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int window_height);
void sdlwindow_toggle_full_screen(running_machine &machine, sdl_window_info *window);
void sdlwindow_modify_prescale(running_machine &machine, sdl_window_info *window, int dir);
void sdlwindow_resize(sdl_window_info *window, INT32 width, INT32 height);
void sdlwindow_clear(sdl_window_info *window);


//============================================================
// PROTOTYPES - drawsdl.c
//============================================================

int drawsdl_init(sdl_draw_info *callbacks);
const char *drawsdl_scale_mode_str(int index);
int drawsdl_scale_mode(const char *s);

//============================================================
// PROTOTYPES - drawogl.c
//============================================================

int drawogl_init(running_machine &machine, sdl_draw_info *callbacks);

//============================================================
// PROTOTYPES - draw13.c
//============================================================

int draw13_init(running_machine &machine, sdl_draw_info *callbacks);

#endif /* __SDLWINDOW__ */