DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
include/sdlmain.h
00001 #include "dosbox.h"
00002 
00003 #include "control.h"
00004 #include "menu.h"
00005 #include "mouse.h"
00006 #include "render.h"
00007 #include "video.h"
00008 
00009 #include "cross.h"
00010 #include "SDL.h"
00011 #include "SDL_video.h"
00012 
00013 #ifdef __WIN32__
00014 #include "SDL_syswm.h"
00015 #endif
00016 
00017 #ifndef DOSBOX_SDLMAIN_H
00018 #define DOSBOX_SDLMAIN_H
00019 
00020 enum SCREEN_TYPES {
00021     SCREEN_SURFACE
00022     ,SCREEN_OPENGL // [FIXME] cannot make this conditional because somehow SDL2 code uses it while C_OPENGL is definitely disabled by C_SDL2 so SCREEN_OPENGL is unavailable
00023 #if C_DIRECT3D
00024     ,SCREEN_DIRECT3D
00025 #endif
00026 };
00027 
00028 enum AUTOLOCK_FEEDBACK
00029 {
00030     AUTOLOCK_FEEDBACK_NONE,
00031     AUTOLOCK_FEEDBACK_BEEP,
00032     AUTOLOCK_FEEDBACK_FLASH
00033 };
00034 
00035 enum PRIORITY_LEVELS {
00036     PRIORITY_LEVEL_PAUSE,
00037     PRIORITY_LEVEL_LOWEST,
00038     PRIORITY_LEVEL_LOWER,
00039     PRIORITY_LEVEL_NORMAL,
00040     PRIORITY_LEVEL_HIGHER,
00041     PRIORITY_LEVEL_HIGHEST
00042 };
00043 
00044 // Screen DPI and size info
00045 class ScreenSizeInfo {
00046 public:
00047     enum method {
00048         METHOD_NONE=0,
00049         METHOD_X11,
00050         METHOD_XRANDR
00051     };
00052 public:
00053     struct wxh {
00054         double      width = -1;
00055         double      height = -1;
00056 
00057         void clear(void) {
00058             width = height = -1;
00059         }
00060     };
00061 public:
00062     wxh             screen_dimensions_pixels;   // size of the screen in pixels
00063     wxh             screen_dimensions_mm;       // size of the screen in mm
00064     wxh             screen_dpi;                 // DPI of the screen
00065     enum method     method = METHOD_NONE;
00066 public:
00067     void clear(void) {
00068         screen_dpi.clear();
00069         screen_dimensions_mm.clear();
00070         screen_dimensions_pixels.clear();
00071         method = METHOD_NONE;
00072     }
00073 };
00074 
00075 extern ScreenSizeInfo       screen_size_info;
00076 
00077 // do not specify any defaults inside, it is zeroed at start of main()
00078 struct SDL_Block {
00079     bool inited;
00080     bool active; // if this isn't set don't draw
00081     bool updating;
00082 #if defined(C_SDL2)
00083     bool update_window;
00084     bool update_display_contents;
00085     int window_desired_width, window_desired_height;
00086 #endif
00087     struct {
00088         Bit32u width;
00089         Bit32u height;
00090         Bit32u bpp;
00091         Bitu flags;
00092         double scalex, scaley;
00093         GFX_CallBack_t callback;
00094     } draw;
00095     bool wait_on_error;
00096     struct {
00097         struct {
00098             Bit16u width, height;
00099             bool fixed;
00100             bool display_res;
00101         } full;
00102         struct {
00103             Bit16u width, height;
00104         } window;
00105         Bit8u bpp;
00106 #if defined(C_SDL2)
00107         Bit32u pixelFormat;
00108 #endif
00109         bool fullscreen;
00110         bool lazy_fullscreen;
00111         bool prevent_fullscreen;
00112         bool lazy_fullscreen_req;
00113         bool doublebuf;
00114         SCREEN_TYPES type;
00115         SCREEN_TYPES want_type;
00116     } desktop;
00117     struct {
00118         SDL_Surface * surface;
00119 #if (HAVE_DDRAW_H) && defined(WIN32)
00120         RECT rect;
00121 #endif
00122     } blit;
00123     struct {
00124         PRIORITY_LEVELS focus;
00125         PRIORITY_LEVELS nofocus;
00126     } priority;
00127     SDL_Rect clip;
00128     SDL_Surface * surface;
00129 #if defined(C_SDL2)
00130     SDL_Window * window;
00131     SDL_Renderer * renderer;
00132     const char * rendererDriver;
00133     int displayNumber;
00134     struct {
00135         SDL_Texture * texture;
00136         SDL_PixelFormat * pixelFormat;
00137     } texture;
00138 #endif
00139     SDL_cond *cond;
00140     struct {
00141         bool autolock;
00142         AUTOLOCK_FEEDBACK autolock_feedback;
00143         bool autoenable;
00144         bool requestlock;
00145         bool locked;
00146         Bitu sensitivity;
00147         MOUSE_EMULATION emulation;
00148     } mouse;
00149     SDL_Rect updateRects[1024];
00150     Bitu overscan_color;
00151     Bitu overscan_width;
00152     Bitu num_joysticks;
00153 #if defined (WIN32)
00154     bool using_windib;
00155 #endif
00156     // state of alt-keys for certain special handlings
00157     Bit16u laltstate;
00158     Bit16u raltstate;
00159     bool must_redraw_all;
00160     bool deferred_resize;
00161     bool init_ignore;
00162     unsigned int gfx_force_redraw_count;
00163     struct {
00164         int x;
00165         int y;
00166         double xToY;
00167         double yToX;
00168     } srcAspect;
00169 #if C_SURFACE_POSTRENDER_ASPECT
00170     std::vector<uint32_t> aspectbuf;
00171 #endif
00172 };
00173 
00174 #if defined(WIN32) && !defined(C_SDL2)
00175 extern "C" unsigned int SDL1_hax_inhibit_WM_PAINT;
00176 #endif
00177 
00178 extern Bitu frames;
00179 extern SDL_Block sdl;
00180 
00181 #include <output/output_surface.h>
00182 #include <output/output_direct3d.h>
00183 #include <output/output_opengl.h>
00184 #include <output/output_tools.h>
00185 #include <output/output_tools_xbrz.h>
00186 
00187 #include "zipfile.h"
00188 
00189 extern Bitu userResizeWindowWidth;
00190 extern Bitu userResizeWindowHeight;
00191 extern Bitu currentWindowWidth;
00192 extern Bitu currentWindowHeight;
00193 
00194 extern ZIPFile savestate_zip;
00195 
00196 void GFX_DrawSDLMenu(DOSBoxMenu &menu, DOSBoxMenu::displaylist &dl);
00197 void GFX_LogSDLState(void);
00198 void GFX_SDL_Overscan(void);
00199 void GFX_SetIcon(void);
00200 void SDL_rect_cliptoscreen(SDL_Rect &r);
00201 void UpdateWindowDimensions(void);
00202 void UpdateWindowDimensions(Bitu width, Bitu height);
00203 
00204 #if defined(C_SDL2)
00205 SDL_Window* GFX_SetSDLWindowMode(Bit16u width, Bit16u height, SCREEN_TYPES screenType);
00206 #endif
00207 
00208 #endif /*DOSBOX_SDLMAIN_H*/