mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
Merging common SDL video code into context_sdl.c, to make adding SDL features easier.
This commit is contained in:
parent
168915faed
commit
ee7e3326e0
6 changed files with 107 additions and 209 deletions
|
@ -14,8 +14,9 @@ noinst_LTLIBRARIES= @VID_TARGETS@ @vid_libs@
|
|||
|
||||
EXTRA_LTLIBRARIES= \
|
||||
libQFjs.la libQFfbdev.la libQFglx.la libQFsvga.la libQFtdfx.la \
|
||||
libQFx11.la libQFsdl.la libQFsdl32.la libQFsgl.la libQFwgl.la libasm.la \
|
||||
libcommon.la libgl.la libsdl.la libsw.la libsw32.la libsvga.la libx11.la
|
||||
libQFx11.la libQFsdl.la libQFsdl32.la libQFsgl.la libQFwgl.la \
|
||||
libasm.la libcommon.la libgl.la libsdl.la libsw.la libsw32.la \
|
||||
libsvga.la libx11.la
|
||||
|
||||
libasm_la_SOURCES= d_copy.S
|
||||
libasmn_la_CFLAGS= @PREFER_NON_PIC@
|
||||
|
@ -62,7 +63,7 @@ libsvga_la_SOURCES= in_svgalib.c
|
|||
libsvga_la_CFLAGS= @PREFER_NON_PIC@ $(SVGA_CFLAGS)
|
||||
libsvga_la_LDFLAGS= -static
|
||||
|
||||
libsdl_la_SOURCES= in_sdl.c
|
||||
libsdl_la_SOURCES= in_sdl.c context_sdl.c
|
||||
libsdl_la_CFLAGS= @PREFER_NON_PIC@ $(SDL_CFLAGS)
|
||||
libsdl_la_LDFLAGS= -static
|
||||
|
||||
|
|
80
libs/video/targets/context_sdl.c
Normal file
80
libs/video/targets/context_sdl.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#include "QF/console.h"
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/va.h"
|
||||
#include "QF/vid.h"
|
||||
|
||||
extern SDL_Surface *screen;
|
||||
|
||||
|
||||
void
|
||||
VID_SDL_GammaCheck (void)
|
||||
{
|
||||
Uint16 redtable[256], greentable[256], bluetable[256];
|
||||
|
||||
if (SDL_GetGammaRamp(redtable, greentable, bluetable) < 0)
|
||||
vid_gamma_avail = false;
|
||||
else
|
||||
vid_gamma_avail = true;
|
||||
}
|
||||
|
||||
void
|
||||
VID_SetCaption (const char *text)
|
||||
{
|
||||
if (text && *text) {
|
||||
char *temp = strdup (text);
|
||||
|
||||
SDL_WM_SetCaption (va ("%s %s: %s", PROGRAM, VERSION, temp), NULL);
|
||||
free (temp);
|
||||
} else {
|
||||
SDL_WM_SetCaption (va ("%s %s", PROGRAM, VERSION), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
qboolean
|
||||
VID_SetGamma (double gamma)
|
||||
{
|
||||
return SDL_SetGamma((float) gamma, (float) gamma, (float) gamma);
|
||||
}
|
||||
|
||||
void
|
||||
VID_Shutdown (void)
|
||||
{
|
||||
SDL_Quit ();
|
||||
}
|
||||
|
||||
void
|
||||
VID_UpdateFullscreen (cvar_t *vid_fullscreen)
|
||||
{
|
||||
if (!vid.initialized)
|
||||
return;
|
||||
if ((vid_fullscreen->int_val && !(screen->flags & SDL_FULLSCREEN))
|
||||
|| (!vid_fullscreen->int_val && screen->flags & SDL_FULLSCREEN))
|
||||
if (!SDL_WM_ToggleFullScreen (screen))
|
||||
Con_Printf ("VID_UpdateFullscreen: error setting fullscreen\n");
|
||||
}
|
||||
|
||||
void
|
||||
VID_Init_Cvars ()
|
||||
{
|
||||
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE,
|
||||
VID_UpdateFullscreen,
|
||||
"Toggles fullscreen mode");
|
||||
vid_system_gamma = Cvar_Get ("vid_system_gamma", "1", CVAR_ARCHIVE, NULL,
|
||||
"Use system gamma control if available");
|
||||
}
|
|
@ -46,7 +46,6 @@ static const char rcsid[] =
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
|
||||
int old_windowed_mouse;
|
||||
|
||||
|
||||
|
@ -803,7 +802,7 @@ IN_LL_SendKeyEvents (void)
|
|||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
//CL_Disconnect ();
|
||||
// CL_Disconnect ();
|
||||
Sys_Quit ();
|
||||
break;
|
||||
default:
|
||||
|
@ -829,7 +828,7 @@ IN_LL_Ungrab_Input (void)
|
|||
void
|
||||
IN_LL_Init (void)
|
||||
{
|
||||
/* Enable UNICODE translation for keyboard input */
|
||||
// Enable UNICODE translation for keyboard input
|
||||
SDL_EnableUNICODE(1);
|
||||
|
||||
if (COM_CheckParm ("-nomouse") && !in_grab->value)
|
||||
|
@ -842,6 +841,8 @@ IN_LL_Init (void)
|
|||
void
|
||||
IN_LL_Init_Cvars (void)
|
||||
{
|
||||
// in_snd_block = Cvar_Get ("in_snd_block", "0", CVAR_ARCHIVE, NULL,
|
||||
// "block sound output on window focus loss");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -44,30 +44,26 @@ static const char rcsid[] =
|
|||
#include "QF/cvar.h"
|
||||
#include "QF/qendian.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
#include "QF/vid.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
#ifdef WIN32
|
||||
/* FIXME: this is evil hack to get full DirectSound support with SDL */
|
||||
#ifdef WIN32 // FIXME: evil hack to get full DirectSound support with SDL
|
||||
#include <windows.h>
|
||||
#include <SDL_syswm.h>
|
||||
HWND mainwindow;
|
||||
#endif
|
||||
|
||||
// static float oldin_grab = 0;
|
||||
|
||||
int modestate; // FIXME: just to avoid cross-compile errors - remove later
|
||||
//int modestate; // FIXME: just to avoid cross-compile errors - remove later
|
||||
|
||||
// The original defaults
|
||||
#define BASEWIDTH 320
|
||||
#define BASEHEIGHT 200
|
||||
#define BASEWIDTH 320
|
||||
#define BASEHEIGHT 200
|
||||
|
||||
byte *VGA_pagebase;
|
||||
int VGA_width, VGA_height, VGA_rowbytes, VGA_bufferrowbytes = 0;
|
||||
|
||||
static SDL_Surface *screen = NULL;
|
||||
SDL_Surface *screen = NULL;
|
||||
|
||||
|
||||
void
|
||||
|
@ -145,33 +141,6 @@ VID_Init (unsigned char *palette)
|
|||
vid.initialized = true;
|
||||
}
|
||||
|
||||
void
|
||||
VID_UpdateFullscreen (cvar_t *vid_fullscreen)
|
||||
{
|
||||
if (!vid.initialized)
|
||||
return;
|
||||
if ((vid_fullscreen->int_val && !(screen->flags & SDL_FULLSCREEN))
|
||||
|| (!vid_fullscreen->int_val && screen->flags & SDL_FULLSCREEN))
|
||||
if (!SDL_WM_ToggleFullScreen (screen))
|
||||
Con_Printf ("VID_UpdateFullscreen: error setting fullscreen\n");
|
||||
}
|
||||
|
||||
void
|
||||
VID_Init_Cvars ()
|
||||
{
|
||||
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE,
|
||||
VID_UpdateFullscreen,
|
||||
"Toggles fullscreen game mode");
|
||||
vid_system_gamma = Cvar_Get ("vid_system_gamma", "1", CVAR_ARCHIVE, NULL,
|
||||
"Use system gamma control if available");
|
||||
}
|
||||
|
||||
void
|
||||
VID_Shutdown (void)
|
||||
{
|
||||
SDL_Quit ();
|
||||
}
|
||||
|
||||
void
|
||||
VID_Update (vrect_t *rects)
|
||||
{
|
||||
|
@ -237,22 +206,3 @@ void
|
|||
VID_UnlockBuffer (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_SetCaption (const char *text)
|
||||
{
|
||||
if (text && *text) {
|
||||
char *temp = strdup (text);
|
||||
|
||||
SDL_WM_SetCaption (va ("%s %s: %s", PROGRAM, VERSION, temp), NULL);
|
||||
free (temp);
|
||||
} else {
|
||||
SDL_WM_SetCaption (va ("%s %s", PROGRAM, VERSION), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
qboolean
|
||||
VID_SetGamma (double gamma)
|
||||
{
|
||||
return false; //FIXME
|
||||
}
|
||||
|
|
|
@ -44,14 +44,12 @@ static const char rcsid[] =
|
|||
#include "QF/cvar.h"
|
||||
#include "QF/qendian.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
#include "QF/vid.h"
|
||||
|
||||
#include "d_iface.h"
|
||||
#include "d_local.h"
|
||||
|
||||
#ifdef WIN32
|
||||
/* FIXME: this is evil hack to get full DirectSound support with SDL */
|
||||
#ifdef WIN32 // FIXME: evil hack to get full DirectSound support with SDL
|
||||
#include <windows.h>
|
||||
#include <SDL_syswm.h>
|
||||
HWND mainwindow;
|
||||
|
@ -61,7 +59,7 @@ HWND mainwindow;
|
|||
|
||||
cvar_t *vid_bitdepth;
|
||||
|
||||
int modestate; // FIXME: just to avoid cross-compile errors - remove later
|
||||
//int modestate; // FIXME: just to avoid cross-compile errors - remove later
|
||||
|
||||
// The original defaults
|
||||
#define BASEWIDTH 320
|
||||
|
@ -70,8 +68,8 @@ int modestate; // FIXME: just to avoid cross-compile errors - remove later
|
|||
byte *VGA_pagebase;
|
||||
int VGA_width, VGA_height, VGA_rowbytes, VGA_bufferrowbytes = 0;
|
||||
|
||||
SDL_Surface *screen = NULL;
|
||||
static SDL_Surface *rendersurface = NULL;
|
||||
static SDL_Surface *screen = NULL;
|
||||
|
||||
|
||||
void
|
||||
|
@ -133,9 +131,9 @@ VID_Init (unsigned char *palette)
|
|||
break;
|
||||
case 16:
|
||||
r_pixbytes = 2;
|
||||
rendersurface = SDL_CreateRGBSurface (SDL_SWSURFACE, vid.width,
|
||||
vid.height, 16, 0xF800, 0x07E0,
|
||||
0x001F, 0x0000);
|
||||
rendersurface = SDL_CreateRGBSurface
|
||||
(SDL_SWSURFACE, vid.width, vid.height, 16, 0xF800, 0x07E0, 0x001F,
|
||||
0x0000);
|
||||
break;
|
||||
case 32:
|
||||
r_pixbytes = 4;
|
||||
|
@ -185,33 +183,6 @@ VID_Init (unsigned char *palette)
|
|||
vid.initialized = true;
|
||||
}
|
||||
|
||||
void
|
||||
VID_UpdateFullscreen (cvar_t *vid_fullscreen)
|
||||
{
|
||||
if (!vid.initialized)
|
||||
return;
|
||||
if ((vid_fullscreen->int_val && !(screen->flags & SDL_FULLSCREEN))
|
||||
|| (!vid_fullscreen->int_val && screen->flags & SDL_FULLSCREEN))
|
||||
if (!SDL_WM_ToggleFullScreen (screen))
|
||||
Con_Printf ("VID_UpdateFullscreen: error setting fullscreen\n");
|
||||
}
|
||||
|
||||
void
|
||||
VID_Init_Cvars ()
|
||||
{
|
||||
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE,
|
||||
VID_UpdateFullscreen,
|
||||
"Toggles fullscreen game mode");
|
||||
vid_bitdepth = Cvar_Get ("vid_bitdepth", "8", CVAR_ROM, NULL, "Sets "
|
||||
"display bitdepth (supported modes: 8 16 32)");
|
||||
}
|
||||
|
||||
void
|
||||
VID_Shutdown (void)
|
||||
{
|
||||
SDL_Quit ();
|
||||
}
|
||||
|
||||
void
|
||||
VID_Update (vrect_t *rects)
|
||||
{
|
||||
|
@ -229,7 +200,8 @@ VID_Update (vrect_t *rects)
|
|||
SDL_BlitSurface(rendersurface, &sdlrect, screen, &sdlrect);
|
||||
}
|
||||
// update display
|
||||
SDL_UpdateRect (screen, rects->x, rects->y, rects->width, rects->height);
|
||||
SDL_UpdateRect (screen, rects->x, rects->y, rects->width,
|
||||
rects->height);
|
||||
rects = rects->pnext;
|
||||
}
|
||||
}
|
||||
|
@ -271,22 +243,3 @@ void
|
|||
VID_UnlockBuffer (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_SetCaption (const char *text)
|
||||
{
|
||||
if (text && *text) {
|
||||
char *temp = strdup (text);
|
||||
|
||||
SDL_WM_SetCaption (va ("%s %s: %s", PROGRAM, VERSION, temp), NULL);
|
||||
free (temp);
|
||||
} else {
|
||||
SDL_WM_SetCaption (va ("%s %s", PROGRAM, VERSION), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
qboolean
|
||||
VID_SetGamma (double gamma)
|
||||
{
|
||||
return false; //FIXME
|
||||
}
|
||||
|
|
|
@ -36,11 +36,8 @@ static const char rcsid[] =
|
|||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#ifndef WIN32
|
||||
# include <signal.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#include "QF/console.h"
|
||||
|
@ -48,7 +45,6 @@ static const char rcsid[] =
|
|||
#include "QF/qargs.h"
|
||||
#include "QF/qendian.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
#include "QF/vid.h"
|
||||
#include "QF/GL/funcs.h"
|
||||
|
||||
|
@ -66,9 +62,12 @@ HWND mainwindow;
|
|||
#define WARP_HEIGHT 200
|
||||
|
||||
int VID_options_items = 1;
|
||||
int modestate;
|
||||
//int modestate; //FIXME: cross-compile issue, ready to remove?
|
||||
|
||||
SDL_Surface *screen = NULL;
|
||||
|
||||
extern void VID_SDL_GammaCheck (void);
|
||||
|
||||
static SDL_Surface *screen = NULL;
|
||||
|
||||
void *
|
||||
QFGL_GetProcAddress (void *handle, const char *name)
|
||||
|
@ -85,47 +84,6 @@ QFGL_LoadLibrary (void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
VID_SDL_GammaCheck (void)
|
||||
{
|
||||
Uint16 redtable[256], greentable[256], bluetable[256];
|
||||
|
||||
if (SDL_GetGammaRamp(redtable, greentable, bluetable) < 0)
|
||||
vid_gamma_avail = false;
|
||||
else
|
||||
vid_gamma_avail = true;
|
||||
}
|
||||
|
||||
void
|
||||
VID_Shutdown (void)
|
||||
{
|
||||
SDL_Quit ();
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
static void
|
||||
signal_handler (int sig)
|
||||
{
|
||||
printf ("Received signal %d, exiting...\n", sig);
|
||||
Sys_Quit ();
|
||||
}
|
||||
|
||||
static void
|
||||
InitSig (void)
|
||||
{
|
||||
signal (SIGHUP, signal_handler);
|
||||
signal (SIGINT, signal_handler);
|
||||
signal (SIGQUIT, signal_handler);
|
||||
signal (SIGILL, signal_handler);
|
||||
signal (SIGTRAP, signal_handler);
|
||||
signal (SIGIOT, signal_handler);
|
||||
signal (SIGBUS, signal_handler);
|
||||
// signal(SIGFPE, signal_handler);
|
||||
signal (SIGSEGV, signal_handler);
|
||||
signal (SIGTERM, signal_handler);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
GL_Init (void)
|
||||
{
|
||||
|
@ -213,14 +171,9 @@ VID_Init (unsigned char *palette)
|
|||
vid.aspect = ((float) vid.height / (float) vid.width) * (4.0 / 3.0);
|
||||
vid.numpages = 2;
|
||||
|
||||
#ifndef WIN32
|
||||
InitSig (); // trap evil signals
|
||||
#endif
|
||||
|
||||
GL_Init ();
|
||||
|
||||
VID_SDL_GammaCheck ();
|
||||
|
||||
VID_InitGamma (palette);
|
||||
VID_SetPalette (palette);
|
||||
|
||||
|
@ -242,43 +195,3 @@ VID_Init (unsigned char *palette)
|
|||
|
||||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
|
||||
void
|
||||
VID_UpdateFullscreen (cvar_t *vid_fullscreen)
|
||||
{
|
||||
if (!vid.initialized)
|
||||
return;
|
||||
if ((vid_fullscreen->int_val && !(screen->flags & SDL_FULLSCREEN))
|
||||
|| (!vid_fullscreen->int_val && screen->flags & SDL_FULLSCREEN))
|
||||
if (!SDL_WM_ToggleFullScreen (screen))
|
||||
Con_Printf ("VID_UpdateFullscreen: error setting fullscreen\n");
|
||||
}
|
||||
|
||||
void
|
||||
VID_Init_Cvars ()
|
||||
{
|
||||
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE,
|
||||
VID_UpdateFullscreen,
|
||||
"Toggles fullscreen mode");
|
||||
vid_system_gamma = Cvar_Get ("vid_system_gamma", "1", CVAR_ARCHIVE, NULL,
|
||||
"Use system gamma control if available");
|
||||
}
|
||||
|
||||
void
|
||||
VID_SetCaption (const char *text)
|
||||
{
|
||||
if (text && *text) {
|
||||
char *temp = strdup (text);
|
||||
|
||||
SDL_WM_SetCaption (va ("%s %s: %s", PROGRAM, VERSION, temp), NULL);
|
||||
free (temp);
|
||||
} else {
|
||||
SDL_WM_SetCaption (va ("%s %s", PROGRAM, VERSION), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
qboolean
|
||||
VID_SetGamma (double gamma)
|
||||
{
|
||||
return SDL_SetGamma((float) gamma, (float) gamma, (float) gamma);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue