mirror of
https://git.code.sf.net/p/quake/nuq
synced 2024-11-25 13:31:19 +00:00
source/vid_svgalib.c source/in_svgalib.c:
"accidently" port over newtree's svga stuff (I copied the wrong file then cleaned up the resulting mess:) Makefile.am include/Makefile.am doc/Makefile.am source/Makefile.am: fix things up so doc no longer causes make to barf and makd dist works source/dirent.c source/fnmatch.c source/in_svgalib.c source/vid_3dfxsvga.c source/vid_mgl.c source/vid_wgl.c: needed for make dist. No, nuq-3dfx does not get created (I don't have the libs or card)
This commit is contained in:
parent
58ef964ae2
commit
8cb963858f
10 changed files with 7317 additions and 656 deletions
|
@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = foreign
|
|||
|
||||
SUBDIRS = include source doc
|
||||
|
||||
EXTRA_DIST = RPM/build_rpm.in RPM/uquake.spec.in \
|
||||
EXTRA_DIST = RPM/build_rpm.in RPM/nuq.spec.in \
|
||||
tools/gas2masm/Makefile tools/gas2masm/gas2masm.c \
|
||||
tools/gas2masm/gas2masm.dsp tools/gas2masm/gas2masm.dsw \
|
||||
tools/gas2masm/gas2masm.mak tools/gas2masm/gas2masm.mdp
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
EXTRA_DIST = adivtab.h anorm_dots.h anorms.h asm_draw.h asm_ia32.h block16.h \
|
||||
block8.h bothdefs.h bspfile.h buildnum.h cdaudio.h checksum.h \
|
||||
cl_slist.h client.h cmd.h commdef.h compat.h console.h crc.h \
|
||||
block8.h bspfile.h cdaudio.h \
|
||||
client.h cmd.h compat.h console.h crc.h \
|
||||
cvar.h d_iface.h d_ifacea.h d_local.h draw.h gl_warp_sin.h \
|
||||
glquake.h in_win.h info.h input.h keys.h link.h \
|
||||
glquake.h info.h input.h keys.h link.h \
|
||||
mathlib.h mdfour.h menu.h model.h modelgen.h msg.h net.h \
|
||||
pmove.h pr_comp.h progdefs.h progs.h protocol.h qargs.h \
|
||||
qdefs.h qendian.h qstructs.h qtypes.h quakeasm.h quakedef.h \
|
||||
pr_comp.h progdefs.h progs.h protocol.h qargs.h \
|
||||
qdefs.h qendian.h qtypes.h quakeasm.h \
|
||||
quakefs.h quakeio.h r_local.h r_shared.h render.h resource.h \
|
||||
sbar.h screen.h server.h sizebuf.h sound.h spritegn.h sys.h \
|
||||
uint32.h vid.h view.h wad.h winquake.h world.h zone.h \
|
||||
|
|
|
@ -43,7 +43,7 @@ noinst_LIBRARIES= libqfsys.a libqfsnd.a libqfcd.a libqfnet.a
|
|||
math_ASM= math.S cl_math.S
|
||||
soft_ASM= d_draw.S d_draw16.S d_parta.S d_polysa.S d_scana.S d_spr8.S \
|
||||
d_varsa.S r_aclipa.S r_aliasa.S r_drawa.S r_edgea.S r_varsa.S \
|
||||
surf16.s surf8.s
|
||||
surf16.S surf8.S
|
||||
sound_ASM= snd_mixa.S
|
||||
common_ASM= sys_ia32.S worlda.S $(math_ASM)
|
||||
#endif
|
||||
|
@ -165,7 +165,7 @@ nuq_sdl_DEPENDENCIES=libqfsys.a libqfsnd.a libqfcd.a libqfnet.a
|
|||
#
|
||||
# ... Linux SVGAlib
|
||||
#
|
||||
svga_SOURCES= d_copy.S vid_svgalib.c
|
||||
svga_SOURCES= d_copy.S vid_svgalib.c in_svgalib.c
|
||||
|
||||
nuq_svga_SOURCES= $(combined_SOURCES) $(soft_SOURCES) $(svga_SOURCES)
|
||||
nuq_svga_LDADD= $(client_LIBS) $(SVGA_LIBS)
|
||||
|
@ -230,6 +230,4 @@ nuq_wgl_DEPENDENCIES=libqfsys.a libqfsnd.a libqfcd.a libqfnet.a
|
|||
# Stuff that doesn't get linked into an executable NEEDS to be mentioned here,
|
||||
# or it won't be distributed with 'make dist'
|
||||
#
|
||||
EXTRA_DIST= nuq-server.mak nuq-server.dsp \
|
||||
nuq-mgl.mak nuq-sdl.mak nuq.dsp \
|
||||
nuq-sgl.mak nuq-wgl.mak
|
||||
EXTRA_DIST= #nuq.dsp
|
||||
|
|
313
source/dirent.c
Normal file
313
source/dirent.c
Normal file
|
@ -0,0 +1,313 @@
|
|||
/*
|
||||
* dirent.c
|
||||
*
|
||||
* Derived from DIRLIB.C by Matt J. Weinstein
|
||||
* This note appears in the DIRLIB.H
|
||||
* DIRLIB.H by M. J. Weinstein Released to public domain 1-Jan-89
|
||||
*
|
||||
* Updated by Jeremy Bettis <jeremy@hksys.com>
|
||||
* Significantly revised and rewinddir, seekdir and telldir added by Colin
|
||||
* Peters <colin@fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
#define SUFFIX "*"
|
||||
#define SLASH "\\"
|
||||
|
||||
#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* is a directory */
|
||||
|
||||
/*
|
||||
* opendir
|
||||
*
|
||||
* Returns a pointer to a DIR structure appropriately filled in to begin
|
||||
* searching a directory.
|
||||
*/
|
||||
DIR *
|
||||
opendir (const char *szPath)
|
||||
{
|
||||
DIR *nd;
|
||||
struct _stat statDir;
|
||||
|
||||
errno = 0;
|
||||
|
||||
if (!szPath)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return (DIR *) 0;
|
||||
}
|
||||
|
||||
if (szPath[0] == '\0')
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return (DIR *) 0;
|
||||
}
|
||||
|
||||
/* Attempt to determine if the given path really is a directory. */
|
||||
if (_stat (szPath, &statDir))
|
||||
{
|
||||
/* Error, stat should have set an error value. */
|
||||
return (DIR *) 0;
|
||||
}
|
||||
|
||||
if (!S_ISDIR (statDir.st_mode))
|
||||
{
|
||||
/* Error, stat reports not a directory. */
|
||||
errno = ENOTDIR;
|
||||
return (DIR *) 0;
|
||||
}
|
||||
|
||||
/* Allocate enough space to store DIR structure and the complete
|
||||
* directory path given. */
|
||||
nd = (DIR *) calloc (1, sizeof (DIR) + strlen (szPath) + strlen (SLASH) +
|
||||
strlen (SUFFIX));
|
||||
|
||||
if (!nd)
|
||||
{
|
||||
/* Error, out of memory. */
|
||||
errno = ENOMEM;
|
||||
return (DIR *) 0;
|
||||
}
|
||||
|
||||
/* Create the search expression. */
|
||||
strcpy (nd->dd_name, szPath);
|
||||
|
||||
/* Add on a slash if the path does not end with one. */
|
||||
if (nd->dd_name[0] != '\0' &&
|
||||
nd->dd_name[strlen (nd->dd_name) - 1] != '/' &&
|
||||
nd->dd_name[strlen (nd->dd_name) - 1] != '\\')
|
||||
{
|
||||
strcat (nd->dd_name, SLASH);
|
||||
}
|
||||
|
||||
/* Add on the search pattern */
|
||||
strcat (nd->dd_name, SUFFIX);
|
||||
|
||||
/* Initialize handle to -1 so that a premature closedir doesn't try
|
||||
* to call _findclose on it. */
|
||||
nd->dd_handle = -1;
|
||||
|
||||
/* Initialize the status. */
|
||||
nd->dd_stat = 0;
|
||||
|
||||
/* Initialize the dirent structure. ino and reclen are invalid under
|
||||
* Win32, and name simply points at the appropriate part of the
|
||||
* findfirst_t structure. */
|
||||
nd->dd_dir.d_ino = 0;
|
||||
nd->dd_dir.d_reclen = 0;
|
||||
nd->dd_dir.d_namlen = 0;
|
||||
nd->dd_dir.d_name = nd->dd_dta.name;
|
||||
|
||||
return nd;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* readdir
|
||||
*
|
||||
* Return a pointer to a dirent structure filled with the information on the
|
||||
* next entry in the directory.
|
||||
*/
|
||||
struct dirent *
|
||||
readdir (DIR * dirp)
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
/* Check for valid DIR struct. */
|
||||
if (!dirp)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return (struct dirent *) 0;
|
||||
}
|
||||
|
||||
if (dirp->dd_dir.d_name != dirp->dd_dta.name)
|
||||
{
|
||||
/* The structure does not seem to be set up correctly. */
|
||||
errno = EINVAL;
|
||||
return (struct dirent *) 0;
|
||||
}
|
||||
|
||||
if (dirp->dd_stat < 0)
|
||||
{
|
||||
/* We have already returned all files in the directory
|
||||
* (or the structure has an invalid dd_stat). */
|
||||
return (struct dirent *) 0;
|
||||
}
|
||||
else if (dirp->dd_stat == 0)
|
||||
{
|
||||
/* We haven't started the search yet. */
|
||||
/* Start the search */
|
||||
dirp->dd_handle = _findfirst (dirp->dd_name, &(dirp->dd_dta));
|
||||
|
||||
if (dirp->dd_handle == -1)
|
||||
{
|
||||
/* Whoops! Seems there are no files in that
|
||||
* directory. */
|
||||
dirp->dd_stat = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dirp->dd_stat = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the next search entry. */
|
||||
if (_findnext (dirp->dd_handle, &(dirp->dd_dta)))
|
||||
{
|
||||
/* We are off the end or otherwise error. */
|
||||
_findclose (dirp->dd_handle);
|
||||
dirp->dd_handle = -1;
|
||||
dirp->dd_stat = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Update the status to indicate the correct
|
||||
* number. */
|
||||
dirp->dd_stat++;
|
||||
}
|
||||
}
|
||||
|
||||
if (dirp->dd_stat > 0)
|
||||
{
|
||||
/* Successfully got an entry. Everything about the file is
|
||||
* already appropriately filled in except the length of the
|
||||
* file name. */
|
||||
dirp->dd_dir.d_namlen = strlen (dirp->dd_dir.d_name);
|
||||
return &dirp->dd_dir;
|
||||
}
|
||||
|
||||
return (struct dirent *) 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* closedir
|
||||
*
|
||||
* Frees up resources allocated by opendir.
|
||||
*/
|
||||
int
|
||||
closedir (DIR * dirp)
|
||||
{
|
||||
int rc;
|
||||
|
||||
errno = 0;
|
||||
rc = 0;
|
||||
|
||||
if (!dirp)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dirp->dd_handle != -1)
|
||||
{
|
||||
rc = _findclose (dirp->dd_handle);
|
||||
}
|
||||
|
||||
/* Delete the dir structure. */
|
||||
free (dirp);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* rewinddir
|
||||
*
|
||||
* Return to the beginning of the directory "stream". We simply call findclose
|
||||
* and then reset things like an opendir.
|
||||
*/
|
||||
void
|
||||
rewinddir (DIR * dirp)
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
if (!dirp)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return;
|
||||
}
|
||||
|
||||
if (dirp->dd_handle != -1)
|
||||
{
|
||||
_findclose (dirp->dd_handle);
|
||||
}
|
||||
|
||||
dirp->dd_handle = -1;
|
||||
dirp->dd_stat = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* telldir
|
||||
*
|
||||
* Returns the "position" in the "directory stream" which can be used with
|
||||
* seekdir to go back to an old entry. We simply return the value in stat.
|
||||
*/
|
||||
long
|
||||
telldir (DIR * dirp)
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
if (!dirp)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
return dirp->dd_stat;
|
||||
}
|
||||
|
||||
/*
|
||||
* seekdir
|
||||
*
|
||||
* Seek to an entry previously returned by telldir. We rewind the directory
|
||||
* and call readdir repeatedly until either dd_stat is the position number
|
||||
* or -1 (off the end). This is not perfect, in that the directory may
|
||||
* have changed while we weren't looking. But that is probably the case with
|
||||
* any such system.
|
||||
*/
|
||||
void
|
||||
seekdir (DIR * dirp, long lPos)
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
if (!dirp)
|
||||
{
|
||||
errno = EFAULT;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lPos < -1)
|
||||
{
|
||||
/* Seeking to an invalid position. */
|
||||
errno = EINVAL;
|
||||
return;
|
||||
}
|
||||
else if (lPos == -1)
|
||||
{
|
||||
/* Seek past end. */
|
||||
if (dirp->dd_handle != -1)
|
||||
{
|
||||
_findclose (dirp->dd_handle);
|
||||
}
|
||||
dirp->dd_handle = -1;
|
||||
dirp->dd_stat = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Rewind and read forward to the appropriate index. */
|
||||
rewinddir (dirp);
|
||||
|
||||
while ((dirp->dd_stat < lPos) && readdir (dirp))
|
||||
;
|
||||
}
|
||||
}
|
220
source/fnmatch.c
Normal file
220
source/fnmatch.c
Normal file
|
@ -0,0 +1,220 @@
|
|||
/*
|
||||
fnmatch.c
|
||||
|
||||
(description)
|
||||
|
||||
Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
|
||||
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
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "fnmatch.h"
|
||||
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
|
||||
|
||||
|
||||
#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* Match STRING against the filename pattern PATTERN, returning zero if
|
||||
it matches, nonzero if not. */
|
||||
int
|
||||
fnmatch (pattern, string, flags)
|
||||
const char *pattern;
|
||||
const char *string;
|
||||
int flags;
|
||||
{
|
||||
register const char *p = pattern, *n = string;
|
||||
register unsigned char c;
|
||||
|
||||
/* Note that this evalutes C many times. */
|
||||
#define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c))
|
||||
|
||||
#ifdef _WIN32
|
||||
flags |= FNM_CASEFOLD;
|
||||
#endif
|
||||
|
||||
while ((c = *p++) != '\0')
|
||||
{
|
||||
c = FOLD (c);
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '?':
|
||||
if (*n == '\0')
|
||||
return FNM_NOMATCH;
|
||||
else if ((flags & FNM_FILE_NAME) && *n == '/')
|
||||
return FNM_NOMATCH;
|
||||
else if ((flags & FNM_PERIOD) && *n == '.' &&
|
||||
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
|
||||
return FNM_NOMATCH;
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
if (!(flags & FNM_NOESCAPE))
|
||||
{
|
||||
c = *p++;
|
||||
c = FOLD (c);
|
||||
}
|
||||
if (FOLD ((unsigned char)*n) != c)
|
||||
return FNM_NOMATCH;
|
||||
break;
|
||||
|
||||
case '*':
|
||||
if ((flags & FNM_PERIOD) && *n == '.' &&
|
||||
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
|
||||
if (((flags & FNM_FILE_NAME) && *n == '/') ||
|
||||
(c == '?' && *n == '\0'))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if (c == '\0')
|
||||
return 0;
|
||||
|
||||
{
|
||||
unsigned char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
|
||||
c1 = FOLD (c1);
|
||||
for (--p; *n != '\0'; ++n)
|
||||
if ((c == '[' || FOLD ((unsigned char)*n) == c1) &&
|
||||
fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
|
||||
return 0;
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
case '[':
|
||||
{
|
||||
/* Nonzero if the sense of the character class is inverted. */
|
||||
register int not;
|
||||
|
||||
if (*n == '\0')
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if ((flags & FNM_PERIOD) && *n == '.' &&
|
||||
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
not = (*p == '!' || *p == '^');
|
||||
if (not)
|
||||
++p;
|
||||
|
||||
c = *p++;
|
||||
for (;;)
|
||||
{
|
||||
register unsigned char cstart = c, cend = c;
|
||||
|
||||
if (!(flags & FNM_NOESCAPE) && c == '\\')
|
||||
cstart = cend = *p++;
|
||||
|
||||
cstart = cend = FOLD (cstart);
|
||||
|
||||
if (c == '\0')
|
||||
/* [ (unterminated) loses. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
c = *p++;
|
||||
c = FOLD (c);
|
||||
|
||||
if ((flags & FNM_FILE_NAME) && c == '/')
|
||||
/* [/] can never match. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if (c == '-' && *p != ']')
|
||||
{
|
||||
cend = *p++;
|
||||
if (!(flags & FNM_NOESCAPE) && cend == '\\')
|
||||
cend = *p++;
|
||||
if (cend == '\0')
|
||||
return FNM_NOMATCH;
|
||||
cend = FOLD (cend);
|
||||
|
||||
c = *p++;
|
||||
}
|
||||
|
||||
if (FOLD ((unsigned char)*n) >= cstart
|
||||
&& FOLD ((unsigned char)*n) <= cend)
|
||||
goto matched;
|
||||
|
||||
if (c == ']')
|
||||
break;
|
||||
}
|
||||
if (!not)
|
||||
return FNM_NOMATCH;
|
||||
break;
|
||||
|
||||
matched:;
|
||||
/* Skip the rest of the [...] that already matched. */
|
||||
while (c != ']')
|
||||
{
|
||||
if (c == '\0')
|
||||
/* [... (unterminated) loses. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
c = *p++;
|
||||
if (!(flags & FNM_NOESCAPE) && c == '\\')
|
||||
/* XXX 1003.2d11 is unclear if this is right. */
|
||||
++p;
|
||||
}
|
||||
if (not)
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (c != FOLD ((unsigned char)*n))
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
++n;
|
||||
}
|
||||
|
||||
if (*n == '\0')
|
||||
return 0;
|
||||
|
||||
if ((flags & FNM_LEADING_DIR) && *n == '/')
|
||||
/* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
|
||||
return 0;
|
||||
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
||||
|
385
source/in_svgalib.c
Normal file
385
source/in_svgalib.c
Normal file
|
@ -0,0 +1,385 @@
|
|||
/*
|
||||
in_svgalib.c
|
||||
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
Copyright (C) 1999-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
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "qtypes.h"
|
||||
#include "keys.h"
|
||||
#include "client.h"
|
||||
#include "sys.h"
|
||||
#include "console.h"
|
||||
#include "cvar.h"
|
||||
#include "cmd.h"
|
||||
#include "host.h"
|
||||
#include "qargs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <vga.h>
|
||||
#include <vgakeyboard.h>
|
||||
#include <vgamouse.h>
|
||||
|
||||
|
||||
static int UseKeyboard = 1;
|
||||
static int UseMouse = 1;
|
||||
static int in_svgalib_inited = 0;
|
||||
|
||||
static unsigned char scantokey[128];
|
||||
static int mouse_buttons;
|
||||
static int mouse_buttonstate;
|
||||
static int mouse_oldbuttonstate;
|
||||
static float mouse_x, mouse_y;
|
||||
static float old_mouse_x, old_mouse_y;
|
||||
static int mx, my;
|
||||
|
||||
static void IN_init_kb();
|
||||
static void IN_init_mouse();
|
||||
|
||||
cvar_t *_windowed_mouse;
|
||||
cvar_t *m_filter;
|
||||
static cvar_t *mouse_button_commands[3];
|
||||
|
||||
static void keyhandler(int scancode, int state)
|
||||
{
|
||||
int sc;
|
||||
|
||||
sc = scancode & 0x7f;
|
||||
#if 0
|
||||
Con_Printf("scancode=%x (%d%s)\n", scancode, sc, scancode&0x80?"+128":"");
|
||||
#endif
|
||||
Key_Event(scantokey[sc], state == KEY_EVENTPRESS);
|
||||
}
|
||||
|
||||
|
||||
static void mousehandler(int buttonstate, int dx, int dy, int dz, int drx, int dry, int drz)
|
||||
{
|
||||
mouse_buttonstate = buttonstate;
|
||||
mx += dx;
|
||||
my += dy;
|
||||
if (drx > 0) {
|
||||
Key_Event(K_MWHEELUP, 1);
|
||||
Key_Event(K_MWHEELUP, 0);
|
||||
} else if (drx < 0) {
|
||||
Key_Event(K_MWHEELDOWN, 1);
|
||||
Key_Event(K_MWHEELDOWN, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Force_CenterView_f(void)
|
||||
{
|
||||
cl.viewangles[PITCH] = 0;
|
||||
}
|
||||
|
||||
|
||||
int IN_Init(void)
|
||||
{
|
||||
if (COM_CheckParm("-nokbd")) UseKeyboard = 0;
|
||||
if (COM_CheckParm("-nomouse")) UseMouse = 0;
|
||||
|
||||
if (UseKeyboard)
|
||||
IN_init_kb();
|
||||
if (UseMouse)
|
||||
IN_init_mouse();
|
||||
|
||||
in_svgalib_inited = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void IN_init_kb()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<128 ; i++) {
|
||||
scantokey[i] = ' ';
|
||||
}
|
||||
|
||||
scantokey[ 1] = K_ESCAPE;
|
||||
scantokey[ 2] = '1';
|
||||
scantokey[ 3] = '2';
|
||||
scantokey[ 4] = '3';
|
||||
scantokey[ 5] = '4';
|
||||
scantokey[ 6] = '5';
|
||||
scantokey[ 7] = '6';
|
||||
scantokey[ 8] = '7';
|
||||
scantokey[ 9] = '8';
|
||||
scantokey[ 10] = '9';
|
||||
scantokey[ 11] = '0';
|
||||
scantokey[ 12] = '-';
|
||||
scantokey[ 13] = '=';
|
||||
scantokey[ 14] = K_BACKSPACE;
|
||||
scantokey[ 15] = K_TAB;
|
||||
scantokey[ 16] = 'q';
|
||||
scantokey[ 17] = 'w';
|
||||
scantokey[ 18] = 'e';
|
||||
scantokey[ 19] = 'r';
|
||||
scantokey[ 20] = 't';
|
||||
scantokey[ 21] = 'y';
|
||||
scantokey[ 22] = 'u';
|
||||
scantokey[ 23] = 'i';
|
||||
scantokey[ 24] = 'o';
|
||||
scantokey[ 25] = 'p';
|
||||
scantokey[ 26] = '[';
|
||||
scantokey[ 27] = ']';
|
||||
scantokey[ 28] = K_ENTER;
|
||||
scantokey[ 29] = K_CTRL; /*left */
|
||||
scantokey[ 30] = 'a';
|
||||
scantokey[ 31] = 's';
|
||||
scantokey[ 32] = 'd';
|
||||
scantokey[ 33] = 'f';
|
||||
scantokey[ 34] = 'g';
|
||||
scantokey[ 35] = 'h';
|
||||
scantokey[ 36] = 'j';
|
||||
scantokey[ 37] = 'k';
|
||||
scantokey[ 38] = 'l';
|
||||
scantokey[ 39] = ';';
|
||||
scantokey[ 40] = '\'';
|
||||
scantokey[ 41] = '`';
|
||||
scantokey[ 42] = K_SHIFT; /*left */
|
||||
scantokey[ 43] = '\\';
|
||||
scantokey[ 44] = 'z';
|
||||
scantokey[ 45] = 'x';
|
||||
scantokey[ 46] = 'c';
|
||||
scantokey[ 47] = 'v';
|
||||
scantokey[ 48] = 'b';
|
||||
scantokey[ 49] = 'n';
|
||||
scantokey[ 50] = 'm';
|
||||
scantokey[ 51] = ',';
|
||||
scantokey[ 52] = '.';
|
||||
scantokey[ 53] = '/';
|
||||
scantokey[ 54] = K_SHIFT; /*right */
|
||||
scantokey[ 55] = KP_MULTIPLY;
|
||||
scantokey[ 56] = K_ALT; /*left */
|
||||
scantokey[ 57] = ' ';
|
||||
scantokey[ 58] = K_CAPSLOCK;
|
||||
scantokey[ 59] = K_F1;
|
||||
scantokey[ 60] = K_F2;
|
||||
scantokey[ 61] = K_F3;
|
||||
scantokey[ 62] = K_F4;
|
||||
scantokey[ 63] = K_F5;
|
||||
scantokey[ 64] = K_F6;
|
||||
scantokey[ 65] = K_F7;
|
||||
scantokey[ 66] = K_F8;
|
||||
scantokey[ 67] = K_F9;
|
||||
scantokey[ 68] = K_F10;
|
||||
scantokey[ 69] = KP_NUMLCK;
|
||||
scantokey[ 70] = K_SCRLCK;
|
||||
scantokey[ 71] = KP_HOME;
|
||||
scantokey[ 72] = KP_UPARROW;
|
||||
scantokey[ 73] = KP_PGUP;
|
||||
scantokey[ 74] = KP_MINUS;
|
||||
scantokey[ 75] = KP_LEFTARROW;
|
||||
scantokey[ 76] = KP_5;
|
||||
scantokey[ 77] = KP_RIGHTARROW;
|
||||
scantokey[ 79] = KP_END;
|
||||
scantokey[ 78] = KP_PLUS;
|
||||
scantokey[ 80] = KP_DOWNARROW;
|
||||
scantokey[ 81] = KP_PGDN;
|
||||
scantokey[ 82] = KP_INS;
|
||||
scantokey[ 83] = KP_DEL;
|
||||
/* 84 to 86 not used */
|
||||
scantokey[ 87] = K_F11;
|
||||
scantokey[ 88] = K_F12;
|
||||
/* 89 to 95 not used */
|
||||
scantokey[ 96] = KP_ENTER; /* keypad enter */
|
||||
scantokey[ 97] = K_CTRL; /* right */
|
||||
scantokey[ 98] = KP_DIVIDE;
|
||||
scantokey[ 99] = K_PRNTSCR; /* print screen */
|
||||
scantokey[100] = K_ALT; /* right */
|
||||
|
||||
scantokey[101] = K_PAUSE; /* break */
|
||||
scantokey[102] = K_HOME;
|
||||
scantokey[103] = K_UPARROW;
|
||||
scantokey[104] = K_PGUP;
|
||||
scantokey[105] = K_LEFTARROW;
|
||||
scantokey[106] = K_RIGHTARROW;
|
||||
scantokey[107] = K_END;
|
||||
scantokey[108] = K_DOWNARROW;
|
||||
scantokey[109] = K_PGDN;
|
||||
scantokey[110] = K_INS;
|
||||
scantokey[111] = K_DEL;
|
||||
scantokey[119] = K_PAUSE;
|
||||
|
||||
if (keyboard_init()) {
|
||||
Sys_Error("keyboard_init() failed");
|
||||
}
|
||||
keyboard_seteventhandler(keyhandler);
|
||||
}
|
||||
|
||||
static void IN_init_mouse()
|
||||
{
|
||||
int mtype;
|
||||
char *mousedev;
|
||||
int mouserate = MOUSE_DEFAULTSAMPLERATE;
|
||||
|
||||
mouse_button_commands[0] = Cvar_Get ("mouse1","+attack",0,"None");
|
||||
mouse_button_commands[1] = Cvar_Get ("mouse2","+strafe",0,"None");
|
||||
mouse_button_commands[2] = Cvar_Get ("mouse2","+forward",0,"None");
|
||||
m_filter = Cvar_Get ("m_filter","0",0,"None");
|
||||
Cmd_AddCommand("force_centerview", Force_CenterView_f);
|
||||
|
||||
mouse_buttons = 3;
|
||||
|
||||
mtype = vga_getmousetype();
|
||||
|
||||
mousedev = "/dev/mouse";
|
||||
if (getenv("MOUSEDEV")) mousedev = getenv("MOUSEDEV");
|
||||
if (COM_CheckParm("-mdev")) {
|
||||
mousedev = com_argv[COM_CheckParm("-mdev")+1];
|
||||
}
|
||||
|
||||
if (getenv("MOUSERATE")) mouserate = atoi(getenv("MOUSERATE"));
|
||||
if (COM_CheckParm("-mrate")) {
|
||||
mouserate = atoi(com_argv[COM_CheckParm("-mrate")+1]);
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("Mouse: dev=%s,type=%s,speed=%d\n",
|
||||
mousedev, mice[mtype].name, mouserate);
|
||||
#endif
|
||||
if (mouse_init(mousedev, mtype, mouserate)) {
|
||||
Con_Printf("No mouse found\n");
|
||||
UseMouse = 0;
|
||||
} else{
|
||||
mouse_seteventhandler((void*)mousehandler);
|
||||
}
|
||||
}
|
||||
|
||||
void IN_Shutdown(void)
|
||||
{
|
||||
Con_Printf("IN_Shutdown\n");
|
||||
|
||||
if (UseMouse) mouse_close();
|
||||
if (UseKeyboard) keyboard_close();
|
||||
in_svgalib_inited = 0;
|
||||
}
|
||||
|
||||
|
||||
void IN_SendKeyEvents(void)
|
||||
{
|
||||
if (!in_svgalib_inited) return;
|
||||
|
||||
if (UseKeyboard) {
|
||||
while ((keyboard_update()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IN_Commands(void)
|
||||
{
|
||||
if (UseMouse)
|
||||
{
|
||||
/* Poll mouse values */
|
||||
while (mouse_update())
|
||||
;
|
||||
|
||||
/* Perform button actions */
|
||||
if ((mouse_buttonstate & MOUSE_LEFTBUTTON) &&
|
||||
!(mouse_oldbuttonstate & MOUSE_LEFTBUTTON))
|
||||
Key_Event (K_MOUSE1, true);
|
||||
else if (!(mouse_buttonstate & MOUSE_LEFTBUTTON) &&
|
||||
(mouse_oldbuttonstate & MOUSE_LEFTBUTTON))
|
||||
Key_Event (K_MOUSE1, false);
|
||||
|
||||
if ((mouse_buttonstate & MOUSE_RIGHTBUTTON) &&
|
||||
!(mouse_oldbuttonstate & MOUSE_RIGHTBUTTON))
|
||||
Key_Event (K_MOUSE2, true);
|
||||
else if (!(mouse_buttonstate & MOUSE_RIGHTBUTTON) &&
|
||||
(mouse_oldbuttonstate & MOUSE_RIGHTBUTTON))
|
||||
Key_Event (K_MOUSE2, false);
|
||||
|
||||
if ((mouse_buttonstate & MOUSE_MIDDLEBUTTON) &&
|
||||
!(mouse_oldbuttonstate & MOUSE_MIDDLEBUTTON))
|
||||
Key_Event (K_MOUSE3, true);
|
||||
else if (!(mouse_buttonstate & MOUSE_MIDDLEBUTTON) &&
|
||||
(mouse_oldbuttonstate & MOUSE_MIDDLEBUTTON))
|
||||
Key_Event (K_MOUSE3, false);
|
||||
|
||||
mouse_oldbuttonstate = mouse_buttonstate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IN_Move(usercmd_t *cmd)
|
||||
{
|
||||
if (!UseMouse) return;
|
||||
|
||||
/* Poll mouse values */
|
||||
while (mouse_update())
|
||||
;
|
||||
|
||||
if (m_filter->value) {
|
||||
mouse_x = (mx + old_mouse_x) * 0.5;
|
||||
mouse_y = (my + old_mouse_y) * 0.5;
|
||||
} else {
|
||||
mouse_x = mx;
|
||||
mouse_y = my;
|
||||
}
|
||||
old_mouse_x = mx;
|
||||
old_mouse_y = my;
|
||||
/* Clear for next update */
|
||||
mx = my = 0;
|
||||
|
||||
mouse_x *= sensitivity->value;
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
/* Add mouse X/Y movement to cmd */
|
||||
if ( (in_strafe.state & 1) ||
|
||||
(lookstrafe->value && (in_mlook.state & 1) )) {
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
} else {
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
}
|
||||
|
||||
if ((in_mlook.state & 1)) V_StopPitchDrift();
|
||||
|
||||
if ((in_mlook.state & 1) && !(in_strafe.state & 1)) {
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
if (cl.viewangles[PITCH] > 80) {
|
||||
cl.viewangles[PITCH] = 80;
|
||||
}
|
||||
if (cl.viewangles[PITCH] < -70) {
|
||||
cl.viewangles[PITCH] = -70;
|
||||
}
|
||||
} else {
|
||||
if ((in_strafe.state & 1) && noclip_anglehack) {
|
||||
cmd->upmove -= m_forward->value * mouse_y;
|
||||
} else {
|
||||
cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
}
|
||||
}
|
||||
}
|
651
source/vid_3dfxsvga.c
Normal file
651
source/vid_3dfxsvga.c
Normal file
|
@ -0,0 +1,651 @@
|
|||
/*
|
||||
vid_3dfxsvga.c
|
||||
|
||||
OpenGL device driver for 3Dfx chipsets running Linux
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
Copyright (C) 1999,2000 Nelson Rush.
|
||||
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
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include "qtypes.h"
|
||||
#include "quakedef.h"
|
||||
#include "glquake.h"
|
||||
#include "sys.h"
|
||||
#include "console.h"
|
||||
#include "cvar.h"
|
||||
#include "sbar.h"
|
||||
#include "qendian.h"
|
||||
#include "qargs.h"
|
||||
//#include "lib_replace.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
# include <dlfcn.h>
|
||||
#endif
|
||||
#ifndef RTLD_LAZY
|
||||
# ifdef DL_LAZY
|
||||
# define RTLD_LAZY DL_LAZY
|
||||
# else
|
||||
# define RTLD_LAZY 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/fxmesa.h>
|
||||
#include <glide/sst1vid.h>
|
||||
|
||||
#define WARP_WIDTH 320
|
||||
#define WARP_HEIGHT 200
|
||||
|
||||
|
||||
//unsigned short d_8to16table[256];
|
||||
unsigned d_8to24table[256];
|
||||
unsigned char d_15to8table[65536];
|
||||
|
||||
static cvar_t *vid_mode;
|
||||
static cvar_t *vid_redrawfull;
|
||||
static cvar_t *vid_waitforrefresh;
|
||||
extern cvar_t *gl_triplebuffer;
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
static void *dlhand = NULL;
|
||||
#endif
|
||||
|
||||
static fxMesaContext fc = NULL;
|
||||
static int scr_width, scr_height;
|
||||
static qboolean is8bit = 0;
|
||||
|
||||
int VID_options_items = 0;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
//int texture_mode = GL_NEAREST;
|
||||
//int texture_mode = GL_NEAREST_MIPMAP_NEAREST;
|
||||
//int texture_mode = GL_NEAREST_MIPMAP_LINEAR;
|
||||
int texture_mode = GL_LINEAR;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_NEAREST;
|
||||
//int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
|
||||
|
||||
int texture_extension_number = 1;
|
||||
|
||||
float gldepthmin, gldepthmax;
|
||||
|
||||
const char *gl_vendor;
|
||||
const char *gl_renderer;
|
||||
const char *gl_version;
|
||||
const char *gl_extensions;
|
||||
|
||||
// ARB Multitexture
|
||||
int gl_mtex_enum = TEXTURE0_SGIS;
|
||||
qboolean gl_arb_mtex = false;
|
||||
qboolean gl_mtexable = false;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
||||
{
|
||||
}
|
||||
|
||||
void D_EndDirectRect (int x, int y, int width, int height)
|
||||
{
|
||||
}
|
||||
|
||||
void VID_Shutdown(void)
|
||||
{
|
||||
if (!fc)
|
||||
return;
|
||||
|
||||
fxMesaDestroyContext(fc);
|
||||
}
|
||||
|
||||
void signal_handler(int sig)
|
||||
{
|
||||
printf("Received signal %d, exiting...\n", sig);
|
||||
Host_Shutdown();
|
||||
abort();
|
||||
//Sys_Quit();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void VID_ShiftPalette(unsigned char *p)
|
||||
{
|
||||
// VID_SetPalette(p);
|
||||
}
|
||||
|
||||
void VID_SetPalette (unsigned char *palette)
|
||||
{
|
||||
byte *pal;
|
||||
unsigned r,g,b;
|
||||
unsigned v;
|
||||
int r1,g1,b1;
|
||||
int k;
|
||||
unsigned short i;
|
||||
unsigned *table;
|
||||
FILE *f;
|
||||
char s[255];
|
||||
//#endif
|
||||
float dist, bestdist;
|
||||
//
|
||||
// 8 8 8 encoding
|
||||
//
|
||||
Con_Printf("Converting 8to24\n");
|
||||
|
||||
pal = palette;
|
||||
table = d_8to24table;
|
||||
for (i=0 ; i<256 ; i++)
|
||||
{
|
||||
r = pal[0];
|
||||
g = pal[1];
|
||||
b = pal[2];
|
||||
pal += 3;
|
||||
|
||||
// v = (255<<24) + (r<<16) + (g<<8) + (b<<0);
|
||||
// v = (255<<0) + (r<<8) + (g<<16) + (b<<24);
|
||||
v = (255<<24) + (r<<0) + (g<<8) + (b<<16);
|
||||
*table++ = v;
|
||||
}
|
||||
d_8to24table[255] = 0; // 255 is transparent
|
||||
|
||||
// JACK: 3D distance calcs - k is last closest, l is the distance.
|
||||
{
|
||||
static qboolean palflag = false;
|
||||
|
||||
// FIXME: Precalculate this and cache to disk.
|
||||
if (palflag)
|
||||
return;
|
||||
palflag = true;
|
||||
}
|
||||
|
||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||
if (f) {
|
||||
fread(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
} else
|
||||
{
|
||||
for (i=0; i < (1<<15); i++) {
|
||||
/* Maps
|
||||
000000000000000
|
||||
000000000011111 = Red = 0x1F
|
||||
000001111100000 = Blue = 0x03E0
|
||||
111110000000000 = Grn = 0x7C00
|
||||
*/
|
||||
r = ((i & 0x1F) << 3)+4;
|
||||
g = ((i & 0x03E0) >> 2)+4;
|
||||
b = ((i & 0x7C00) >> 7)+4;
|
||||
pal = (unsigned char *)d_8to24table;
|
||||
for (v=0,k=0,bestdist=10000.0; v<256; v++,pal+=4) {
|
||||
r1 = (int)r - (int)pal[0];
|
||||
g1 = (int)g - (int)pal[1];
|
||||
b1 = (int)b - (int)pal[2];
|
||||
dist = sqrt(((r1*r1)+(g1*g1)+(b1*b1)));
|
||||
if (dist < bestdist) {
|
||||
k=v;
|
||||
bestdist = dist;
|
||||
}
|
||||
}
|
||||
d_15to8table[i]=k;
|
||||
}
|
||||
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (s);
|
||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||
if ((f = fopen(s, "wb")) != NULL) {
|
||||
fwrite(d_15to8table, 1<<15, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
CheckMultiTextureExtensions
|
||||
|
||||
Check for ARB, SGIS, or EXT multitexture support
|
||||
*/
|
||||
void
|
||||
CheckMultiTextureExtensions ( void )
|
||||
{
|
||||
Con_Printf ("Checking for multitexture... ");
|
||||
if (COM_CheckParm ("-nomtex"))
|
||||
{
|
||||
Con_Printf ("disabled\n");
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_DLOPEN
|
||||
dlhand = dlopen (NULL, RTLD_LAZY);
|
||||
if (dlhand == NULL)
|
||||
{
|
||||
Con_Printf ("unable to check\n");
|
||||
return;
|
||||
}
|
||||
if (strstr(gl_extensions, "GL_ARB_multitexture "))
|
||||
{
|
||||
Con_Printf ("GL_ARB_multitexture\n");
|
||||
qglMTexCoord2f = (void *)dlsym(dlhand, "glMultiTexCoord2fARB");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "glActiveTextureARB");
|
||||
gl_mtex_enum = GL_TEXTURE0_ARB;
|
||||
gl_mtexable = true;
|
||||
gl_arb_mtex = true;
|
||||
} else if (strstr(gl_extensions, "GL_SGIS_multitexture "))
|
||||
{
|
||||
Con_Printf ("GL_SGIS_multitexture\n");
|
||||
qglMTexCoord2f = (void *)dlsym(dlhand, "glMTexCoord2fSGIS");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureSGIS");
|
||||
gl_mtex_enum = TEXTURE0_SGIS;
|
||||
gl_mtexable = true;
|
||||
gl_arb_mtex = false;
|
||||
} else if (strstr(gl_extensions, "GL_EXT_multitexture "))
|
||||
{
|
||||
Con_Printf ("GL_EXT_multitexture\n");
|
||||
qglMTexCoord2f = (void *)dlsym(dlhand, "glMTexCoord2fEXT");
|
||||
qglSelectTexture = (void *)dlsym(dlhand, "glSelectTextureEXT");
|
||||
gl_mtex_enum = TEXTURE0_SGIS;
|
||||
gl_mtexable = true;
|
||||
gl_arb_mtex = false;
|
||||
} else {
|
||||
Con_Printf ("none found\n");
|
||||
}
|
||||
dlclose(dlhand);
|
||||
dlhand = NULL;
|
||||
#else
|
||||
gl_mtexable = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
typedef void (GLAPIENTRY *gl3DfxSetDitherModeEXT_FUNC) (GrDitherMode_t mode);
|
||||
|
||||
/*
|
||||
===============
|
||||
GL_Init
|
||||
===============
|
||||
*/
|
||||
void GL_Init (void)
|
||||
{
|
||||
gl_vendor = glGetString (GL_VENDOR);
|
||||
Con_Printf ("GL_VENDOR: %s\n", gl_vendor);
|
||||
gl_renderer = glGetString (GL_RENDERER);
|
||||
Con_Printf ("GL_RENDERER: %s\n", gl_renderer);
|
||||
|
||||
gl_version = glGetString (GL_VERSION);
|
||||
Con_Printf ("GL_VERSION: %s\n", gl_version);
|
||||
gl_extensions = glGetString (GL_EXTENSIONS);
|
||||
Con_Printf ("GL_EXTENSIONS: %s\n", gl_extensions);
|
||||
|
||||
CheckMultiTextureExtensions ();
|
||||
|
||||
glClearColor (1,0,0,0);
|
||||
glCullFace(GL_FRONT);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, 0.666);
|
||||
|
||||
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
|
||||
glShadeModel (GL_FLAT);
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
Con_Printf ("Dithering: ");
|
||||
|
||||
dlhand = dlopen (NULL, RTLD_LAZY);
|
||||
|
||||
if (dlhand == NULL) {
|
||||
Con_SafePrintf ("unable to set.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr(gl_extensions, "3DFX_set_dither_mode")) {
|
||||
gl3DfxSetDitherModeEXT_FUNC dither_select = NULL;
|
||||
|
||||
dither_select = (void *) dlsym(dlhand, "gl3DfxSetDitherModeEXT");
|
||||
|
||||
if (COM_CheckParm ("-dither_2x2")) {
|
||||
dither_select(GR_DITHER_2x2);
|
||||
Con_Printf ("2x2.\n");
|
||||
} else if (COM_CheckParm ("-dither_4x4")) {
|
||||
dither_select(GR_DITHER_4x4);
|
||||
Con_Printf ("4x4.\n");
|
||||
} else {
|
||||
glDisable(GL_DITHER);
|
||||
Con_Printf ("disabled.\n");
|
||||
}
|
||||
}
|
||||
dlclose(dlhand);
|
||||
dlhand = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
GL_BeginRendering
|
||||
|
||||
=================
|
||||
*/
|
||||
void GL_BeginRendering (int *x, int *y, int *width, int *height)
|
||||
{
|
||||
*x = *y = 0;
|
||||
*width = scr_width;
|
||||
*height = scr_height;
|
||||
|
||||
// if (!wglMakeCurrent( maindc, baseRC ))
|
||||
// Sys_Error ("wglMakeCurrent failed");
|
||||
|
||||
// glViewport (*x, *y, *width, *height);
|
||||
}
|
||||
|
||||
|
||||
void GL_EndRendering (void)
|
||||
{
|
||||
glFlush();
|
||||
fxMesaSwapBuffers();
|
||||
Sbar_Changed ();
|
||||
}
|
||||
|
||||
static int resolutions[][3]={
|
||||
{ 320, 200, GR_RESOLUTION_320x200 },
|
||||
{ 320, 240, GR_RESOLUTION_320x240 },
|
||||
{ 400, 256, GR_RESOLUTION_400x256 },
|
||||
{ 400, 300, GR_RESOLUTION_400x300 },
|
||||
{ 512, 256, GR_RESOLUTION_512x256 },
|
||||
{ 512, 384, GR_RESOLUTION_512x384 },
|
||||
{ 640, 200, GR_RESOLUTION_640x200 },
|
||||
{ 640, 350, GR_RESOLUTION_640x350 },
|
||||
{ 640, 400, GR_RESOLUTION_640x400 },
|
||||
{ 640, 480, GR_RESOLUTION_640x480 },
|
||||
{ 800, 600, GR_RESOLUTION_800x600 },
|
||||
{ 856, 480, GR_RESOLUTION_856x480 },
|
||||
{ 960, 720, GR_RESOLUTION_960x720 },
|
||||
#ifdef GR_RESOLUTION_1024x768
|
||||
{ 1024, 768, GR_RESOLUTION_1024x768 },
|
||||
#endif
|
||||
#ifdef GR_RESOLUTION_1152x864
|
||||
{ 1152, 864, GR_RESOLUTION_1152x864 },
|
||||
#endif
|
||||
#ifdef GR_RESOLUTION_1280x960
|
||||
{ 1280, 960, GR_RESOLUTION_1280x960 },
|
||||
#endif
|
||||
#ifdef GR_RESOLUTION_1280x1024
|
||||
{ 1280, 1024, GR_RESOLUTION_1280x1024 },
|
||||
#endif
|
||||
#ifdef GR_RESOLUTION_1600x1024
|
||||
{ 1600, 1024, GR_RESOLUTION_1600x1024 },
|
||||
#endif
|
||||
#ifdef GR_RESOLUTION_1600x1200
|
||||
{ 1600, 1200, GR_RESOLUTION_1600x1200 },
|
||||
#endif
|
||||
#ifdef GR_RESOLUTION_1792x1344
|
||||
{ 1792, 1344, GR_RESOLUTION_1792x1344 },
|
||||
#endif
|
||||
#ifdef GR_RESOLUTION_1856x1392
|
||||
{ 1856, 1392, GR_RESOLUTION_1856x1392 },
|
||||
#endif
|
||||
#ifdef GR_RESOLUTION_1920x1440
|
||||
{ 1920, 1440, GR_RESOLUTION_1920x1440 },
|
||||
#endif
|
||||
#ifdef GR_RESOLUTION_2048x1536
|
||||
{ 2048, 1536, GR_RESOLUTION_2048x1536 },
|
||||
#endif
|
||||
#ifdef GR_RESOLUTION_2048x2048
|
||||
{ 2048, 2048, GR_RESOLUTION_2048x2048 }
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NUM_RESOLUTIONS (sizeof(resolutions)/(sizeof(int)*3))
|
||||
|
||||
|
||||
static int
|
||||
findres(int *width, int *height)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i < NUM_RESOLUTIONS; i++) {
|
||||
if((*width <= resolutions[i][0]) &&
|
||||
(*height <= resolutions[i][1])) {
|
||||
*width = resolutions[i][0];
|
||||
*height = resolutions[i][1];
|
||||
return resolutions[i][2];
|
||||
}
|
||||
}
|
||||
|
||||
*width = 640;
|
||||
*height = 480;
|
||||
return GR_RESOLUTION_640x480;
|
||||
}
|
||||
|
||||
qboolean VID_Is8bit(void)
|
||||
{
|
||||
return is8bit;
|
||||
}
|
||||
|
||||
typedef void (GLAPIENTRY *glColorTableEXT_FUNC) (GLenum, GLenum, GLsizei,
|
||||
GLenum, GLenum, const GLvoid *);
|
||||
typedef void (GLAPIENTRY *gl3DfxSetPaletteEXT_FUNC) (GLuint *pal);
|
||||
|
||||
void VID_Init8bitPalette()
|
||||
{
|
||||
// Check for 8bit Extensions and initialize them.
|
||||
int i;
|
||||
|
||||
dlhand = dlopen (NULL, RTLD_LAZY);
|
||||
|
||||
Con_SafePrintf ("8-bit GL extensions: ");
|
||||
|
||||
if (dlhand == NULL) {
|
||||
Con_SafePrintf ("unable to check.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (COM_CheckParm("-no8bit")) {
|
||||
Con_SafePrintf("disabled.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr(gl_extensions, "3DFX_set_global_palette")) {
|
||||
char *oldpal;
|
||||
GLubyte table[256][4];
|
||||
gl3DfxSetPaletteEXT_FUNC load_texture = NULL;
|
||||
|
||||
Con_SafePrintf("3DFX_set_global_palette.\n");
|
||||
load_texture = (void *) dlsym(dlhand, "gl3DfxSetPaletteEXT");
|
||||
|
||||
glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
|
||||
oldpal = (char *) d_8to24table; //d_8to24table3dfx;
|
||||
for (i=0;i<256;i++) {
|
||||
table[i][2] = *oldpal++;
|
||||
table[i][1] = *oldpal++;
|
||||
table[i][0] = *oldpal++;
|
||||
table[i][3] = 255;
|
||||
oldpal++;
|
||||
}
|
||||
load_texture((GLuint *)table);
|
||||
is8bit = true;
|
||||
} else if (strstr(gl_extensions, "GL_EXT_shared_texture_palette")) {
|
||||
char thePalette[256*3];
|
||||
char *oldPalette, *newPalette;
|
||||
glColorTableEXT_FUNC load_texture = NULL;
|
||||
|
||||
Con_SafePrintf("GL_EXT_shared.\n");
|
||||
load_texture = (void *) dlsym(dlhand, "glColorTableEXT");
|
||||
|
||||
glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
|
||||
oldPalette = (char *) d_8to24table; //d_8to24table3dfx;
|
||||
newPalette = thePalette;
|
||||
for (i=0;i<256;i++) {
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
*newPalette++ = *oldPalette++;
|
||||
oldPalette++;
|
||||
}
|
||||
load_texture(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
|
||||
is8bit = true;
|
||||
}
|
||||
|
||||
dlclose(dlhand);
|
||||
dlhand = NULL;
|
||||
Con_SafePrintf ("not found.\n");
|
||||
}
|
||||
|
||||
void VID_Init(unsigned char *palette)
|
||||
{
|
||||
int i;
|
||||
GLint attribs[32];
|
||||
char gldir[MAX_OSPATH];
|
||||
int width = 640, height = 480;
|
||||
|
||||
vid_mode = Cvar_Get ("vid_mode", "5", 0, "None");
|
||||
vid_redrawfull = Cvar_Get ("vid_redrawfull", "0", 0," None");
|
||||
vid_waitforrefresh = Cvar_Get ("vid_waitforrefresh", "0", CVAR_ARCHIVE,
|
||||
"None");
|
||||
|
||||
vid.maxwarpwidth = WARP_WIDTH;
|
||||
vid.maxwarpheight = WARP_HEIGHT;
|
||||
vid.colormap = host_colormap;
|
||||
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
|
||||
|
||||
// interpret command-line params
|
||||
|
||||
// set vid parameters
|
||||
attribs[0] = FXMESA_DOUBLEBUFFER;
|
||||
attribs[1] = FXMESA_ALPHA_SIZE;
|
||||
attribs[2] = 1;
|
||||
attribs[3] = FXMESA_DEPTH_SIZE;
|
||||
attribs[4] = 1;
|
||||
attribs[5] = FXMESA_NONE;
|
||||
|
||||
if ((i = COM_CheckParm("-width")) != 0)
|
||||
width = atoi(com_argv[i+1]);
|
||||
if ((i = COM_CheckParm("-height")) != 0)
|
||||
height = atoi(com_argv[i+1]);
|
||||
|
||||
if ((i = COM_CheckParm("-conwidth")) != 0)
|
||||
vid.conwidth = atoi(com_argv[i+1]);
|
||||
else
|
||||
vid.conwidth = 640;
|
||||
|
||||
vid.conwidth &= 0xfff8; // make it a multiple of eight
|
||||
|
||||
if (vid.conwidth < 320)
|
||||
vid.conwidth = 320;
|
||||
|
||||
// pick a conheight that matches with correct aspect
|
||||
vid.conheight = vid.conwidth*3 / 4;
|
||||
|
||||
if ((i = COM_CheckParm("-conheight")) != 0)
|
||||
vid.conheight = atoi(com_argv[i+1]);
|
||||
if (vid.conheight < 200)
|
||||
vid.conheight = 200;
|
||||
|
||||
fc = fxMesaCreateContext(0, findres(&width, &height), GR_REFRESH_75Hz,
|
||||
attribs);
|
||||
if (!fc)
|
||||
Sys_Error("Unable to create 3DFX context.\n");
|
||||
|
||||
scr_width = width;
|
||||
scr_height = height;
|
||||
|
||||
fxMesaMakeCurrent(fc);
|
||||
|
||||
if (vid.conheight > height)
|
||||
vid.conheight = height;
|
||||
if (vid.conwidth > width)
|
||||
vid.conwidth = width;
|
||||
vid.width = vid.conwidth;
|
||||
vid.height = vid.conheight;
|
||||
|
||||
vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0);
|
||||
vid.numpages = 2;
|
||||
|
||||
InitSig(); // trap evil signals
|
||||
|
||||
GL_Init();
|
||||
|
||||
snprintf(gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
||||
Sys_mkdir (gldir);
|
||||
|
||||
VID_SetPalette(palette);
|
||||
|
||||
// Check for 3DFX Extensions and initialize them.
|
||||
VID_Init8bitPalette();
|
||||
|
||||
Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
|
||||
|
||||
vid.recalc_refdef = 1; // force a surface cache flush
|
||||
}
|
||||
|
||||
void VID_ExtraOptionDraw(unsigned int options_draw_cursor)
|
||||
{
|
||||
/* Port specific Options menu entrys */
|
||||
}
|
||||
|
||||
void VID_ExtraOptionCmd(int option_cursor)
|
||||
{
|
||||
/*
|
||||
switch(option_cursor)
|
||||
{
|
||||
case 12: // Always start with 12
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
void VID_InitCvars ()
|
||||
{
|
||||
gl_triplebuffer = Cvar_Get ("gl_triplebuffer","1",CVAR_ARCHIVE,"None");
|
||||
}
|
||||
|
||||
void
|
||||
VID_LockBuffer ( void )
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VID_UnlockBuffer ( void )
|
||||
{
|
||||
}
|
||||
|
||||
void VID_SetCaption (char *text)
|
||||
{
|
||||
}
|
3451
source/vid_mgl.c
Normal file
3451
source/vid_mgl.c
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
1963
source/vid_wgl.c
Normal file
1963
source/vid_wgl.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue