backport the gamma code from the quakeforge tree in preparation for 0.3.1

Doesn't work yet because VID_UpdateGamma needs to be called at the
appropriate time and cvar callbacks are not implemented in newtree.
This commit is contained in:
Bill Currie 2001-04-23 03:52:20 +00:00
parent b9caa4273c
commit bd06625c55
15 changed files with 353 additions and 192 deletions

View file

@ -36,32 +36,35 @@
#include "qtypes.h" #include "qtypes.h"
void GetEvent( void );
extern Display *x_disp; extern Display *x_disp;
extern int x_screen;
extern Window x_root;
extern XVisualInfo *x_visinfo;
extern Visual *x_vis; extern Visual *x_vis;
extern Window x_root;
extern Window x_win; extern Window x_win;
extern qboolean doShm; extern XVisualInfo *x_visinfo;
extern double x_gamma;
extern int x_screen;
extern int x_shmeventtype; extern int x_shmeventtype;
extern qboolean doShm;
extern qboolean oktodraw; extern qboolean oktodraw;
extern struct cvar_s *vid_fullscreen; extern struct cvar_s *vid_fullscreen;
qboolean x11_add_event (int event, void (*event_handler)(XEvent *)); void GetEvent (void);
qboolean x11_del_event (int event, void (*event_handler)(XEvent *));
void x11_process_event (void); double X11_GetGamma (void);
void x11_process_events (void); qboolean X11_AddEvent (int event, void (*event_handler)(XEvent *));
void x11_open_display (void); qboolean X11_RemoveEvent (int event, void (*event_handler)(XEvent *));
void x11_close_display (void); qboolean X11_SetGamma (double);
void x11_create_null_cursor (void); void X11_CloseDisplay (void);
void x11_set_vidmode (int, int); void X11_CreateNullCursor (void);
void x11_restore_vidmode (void); void X11_CreateWindow (int, int);
void x11_create_window (int, int); void X11_ForceViewPort (void);
void x11_grab_keyboard (void); void X11_GrabKeyboard (void);
void x11_set_caption (char *); void X11_Init_Cvars (void);
void x11_force_view_port (void); void X11_OpenDisplay (void);
void x11_Init_Cvars (void); void X11_ProcessEvent (void);
void X11_ProcessEvents (void);
void X11_RestoreVidMode (void);
void X11_SetCaption (char *);
void X11_SetVidMode (int, int);
#endif // __context_x11_h_ #endif // __context_x11_h_

View file

@ -65,6 +65,7 @@ extern unsigned short d_8to16table[256];
extern unsigned int d_8to24table[256]; extern unsigned int d_8to24table[256];
extern int scr_width, scr_height; extern int scr_width, scr_height;
extern qboolean DDActive; extern qboolean DDActive;
extern byte gammatable[256];
// called at startup and after any gamma correction // called at startup and after any gamma correction
void VID_SetPalette (unsigned char *palette); void VID_SetPalette (unsigned char *palette);
@ -108,4 +109,9 @@ void VID_GetWindowSize (int def_w, int def_h);
int VID_ForceUnlockedAndReturnState (void); int VID_ForceUnlockedAndReturnState (void);
void VID_ForceLockState (int lk); void VID_ForceLockState (int lk);
void VID_InitGamma (unsigned char *);
double VID_GetGamma (void);
qboolean VID_SetGamma (double);
void VID_UpdateGamma (struct cvar_s *);
#endif // __vid_h_ #endif // __vid_h_

View file

