2018-04-12 21:02:51 +00:00
|
|
|
// SDL interface layer for the Build Engine
|
2013-10-06 07:49:53 +00:00
|
|
|
// Use SDL 1.2 or 2.0 from http://www.libsdl.org
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2019-09-21 21:45:57 +00:00
|
|
|
#include <Windows.h>
|
2019-09-22 21:15:46 +00:00
|
|
|
#include <CommCtrl.h>
|
2009-08-03 22:15:53 +00:00
|
|
|
#include <signal.h>
|
2019-10-03 22:26:13 +00:00
|
|
|
#include <string>
|
2019-10-23 23:20:58 +00:00
|
|
|
#include <stdexcept>
|
2019-12-23 14:40:17 +00:00
|
|
|
# include "gl_load.h"
|
2018-11-18 18:09:48 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
#include "a.h"
|
|
|
|
#include "build.h"
|
2019-12-17 22:25:07 +00:00
|
|
|
|
2019-09-19 21:02:57 +00:00
|
|
|
#include "common.h"
|
2018-11-18 18:09:48 +00:00
|
|
|
#include "compat.h"
|
2015-01-11 04:52:15 +00:00
|
|
|
#include "engine_priv.h"
|
2018-11-18 18:09:48 +00:00
|
|
|
#include "osd.h"
|
2016-06-21 00:33:06 +00:00
|
|
|
#include "palette.h"
|
2018-11-18 18:09:48 +00:00
|
|
|
#include "renderlayer.h"
|
|
|
|
#include "sdl_inc.h"
|
2018-07-14 21:36:44 +00:00
|
|
|
#include "softsurface.h"
|
2019-09-23 17:29:25 +00:00
|
|
|
#include "m_argv.h"
|
2019-09-25 21:00:10 +00:00
|
|
|
#include "mmulti.h"
|
2019-10-03 22:26:13 +00:00
|
|
|
#include "scriptfile.h"
|
|
|
|
#include "zstring.h"
|
2019-10-26 11:16:32 +00:00
|
|
|
#include "gameconfigfile.h"
|
|
|
|
#include "gamecontrol.h"
|
|
|
|
#include "resourcefile.h"
|
|
|
|
#include "sc_man.h"
|
2019-10-26 11:41:42 +00:00
|
|
|
#include "i_specialpaths.h"
|
2019-10-28 00:12:31 +00:00
|
|
|
#include "inputstate.h"
|
2019-10-27 12:40:24 +00:00
|
|
|
#include "c_cvars.h"
|
2019-11-04 19:29:07 +00:00
|
|
|
#include "i_time.h"
|
2019-11-05 19:07:16 +00:00
|
|
|
#include "c_dispatch.h"
|
2019-11-07 19:31:16 +00:00
|
|
|
#include "d_gui.h"
|
2019-12-05 20:39:02 +00:00
|
|
|
#include "menu.h"
|
2019-11-07 19:31:16 +00:00
|
|
|
#include "utf8.h"
|
|
|
|
#include "imgui.h"
|
|
|
|
#include "imgui_impl_sdl.h"
|
|
|
|
#include "imgui_impl_opengl3.h"
|
2019-12-05 20:39:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-01 06:26:49 +00:00
|
|
|
#ifndef NETCODE_DISABLE
|
|
|
|
#include "enet.h"
|
|
|
|
#endif
|
2019-09-23 21:33:59 +00:00
|
|
|
#include "../../glbackend/glbackend.h"
|
2018-11-18 18:09:48 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
#ifdef USE_OPENGL
|
|
|
|
# include "glbuild.h"
|
2018-06-13 19:15:16 +00:00
|
|
|
# include "glsurface.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
#endif
|
|
|
|
|
2014-07-22 11:19:45 +00:00
|
|
|
#if defined HAVE_GTK2
|
2006-04-13 20:47:06 +00:00
|
|
|
# include "gtkbits.h"
|
2014-07-22 11:19:45 +00:00
|
|
|
#endif
|
2018-11-18 18:09:48 +00:00
|
|
|
|
2019-09-10 17:06:20 +00:00
|
|
|
#if defined __APPLE__
|
2018-11-18 18:09:48 +00:00
|
|
|
# include "osxbits.h"
|
|
|
|
# include <mach/mach.h>
|
|
|
|
# include <mach/mach_time.h>
|
2014-12-17 13:01:13 +00:00
|
|
|
#endif
|
2011-07-20 23:04:20 +00:00
|
|
|
|
2019-12-22 17:53:58 +00:00
|
|
|
FString progdir;
|
|
|
|
|
2019-10-27 12:40:24 +00:00
|
|
|
CVAR(Int, r_displayindex, 0, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
|
|
|
CVAR(Int, r_borderless, 2, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
|
|
|
CVAR(Int, maxrefreshfreq, 0, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
|
|
|
CVAR(Int, windowpos, 0, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
|
|
|
CVAR(Int, windowx, -1, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
|
|
|
CVAR(Int, windowy, -1, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
|
|
|
|
2016-12-26 06:01:44 +00:00
|
|
|
#if SDL_MAJOR_VERSION != 1
|
2016-10-20 06:26:17 +00:00
|
|
|
static SDL_version linked;
|
2016-12-26 06:01:44 +00:00
|
|
|
#endif
|
2016-10-20 06:26:17 +00:00
|
|
|
|
2019-11-10 10:42:25 +00:00
|
|
|
double g_beforeSwapTime;
|
2019-09-21 20:53:00 +00:00
|
|
|
GameInterface* gi;
|
|
|
|
|
2019-12-14 16:15:17 +00:00
|
|
|
void buildkeytranslationtable();;
|
|
|
|
|
2019-09-25 21:00:10 +00:00
|
|
|
int myconnectindex, numplayers;
|
|
|
|
int connecthead, connectpoint2[MAXMULTIPLAYERS];
|
|
|
|
unsigned char syncstate;
|
|
|
|
|
2010-05-18 05:14:17 +00:00
|
|
|
/// These can be useful for debugging sometimes...
|
|
|
|
//#define SDL_WM_GrabInput(x) SDL_WM_GrabInput(SDL_GRAB_OFF)
|
|
|
|
//#define SDL_ShowCursor(x) SDL_ShowCursor(SDL_ENABLE)
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
#define SURFACE_FLAGS (SDL_SWSURFACE|SDL_HWPALETTE|SDL_HWACCEL)
|
|
|
|
|
|
|
|
// undefine to restrict windowed resolutions to conventional sizes
|
|
|
|
#define ANY_WINDOWED_SIZE
|
|
|
|
|
2006-08-07 06:18:57 +00:00
|
|
|
// fix for mousewheel
|
2013-12-20 07:24:09 +00:00
|
|
|
int32_t inputchecked = 0;
|
2019-11-23 22:05:24 +00:00
|
|
|
bool screenshot_requested;
|
2006-08-07 06:18:57 +00:00
|
|
|
|
2019-12-01 08:02:17 +00:00
|
|
|
char appactive=1, novideo=0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
// video
|
2013-10-08 09:59:59 +00:00
|
|
|
static SDL_Surface *sdl_surface/*=NULL*/;
|
2014-04-12 08:45:26 +00:00
|
|
|
|
Add prototypical SDL 2.X support.
Doesn't work: indexed-color modes, gamma (at least for X11), mouse wheel,
special keys like ENTER or BACKSPACE in the OSD, probably more...
In build/Makefile.shared, we now have logic to autodetect an SDL2 installed
in /usr/local, however OS X and Wii builds follow other Makefile code paths,
it seems. Note that the matching SDL2_mixer must be used then, too.
In source/jaudiolib/src/driver_sdl.c, change the #includes from <SDL/SDL_xxx.h>
to "SDL_xxx.h". SDL wiki says this is the most portable way, hopefully this
doesn't break builds for anyone.
git-svn-id: https://svn.eduke32.com/eduke32@2777 1a8010ca-5511-0410-912e-c29ae57300e0
2012-06-22 21:39:53 +00:00
|
|
|
#if SDL_MAJOR_VERSION==2
|
2019-11-07 19:31:16 +00:00
|
|
|
SDL_Window *sdl_window=NULL;
|
|
|
|
SDL_GLContext sdl_context=NULL;
|
Add prototypical SDL 2.X support.
Doesn't work: indexed-color modes, gamma (at least for X11), mouse wheel,
special keys like ENTER or BACKSPACE in the OSD, probably more...
In build/Makefile.shared, we now have logic to autodetect an SDL2 installed
in /usr/local, however OS X and Wii builds follow other Makefile code paths,
it seems. Note that the matching SDL2_mixer must be used then, too.
In source/jaudiolib/src/driver_sdl.c, change the #includes from <SDL/SDL_xxx.h>
to "SDL_xxx.h". SDL wiki says this is the most portable way, hopefully this
doesn't break builds for anyone.
git-svn-id: https://svn.eduke32.com/eduke32@2777 1a8010ca-5511-0410-912e-c29ae57300e0
2012-06-22 21:39:53 +00:00
|
|
|
#endif
|
2014-04-12 08:45:26 +00:00
|
|
|
|
2019-11-07 19:31:16 +00:00
|
|
|
void ImGui_Init_Backend()
|
|
|
|
{
|
|
|
|
ImGui_ImplSDL2_InitForOpenGL(sdl_window, sdl_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImGui_Begin_Frame()
|
|
|
|
{
|
|
|
|
ImGui_ImplOpenGL3_NewFrame();
|
|
|
|
ImGui_ImplSDL2_NewFrame(sdl_window);
|
|
|
|
ImGui::NewFrame();
|
|
|
|
}
|
|
|
|
|
2019-08-27 13:39:54 +00:00
|
|
|
int32_t xres=-1, yres=-1, bpp=0, fullscreen=0, bytesperline, refreshfreq=-1;
|
2008-02-16 22:27:08 +00:00
|
|
|
intptr_t frameplace=0;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t lockcount=0;
|
2006-04-13 20:47:06 +00:00
|
|
|
char modechange=1;
|
|
|
|
char offscreenrendering=0;
|
|
|
|
char videomodereset = 0;
|
2009-01-09 09:29:17 +00:00
|
|
|
static uint16_t sysgamma[3][256];
|
2006-04-13 20:47:06 +00:00
|
|
|
#ifdef USE_OPENGL
|
|
|
|
// OpenGL stuff
|
2008-08-26 19:50:34 +00:00
|
|
|
char nogl=0;
|
2013-10-13 09:08:31 +00:00
|
|
|
#endif
|
2016-12-26 06:01:48 +00:00
|
|
|
static int32_t vsync_renderlayer;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-12-28 20:34:57 +00:00
|
|
|
// last gamma, contrast, brightness
|
|
|
|
|
2011-11-25 09:50:07 +00:00
|
|
|
//#define KEY_PRINT_DEBUG
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-01-16 02:50:27 +00:00
|
|
|
static SDL_Surface *appicon = NULL;
|
2014-12-27 18:36:14 +00:00
|
|
|
#if !defined __APPLE__ && !defined EDUKE32_TOUCH_DEVICES
|
2011-01-16 02:50:27 +00:00
|
|
|
static SDL_Surface *loadappicon(void);
|
2014-10-16 21:03:24 +00:00
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-10-21 02:20:40 +00:00
|
|
|
// Joystick dead and saturation zones
|
2019-08-13 09:15:49 +00:00
|
|
|
uint16_t joydead[9], joysatur[9];
|
2010-10-21 02:20:40 +00:00
|
|
|
|
2019-10-23 23:20:58 +00:00
|
|
|
#define MAX_ERRORTEXT 4096
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// I_Error
|
|
|
|
//
|
|
|
|
// Throw an error that will send us to the console if we are far enough
|
|
|
|
// along in the startup process.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void I_Error(const char *error, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char errortext[MAX_ERRORTEXT];
|
|
|
|
|
|
|
|
va_start(argptr, error);
|
2019-10-27 07:14:58 +00:00
|
|
|
vsnprintf(errortext, MAX_ERRORTEXT, error, argptr);
|
2019-10-23 23:20:58 +00:00
|
|
|
va_end(argptr);
|
|
|
|
#ifdef _WIN32
|
|
|
|
OutputDebugStringA(errortext);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
throw std::runtime_error(errortext);
|
|
|
|
}
|
2019-12-22 19:55:47 +00:00
|
|
|
|
|
|
|
void I_FatalError(const char* error, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char errortext[MAX_ERRORTEXT];
|
|
|
|
|
|
|
|
va_start(argptr, error);
|
|
|
|
vsnprintf(errortext, MAX_ERRORTEXT, error, argptr);
|
|
|
|
va_end(argptr);
|
|
|
|
#ifdef _WIN32
|
|
|
|
OutputDebugStringA(errortext);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
throw std::runtime_error(errortext);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-24 09:13:29 +00:00
|
|
|
#ifdef _WIN32
|
2014-11-29 03:07:33 +00:00
|
|
|
# if SDL_MAJOR_VERSION != 1
|
2012-11-24 09:13:29 +00:00
|
|
|
//
|
2013-10-07 10:05:03 +00:00
|
|
|
// win_gethwnd() -- gets the window handle
|
|
|
|
//
|
|
|
|
HWND win_gethwnd(void)
|
|
|
|
{
|
|
|
|
struct SDL_SysWMinfo wmInfo;
|
|
|
|
SDL_VERSION(&wmInfo.version);
|
|
|
|
|
2014-04-12 08:45:26 +00:00
|
|
|
if (SDL_GetWindowWMInfo(sdl_window, &wmInfo) != SDL_TRUE)
|
|
|
|
return 0;
|
|
|
|
|
2013-10-07 10:05:03 +00:00
|
|
|
if (wmInfo.subsystem == SDL_SYSWM_WINDOWS)
|
|
|
|
return wmInfo.info.win.window;
|
|
|
|
|
|
|
|
initprintf("win_gethwnd: Unknown WM subsystem?!\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-11-29 03:07:33 +00:00
|
|
|
# endif
|
2013-10-07 10:05:03 +00:00
|
|
|
//
|
2012-11-24 09:13:29 +00:00
|
|
|
// win_gethinstance() -- gets the application instance
|
|
|
|
//
|
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
|
|
|
{
|
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
|
|
|
return (HINSTANCE)GetModuleHandle(NULL);
|
2012-11-24 09:13:29 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-05-17 12:35:03 +00:00
|
|
|
|
2014-07-28 06:43:16 +00:00
|
|
|
int32_t wm_msgbox(const char *name, const char *fmt, ...)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-09-21 20:10:51 +00:00
|
|
|
char buf[2048];
|
2006-04-24 19:04:22 +00:00
|
|
|
va_list va;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-03-25 09:21:18 +00:00
|
|
|
UNREFERENCED_PARAMETER(name);
|
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
va_start(va,fmt);
|
2013-10-27 21:12:25 +00:00
|
|
|
vsnprintf(buf,sizeof(buf),fmt,va);
|
2006-04-24 19:04:22 +00:00
|
|
|
va_end(va);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2015-01-25 12:16:10 +00:00
|
|
|
#if defined EDUKE32_OSX
|
2006-04-24 19:04:22 +00:00
|
|
|
return osx_msgbox(name, buf);
|
2014-01-12 14:06:15 +00:00
|
|
|
#elif defined _WIN32
|
2019-09-22 21:15:46 +00:00
|
|
|
MessageBoxA(win_gethwnd(),buf,name,MB_OK|MB_TASKMODAL);
|
2014-01-12 14:06:15 +00:00
|
|
|
return 0;
|
2014-12-27 18:36:14 +00:00
|
|
|
#elif defined EDUKE32_TOUCH_DEVICES
|
2014-04-15 19:02:48 +00:00
|
|
|
initprintf("wm_msgbox called. Message: %s: %s",name,buf);
|
|
|
|
return 0;
|
2014-12-18 18:15:26 +00:00
|
|
|
#elif defined GEKKO
|
|
|
|
puts(buf);
|
|
|
|
return 0;
|
2016-12-26 06:02:06 +00:00
|
|
|
#else
|
2016-12-29 02:57:33 +00:00
|
|
|
# if defined HAVE_GTK2
|
|
|
|
if (gtkbuild_msgbox(name, buf) >= 0)
|
|
|
|
return 0;
|
|
|
|
# endif
|
|
|
|
# if SDL_MAJOR_VERSION > 1
|
|
|
|
# if !defined _WIN32
|
|
|
|
// Replace all tab chars with spaces because the hand-rolled SDL message
|
|
|
|
// box diplays the former as N/L instead of whitespace.
|
|
|
|
for (size_t i=0; i<sizeof(buf); i++)
|
|
|
|
if (buf[i] == '\t')
|
|
|
|
buf[i] = ' ';
|
|
|
|
# endif
|
|
|
|
return SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, name, buf, NULL);
|
|
|
|
# else
|
2006-04-24 19:04:22 +00:00
|
|
|
puts(buf);
|
|
|
|
puts(" (press Return or Enter to continue)");
|
|
|
|
getchar();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
return 0;
|
2016-12-29 02:57:33 +00:00
|
|
|
# endif
|
2016-12-26 06:02:06 +00:00
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2014-11-22 12:33:47 +00:00
|
|
|
|
2019-10-19 23:14:48 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
void videoResetMode(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
videomodereset = 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// begindrawing() -- locks the framebuffer for drawing
|
|
|
|
//
|
2015-07-25 17:23:21 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
void videoBeginDrawing(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-17 05:05:16 +00:00
|
|
|
if (bpp > 8)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (offscreenrendering) return;
|
|
|
|
frameplace = 0;
|
|
|
|
bytesperline = 0;
|
|
|
|
modechange = 0;
|
|
|
|
return;
|
|
|
|
}
|
2018-06-13 19:15:16 +00:00
|
|
|
|
2018-06-28 02:00:42 +00:00
|
|
|
// lock the frame
|
|
|
|
if (lockcount++ > 0)
|
|
|
|
return;
|
|
|
|
|
2019-08-01 00:08:02 +00:00
|
|
|
static intptr_t backupFrameplace = 0;
|
2018-06-28 02:00:42 +00:00
|
|
|
|
2019-06-25 18:35:05 +00:00
|
|
|
if (inpreparemirror)
|
|
|
|
{
|
2019-08-01 00:08:02 +00:00
|
|
|
//POGO: if we are offscreenrendering and we need to render a mirror
|
|
|
|
// or we are rendering a mirror and we start offscreenrendering,
|
|
|
|
// backup our offscreen target so we can restore it later
|
|
|
|
// (but only allow one level deep,
|
|
|
|
// i.e. no viewscreen showing a camera showing a mirror that reflects the same viewscreen and recursing)
|
|
|
|
if (offscreenrendering)
|
|
|
|
{
|
|
|
|
if (!backupFrameplace)
|
|
|
|
backupFrameplace = frameplace;
|
|
|
|
else if (frameplace != (intptr_t)mirrorBuffer &&
|
|
|
|
frameplace != backupFrameplace)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-25 18:35:05 +00:00
|
|
|
frameplace = (intptr_t)mirrorBuffer;
|
2019-08-01 00:08:02 +00:00
|
|
|
|
|
|
|
if (offscreenrendering)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (offscreenrendering)
|
|
|
|
{
|
|
|
|
if (backupFrameplace)
|
|
|
|
{
|
|
|
|
frameplace = backupFrameplace;
|
|
|
|
backupFrameplace = 0;
|
|
|
|
}
|
|
|
|
return;
|
2019-06-25 18:35:05 +00:00
|
|
|
}
|
|
|
|
else
|
2018-07-14 21:36:44 +00:00
|
|
|
#ifdef USE_OPENGL
|
2018-06-28 02:00:42 +00:00
|
|
|
if (!nogl)
|
|
|
|
{
|
2018-06-13 19:15:16 +00:00
|
|
|
frameplace = (intptr_t)glsurface_getBuffer();
|
|
|
|
}
|
2019-06-25 18:35:05 +00:00
|
|
|
else
|
2018-07-14 21:36:44 +00:00
|
|
|
#endif
|
2019-06-25 18:35:05 +00:00
|
|
|
{
|
|
|
|
frameplace = (intptr_t)softsurface_getBuffer();
|
|
|
|
}
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2018-07-14 21:36:44 +00:00
|
|
|
if (modechange)
|
2006-11-17 05:05:16 +00:00
|
|
|
{
|
2018-07-14 21:36:44 +00:00
|
|
|
bytesperline = xdim;
|
2012-12-14 19:28:17 +00:00
|
|
|
calc_ylookup(bytesperline, ydim);
|
2006-04-24 19:04:22 +00:00
|
|
|
modechange=0;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// enddrawing() -- unlocks the framebuffer
|
|
|
|
//
|
2018-04-12 21:02:51 +00:00
|
|
|
void videoEndDrawing(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2018-06-28 02:00:42 +00:00
|
|
|
if (bpp > 8)
|
2006-11-17 05:05:16 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (!offscreenrendering) frameplace = 0;
|
|
|
|
return;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
if (!frameplace) return;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (lockcount > 1) { lockcount--; return; }
|
2006-04-24 19:04:22 +00:00
|
|
|
if (!offscreenrendering) frameplace = 0;
|
|
|
|
if (lockcount == 0) return;
|
|
|
|
lockcount = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// showframe() -- update the display
|
|
|
|
//
|
2018-07-14 21:36:44 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-12-27 18:36:14 +00:00
|
|
|
#if !defined __APPLE__ && !defined EDUKE32_TOUCH_DEVICES
|
2019-09-22 21:15:46 +00:00
|
|
|
extern struct sdlappicon sdlappicon;
|
2014-11-22 12:34:29 +00:00
|
|
|
static inline SDL_Surface *loadappicon(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2014-11-22 12:34:29 +00:00
|
|
|
SDL_Surface *surf = SDL_CreateRGBSurfaceFrom((void *)sdlappicon.pixels, sdlappicon.width, sdlappicon.height, 32,
|
|
|
|
sdlappicon.width * 4, 0xffl, 0xff00l, 0xff0000l, 0xff000000l);
|
2006-04-24 19:04:22 +00:00
|
|
|
return surf;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// ---------------------------------------
|
|
|
|
//
|
|
|
|
// Miscellany
|
|
|
|
//
|
|
|
|
// ---------------------------------------
|
|
|
|
//
|
2006-04-24 19:04:22 +00:00
|
|
|
//
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2019-09-22 21:15:46 +00:00
|
|
|
auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries.
|
2019-11-20 19:07:33 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// debugprintf() -- sends a debug string to the debugger
|
|
|
|
//
|
|
|
|
void debugprintf(const char* f, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
if (!IsDebuggerPresent()) return;
|
|
|
|
|
|
|
|
va_start(va, f);
|
|
|
|
Bvsnprintf(buf, 1024, f, va);
|
|
|
|
va_end(va);
|
|
|
|
|
|
|
|
OutputDebugStringA(buf);
|
|
|
|
}
|
2019-11-23 22:05:24 +00:00
|
|
|
|