2006-04-13 20:47:06 +00:00
|
|
|
// SDL interface layer
|
|
|
|
// for the Build Engine
|
2012-03-12 04:47:04 +00:00
|
|
|
// by Jonathon Fowler (jf@jonof.id.au)
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#ifndef build_interface_layer_
|
|
|
|
#define build_interface_layer_ SDL
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-11-05 02:49:08 +00:00
|
|
|
#include "sdl_inc.h"
|
|
|
|
#include "compat.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
#include "baselayer.h"
|
|
|
|
|
2012-11-24 09:13:29 +00:00
|
|
|
#ifdef _WIN32
|
2013-10-07 10:05:03 +00:00
|
|
|
HWND win_gethwnd(void);
|
Win64 support! (Meaning it works, not that we recommend it for everyday use.)
This includes a complete Windows header and library refresh, including the addition of 64-bit compiled libs:
*libogg 1.3.0
*libvorbis 1.3.3
*zlib 1.2.7
*libpng 1.5.13
*libvpx 9a3de881c0e681ba1a79a166a86308bbc84b4acd
*SDL_mixer 1.2.12 (for RENDERTYPE=SDL)
*DirectX import libraries: dsound and dxguid (now included)
To build in 64-bit, you essentially need MinGW's MSYS (but not MinGW itself) and MinGW-w64 at the top of your PATH. The target is automatically detected using `$(CC) -dumpmachine`. The EDukeWiki will get detailed instrucitons.
All compiler and linker warnings when building in 64-bit mode have been fixed.
Remaining 64-bit to-do:
- The ebacktrace dll does not build under 64-bit. It uses code specific to the format of 32-bit executables and will have to be ported to work with 64-bit executables. A future 64-bit version will be named ebacktrace1-64.dll.
- RENDERTYPE=SDL crashes in SDL_mixer's Mix_Linked_Version().
- DirectInput gives an error and does not function. This only affects joysticks, and the error never happens without any plugged in.
- Port the classic renderer ASM to 64-bit. (Just kidding, this is way out of my league.)
This commit includes a fair bit of Makefile development spanning all platforms, including simplifying the SDLCONFIG code, fixing build on Mac OS X (thanks rhoenie!), globally factoring Apple brew/port inclusion, enforcing that all -L come before all -l, and ensuring that $(shell ) is always :='d.
In addition, I have resurrected the old GCC_MAJOR and GCC_MINOR detection using `$(CC) -dumpversion`, but I have made it failsafe in case the command fails or the version is manually specified. I have applied this new fine-grained detection where applicable, including allowing LTO, and restraining -W's to versions that support them.
git-svn-id: https://svn.eduke32.com/eduke32@3278 1a8010ca-5511-0410-912e-c29ae57300e0
2012-12-13 02:37:20 +00:00
|
|
|
HINSTANCE win_gethinstance(void);
|
2012-11-24 09:13:29 +00:00
|
|
|
#endif
|
|
|
|
|
2013-10-07 10:03:11 +00:00
|
|
|
#include "sdlappicon.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-11-05 20:04:02 +00:00
|
|
|
#if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3) // SDL 1.2
|
|
|
|
int32_t SDL_WaitEventTimeout(SDL_Event *event, int32_t timeout);
|
|
|
|
#endif
|
|
|
|
|
2014-11-22 12:33:47 +00:00
|
|
|
#define SDL_GL_ATTRIBUTES(iter, attrib) \
|
|
|
|
for (iter = 0; iter < (int32_t)ARRAY_SIZE(attrib); iter++) \
|
|
|
|
{ \
|
|
|
|
j = attrib[iter].value; \
|
|
|
|
if (!multisamplecheck && \
|
|
|
|
(attrib[iter].attr == SDL_GL_MULTISAMPLEBUFFERS || attrib[iter].attr == SDL_GL_MULTISAMPLESAMPLES)) \
|
|
|
|
{ \
|
|
|
|
j = 0; \
|
|
|
|
} \
|
|
|
|
SDL_GL_SetAttribute(attrib[iter].attr, j); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SDL_ADDMODE(x, y, c, f) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if (validmodecnt < MAXVALIDMODES) \
|
|
|
|
{ \
|
|
|
|
int32_t mn; \
|
|
|
|
for (mn = 0; mn < validmodecnt; mn++) \
|
|
|
|
if (validmode[mn].xdim == x && validmode[mn].ydim == y && validmode[mn].bpp == c && \
|
|
|
|
validmode[mn].fs == f) \
|
|
|
|
break; \
|
|
|
|
if (mn == validmodecnt) \
|
|
|
|
{ \
|
|
|
|
validmode[validmodecnt].xdim = x; \
|
|
|
|
validmode[validmodecnt].ydim = y; \
|
|
|
|
validmode[validmodecnt].bpp = c; \
|
|
|
|
validmode[validmodecnt].fs = f; \
|
|
|
|
validmodecnt++; \
|
|
|
|
/*initprintf(" - %dx%d %d-bit %s\n", x, y, c, (f&1)?"fullscreen":"windowed");*/ \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define SDL_CHECKMODE(w, h) ((w < maxx) && (h < maxy))
|
|
|
|
|
|
|
|
#define SDL_CHECKFSMODES(w, h) \
|
|
|
|
if (w == 0 && h == 0) \
|
|
|
|
{ \
|
|
|
|
initprintf("No fullscreen modes available!\n"); \
|
|
|
|
w = MAXXDIM; \
|
|
|
|
h = MAXYDIM; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#if SDL_MAJOR_VERSION != 1
|
|
|
|
#define SDL2_VIDEO_ERR(XX) \
|
|
|
|
{ \
|
|
|
|
initprintf("Unable to set video mode: " XX " failed: %s\n", SDL_GetError()); \
|
|
|
|
destroy_window_resources(); \
|
|
|
|
return -1; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SDL2_VIDEO_FALLBACK(XX) \
|
|
|
|
{ \
|
|
|
|
initprintf("Falling back to SDL_GetWindowSurface: " XX " failed: %s\n", SDL_GetError()); \
|
|
|
|
}
|
|
|
|
#define SDL2_RENDERER_DESTROY(XX) SDL_DestroyRenderer(XX), XX = NULL
|
|
|
|
#endif
|
|
|
|
|
2012-11-05 02:49:08 +00:00
|
|
|
static inline void idle_waitevent_timeout(uint32_t timeout)
|
|
|
|
{
|
|
|
|
SDL_WaitEventTimeout(NULL, timeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void idle_waitevent(void)
|
|
|
|
{
|
|
|
|
SDL_WaitEvent(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void idle(void)
|
|
|
|
{
|
2012-11-24 09:13:29 +00:00
|
|
|
#ifndef _WIN32
|
2012-11-05 02:49:08 +00:00
|
|
|
usleep(1000);
|
2012-11-24 09:13:29 +00:00
|
|
|
#else
|
|
|
|
Sleep(1);
|
|
|
|
#endif
|
2012-11-05 02:49:08 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
#else
|
2014-11-22 12:32:56 +00:00
|
|
|
#if (build_interface_layer_ != SDL)
|
|
|
|
#error "Already using the " build_interface_layer_ ". Can't now use SDL."
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
2014-11-22 12:32:56 +00:00
|
|
|
#endif // build_interface_layer_
|
2006-04-13 20:47:06 +00:00
|
|
|
|