@ -60,7 +60,6 @@
# include <X11/extensions/xf86vmode.h> # include <X11/extensions/xf86vmode.h>
#endif #endif
#include "commdef.h"
#include "console.h" #include "console.h"
#include "context_x11.h" #include "context_x11.h"
#include "cvar.h" #include "cvar.h"
@ -99,7 +98,10 @@ static qboolean vidmode_avail = false;
static qboolean vidmode_active = false; static qboolean vidmode_active = false;
cvar_t *vid_fullscreen; cvar_t *vid_fullscreen;
cvar_t *vid_system_gamma;
qboolean vid_gamma_avail;
qboolean vid_fullscreen_active; qboolean vid_fullscreen_active;
static double x_gamma;
static int xss_timeout; static int xss_timeout;
static int xss_interval; static int xss_interval;
@ -107,13 +109,14 @@ static int xss_blanking;
static int xss_exposures; static int xss_exposures;
qboolean qboolean
x11_add_event (int event, void (*event_handler) (XEvent *)) X11_AddEvent (int event, void (*event_handler) (XEvent *))
{ {
if (event >= LASTEvent) { if (event >= LASTEvent) {
printf ("event: %d, LASTEvent: %d\n", event, LASTEvent); printf ("event: %d, LASTEvent: %d\n", event, LASTEvent);
return false; return false;
} }
if (event_handlers[event] != NULL)
if (event_handlers[event])
return false; return false;
event_handlers[event] = event_handler; event_handlers[event] = event_handler;
@ -121,10 +124,11 @@ x11_add_event (int event, void (*event_handler) (XEvent *))
} }
qboolean qboolean
x11_del_event (int event, void (*event_handler) (XEvent *)) X11_RemoveEvent (int event, void (*event_handler) (XEvent *))
{ {
if (event >= LASTEvent) if (event >= LASTEvent)
return false; return false;
if (event_handlers[event] != event_handler) if (event_handlers[event] != event_handler)
return false; return false;
@ -133,7 +137,7 @@ x11_del_event (int event, void (*event_handler) (XEvent *))
} }
void void
x11_process_event (void) X11_ProcessEvent (void)
{ {
XEvent x_event; XEvent x_event;
@ -149,11 +153,11 @@ x11_process_event (void)
} }
void void
x11_process_events (void) X11_ProcessEvents (void)
{ {
/* Get events from X server. */ /* Get events from X server. */
while (XPending (x_disp)) { while (XPending (x_disp)) {
x11_process_event (); X11_ProcessEvent ();
} }
} }
@ -173,12 +177,12 @@ TragicDeath (int sig)
} }
void void
x11_open_display (void) X11_OpenDisplay (void)
{ {
if (!x_disp) { if (!x_disp) {
x_disp = XOpenDisplay (NULL); x_disp = XOpenDisplay (NULL);
if (!x_disp) { if (!x_disp) {
Sys_Error ("x11_open_display: Could not open display [%s]\n", Sys_Error ("X11_OpenDisplay: Could not open display [%s]\n",
XDisplayName (NULL)); XDisplayName (NULL));
} }
@ -193,7 +197,7 @@ x11_open_display (void)
signal (SIGTRAP, TragicDeath); signal (SIGTRAP, TragicDeath);
signal (SIGIOT, TragicDeath); signal (SIGIOT, TragicDeath);
signal (SIGBUS, TragicDeath); signal (SIGBUS, TragicDeath);
/* signal(SIGFPE, TragicDeath); */ // signal(SIGFPE, TragicDeath);
signal (SIGSEGV, TragicDeath); signal (SIGSEGV, TragicDeath);
signal (SIGTERM, TragicDeath); signal (SIGTERM, TragicDeath);
@ -207,7 +211,7 @@ x11_open_display (void)
} }
void void
x11_close_display (void) X11_CloseDisplay (void)
{ {
if (nullcursor != None) { if (nullcursor != None) {
XFreeCursor (x_disp, nullcursor); XFreeCursor (x_disp, nullcursor);
@ -221,12 +225,12 @@ x11_close_display (void)
} }
/* /*
x11_create_null_cursor X11_CreateNullCursor
Create an empty cursor Create an empty cursor (in other words, make it disappear)
*/ */
void void
x11_create_null_cursor (void) X11_CreateNullCursor (void)
{ {
Pixmap cursormask; Pixmap cursormask;
XGCValues xgc; XGCValues xgc;
@ -254,7 +258,7 @@ x11_create_null_cursor (void)
} }
void void
x11_set_vidmode (int width, int height) X11_SetVidMode (int width, int height)
{ {
const char *str = getenv ("MESA_GLX_FX"); const char *str = getenv ("MESA_GLX_FX");
@ -268,6 +272,10 @@ x11_set_vidmode (int width, int height)
#ifdef HAVE_VIDMODE #ifdef HAVE_VIDMODE
vidmode_avail = VID_CheckVMode (x_disp, NULL, NULL); vidmode_avail = VID_CheckVMode (x_disp, NULL, NULL);
if (vidmode_avail) {
vid_gamma_avail = ((x_gamma = X11_GetGamma ()) > 0);
}
if (vid_fullscreen->int_val && vidmode_avail) { if (vid_fullscreen->int_val && vidmode_avail) {
int i, dotclock; int i, dotclock;
@ -300,25 +308,27 @@ x11_set_vidmode (int width, int height)
XSetScreenSaver (x_disp, 0, xss_interval, xss_blanking, xss_exposures); XSetScreenSaver (x_disp, 0, xss_interval, xss_blanking, xss_exposures);
XF86VidModeSwitchToMode (x_disp, x_screen, vidmodes[best_mode]); XF86VidModeSwitchToMode (x_disp, x_screen, vidmodes[best_mode]);
x11_force_view_port (); X11_ForceViewPort ();
vidmode_active = true; vidmode_active = true;
} else { } else {
Con_Printf ("VID: Mode %dx%d can't go fullscreen.\n", vid.width, vid.height); Con_Printf ("VID: Mode %dx%d can't go fullscreen.\n", vid.width, vid.height);
vidmode_avail = vidmode_active = false; vid_gamma_avail = vidmode_avail = vidmode_active = false;
} }
} }
#endif #endif
} }
void void
x11_Init_Cvars (void) X11_Init_Cvars (void)
{ {
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ROM, vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ROM,
"Toggles fullscreen game mode"); "Toggles fullscreen game mode");
vid_system_gamma = Cvar_Get ("vid_system_gamma", "1", CVAR_ARCHIVE,
"Use system gamma control if available");
} }
void void
x11_create_window (int width, int height) X11_CreateWindow (int width, int height)
{ {
XSetWindowAttributes attr; XSetWindowAttributes attr;
XClassHint *ClassHint; XClassHint *ClassHint;
@ -355,7 +365,7 @@ x11_create_window (int width, int height)
XFree (SizeHints); XFree (SizeHints);
} }
// Set window title // Set window title
x11_set_caption (va ("%s %s", PROGRAM, VERSION)); X11_SetCaption (va ("%s %s", PROGRAM, VERSION));
// Set icon name // Set icon name
XSetIconName (x_disp, x_win, PROGRAM); XSetIconName (x_disp, x_win, PROGRAM);
@ -378,7 +388,7 @@ x11_create_window (int width, int height)
XMoveWindow (x_disp, x_win, 0, 0); XMoveWindow (x_disp, x_win, 0, 0);
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0,
vid.width + 2, vid.height + 2); vid.width + 2, vid.height + 2);
x11_force_view_port (); X11_ForceViewPort ();
} }
XMapWindow (x_disp, x_win); XMapWindow (x_disp, x_win);
@ -389,13 +399,14 @@ x11_create_window (int width, int height)
} }
void void
x11_restore_vidmode (void) X11_RestoreVidMode (void)
{ {
XSetScreenSaver (x_disp, xss_timeout, xss_interval, xss_blanking, XSetScreenSaver (x_disp, xss_timeout, xss_interval, xss_blanking,
xss_exposures); xss_exposures);
#ifdef HAVE_VIDMODE #ifdef HAVE_VIDMODE
if (vidmode_active) { if (vidmode_active) {
X11_SetGamma (x_gamma);
XF86VidModeSwitchToMode (x_disp, x_screen, vidmodes[original_mode]); XF86VidModeSwitchToMode (x_disp, x_screen, vidmodes[original_mode]);
XFree (vidmodes); XFree (vidmodes);
} }
@ -403,7 +414,7 @@ x11_restore_vidmode (void)
} }
void void
x11_grab_keyboard (void) X11_GrabKeyboard (void)
{ {
#ifdef HAVE_VIDMODE #ifdef HAVE_VIDMODE
if (vidmode_active && vid_fullscreen->int_val) { if (vidmode_active && vid_fullscreen->int_val) {
@ -414,14 +425,14 @@ x11_grab_keyboard (void)
} }
void void
x11_set_caption (char *text) X11_SetCaption (char *text)
{ {
if (x_disp && x_win && text) if (x_disp && x_win && text)
XStoreName (x_disp, x_win, text); XStoreName (x_disp, x_win, text);
} }
void void
x11_force_view_port (void) X11_ForceViewPort (void)
{ {
#ifdef HAVE_VIDMODE #ifdef HAVE_VIDMODE
int x, y; int x, y;
@ -435,3 +446,37 @@ x11_force_view_port (void)
} }
#endif #endif
} }
double
X11_GetGamma (void)
{
#ifdef HAVE_VIDMODE
# ifdef X_XF86VidModeGetGamma
XF86VidModeGamma xgamma;
if (vidmode_avail && vid_system_gamma->int_val) {
if (XF86VidModeGetGamma (x_disp, x_screen, &xgamma)) {
return ((xgamma.red + xgamma.green + xgamma.blue) / 3);
}
}
# endif
#endif
return -1.0;
}
qboolean
X11_SetGamma (double gamma)
{
#ifdef HAVE_VIDMODE
# ifdef X_XF86VidModeSetGamma
XF86VidModeGamma xgamma;
if (vidmode_avail && vid_system_gamma->int_val) {
xgamma.red = xgamma.green = xgamma.blue = (float) gamma;
if (XF86VidModeSetGamma (x_disp, x_screen, &xgamma))
return true;
}
# endif
#endif
return false;
}

View file

@ -426,7 +426,7 @@ void
IN_SendKeyEvents (void) IN_SendKeyEvents (void)
{ {
/* Get events from X server. */ /* Get events from X server. */
x11_process_events (); X11_ProcessEvents ();
} }
@ -487,7 +487,7 @@ IN_Shutdown (void)
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp), 0); XF86DGADirectVideo (x_disp, DefaultScreen (x_disp), 0);
#endif #endif
} }
x11_close_display (); X11_CloseDisplay ();
} }
void void
@ -505,7 +505,7 @@ IN_Init (void)
if (!x_win) if (!x_win)
Sys_Error ("IN: No window!!\n"); Sys_Error ("IN: No window!!\n");
x11_open_display (); // call to increment the reference X11_OpenDisplay (); // call to increment the reference
// counter // counter
{ {
@ -536,11 +536,11 @@ IN_Init (void)
mouse_x = mouse_y = 0.0; mouse_x = mouse_y = 0.0;
mouse_avail = 1; mouse_avail = 1;
x11_add_event (KeyPress, &event_key); X11_AddEvent (KeyPress, &event_key);
x11_add_event (KeyRelease, &event_key); X11_AddEvent (KeyRelease, &event_key);
x11_add_event (ButtonPress, &event_button); X11_AddEvent (ButtonPress, &event_button);
x11_add_event (ButtonRelease, &event_button); X11_AddEvent (ButtonRelease, &event_button);
x11_add_event (MotionNotify, &event_motion); X11_AddEvent (MotionNotify, &event_motion);
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "Force view of player to center"); Cmd_AddCommand ("force_centerview", Force_CenterView_f, "Force view of player to center");
} }

