DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
sys_sdl.c
Go to the documentation of this file.
1/*
2 * Include this BEFORE darkplaces.h because it breaks wrapping
3 * _Static_assert. Cloudwalk has no idea how or why so don't ask.
4 */
5#include <SDL.h>
6
7#include "darkplaces.h"
8
9#ifdef WIN32
10#ifdef _MSC_VER
11#pragma comment(lib, "sdl2.lib")
12#pragma comment(lib, "sdl2main.lib")
13#endif
14#endif
15
16
17// =======================================================================
18// General routines
19// =======================================================================
20
22{
23 SDL_Quit();
24}
25
26// Sys_Error early in startup might screw with automated
27// workflows or something if we show the dialog by default.
28static qbool nocrashdialog = true;
29void Sys_SDL_Dialog(const char *title, const char *string)
30{
31 if(!nocrashdialog)
32 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, string, NULL);
33}
34
36{
37 char *data = NULL;
38 char *cliptext;
39
40 cliptext = SDL_GetClipboardText();
41 if (cliptext != NULL) {
42 size_t allocsize;
43 allocsize = min(MAX_INPUTLINE, strlen(cliptext) + 1);
44 data = (char *)Z_Malloc (allocsize);
45 dp_strlcpy (data, cliptext, allocsize);
46 SDL_free(cliptext);
47 }
48
49 return data;
50}
51
52void Sys_SDL_Init(void)
53{
54 // we don't know which systems we'll want to init, yet...
55 if (SDL_Init(0) < 0)
56 Sys_Error("SDL_Init failed: %s\n", SDL_GetError());
57
58 // COMMANDLINEOPTION: sdl: -nocrashdialog disables "Engine Error" crash dialog boxes
59 if(!Sys_CheckParm("-nocrashdialog"))
60 nocrashdialog = false;
61}
62
64unsigned int Sys_SDL_GetTicks (void)
65{
66 return SDL_GetTicks();
67}
68void Sys_SDL_Delay (unsigned int milliseconds)
69{
70 SDL_Delay(milliseconds);
71}
72
73int main(int argc, char *argv[])
74{
75 return Sys_Main(argc, argv);
76}
#define dp_strlcpy(dst, src, dsize)
Definition common.h:303
GLsizeiptr const GLvoid * data
Definition glquake.h:639
#define min(A, B)
Definition mathlib.h:37
float strlen(string s)
string argv(float n)
#define MAX_INPUTLINE
maximum size of console commandline, QuakeC strings, and many other text processing buffers
Definition qdefs.h:94
#define NULL
Definition qtypes.h:12
bool qbool
Definition qtypes.h:9
void main(void)\n"
void Sys_Error(const char *error,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
Causes the entire program to exit ASAP.
Definition sys_shared.c:724
int Sys_Main(int argc, char *argv[])
main() but renamed so we can wrap it in sys_sdl.c and sys_null.c to avoid needing to include SDL....
int Sys_CheckParm(const char *parm)
Definition sys_shared.c:327
void Sys_SDL_Init(void)
Definition sys_sdl.c:52
static qbool nocrashdialog
Definition sys_sdl.c:28
unsigned int Sys_SDL_GetTicks(void)
Definition sys_sdl.c:64
void Sys_SDL_Dialog(const char *title, const char *string)
Definition sys_sdl.c:29
char * Sys_SDL_GetClipboardData(void)
Definition sys_sdl.c:35
void Sys_SDL_Shutdown(void)
INFO: This is only called by Host_Shutdown so we dont need testing for recursion.
Definition sys_sdl.c:21
void Sys_SDL_Delay(unsigned int milliseconds)
Definition sys_sdl.c:68
qbool sys_supportsdlgetticks
Definition sys_sdl.c:63
#define Z_Malloc(size)
Definition zone.h:161