#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:
{
SDL_FreeSurface(vid_softsurface);
vid_softsurface = SDL_CreateRGBSurface(SDL_SWSURFACE, vid.width, vid.height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
- vid.softpixels = vid_softsurface->pixels;
+ vid.softpixels = (unsigned int *)vid_softsurface->pixels;
SDL_SetAlpha(vid_softsurface, 0, 255);
if (vid.softdepthpixels)
free(vid.softdepthpixels);
- vid.softdepthpixels = calloc(1, vid.width * vid.height * 4);
+ vid.softdepthpixels = (unsigned int*)calloc(1, vid.width * vid.height * 4);
}
#ifdef SDL_R_RESTART
// better not call R_Modules_Restart from here directly, as this may wreak havoc...
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;
}
SDL_SetAlpha(vid_softsurface, 0, 255);
- vid.softpixels = vid_softsurface->pixels;
- vid.softdepthpixels = calloc(1, mode->width * mode->height * 4);
- DPSOFTRAST_Init(mode->width, mode->height, vid_softsurface->pixels, vid.softdepthpixels);
+ vid.softpixels = (unsigned int *)vid_softsurface->pixels;
+ vid.softdepthpixels = (unsigned int *)calloc(1, mode->width * mode->height * 4);
+ 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
vid.support.arb_draw_buffers = true;
vid.support.arb_occlusion_query = true;
vid.support.arb_shadow = true;
- vid.support.arb_texture_compression = true;
+ //vid.support.arb_texture_compression = true;
vid.support.arb_texture_cube_map = true;
vid.support.arb_texture_non_power_of_two = false;
vid.support.arb_vertex_buffer_object = true;
vid.support.ext_draw_range_elements = true;
vid.support.ext_framebuffer_object = true;
vid.support.ext_texture_3d = true;
- vid.support.ext_texture_compression_s3tc = true;
+ //vid.support.ext_texture_compression_s3tc = true;
vid.support.ext_texture_filter_anisotropic = true;
vid.support.ati_separate_stencil = true;
{
if (!SDL_WasInit(SDL_INIT_VIDEO) && SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
Sys_Error ("Failed to init SDL video subsystem: %s", SDL_GetError());
+#ifdef SSE2_PRESENT
if (vid_soft.integer)
return VID_InitModeSoft(mode);
else
+#endif
return VID_InitModeGL(mode);
}
{
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;