View file

@ -43,11 +43,11 @@
static int snd_inited; static int snd_inited;
static snd_pcm_t *pcm; static snd_pcm_t *pcm;
static const snd_pcm_channel_area_t *mmap_areas;
static char *pcmname = NULL; static char *pcmname = NULL;
size_t buffer_size; size_t buffer_size;
qboolean SNDDMA_Init(void) qboolean
SNDDMA_Init(void)
{ {
int err,i; int err,i;
int rate=-1,bps=-1,stereo=-1,frag_size; int rate=-1,bps=-1,stereo=-1,frag_size;
@ -189,19 +189,17 @@ qboolean SNDDMA_Init(void)
goto error; goto error;
} }
mmap_areas = snd_pcm_mmap_running_areas(pcm);
shm=&sn; shm=&sn;
memset((dma_t*)shm,0,sizeof(*shm)); memset((dma_t*)shm,0,sizeof(*shm));
shm->splitbuffer = 0; shm->splitbuffer = 0;
shm->channels=stereo+1; shm->channels=stereo+1;
shm->submission_chunk=snd_pcm_hw_params_get_period_size(hw, 0); // don't mix less than this # shm->submission_chunk = snd_pcm_hw_params_get_period_size (hw, 0); // don't mix less than this #
shm->samplepos=0; // in mono samples shm->samplepos=0; // in mono samples
shm->samplebits=bps; shm->samplebits=bps;
buffer_size = snd_pcm_hw_params_get_buffer_size(hw); buffer_size = snd_pcm_hw_params_get_buffer_size(hw);
shm->samples=buffer_size*shm->channels; // mono samples in buffer shm->samples=buffer_size*shm->channels; // mono samples in buffer
shm->speed=rate; shm->speed=rate;
shm->buffer=(unsigned char*)mmap_areas->addr; SNDDMA_GetDMAPos ();//XXX sets shm->buffer
Con_Printf("%5d stereo\n", shm->channels - 1); Con_Printf("%5d stereo\n", shm->channels - 1);
Con_Printf("%5d samples\n", shm->samples); Con_Printf("%5d samples\n", shm->samples);
Con_Printf("%5d samplepos\n", shm->samplepos); Con_Printf("%5d samplepos\n", shm->samplepos);
@ -218,89 +216,61 @@ qboolean SNDDMA_Init(void)
return 0; return 0;
} }
static inline int int
get_hw_ptr() SNDDMA_GetDMAPos(void)
{ {
size_t app_ptr; snd_pcm_uframes_t offset;
snd_pcm_sframes_t delay; snd_pcm_uframes_t nframes = shm->samples/shm->channels;
int hw_ptr; const snd_pcm_channel_area_t *areas;
if (snd_pcm_state (pcm) != SND_PCM_STATE_RUNNING) if (!snd_inited)
return 0; return 0;
app_ptr = snd_pcm_mmap_offset (pcm);
snd_pcm_delay (pcm, &delay);
hw_ptr = app_ptr - delay;
if (hw_ptr < 0)
hw_ptr += buffer_size;
return hw_ptr;
}
int SNDDMA_GetDMAPos(void) snd_pcm_mmap_begin (pcm, &areas, &offset, &nframes);
{ offset *= shm->channels;
int hw_ptr; nframes *= shm->channels;
shm->samplepos = offset;
shm->buffer = areas->addr;//XXX FIXME there's an area per channel
if (!snd_inited) return 0;
hw_ptr = get_hw_ptr();
hw_ptr *= shm->channels;
shm->samplepos = hw_ptr;
return shm->samplepos; return shm->samplepos;
} }
void SNDDMA_Shutdown(void) void
SNDDMA_Shutdown(void)
{ {
if (snd_inited) if (snd_inited) {
{
snd_pcm_close(pcm); snd_pcm_close(pcm);
snd_inited = 0; snd_inited = 0;
} }
} }
/* /*
============== SNDDMA_Submit
SNDDMA_Submit
Send sound to device if buffer isn't really the dma buffer Send sound to device if buffer isn't really the dma buffer
===============
*/ */
void SNDDMA_Submit(void) void
SNDDMA_Submit(void)
{ {
int count = paintedtime - soundtime; snd_pcm_uframes_t offset;
int avail; snd_pcm_uframes_t nframes;
int missed; const snd_pcm_channel_area_t *areas;
int state; int state;
int hw_ptr; int count = paintedtime - soundtime;
int offset;
nframes = count / shm->channels;
snd_pcm_mmap_begin (pcm, &areas, &offset, &nframes);
state = snd_pcm_state (pcm); state = snd_pcm_state (pcm);
switch (state) { switch (state) {
case SND_PCM_STATE_PREPARED: case SND_PCM_STATE_PREPARED:
snd_pcm_mmap_forward (pcm, count); snd_pcm_mmap_commit (pcm, offset, nframes);
snd_pcm_start (pcm); snd_pcm_start (pcm);
break; break;
case SND_PCM_STATE_RUNNING: case SND_PCM_STATE_RUNNING:
hw_ptr = get_hw_ptr(); snd_pcm_mmap_commit (pcm, offset, nframes);
missed = hw_ptr - shm->samplepos / shm->channels;
if (missed < 0)
missed += buffer_size;
count -= missed;
offset = snd_pcm_mmap_offset (pcm);
if (offset > hw_ptr)
count -= (offset - hw_ptr);
else
count -= (buffer_size - hw_ptr + offset);
if (count < 0) {
snd_pcm_rewind (pcm, -count);
} else {
avail = snd_pcm_avail_update(pcm);
if (avail < 0)
avail = buffer_size;
if (count > avail)
count = avail;
if (count)
snd_pcm_mmap_forward (pcm, count);
}
break; break;
default: default:
break; break;

View file

@ -29,15 +29,30 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <math.h>
#include "compat.h"
#include "console.h"
#include "cvar.h" #include "cvar.h"
#include "vid.h"
#include "va.h"
#include "qargs.h" #include "qargs.h"
#include "sys.h" #include "sys.h"
#include "va.h"
#include "vid.h"
#include "view.h"
extern viddef_t vid; // global video state extern viddef_t vid; // global video state
/*
Software and hardware gamma support
*/
byte gammatable[256];
cvar_t *vid_gamma;
cvar_t *vid_system_gamma;
qboolean vid_gamma_avail; // hardware gamma availability
/*
Screen size
*/
int scr_width, scr_height; int scr_width, scr_height;
cvar_t *vid_width; cvar_t *vid_width;
cvar_t *vid_height; cvar_t *vid_height;
@ -88,27 +103,79 @@ VID_GetWindowSize (int def_w, int def_h)
scr_height = vid.height = vid_height->int_val; scr_height = vid.height = vid_height->int_val;
} }
#if 0 /****************************************************************************
VID_Calc_Gamma (void) * GAMMA FUNCTIONS *
{ ****************************************************************************/
float f;
int i;
int v;
byte
float g = bound (0.3, gamma->value, 3);
Cvar_SetValue (gamma, g); void
if (gamma_flipped->int_val) VID_BuildGammaTable (double gamma)
g = 1 / g; {
int i;
if (gamma == 1.0) { // linear, don't bother with the math
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
f = pow ((i + 1) / 256.0, g); gammatable[i] = i;
v = f * 255 + 0.5; }
lightmap_gamma[i] = bound (0, v, 255); } else {
for (j = 0; j < 3; j++) { double g = 1.0 / gamma;
f = pow ((host_basepal[i * 3 + j] + 1) / 256.0, g); int v;
v = f * 255 + 0.5;
palette[i] = bound (0, v, 255); for (i = 0; i < 256; i++) { // Build/update gamma lookup table
v = (int) ((255.0 * pow ((double) i / 255.0, g)) + 0.5);
gammatable[i] = bound (0, v, 255);
} }
} }
} }
#endif
/*
VID_UpdateGamma
This is a callback to update the palette or system gamma whenever the
vid_gamma Cvar is changed.
*/
void
VID_UpdateGamma (cvar_t *vid_gamma)
{
double gamma = bound (0.1, vid_gamma->value, 9.9);
if (vid_gamma->flags & CVAR_ROM) // System gamma unavailable
return;
if (vid_gamma_avail && vid_system_gamma->int_val) { // Have system, use it
Con_DPrintf ("Setting hardware gamma to %g\n", gamma);
VID_BuildGammaTable (1.0); // hardware gamma wants a linear palette
VID_SetGamma (gamma);
} else { // We have to hack the palette
Con_DPrintf ("Setting software gamma to %g\n", gamma);
VID_BuildGammaTable (gamma);
V_UpdatePalette (); // update with the new palette
}
}
/*
VID_InitGamma
Initialize the vid_gamma Cvar, and set up the palette
*/
void
VID_InitGamma (unsigned char *pal)
{
int i;
double gamma = 1.45;
if ((i = COM_CheckParm ("-gamma"))) {
gamma = atof (com_argv[i + 1]);
}
gamma = bound (0.1, gamma, 9.9);
vid_gamma = Cvar_Get ("vid_gamma", va ("%f", gamma), CVAR_ARCHIVE,
"Gamma correction");
VID_UpdateGamma (vid_gamma);
VID_BuildGammaTable (vid_gamma->value);
}
void
VID_HandlePause (qboolean paused)
{
}

