2001-04-15 04:18:22 +00:00
|
|
|
/*
|
|
|
|
vid_x11.c
|
|
|
|
|
|
|
|
General X11 video driver
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
Copyright (C) 1999-2000 contributors of the QuakeForge project
|
|
|
|
Copyright (C) 2000 Marcus Sundberg [mackan@stacken.kth.se]
|
|
|
|
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
|
|
|
Please see the file "AUTHORS" for a list of contributors
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#define _BSD
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_VIDMODE
|
|
|
|
# include <X11/extensions/xf86vmode.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/console.h"
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/qendian.h"
|
2001-04-15 08:04:15 +00:00
|
|
|
#include "QF/screen.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/va.h"
|
2012-02-14 10:47:02 +00:00
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
#include "compat.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "context_x11.h"
|
2003-01-06 18:28:13 +00:00
|
|
|
#include "d_iface.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "dga_check.h"
|
2012-02-17 07:13:56 +00:00
|
|
|
#include "vid_internal.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2019-07-08 04:40:29 +00:00
|
|
|
static vid_internal_t vid_internal;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
int VID_options_items = 1;
|
|
|
|
|
|
|
|
void
|
|
|
|
D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
|
|
|
{
|
|
|
|
// direct drawing of the "accessing disk" icon isn't supported
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
D_EndDirectRect (int x, int y, int width, int height)
|
|
|
|
{
|
|
|
|
// direct drawing of the "accessing disk" icon isn't supported
|
|
|
|
}
|
|
|
|
|
2019-07-12 14:15:26 +00:00
|
|
|
static void
|
|
|
|
VID_shutdown (void)
|
|
|
|
{
|
|
|
|
Sys_MaskPrintf (SYS_VID, "VID_shutdown\n");
|
|
|
|
X11_CloseDisplay ();
|
|
|
|
}
|
|
|
|
|
2012-02-18 12:33:54 +00:00
|
|
|
/*
|
|
|
|
Set up color translation tables and the window. Takes a 256-color 8-bit
|
|
|
|
palette. Palette data will go away after the call, so copy it if you'll
|
|
|
|
need it later.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
VID_Init (byte *palette, byte *colormap)
|
|
|
|
{
|
2019-07-12 14:15:26 +00:00
|
|
|
Sys_RegisterShutdown (VID_shutdown);
|
|
|
|
|
2019-07-08 16:00:47 +00:00
|
|
|
vid_internal.gl_context = X11_GL_Context;
|
|
|
|
vid_internal.sw_context = X11_SW_Context;
|
|
|
|
#ifdef HAVE_VULKAN
|
|
|
|
vid_internal.vulkan_context = X11_Vulkan_Context;
|
|
|
|
#endif
|
2012-04-11 07:44:38 +00:00
|
|
|
|
2019-07-08 05:02:24 +00:00
|
|
|
R_LoadModule (&vid_internal);
|
2012-04-10 04:27:53 +00:00
|
|
|
|
2012-02-14 10:47:02 +00:00
|
|
|
viddef.numpages = 2;
|
2012-02-17 07:13:56 +00:00
|
|
|
viddef.colormap8 = colormap;
|
2012-02-14 10:47:02 +00:00
|
|
|
viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES];
|
2012-02-18 12:33:54 +00:00
|
|
|
|
|
|
|
srandom (getpid ());
|
|
|
|
|
|
|
|
VID_GetWindowSize (320, 200);
|
|
|
|
X11_OpenDisplay ();
|
2019-07-08 16:00:47 +00:00
|
|
|
vid_internal.choose_visual ();
|
2012-02-14 10:47:02 +00:00
|
|
|
X11_SetVidMode (viddef.width, viddef.height);
|
|
|
|
X11_CreateWindow (viddef.width, viddef.height);
|
2012-02-18 12:33:54 +00:00
|
|
|
X11_CreateNullCursor (); // hide mouse pointer
|
2019-07-08 16:00:47 +00:00
|
|
|
vid_internal.create_context ();
|
2012-02-18 12:33:54 +00:00
|
|
|
|
|
|
|
VID_InitGamma (palette);
|
2019-07-08 04:40:29 +00:00
|
|
|
viddef.vid_internal->set_palette (viddef.palette);
|
2012-02-18 12:33:54 +00:00
|
|
|
|
|
|
|
Sys_MaskPrintf (SYS_VID, "Video mode %dx%d initialized.\n",
|
2012-02-14 10:47:02 +00:00
|
|
|
viddef.width, viddef.height);
|
2001-05-25 04:03:47 +00:00
|
|
|
|
2012-02-14 10:47:02 +00:00
|
|
|
viddef.initialized = true;
|
|
|
|
viddef.recalc_refdef = 1; // force a surface cache flush
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VID_Init_Cvars ()
|
|
|
|
{
|
|
|
|
X11_Init_Cvars ();
|
2019-07-08 16:00:47 +00:00
|
|
|
#ifdef HAVE_VULKAN
|
|
|
|
X11_Vulkan_Init_Cvars ();
|
|
|
|
#endif
|
|
|
|
X11_GL_Init_Cvars ();
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
2019-07-08 16:00:47 +00:00
|
|
|
#if 0
|
2001-04-15 04:18:22 +00:00
|
|
|
static int config_notify = 0;
|
|
|
|
static int config_notify_width;
|
|
|
|
static int config_notify_height;
|
|
|
|
|
2019-07-08 16:00:47 +00:00
|
|
|
static void
|
|
|
|
update ()
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
/* If the window changes dimension, skip this frame. */
|
|
|
|
if (config_notify) {
|
|
|
|
fprintf (stderr, "config notify\n");
|
|
|
|
config_notify = 0;
|
2012-02-14 10:47:02 +00:00
|
|
|
viddef.width = config_notify_width & ~7;
|
|
|
|
viddef.height = config_notify_height;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2001-04-16 19:25:55 +00:00
|
|
|
VID_InitBuffers ();
|
|
|
|
|
2012-02-14 10:47:02 +00:00
|
|
|
viddef.recalc_refdef = 1; /* force a surface cache flush */
|
2001-04-15 04:18:22 +00:00
|
|
|
Con_CheckResize ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-07-08 16:00:47 +00:00
|
|
|
#endif
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
VID_LockBuffer (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VID_UnlockBuffer (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-07-15 07:04:17 +00:00
|
|
|
VID_SetCaption (const char *text)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
if (text && *text) {
|
|
|
|
char *temp = strdup (text);
|
|
|
|
|
2010-08-19 06:01:43 +00:00
|
|
|
X11_SetCaption (va ("%s: %s", PACKAGE_STRING, temp));
|
2001-04-15 04:18:22 +00:00
|
|
|
free (temp);
|
|
|
|
} else {
|
2010-08-19 06:01:43 +00:00
|
|
|
X11_SetCaption (va ("%s", PACKAGE_STRING));
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean
|
|
|
|
VID_SetGamma (double gamma)
|
|
|
|
{
|
|
|
|
return X11_SetGamma (gamma);
|
|
|
|
}
|