#include "image.h"
#include "dpsoftrast.h"
+#ifndef __IPHONEOS__
#ifdef MACOSX
#include <Carbon/Carbon.h>
#include <IOKit/hidsystem/IOHIDLib.h>
return iohandle;
}
#endif
+#endif
#ifdef WIN32
#define SDL_R_RESTART
qboolean vid_supportrefreshrate = false;
cvar_t vid_soft = {CVAR_SAVE, "vid_soft", "0", "enables use of the DarkPlaces Software Rasterizer rather than OpenGL or Direct3D"};
+cvar_t vid_soft_threads = {CVAR_SAVE, "vid_soft_threads", "2", "the number of threads the DarkPlaces Software Rasterizer should use"};
cvar_t joy_detected = {CVAR_READONLY, "joy_detected", "0", "number of joysticks detected by engine"};
cvar_t joy_enable = {CVAR_SAVE, "joy_enable", "0", "enables joystick support"};
cvar_t joy_index = {0, "joy_index", "0", "selects which joystick to use if you have multiple"};
static qboolean vid_usingmouse = false;
static qboolean vid_usinghidecursor = false;
static qboolean vid_isfullscreen;
+#if !(SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2)
+static qboolean vid_usingvsync = false;
+#endif
static int vid_numjoysticks = 0;
#define MAX_JOYSTICKS 8
static SDL_Joystick *vid_joysticks[MAX_JOYSTICKS];
void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor)
{
+#ifndef __IPHONEOS__
#ifdef MACOSX
if(relative)
if(vid_usingmouse && (vid_usingnoaccel != !!apple_mouse_noaccel.integer))
VID_SetMouse(false, false, false); // ungrab first!
+#endif
#endif
if (vid_usingmouse != relative)
{
vid_usingmouse = relative;
cl_ignoremousemoves = 2;
SDL_WM_GrabInput( relative ? SDL_GRAB_ON : SDL_GRAB_OFF );
+#ifndef __IPHONEOS__
#ifdef MACOSX
if(relative)
{
Con_Print("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
}
}
+#endif
#endif
}
if (vid_usinghidecursor != hidecursor)
// Message Handling
////
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2
static int Sys_EventFilter( SDL_Event *event )
{
//TODO: Add a quit query in linux, too - though linux user are more likely to know what they do
}
return 1;
}
+#endif
#ifdef SDL_R_RESTART
static qboolean sdl_needs_restart;
while( SDL_PollEvent( &event ) )
switch( event.type ) {
case SDL_QUIT:
+#if !(SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2)
+#ifdef WIN32
+ if (MessageBox( NULL, "Are you sure you want to quit?", "Confirm Exit", MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION ) == IDNO)
+ return 0;
+#endif
+#endif
Sys_Quit(0);
break;
case SDL_KEYDOWN:
return p;
}
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2
static int Sys_EventFilter( SDL_Event *event );
+#endif
static qboolean vid_sdl_initjoysticksystem = false;
void VID_Init (void)
{
+#ifndef __IPHONEOS__
#ifdef MACOSX
Cvar_RegisterVariable(&apple_mouse_noaccel);
+#endif
#endif
Cvar_RegisterVariable(&vid_soft);
+ Cvar_RegisterVariable(&vid_soft_threads);
Cvar_RegisterVariable(&joy_detected);
Cvar_RegisterVariable(&joy_enable);
Cvar_RegisterVariable(&joy_index);
}
static void VID_SetIcon_Post(void)
{
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2
+// LordHavoc: info.info.x11.lock_func and accompanying code do not seem to compile with SDL 1.3
#if SDL_VIDEO_DRIVER_X11 && !SDL_VIDEO_DRIVER_QUARTZ
int j;
char *data;
}
}
#endif
+#endif
}
qboolean VID_InitModeGL(viddef_mode_t *mode)
{
int i;
+// FIXME SDL_SetVideoMode
static int notfirstvideomode = false;
int flags = SDL_OPENGL;
const char *drivername;
}
if (mode->stereobuffer)
SDL_GL_SetAttribute (SDL_GL_STEREO, 1);
- if (vid_vsync.integer)
- SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
- else
- SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 0);
if (mode->samples > 1)
{
SDL_GL_SetAttribute (SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute (SDL_GL_MULTISAMPLESAMPLES, mode->samples);
}
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2
+ if (vid_vsync.integer)
+ SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
+ else
+ SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 0);
+#else
+ // TODO: SDL_GL_CONTEXT_MAJOR_VERSION, SDL_GL_CONTEXT_MINOR_VERSION
+#endif
video_bpp = mode->bitsperpixel;
video_flags = flags;
// set window title
VID_SetCaption();
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2
// set up an event filter to ask confirmation on close button in WIN32
SDL_SetEventFilter( (SDL_EventFilter) Sys_EventFilter );
+#endif
// init keyboard
SDL_EnableUNICODE( SDL_ENABLE );
// enable key repeat since everyone expects it
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
+#if !(SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2)
+ SDL_GL_SetSwapInterval(vid_vsync.integer != 0);
+ vid_usingvsync = (vid_vsync.integer != 0);
+#endif
+
gl_platform = "SDL";
gl_platformextensions = "";
qboolean VID_InitModeSoft(viddef_mode_t *mode)
{
+// FIXME SDL_SetVideoMode
int i;
int flags = SDL_HWSURFACE;
vid.softpixels = (unsigned int *)vid_softsurface->pixels;
vid.softdepthpixels = (unsigned int *)calloc(1, mode->width * mode->height * 4);
- DPSOFTRAST_Init(mode->width, mode->height, (unsigned int *)vid_softsurface->pixels, (unsigned int *)vid.softdepthpixels);
+ DPSOFTRAST_Init(mode->width, mode->height, vid_soft_threads.integer, (unsigned int *)vid_softsurface->pixels, (unsigned int *)vid.softdepthpixels);
// set window title
VID_SetCaption();
// set up an event filter to ask confirmation on close button in WIN32
+#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2
SDL_SetEventFilter( (SDL_EventFilter) Sys_EventFilter );
+#endif
// init keyboard
SDL_EnableUNICODE( SDL_ENABLE );
// enable key repeat since everyone expects it
{
qglFinish();CHECKGLERROR
}
+#if !(SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION == 2)
+{
+ qboolean vid_usevsync;
+ vid_usevsync = (vid_vsync.integer && !cls.timedemo);
+ if (vid_usingvsync != vid_usevsync)
+ {
+ if (SDL_GL_SetSwapInterval(vid_usevsync != 0) >= 0)
+ Con_DPrintf("Vsync %s\n", vid_usevsync ? "activated" : "deactivated");
+ else
+ Con_DPrintf("ERROR: can't %s vsync\n", vid_usevsync ? "activate" : "deactivate");
+ }
+}
+#endif
SDL_GL_SwapBuffers();
break;
case RENDERPATH_SOFT:
+ DPSOFTRAST_Finish();
SDL_BlitSurface(vid_softsurface, NULL, screen, NULL);
SDL_Flip(screen);
break;