View file

@ -312,3 +312,12 @@ void
VID_SetCaption (char *text) VID_SetCaption (char *text)
{ {
} }
qboolean
VID_SetGamma (double gamma)
{
// FIXME: Need function for HW gamma correction
// return X11_SetGamma (gamma);
grGammaCorrectionValue((float) gamma);
return true;
}

View file

@ -701,3 +701,9 @@ void
VID_SetCaption (char *text) VID_SetCaption (char *text)
{ {
} }
qboolean
VID_SetGamma (double gamma)
{
return false;
}

View file

@ -82,8 +82,8 @@ VID_Shutdown (void)
Con_Printf ("VID_Shutdown\n"); Con_Printf ("VID_Shutdown\n");
x11_restore_vidmode (); X11_RestoreVidMode ();
x11_close_display (); X11_CloseDisplay ();
} }
#if 0 #if 0
@ -170,7 +170,7 @@ VID_Init (unsigned char *palette)
vid.conheight = atoi (com_argv[i + 1]); vid.conheight = atoi (com_argv[i + 1]);
vid.conheight = max (vid.conheight, 200); vid.conheight = max (vid.conheight, 200);
x11_open_display (); X11_OpenDisplay ();
x_visinfo = glXChooseVisual (x_disp, x_screen, attrib); x_visinfo = glXChooseVisual (x_disp, x_screen, attrib);
if (!x_visinfo) { if (!x_visinfo) {
@ -180,12 +180,12 @@ VID_Init (unsigned char *palette)
} }
x_vis = x_visinfo->visual; x_vis = x_visinfo->visual;
x11_set_vidmode (scr_width, scr_height); X11_SetVidMode (scr_width, scr_height);
x11_create_window (scr_width, scr_height); X11_CreateWindow (scr_width, scr_height);
/* Invisible cursor */ /* Invisible cursor */
x11_create_null_cursor (); X11_CreateNullCursor ();
x11_grab_keyboard (); X11_GrabKeyboard ();
XSync (x_disp, 0); XSync (x_disp, 0);
@ -219,7 +219,7 @@ VID_Init (unsigned char *palette)
void void
VID_Init_Cvars () VID_Init_Cvars ()
{ {
x11_Init_Cvars (); X11_Init_Cvars ();
} }
void void
@ -228,9 +228,21 @@ VID_SetCaption (char *text)
if (text && *text) { if (text && *text) {
char *temp = strdup (text); char *temp = strdup (text);
x11_set_caption (va ("%s %s: %s", PROGRAM, VERSION, temp)); X11_SetCaption (va ("%s %s: %s", PROGRAM, VERSION, temp));
free (temp); free (temp);
} else { } else {
x11_set_caption (va ("%s %s", PROGRAM, VERSION)); X11_SetCaption (va ("%s %s", PROGRAM, VERSION));
} }
} }
double
VID_GetGamma (void)
{
return (double) X11_GetGamma ();
}
qboolean
VID_SetGamma (double gamma)
{
return X11_SetGamma (gamma);
}

