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 // do not specify any defaults inside, it is zeroed at start of main()
00045 struct SDL_Block {
00046     bool inited;
00047     bool active; // if this isn't set don't draw
00048     bool updating;
00049 #if defined(C_SDL2)
00050     bool update_window;
00051     bool update_display_contents;
00052     int window_desired_width, window_desired_height;
00053 #endif
00054     struct {
00055         Bit32u width;
00056         Bit32u height;
00057         Bit32u bpp;
00058         Bitu flags;
00059         double scalex, scaley;
00060         GFX_CallBack_t callback;
00061     } draw;
00062     bool wait_on_error;
00063     struct {
00064         struct {
00065             Bit16u width, height;
00066             bool fixed;
00067             bool display_res;
00068         } full;
00069         struct {
00070             Bit16u width, height;
00071         } window;
00072         Bit8u bpp;
00073 #if defined(C_SDL2)
00074         Bit32u pixelFormat;
00075 #endif
00076         bool fullscreen;
00077         bool lazy_fullscreen;
00078         bool prevent_fullscreen;
00079         bool lazy_fullscreen_req;
00080         bool doublebuf;
00081         SCREEN_TYPES type;
00082         SCREEN_TYPES want_type;
00083     } desktop;
00084     struct {
00085         SDL_Surface * surface;
00086 #if (HAVE_DDRAW_H) && defined(WIN32)
00087         RECT rect;
00088 #endif
00089     } blit;
00090     struct {
00091         PRIORITY_LEVELS focus;
00092         PRIORITY_LEVELS nofocus;
00093     } priority;
00094     SDL_Rect clip;
00095     SDL_Surface * surface;
00096 #if defined(C_SDL2)
00097     SDL_Window * window;
00098     SDL_Renderer * renderer;
00099     const char * rendererDriver;
00100     int displayNumber;
00101     struct {
00102         SDL_Texture * texture;
00103         SDL_PixelFormat * pixelFormat;
00104     } texture;
00105 #endif
00106     SDL_cond *cond;
00107     struct {
00108         bool autolock;
00109         AUTOLOCK_FEEDBACK autolock_feedback;
00110         bool autoenable;
00111         bool requestlock;
00112         bool locked;
00113         Bitu sensitivity;
00114         MOUSE_EMULATION emulation;
00115     } mouse;
00116     SDL_Rect updateRects[1024];
00117     Bitu overscan_color;
00118     Bitu overscan_width;
00119     Bitu num_joysticks;
00120 #if defined (WIN32)
00121     bool using_windib;
00122 #endif
00123     // state of alt-keys for certain special handlings
00124     Bit16u laltstate;
00125     Bit16u raltstate;
00126     bool must_redraw_all;
00127     bool deferred_resize;
00128     bool init_ignore;
00129     unsigned int gfx_force_redraw_count;
00130     struct {
00131         int x;
00132         int y;
00133         double xToY;
00134         double yToX;
00135     } srcAspect;
00136 #if C_SURFACE_POSTRENDER_ASPECT
00137     std::vector<uint32_t> aspectbuf;
00138 #endif
00139 };
00140 
00141 #if defined(WIN32) && !defined(C_SDL2)
00142 extern "C" unsigned int SDL1_hax_inhibit_WM_PAINT;
00143 #endif
00144 
00145 extern Bitu frames;
00146 extern SDL_Block sdl;
00147 
00148 #include <output/output_surface.h>
00149 #include <output/output_direct3d.h>
00150 #include <output/output_opengl.h>
00151 #include <output/output_tools.h>
00152 #include <output/output_tools_xbrz.h>
00153 
00154 #include "zipfile.h"
00155 
00156 extern Bitu userResizeWindowWidth;
00157 extern Bitu userResizeWindowHeight;
00158 extern Bitu currentWindowWidth;
00159 extern Bitu currentWindowHeight;
00160 
00161 extern ZIPFile savestate_zip;
00162 
00163 void GFX_DrawSDLMenu(DOSBoxMenu &menu, DOSBoxMenu::displaylist &dl);
00164 void GFX_LogSDLState(void);
00165 void GFX_SDL_Overscan(void);
00166 void GFX_SetIcon(void);
00167 void SDL_rect_cliptoscreen(SDL_Rect &r);
00168 void UpdateWindowDimensions(void);
00169 void UpdateWindowDimensions(Bitu width, Bitu height);
00170 
00171 #if defined(C_SDL2)
00172 SDL_Window* GFX_SetSDLWindowMode(Bit16u width, Bit16u height, SCREEN_TYPES screenType);
00173 #endif
00174 
00175 #endif /*DOSBOX_SDLMAIN_H*/