/* 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 #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #include #include #include #include #ifdef HAVE_VIDMODE # include #endif #include "QF/cmd.h" #include "QF/console.h" #include "QF/cvar.h" #include "QF/qendian.h" #include "QF/screen.h" #include "QF/sys.h" #include "QF/va.h" #include "compat.h" #include "context_x11.h" #include "d_iface.h" #include "dga_check.h" #include "vid_internal.h" static vid_internal_t vid_internal; 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 } static void VID_shutdown (void) { Sys_MaskPrintf (SYS_VID, "VID_shutdown\n"); X11_CloseDisplay (); } /* 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) { Sys_RegisterShutdown (VID_shutdown); 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 R_LoadModule (&vid_internal); viddef.numpages = 2; viddef.colormap8 = colormap; viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES]; srandom (getpid ()); VID_GetWindowSize (320, 200); X11_OpenDisplay (); vid_internal.choose_visual (); X11_SetVidMode (viddef.width, viddef.height); X11_CreateWindow (viddef.width, viddef.height); X11_CreateNullCursor (); // hide mouse pointer vid_internal.create_context (); VID_InitGamma (palette); viddef.vid_internal->set_palette (viddef.palette); Sys_MaskPrintf (SYS_VID, "Video mode %dx%d initialized.\n", viddef.width, viddef.height); viddef.initialized = true; viddef.recalc_refdef = 1; // force a surface cache flush } void VID_Init_Cvars () { X11_Init_Cvars (); #ifdef HAVE_VULKAN X11_Vulkan_Init_Cvars (); #endif X11_GL_Init_Cvars (); } #if 0 static int config_notify = 0; static int config_notify_width; static int config_notify_height; static void update () { /* If the window changes dimension, skip this frame. */ if (config_notify) { fprintf (stderr, "config notify\n"); config_notify = 0; viddef.width = config_notify_width & ~7; viddef.height = config_notify_height; VID_InitBuffers (); viddef.recalc_refdef = 1; /* force a surface cache flush */ Con_CheckResize (); return; } } #endif void VID_LockBuffer (void) { } void VID_UnlockBuffer (void) { } void VID_SetCaption (const char *text) { if (text && *text) { char *temp = strdup (text); X11_SetCaption (va ("%s: %s", PACKAGE_STRING, temp)); free (temp); } else { X11_SetCaption (va ("%s", PACKAGE_STRING)); } } qboolean VID_SetGamma (double gamma) { return X11_SetGamma (gamma); }