View file

@ -3195,3 +3195,9 @@ VID_SetCaption (char *text)
SetWindowText (mainwindow, (LPSTR) va ("%s %s", PROGRAM, VERSION)); SetWindowText (mainwindow, (LPSTR) va ("%s %s", PROGRAM, VERSION));
} }
} }
qboolean
VID_SetGamma (double gamma)
{
return false; //FIXME
}

View file

@ -288,3 +288,10 @@ VID_SetCaption (char *text)
SDL_WM_SetCaption (va ("%s %s", PROGRAM, VERSION), NULL); SDL_WM_SetCaption (va ("%s %s", PROGRAM, VERSION), NULL);
} }
} }
qboolean
VID_SetGamma (double gamma)
{
// return SDL_SetGamma ((float) gamma, (float) gamma, (float) gamma);
return false; // FIXME
}

View file

@ -240,3 +240,9 @@ VID_SetCaption (char *text)
SDL_WM_SetCaption (va ("%s %s", PROGRAM, VERSION), NULL); SDL_WM_SetCaption (va ("%s %s", PROGRAM, VERSION), NULL);
} }
} }
qboolean
VID_SetGamma (double gamma)
{
return SDL_SetGamma((float) gamma, (float) gamma, (float) gamma);
}

View file

@ -759,3 +759,9 @@ void
VID_SetCaption (char *text) VID_SetCaption (char *text)
{ {
} }
qboolean
VID_SetGamma (double gamma)
{
return false; //FIXME
}

View file

@ -1785,3 +1785,9 @@ VID_SetCaption (char *text)
SetWindowText (mainwindow, (LPSTR) va ("%s %s", PROGRAM, VERSION)); SetWindowText (mainwindow, (LPSTR) va ("%s %s", PROGRAM, VERSION));
} }
} }
qboolean
VID_SetGamma (double gamma)
{
return false; //FIXME
}

View file

@ -519,7 +519,7 @@ VID_Init (unsigned char *palette)
verbose = COM_CheckParm ("-verbose"); verbose = COM_CheckParm ("-verbose");
// open the display // open the display
x11_open_display (); X11_OpenDisplay ();
template_mask = 0; template_mask = 0;
@ -567,13 +567,13 @@ VID_Init (unsigned char *palette)
} }
/* Setup attributes for main window */ /* Setup attributes for main window */
x11_set_vidmode (vid.width, vid.height); X11_SetVidMode (vid.width, vid.height);
/* Create the main window */ /* Create the main window */
x11_create_window (vid.width, vid.height); X11_CreateWindow (vid.width, vid.height);
/* Invisible cursor */ /* Invisible cursor */
x11_create_null_cursor (); X11_CreateNullCursor ();
if (x_visinfo->depth == 8) { if (x_visinfo->depth == 8) {
/* Create and upload the palette */ /* Create and upload the palette */
@ -592,7 +592,7 @@ VID_Init (unsigned char *palette)
x_gc = XCreateGC (x_disp, x_win, valuemask, &xgcvalues); x_gc = XCreateGC (x_disp, x_win, valuemask, &xgcvalues);
} }
x11_grab_keyboard (); X11_GrabKeyboard ();
// wait for first exposure event // wait for first exposure event
{ {
@ -640,13 +640,13 @@ VID_Init (unsigned char *palette)
vid.aspect = ((float) vid.height / (float) vid.width) * (320.0 / 240.0); vid.aspect = ((float) vid.height / (float) vid.width) * (320.0 / 240.0);
// XSynchronize (x_disp, False); // XSynchronize (x_disp, False);
x11_add_event (x_shmeventtype, event_shm); X11_AddEvent (x_shmeventtype, event_shm);
} }
void void
VID_Init_Cvars () VID_Init_Cvars ()
{ {
x11_Init_Cvars (); X11_Init_Cvars ();
} }
@ -696,8 +696,8 @@ VID_Shutdown (void)
{ {
Sys_Printf ("VID_Shutdown\n"); Sys_Printf ("VID_Shutdown\n");
if (x_disp) { if (x_disp) {
x11_restore_vidmode (); X11_RestoreVidMode ();
x11_close_display (); X11_CloseDisplay ();
} }
} }
@ -757,7 +757,7 @@ VID_Update (vrect_t *rects)
} }
oktodraw = false; oktodraw = false;
while (!oktodraw) while (!oktodraw)
x11_process_event (); X11_ProcessEvent ();
rects = rects->pnext; rects = rects->pnext;
current_framebuffer = !current_framebuffer; current_framebuffer = !current_framebuffer;
@ -813,9 +813,21 @@ VID_SetCaption (char *text)
if (text && *text) { if (text && *text) {
char *temp = strdup (text); char *temp = strdup (text);
x11_set_caption (va ("%s %s: %s", PROGRAM, VERSION, temp)); X11_SetCaption (va ("%s %s: %s", PROGRAM, VERSION, temp));
free (temp); free (temp);
} else { } else {
x11_set_caption (va ("%s %s", PROGRAM, VERSION)); X11_SetCaption (va ("%s %s", PROGRAM, VERSION));
} }
} }
double
VID_GetGamma (void)
{
return (double) X11_GetGamma ();
}
qboolean
VID_SetGamma (double gamma)
{
return X11_SetGamma (gamma);
}