- Applied patch from Vincent S. Cojot for solaris. He's

taken his patch against icculus.org's quake2 tree, and
  applied it to solaris/ and then migrated that stuff to our
  tree in src/ so it gets built.
This commit is contained in:
Jamie Wilkinson 2002-11-24 05:14:29 +00:00
parent a937e44276
commit bd911a47db
73 changed files with 17118 additions and 96 deletions

View file

@ -53,6 +53,21 @@ dnl --------------------
dnl Checks for libraries
dnl --------------------
AC_PATH_PROG(unamepath, uname)
if test "_$unamepath" = _; then
system="unknown"
else
AC_MSG_CHECKING(system type)
system=`$unamepath -s`
AC_MSG_RESULT($system)
if test "$system" = "SunOS"; then
SYSTEM_LIBS="$SYSTEM_LIBS -lsocket -lnsl"
else
SYSTEM_LIBS=""
fi
AC_SUBST(SYSTEM_LIBS)
fi
dnl Check for ossaudio on NetBSD
OSS_LIBS=""
AC_CHECK_LIB([ossaudio], [_oss_ioctl], [OSS_LIBS="-lossaudio"])
@ -98,6 +113,8 @@ dnl Check for X11
AC_PATH_XTRA
if test "x$no_x" = x; then
HAVE_X=yes
HAVE_XF86_VIDMODE=yes
HAVE_XF86_DGA=yes
XTRA_LIBS="-lX11"
AC_CHECK_LIB(Xext, XShmQueryExtension,
XTRA_LIBS="$XTRA_LIBS -lXext",
@ -110,11 +127,12 @@ if test "x$no_x" = x; then
AC_CHECK_HEADER(X11/extensions/xf86vmode.h,
dnl Make sure the library works
AC_CHECK_LIB(Xxf86vm, XF86VidModeSwitchToMode,
XTRA_LIBS="$XTRA_LIBS -lXxf86vm",
HAVE_X=no,
XTRA_LIBS="$XTRA_LIBS -lXxf86vm"
AC_DEFINE(HAVE_XF86_VIDMODE, 1, [Define this if you have the xf86vmode extension and its Xxf86vm library.]),
HAVE_XF86_VIDMODE=no,
[$X_LIBS $XTRA_LIBS $X_EXTRA_LIBS]
),
HAVE_X=no,
HAVE_XF86_VIDMODE=no,
[#include <X11/Xlib.h>]
)
CPPFLAGS="$save_CPPFLAGS"
@ -124,11 +142,12 @@ if test "x$no_x" = x; then
CPPFLAGS="$CPPFLAGS $X_CFLAGS"
AC_CHECK_HEADER(X11/extensions/xf86dga.h,
AC_CHECK_LIB(Xxf86dga, XF86DGAQueryVersion,
XTRA_LIBS="$XTRA_LIBS -lXxf86dga",
HAVE_X=no,
XTRA_LIBS="$XTRA_LIBS -lXxf86dga"
AC_DEFINE(HAVE_XF86_DGA, 1, [Define this if you have the xf86dga extension and its Xxf86dga library.]),
HAVE_XF86_DGA=no,
[$X_LIBS $XTRA_LIBS $X_EXTRA_LIBS]
),
HAVE_X=no,
HAVE_XF86_DGA=no,
[#include <X11/Xlib.h>]
)
CPPFLAGS="$save_CPPFLAGS"
@ -138,6 +157,8 @@ if test "x$no_x" = x; then
fi
fi
AC_SUBST(HAVE_X)
AC_SUBST(HAVE_XF86_VIDMODE)
AC_SUBST(HAVE_XF86_DGA)
AC_SUBST(XTRA_LIBS)
dnl Check for OpenGL
@ -170,6 +191,12 @@ if test "x$HAVE_OPENGL" != xno; then
[$OPENGL_LIBS]
)
fi
if test "x$HAVE_OPENGL" = xyes; then
AC_CHECK_HEADER(GL/glext.h, HAVE_OPENGL_GLEXT=yes
AC_DEFINE(HAVE_OPENGL_GLEXT, 1, [Define this if you have GL/glext.h]),
HAVE_OPENGL_GLEXT=no,
[#include <GL/gl.h>])
fi
if test "x$HAVE_OPENGL" != xyes; then
OPENGL_CFLAGS=""
OPENGL_LIBS=""
@ -208,7 +235,6 @@ dnl -----------------------
#AC_HEADER_DIRENT
#AC_HEADER_STDC
dnl AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([ soundcard.h ])
AC_CHECK_HEADERS([ sys/soundcard.h ])
dnl -------------------------------------------------------------
@ -299,8 +325,13 @@ AC_ARG_ENABLE(joystick,
[ --disable-joystick disable joystick support ],
AC_MSG_RESULT(no),
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_JOYSTICK, 1, [Define this if you want joystick support to be built])
HAVE_JOYSTICK=yes
)
if test "x$HAVE_JOYSTICK" = "xyes";then
AC_CHECK_HEADER(linux/joystick.h, HAVE_JOYSTICK=yes
AC_DEFINE(HAVE_JOYSTICK, 1, [Define this if you want joystick support to be built])
, HAVE_JOYSTICK=no)
fi
dnl -------------------------
dnl Optimising compiler flags
@ -361,6 +392,35 @@ case "${host}" in
esac
AM_CONDITIONAL(ASM_ARCH, test "$ASM_ARCH" = "yes")
dnl -------------------
dnl Checks for SDL-only platforms
dnl -------------------
AC_MSG_CHECKING(if SDL sound can be used instead of native drivers)
case "${host}" in
*-sun-solaris*)
AC_MSG_RESULT(yes)
AC_MSG_WARN(Defaulting to SDL sound under Solaris due to temporary lack of native support.)
BUILD_SDLQUAKE2=yes
AC_DEFINE(BUILD_SDLQUAKE2, 1, [Define this if you want SDL sound instead of native drivers])
;;
i?86-*-*)
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(if SDL sound will be used)
AC_ARG_ENABLE(sdlsound,
[ --enable-sdlsound enable SDL sound instead of native drivers ],
AC_MSG_RESULT(SDL sound enabled)
AC_DEFINE(BUILD_SDLQUAKE2, 1, [Define this if you want SDL sound instead of native drivers])
BUILD_SDLQUAKE2=yes,
AC_MSG_RESULT(SDL sound disabled\, using native drivers)
)
;;
*)
AC_MSG_RESULT(no)
;;
esac
AM_CONDITIONAL(BUILD_SDLQUAKE2, test "x$BUILD_SDLQUAKE2" = "xyes")
dnl ---------------------------------------------------
dnl Check if the xatrix and rogue sources are available
dnl ---------------------------------------------------
@ -466,4 +526,5 @@ AC_OUTPUT
VID_REFS=`echo $VID_REFS | sed -e 's/ref_//g' -e 's/\.la//g'`
AC_MSG_RESULT([
Video refreshers: ${VID_REFS- none}
Platform: ${host}
])

111
docs/README.Solaris Normal file
View file

@ -0,0 +1,111 @@
Updated. Wed Jul 31 14:06:00 MEST 2002
(Vincent S. Cojot <coyote@step.polymtl.ca>)
Tested with:
-----------------------------------------------------
Machine 1:
- Solaris 8 10/00 for Sparc on an Ultra2 (1300) with a Creator3D card.
- SDL-1.2.3 (http://www.libsdl.org)
- X11R6.4 (comes with Solaris 8).
- XIL-1.4 (comes with Solaris 8).
- OpenGL-1.2.2 (see http://www.sun.com/solaris/opengl if using Solaris 8
older than 10/01).
Machine 2:
- Solaris 8 02/02 for Sparc on a SunBlade 2000 (900Mhz CU) and XVR-1000 card.
- SDL-1.2.4 (http://www.libsdl.org)
- X11R6.4 (comes with Solaris 8).
- XIL-1.4 (comes with Solaris 8).
- OpenGL-1.2.3.
(BIG PROBLEM with Multi-Texturing: SEE BELOW)
Installation instructions:
-----------------------------------------------------
Use the README file at the top level for installation instructions..
See the Solaris-Specific make options at the top of
the Solaris Makefile (Makefile.Solaris). Most interesting options
are:
BUILD_X11=YES (for X11 rendering)
BUILD_GLX=YES (for GLX rendering)
BUILD_SDL=YES (for SDL rendering)
BUILD_SDLGL=YES (for GLX rendering with SDL)
BUILD_XIL=YES (for XIL rendering)
BUILD_CORONA=YES (for the SunRay Terminal, -unverified- by me since I don't have the SDK)
BUILD_DEDICATED=YES (Will build a dedicated quake2 server binary).
BUILD_SOLARIS_PKG=YES # Build a Solaris package of all of the binaries for use with pkgadd.
BUILD_DATA_PKG=YES # Build a Solaris package of the game (shareware or final) \
# data files for use with pkgadd.
Notes on packages:
-----------------------------------------------------
The "release" and "debug" packages of the binaries get built by default.
This should result in something like this:
# ls -la releasesparc/pkg/*pkg debugsparc/pkg/*pkg
-rw-r--r-- 1 root other 16548352 Aug 2 11:33 debugsparc/pkg/iDquake2-debug-r0.13.1-sparc.pkg
-rw-r--r-- 1 root other 5249536 Aug 2 11:27 releasesparc/pkg/iDquake2-release-r0.13.1-sparc.pkg
To build the the data "iDquake2d" package, edit the line in the Makefile
that says "PKG_DATA_BUILD_DIR=/usr/local/src/quake2-data/quake2" and point
it to the correct location for your data files.
Set BUILD_DATA_PKG=YES in Makefile.Solaris.
(WARNING: -everything- under ../baseq2 gets taken.
Next, run "gmake -f Makefile.Solaris".
This should result in something like this:
-rw-r--r-- 1 root other 52185600 Aug 2 11:27 releasesparc/pkg/iDquake2d-release-r0.13.1-sparc.pkg
After installation, you get:
# pkginfo |grep -i quake2
application iDquake2 ID Software Quake2 3.21 for Solaris 8 (X11,XIL,GLX,SDL)
application iDquake2d ID Software Quake2 shareware data files for Solaris 8 (X11,XIL,GLX,SDL)
What's working:
-----------------------------------------------------
- The Quake2 binary
- The SDL Quake2 binary (uses SDL for sound and CD).
- X11 rendering (ref_softx.so)
- XIL rendering (ref_xil.so) (Faster for some routines)
- SDL rendering (ref_softsdl.so) (Nice full screen effect on Solaris displays)
- GLX rendering (ref_glx.so) (Works semi-OK on my Ultra2/Creator3d but
it's s-l-o-w).
What's still broken:
-----------------------------------------------------
- SDLGL renderer (loads, colors are all wrong. Colormap
problem? Update: it may be an endianness problem in
SDL since it displays fine to a remote x86 Linux machine
with NVidia drivers. Being worked on, priority #2).
- quake2 and sdlquake2 Seg fault when quitting the game
(not a show stoppper but being worked on, priority #1).
Update: FIXED (replace exit(0) with commented out
_exit(0) in Sys_Quit() in src/solaris/sys_solaris.c.
- WARNING: On my new XVR-1000 card and with OpenGL-1.2.3
the textures are messed up and jumping in GLX mode!
All of the quake2-r versions hexibit this problem.
I'm investigating the issue....
Note: the Utah-GLX project has a quake2 solaris source
port that does -not- exhibit this problem (seems to be in
ref_gl).
Update: Sept 4th 2002: Sun has acknowledged the problem.
Patches 112565-05 (5.9) and 112564-05 (5.8) don't help.
It looks like a problem with multi-texturing but there
is a WORKAROUND: add the following to your quake2 cmd
line (without quotes): "+set gl_ext_multitexture 0"
Thank you!
-----------------------------------------------------
Thanks for this Solaris release go to:
- Martin englund and Elias Mårtensson from SUN (sweden).
They ported Quake2 to Solaris with XIL and OpenGL
and Martin made this release possible by contributing the source code
once Quake2 was open-source'd by Id Software in dec' 2001.
- Id software.
(for such a great multi-platform game, Zoid for porting it to Linux).
- The guys at icculus for hosting this quake2 project
(Steven Fuller, Brendan Burns and others..).
This file written by Vincent S. Cojot <coyote@step.polymtl.ca>
(Maintainer wannabe).

111
solaris/README.Solaris Normal file
View file

@ -0,0 +1,111 @@
Updated. Wed Jul 31 14:06:00 MEST 2002
(Vincent S. Cojot <coyote@step.polymtl.ca>)
Tested with:
-----------------------------------------------------
Machine 1:
- Solaris 8 10/00 for Sparc on an Ultra2 (1300) with a Creator3D card.
- SDL-1.2.3 (http://www.libsdl.org)
- X11R6.4 (comes with Solaris 8).
- XIL-1.4 (comes with Solaris 8).
- OpenGL-1.2.2 (see http://www.sun.com/solaris/opengl if using Solaris 8
older than 10/01).
Machine 2:
- Solaris 8 02/02 for Sparc on a SunBlade 2000 (900Mhz CU) and XVR-1000 card.
- SDL-1.2.4 (http://www.libsdl.org)
- X11R6.4 (comes with Solaris 8).
- XIL-1.4 (comes with Solaris 8).
- OpenGL-1.2.3.
(BIG PROBLEM with Multi-Texturing: SEE BELOW)
Installation instructions:
-----------------------------------------------------
Use the README file at the top level for installation instructions..
See the Solaris-Specific make options at the top of
the Solaris Makefile (Makefile.Solaris). Most interesting options
are:
BUILD_X11=YES (for X11 rendering)
BUILD_GLX=YES (for GLX rendering)
BUILD_SDL=YES (for SDL rendering)
BUILD_SDLGL=YES (for GLX rendering with SDL)
BUILD_XIL=YES (for XIL rendering)
BUILD_CORONA=YES (for the SunRay Terminal, -unverified- by me since I don't have the SDK)
BUILD_DEDICATED=YES (Will build a dedicated quake2 server binary).
BUILD_SOLARIS_PKG=YES # Build a Solaris package of all of the binaries for use with pkgadd.
BUILD_DATA_PKG=YES # Build a Solaris package of the game (shareware or final) \
# data files for use with pkgadd.
Notes on packages:
-----------------------------------------------------
The "release" and "debug" packages of the binaries get built by default.
This should result in something like this:
# ls -la releasesparc/pkg/*pkg debugsparc/pkg/*pkg
-rw-r--r-- 1 root other 16548352 Aug 2 11:33 debugsparc/pkg/iDquake2-debug-r0.13.1-sparc.pkg
-rw-r--r-- 1 root other 5249536 Aug 2 11:27 releasesparc/pkg/iDquake2-release-r0.13.1-sparc.pkg
To build the the data "iDquake2d" package, edit the line in the Makefile
that says "PKG_DATA_BUILD_DIR=/usr/local/src/quake2-data/quake2" and point
it to the correct location for your data files.
Set BUILD_DATA_PKG=YES in Makefile.Solaris.
(WARNING: -everything- under ../baseq2 gets taken.
Next, run "gmake -f Makefile.Solaris".
This should result in something like this:
-rw-r--r-- 1 root other 52185600 Aug 2 11:27 releasesparc/pkg/iDquake2d-release-r0.13.1-sparc.pkg
After installation, you get:
# pkginfo |grep -i quake2
application iDquake2 ID Software Quake2 3.21 for Solaris 8 (X11,XIL,GLX,SDL)
application iDquake2d ID Software Quake2 shareware data files for Solaris 8 (X11,XIL,GLX,SDL)
What's working:
-----------------------------------------------------
- The Quake2 binary
- The SDL Quake2 binary (uses SDL for sound and CD).
- X11 rendering (ref_softx.so)
- XIL rendering (ref_xil.so) (Faster for some routines)
- SDL rendering (ref_softsdl.so) (Nice full screen effect on Solaris displays)
- GLX rendering (ref_glx.so) (Works semi-OK on my Ultra2/Creator3d but
it's s-l-o-w).
What's still broken:
-----------------------------------------------------
- SDLGL renderer (loads, colors are all wrong. Colormap
problem? Update: it may be an endianness problem in
SDL since it displays fine to a remote x86 Linux machine
with NVidia drivers. Being worked on, priority #2).
- quake2 and sdlquake2 Seg fault when quitting the game
(not a show stoppper but being worked on, priority #1).
Update: FIXED (replace exit(0) with commented out
_exit(0) in Sys_Quit() in src/solaris/sys_solaris.c.
- WARNING: On my new XVR-1000 card and with OpenGL-1.2.3
the textures are messed up and jumping in GLX mode!
All of the quake2-r versions hexibit this problem.
I'm investigating the issue....
Note: the Utah-GLX project has a quake2 solaris source
port that does -not- exhibit this problem (seems to be in
ref_gl).
Update: Sept 4th 2002: Sun has acknowledged the problem.
Patches 112565-05 (5.9) and 112564-05 (5.8) don't help.
It looks like a problem with multi-texturing but there
is a WORKAROUND: add the following to your quake2 cmd
line (without quotes): "+set gl_ext_multitexture 0"
Thank you!
-----------------------------------------------------
Thanks for this Solaris release go to:
- Martin englund and Elias Mårtensson from SUN (sweden).
They ported Quake2 to Solaris with XIL and OpenGL
and Martin made this release possible by contributing the source code
once Quake2 was open-source'd by Id Software in dec' 2001.
- Id software.
(for such a great multi-platform game, Zoid for porting it to Linux).
- The guys at icculus for hosting this quake2 project
(Steven Fuller, Brendan Burns and others..).
This file written by Vincent S. Cojot <coyote@step.polymtl.ca>
(Maintainer wannabe).

383
solaris/cd_sdl.c Normal file
View file

@ -0,0 +1,383 @@
/*
snd_sdl.c
CD code taken from SDLQuake and modified to work with Quake2
Robert Bäuml 2001-12-25
W.P. van Paassen 2002-01-06
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 <stdio.h>
#include "SDL.h"
#include "../client/client.h"
static qboolean cdValid = false;
static qboolean initialized = false;
static qboolean enabled = true;
static qboolean playLooping = false;
static SDL_CD *cd_id;
static float cdvolume = 1.0;
static int lastTrack = 0;
cvar_t *cd_volume;
cvar_t *cd_nocd;
cvar_t *cd_dev;
static void CD_f();
static void CDAudio_Eject()
{
if(!cd_id || !enabled) return;
if(SDL_CDEject(cd_id))
Com_DPrintf("Unable to eject CD-ROM tray.\n");
}
void CDAudio_Play(int track, qboolean looping)
{
CDstatus cd_stat;
lastTrack = track+1;
if(!cd_id || !enabled) return;
cd_stat=SDL_CDStatus(cd_id);
if(!cdValid)
{
if(!CD_INDRIVE(cd_stat) ||(!cd_id->numtracks)) return;
cdValid = true;
}
if((track < 1) || (track >= cd_id->numtracks))
{
Com_DPrintf("CDAudio: Bad track number: %d\n",track);
return;
}
track--; /* Convert track from person to SDL value */
if(cd_stat == CD_PLAYING)
{
if(cd_id->cur_track == track) return;
CDAudio_Stop();
}
if(SDL_CDPlay(cd_id,cd_id->track[track].offset,
cd_id->track[track].length))
{
Com_DPrintf("CDAudio_Play: Unable to play track: %d (%s)\n",track+1, SDL_GetError());
return;
}
playLooping = looping;
}
void CDAudio_RandomPlay(void)
{
int track, i = 0, free_tracks = 0;
float f;
CDstatus cd_stat;
byte* track_bools;
if (!cd_id || !enabled)
return;
track_bools = (byte*)malloc(cd_id->numtracks* sizeof(byte));
if (track_bools == 0)
return;
//create array of available audio tracknumbers
for (; i < cd_id->numtracks; i++)
{
track_bools[i] = cd_id->track[i].type == SDL_AUDIO_TRACK;
free_tracks += track_bools[i];
}
if (!free_tracks)
{
Com_DPrintf("CDAudio_RandomPlay: Unable to find and play a random audio track, insert an audio cd please");
goto free_end;
}
//choose random audio track
do
{
do
{
f = ((float)rand()) / ((float)RAND_MAX + 1.0);
track = (int)(cd_id->numtracks * f);
}
while(!track_bools[track]);
lastTrack = track+1;
cd_stat=SDL_CDStatus(cd_id);
if(!cdValid)
{
if(!CD_INDRIVE(cd_stat) ||(!cd_id->numtracks))
{
goto free_end;
}
cdValid = true;
}
if(cd_stat == CD_PLAYING)
{
if(cd_id->cur_track == track + 1)
{
goto free_end;
}
CDAudio_Stop();
}
if (SDL_CDPlay(cd_id,cd_id->track[track].offset,
cd_id->track[track].length))
{
track_bools[track] = 0;
free_tracks--;
}
else
{
playLooping = true;
break;
}
}
while (free_tracks > 0);
free_end:
free((void*)track_bools);
}
void CDAudio_Stop()
{
int cdstate;
if(!cd_id || !enabled) return;
cdstate = SDL_CDStatus(cd_id);
if((cdstate != CD_PLAYING) && (cdstate != CD_PAUSED)) return;
if(SDL_CDStop(cd_id))
Com_DPrintf("CDAudio_Stop: Failed to stop track.\n");
playLooping = 0;
}
void CDAudio_Pause()
{
if(!cd_id || !enabled) return;
if(SDL_CDStatus(cd_id) != CD_PLAYING) return;
if(SDL_CDPause(cd_id))
Com_DPrintf("CDAudio_Pause: Failed to pause track.\n");
}
void CDAudio_Resume()
{
if(!cd_id || !enabled) return;
if(SDL_CDStatus(cd_id) != CD_PAUSED) return;
if(SDL_CDResume(cd_id))
Com_DPrintf("CDAudio_Resume: Failed to resume track.\n");
}
void CDAudio_Update()
{
if(!cd_id || !enabled) return;
if(cd_volume && cd_volume->value != cdvolume)
{
if(cdvolume)
{
Cvar_SetValue("cd_volume",0.0);
CDAudio_Pause();
}
else
{
Cvar_SetValue("cd_volume",1.0);
CDAudio_Resume();
}
cdvolume = cd_volume->value;
return;
}
if(cd_nocd->value)
{
CDAudio_Stop();
return;
}
if(playLooping &&
(SDL_CDStatus(cd_id) != CD_PLAYING) &&
(SDL_CDStatus(cd_id) != CD_PAUSED))
{
CDAudio_Play(lastTrack,true);
}
}
int CDAudio_Init()
{
cvar_t *cv;
if (initialized)
return 0;
cv = Cvar_Get ("nocdaudio", "0", CVAR_NOSET);
if (cv->value)
return -1;
cd_nocd = Cvar_Get ("cd_nocd", "0", CVAR_ARCHIVE );
if ( cd_nocd->value)
return -1;
cd_volume = Cvar_Get ("cd_volume", "1", CVAR_ARCHIVE);
if (SDL_WasInit(SDL_INIT_EVERYTHING) == 0) {
if (SDL_Init(SDL_INIT_CDROM) < 0) {
Com_Printf ("Couldn't init SDL cdrom: %s\n", SDL_GetError ());
return -1;
}
} else if (SDL_WasInit(SDL_INIT_CDROM) == 0) {
if (SDL_InitSubSystem(SDL_INIT_CDROM) < 0) {
Com_Printf ("Couldn't init SDL cdrom: %s\n", SDL_GetError ());
return -1;
}
}
cd_id = SDL_CDOpen(0);
if(!cd_id)
{
Com_Printf("CDAudio_Init: Unable to open default CD-ROM drive: %s\n",
SDL_GetError());
return -1;
}
initialized = true;
enabled = true;
cdValid = true;
if(!CD_INDRIVE(SDL_CDStatus(cd_id)))
{
Com_Printf("CDAudio_Init: No CD in drive.\n");
cdValid = false;
}
if(!cd_id->numtracks)
{
Com_Printf("CDAudio_Init: CD contains no audio tracks.\n");
cdValid = false;
}
Cmd_AddCommand("cd",CD_f);
Com_Printf("CD Audio Initialized.\n");
return 0;
}
void CDAudio_Shutdown()
{
if(!cd_id) return;
CDAudio_Stop();
SDL_CDClose(cd_id);
cd_id = NULL;
if (SDL_WasInit(SDL_INIT_EVERYTHING) == SDL_INIT_CDROM)
SDL_Quit();
else
SDL_QuitSubSystem(SDL_INIT_CDROM);
initialized = false;
}
static void CD_f()
{
char *command;
int cdstate;
if(Cmd_Argc() < 2) return;
command = Cmd_Argv(1);
if(!Q_strcasecmp(command,"on"))
{
enabled = true;
}
if(!Q_strcasecmp(command,"off"))
{
if(!cd_id) return;
cdstate = SDL_CDStatus(cd_id);
if((cdstate == CD_PLAYING) || (cdstate == CD_PAUSED))
CDAudio_Stop();
enabled = false;
return;
}
if(!Q_strcasecmp(command,"play"))
{
CDAudio_Play((byte)atoi(Cmd_Argv(2)),false);
return;
}
if(!Q_strcasecmp(command,"loop"))
{
CDAudio_Play((byte)atoi(Cmd_Argv(2)),true);
return;
}
if(!Q_strcasecmp(command,"stop"))
{
CDAudio_Stop();
return;
}
if(!Q_strcasecmp(command,"pause"))
{
CDAudio_Pause();
return;
}
if(!Q_strcasecmp(command,"resume"))
{
CDAudio_Resume();
return;
}
if(!Q_strcasecmp(command,"eject"))
{
CDAudio_Eject();
return;
}
if(!Q_strcasecmp(command,"info"))
{
if(!cd_id) return;
cdstate = SDL_CDStatus(cd_id);
Com_Printf("%d tracks\n",cd_id->numtracks);
if(cdstate == CD_PLAYING)
Com_Printf("Currently %s track %d\n",
playLooping ? "looping" : "playing",
cd_id->cur_track+1);
else
if(cdstate == CD_PAUSED)
Com_Printf("Paused %s track %d\n",
playLooping ? "looping" : "playing",
cd_id->cur_track+1);
return;
}
}
void CDAudio_Activate (qboolean active)
{
if (active)
CDAudio_Resume ();
else
CDAudio_Pause ();
}

64
solaris/cd_solaris.c Normal file
View file

@ -0,0 +1,64 @@
/*
Copyright (C) 1997-2001 Id Software, 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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <sys/types.h>
#include "../client/client.h"
void CDAudio_Play(int track, qboolean looping)
{
// Com_Printf("XXX - CDAudio_Play %i (%i)\n", track, looping);
}
void CDAudio_RandomPlay(void)
{
// Com_Printf("XXX - CDAudio_RandomPlay\n");
}
void CDAudio_Stop(void)
{
// Com_Printf("XXX - CDAudio_Stop\n");
}
void CDAudio_Resume(void)
{
// Com_Printf("XXX - CDAudio_Resume\n");
}
void CDAudio_Update(void)
{
// Com_Printf("XXX - CDAudio_Update\n");
}
int CDAudio_Init(void)
{
// Com_Printf("XXX - CDAudio_Init\n");
return 0;
}
void CDAudio_Shutdown(void)
{
// Com_Printf("XXX - CDAudio_Shutdown\n");
}

952
solaris/gl_glx.c Normal file
View file

@ -0,0 +1,952 @@
/*
Copyright (C) 1997-2001 Id Software, 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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
** GLW_IMP.C
**
** This file contains ALL Solaris specific stuff having to do with the
** OpenGL refresh. When a port is being made the following functions
** must be implemented by the port:
**
** GLimp_EndFrame
** GLimp_Init
** GLimp_Shutdown
** GLimp_SwitchFullscreen
**
*/
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <stdarg.h>
#include <stdio.h>
#include <signal.h>
#include <dlfcn.h>
#include <GL/glx.h>
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#include <X11/Sunkeysym.h>
#include "../ref_gl/gl_local.h"
#include "../client/keys.h"
#include "../solaris/rw_solaris.h"
#include "../solaris/glw_solaris.h"
#include "../solaris/gl_glx.h"
glwstate_t glw_state;
static Display *dpy = NULL;
static int scrnum;
static Window win;
static GLXContext ctx = NULL;
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | \
PointerMotionMask | ButtonMotionMask )
#define X_MASK (KEY_MASK | MOUSE_MASK | VisibilityChangeMask | StructureNotifyMask )
struct
{
int key;
int down;
} keyq[64];
static int keyq_head=0;
static int keyq_tail=0;
static int window_width;
static int window_height;
/*****************************************************************************/
/* MOUSE */
/*****************************************************************************/
// this is inside the renderer shared lib, so these are called from vid_so
static qboolean mouse_avail;
static int mouse_buttonstate;
static int mouse_oldbuttonstate;
static int mouse_x, mouse_y;
static int old_mouse_x, old_mouse_y;
static int mx, my;
static int old_windowed_mouse;
static int p_mouse_x, p_mouse_y;
static cvar_t *_windowed_mouse;
static cvar_t *m_filter;
static cvar_t *in_mouse;
static qboolean mlooking;
static qboolean mouse_active = false;
// stencilbuffer shadows
qboolean have_stencil = false;
// state struct passed in Init
static in_state_t *in_state;
static cvar_t *sensitivity;
static cvar_t *lookstrafe;
static cvar_t *m_side;
static cvar_t *m_yaw;
static cvar_t *m_pitch;
static cvar_t *m_forward;
static cvar_t *freelook;
static cvar_t *r_fakeFullscreen;
static Cursor CreateNullCursor(Display *display, Window root)
{
Pixmap cursormask;
XGCValues xgc;
GC gc;
XColor dummycolour;
Cursor cursor;
cursormask = XCreatePixmap( display, root, 1, 1, 1 );
xgc.function = GXclear;
gc = XCreateGC( display, cursormask, GCFunction, &xgc );
XFillRectangle( display, cursormask, gc, 0, 0, 1, 1 );
dummycolour.pixel = 0;
dummycolour.red = 0;
dummycolour.flags = DoRed;
cursor = XCreatePixmapCursor( display, cursormask, cursormask,
&dummycolour, &dummycolour, 0,0 );
XFreePixmap( display, cursormask );
XFreeGC( display, gc );
return cursor;
}
static void install_grabs(void)
{
// inviso cursor
XDefineCursor(dpy, win, CreateNullCursor(dpy, win));
XGrabPointer(dpy, win,
True,
0,
GrabModeAsync, GrabModeAsync,
win,
None,
CurrentTime);
#ifdef __linux__
if (in_dgamouse->value) {
int MajorVersion, MinorVersion;
if (!XF86DGAQueryVersion(dpy, &MajorVersion, &MinorVersion)) {
// unable to query, probalby not supported
VID_Printf( PRINT_ALL, "Failed to detect XF86DGA Mouse\n" );
Cvar_Set( "in_dgamouse", "0" );
} else {
dgamouse = true;
XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
}
} else
#endif /*__linux__ */
{
XWarpPointer(dpy, None, win,
0, 0, 0, 0,
vid.width / 2, vid.height / 2);
}
XGrabKeyboard(dpy, win,
False,
GrabModeAsync, GrabModeAsync,
CurrentTime);
mouse_active = true;
// XSync(dpy, True);
}
static void uninstall_grabs(void)
{
if (!dpy || !win)
return;
#ifdef __linux__
if (dgamouse) {
dgamouse = false;
XF86DGADirectVideo(dpy, DefaultScreen(dpy), 0);
}
#endif
XUngrabPointer(dpy, CurrentTime);
XUngrabKeyboard(dpy, CurrentTime);
// inviso cursor
XUndefineCursor(dpy, win);
mouse_active = false;
}
static void Force_CenterView_f (void)
{
in_state->viewangles[PITCH] = 0;
}
static void RW_IN_MLookDown (void)
{
mlooking = true;
}
static void RW_IN_MLookUp (void)
{
mlooking = false;
in_state->IN_CenterView_fp ();
}
void RW_IN_Init(in_state_t *in_state_p)
{
int mtype;
int i;
in_state = in_state_p;
// mouse variables
_windowed_mouse = ri.Cvar_Get( "_windowed_mouse", "0", CVAR_ARCHIVE );
m_filter = ri.Cvar_Get ("m_filter", "0", 0);
in_mouse = ri.Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
freelook = ri.Cvar_Get( "freelook", "0", 0 );
lookstrafe = ri.Cvar_Get ("lookstrafe", "0", 0);
sensitivity = ri.Cvar_Get ("sensitivity", "3", 0);
m_pitch = ri.Cvar_Get ("m_pitch", "0.022", 0);
m_yaw = ri.Cvar_Get ("m_yaw", "0.022", 0);
m_forward = ri.Cvar_Get ("m_forward", "1", 0);
m_side = ri.Cvar_Get ("m_side", "0.8", 0);
ri.Cmd_AddCommand ("+mlook", RW_IN_MLookDown);
ri.Cmd_AddCommand ("-mlook", RW_IN_MLookUp);
ri.Cmd_AddCommand ("force_centerview", Force_CenterView_f);
mx = my = 0.0;
mouse_avail = true;
}
void RW_IN_Shutdown(void)
{
mouse_avail = false;
ri.Cmd_RemoveCommand( "+mlook" );
ri.Cmd_RemoveCommand( "-mlook" );
ri.Cmd_RemoveCommand( "force_centerview" );}
/*
===========
IN_Commands
===========
*/
void RW_IN_Commands (void)
{
int i;
if (!mouse_avail)
return;
for( i = 0 ; i < 3 ; i++ ) {
if( (mouse_buttonstate & (1<<i)) && !(mouse_oldbuttonstate & (1<<i)) ) {
in_state->Key_Event_fp (K_MOUSE1 + i, true);
}
if( !(mouse_buttonstate & (1<<i)) && (mouse_oldbuttonstate & (1<<i)) ) {
in_state->Key_Event_fp (K_MOUSE1 + i, false);
}
}
mouse_oldbuttonstate = mouse_buttonstate;
}
/*
===========
IN_Move
===========
*/
void RW_IN_Move (usercmd_t *cmd)
{
if (!mouse_avail)
return;
if( m_filter->value )
{
mx = (mx + old_mouse_x) * 0.5;
my = (my + old_mouse_y) * 0.5;
}
old_mouse_x = mx;
old_mouse_y = my;
mx *= sensitivity->value;
my *= sensitivity->value;
// add mouse X/Y movement to cmd
if( (*in_state->in_strafe_state & 1) ||
(lookstrafe->value && mlooking ) ) {
cmd->sidemove += m_side->value * mx;
}
else {
in_state->viewangles[YAW] -= m_yaw->value * mx;
}
if( (mlooking || freelook->value) &&
!(*in_state->in_strafe_state & 1) ) {
in_state->viewangles[PITCH] += m_pitch->value * my;
}
else {
cmd->forwardmove -= m_forward->value * my;
}
mx = 0;
my = 0;
}
static void IN_DeactivateMouse( void )
{
if (!mouse_avail || !dpy || !win)
return;
if (mouse_active) {
uninstall_grabs();
mouse_active = false;
}
}
static void IN_ActivateMouse( void )
{
if (!mouse_avail || !dpy || !win)
return;
if (!mouse_active) {
mx = my = 0; // don't spazz
install_grabs();
mouse_active = true;
}
}
void RW_IN_Frame (void)
{
}
void RW_IN_Activate(qboolean active)
{
}
/*****************************************************************************/
/* KEYBOARD */
/*****************************************************************************/
int XLateKey(XKeyEvent *ev)
{
int key;
char buf[64];
KeySym keysym;
key = 0;
XLookupString( ev, buf, sizeof buf, &keysym, 0 );
switch( keysym ) {
case XK_KP_9:
case XK_F29:
case XK_KP_Page_Up: key = K_KP_PGUP; break;
case XK_Page_Up: key = K_PGUP; break;
case XK_KP_3:
case XK_F35:
case XK_KP_Page_Down: key = K_KP_PGDN; break;
case XK_Page_Down: key = K_PGDN; break;
case XK_KP_7:
case XK_F27:
case XK_KP_Home: key = K_KP_HOME; break;
case XK_Home: key = K_HOME; break;
case XK_KP_1:
case XK_F33:
case XK_KP_End: key = K_KP_END; break;
case XK_End: key = K_END; break;
case XK_KP_4:
case XK_KP_Left: key = K_KP_LEFTARROW; break;
case XK_Left: key = K_LEFTARROW; break;
case XK_KP_6:
case XK_KP_Right: key = K_KP_RIGHTARROW; break;
case XK_Right: key = K_RIGHTARROW; break;
case XK_KP_2:
case XK_KP_Down: key = K_KP_DOWNARROW; break;
case XK_Down: key = K_DOWNARROW; break;
case XK_KP_8:
case XK_KP_Up: key = K_KP_UPARROW; break;
case XK_Up: key = K_UPARROW; break;
case XK_Escape: key = K_ESCAPE; break;
case XK_KP_Enter: key = K_KP_ENTER; break;
case XK_Return: key = K_ENTER; break;
case XK_Tab: key = K_TAB; break;
case XK_F1: key = K_F1; break;
case XK_F2: key = K_F2; break;
case XK_F3: key = K_F3; break;
case XK_F4: key = K_F4; break;
case XK_F5: key = K_F5; break;
case XK_F6: key = K_F6; break;
case XK_F7: key = K_F7; break;
case XK_F8: key = K_F8; break;
case XK_F9: key = K_F9; break;
case XK_F10: key = K_F10; break;
case SunXK_F36: key = K_F11; break;
case SunXK_F37: key = K_F12; break;
case XK_BackSpace: key = K_BACKSPACE; break;
case XK_KP_Separator:
case XK_KP_Delete: key = K_KP_DEL; break;
case XK_Delete: key = K_DEL; break;
case XK_Pause: key = K_PAUSE; break;
case XK_Shift_L:
case XK_Shift_R: key = K_SHIFT; break;
case XK_Execute:
case XK_Control_L:
case XK_Control_R: key = K_CTRL; break;
case XK_Alt_L:
case XK_Meta_L:
case XK_Alt_R:
case XK_Meta_R: key = K_ALT; break;
case XK_KP_5:
case XK_F31: key = K_KP_5; break;
case XK_Insert: key = K_INS; break;
case XK_KP_0:
case XK_KP_Insert: key = K_KP_INS; break;
case XK_F26:
case XK_KP_Multiply: key = '*'; break;
case XK_KP_Add: key = K_KP_PLUS; break;
case XK_F24:
case XK_KP_Subtract: key = K_KP_MINUS; break;
case XK_F25:
case XK_KP_Divide: key = K_KP_SLASH; break;
case XK_F11:
if( ev->type == KeyPress ) {
if( _windowed_mouse->value ) {
Cvar_SetValue( "_windowed_mouse", 0 );
}
else {
Cvar_SetValue( "_windowed_mouse", 1 );
}
}
break;
#if 0
case 0x021: key = '1';break;/* [!] */
case 0x040: key = '2';break;/* [@] */
case 0x023: key = '3';break;/* [#] */
case 0x024: key = '4';break;/* [$] */
case 0x025: key = '5';break;/* [%] */
case 0x05e: key = '6';break;/* [^] */
case 0x026: key = '7';break;/* [&] */
case 0x02a: key = '8';break;/* [*] */
case 0x028: key = '9';;break;/* [(] */
case 0x029: key = '0';break;/* [)] */
case 0x05f: key = '-';break;/* [_] */
case 0x02b: key = '=';break;/* [+] */
case 0x07c: key = '\'';break;/* [|] */
case 0x07d: key = '[';break;/* [}] */
case 0x07b: key = ']';break;/* [{] */
case 0x022: key = '\'';break;/* ["] */
case 0x03a: key = ';';break;/* [:] */
case 0x03f: key = '/';break;/* [?] */
case 0x03e: key = '.';break;/* [>] */
case 0x03c: key = ',';break;/* [<] */
#endif
default:
key = *(unsigned char*)buf;
if (key >= 'A' && key <= 'Z')
key = key - 'A' + 'a';
break;
}
return key;
}
void GetEvent(void)
{
XEvent x_event;
int b;
XNextEvent(dpy, &x_event);
switch(x_event.type) {
case KeyPress:
keyq[keyq_head].key = XLateKey(&x_event.xkey);
keyq[keyq_head].down = true;
keyq_head = (keyq_head + 1) & 63;
break;
case KeyRelease:
/*
* This is a hack in order to avoid disabling key repeat, which
* would cause a lot of problems when changing to other windows
* or when the program crashes.
*
* Whenever a key release event occurs, we check to see if the
* next event in the queue is a press event of the same key
* with the same time stamp. If it is, we simply discard this
* and the next event.
*/
if( XPending( dpy ) > 0 ) {
XEvent tmp_event;
XPeekEvent( dpy, &tmp_event );
if( tmp_event.type == KeyPress &&
tmp_event.xkey.keycode == x_event.xkey.keycode &&
tmp_event.xkey.time == x_event.xkey.time ) {
XNextEvent( dpy, &tmp_event );
break;
}
}
keyq[keyq_head].key = XLateKey(&x_event.xkey);
keyq[keyq_head].down = false;
keyq_head = (keyq_head + 1) & 63;
break;
case MotionNotify:
if( _windowed_mouse->value ) {
int xoffset = ((int)x_event.xmotion.x - (int)(window_width / 2));
int yoffset = ((int)x_event.xmotion.y - (int)(window_height / 2));
if( xoffset != 0 || yoffset != 0 ) {
mx += xoffset;
my += yoffset;
/* move the mouse to the window center again */
XSelectInput( dpy, win, X_MASK & ~PointerMotionMask );
XWarpPointer( dpy, None, win, 0, 0, 0, 0,
(window_width / 2), (window_height / 2) );
XSelectInput( dpy, win, X_MASK );
}
}
else {
mx = ((int)x_event.xmotion.x - (int)p_mouse_x);
my = ((int)x_event.xmotion.y - (int)p_mouse_y);
p_mouse_x = x_event.xmotion.x;
p_mouse_y = x_event.xmotion.y;
}
break;
case ButtonPress:
b = -1;
if( x_event.xbutton.button == 1 ) {
b = 0;
}
else if( x_event.xbutton.button == 2 ) {
b = 2;
}
else if( x_event.xbutton.button == 3 ) {
b = 1;
}
if( b >= 0 ) {
mouse_buttonstate |= 1 << b;
}
break;
case ButtonRelease:
b = -1;
if( x_event.xbutton.button == 1 ) {
b = 0;
}
else if( x_event.xbutton.button == 2 ) {
b = 2;
}
else if( x_event.xbutton.button == 3 ) {
b = 1;
}
if( b >= 0 ) {
mouse_buttonstate &= ~(1 << b);
}
break;
#if 0
case ConfigureNotify:
config_notify_width = x_event.xconfigure.width;
config_notify_height = x_event.xconfigure.height;
if( xil_keepaspect->value && !force_resize ) {
double aspect = (double)vid.width / vid.height;
if( config_notify_height > config_notify_width / aspect ) {
force_resize = 1;
XResizeWindow( dpy, win,
config_notify_width,
(int)(config_notify_width / aspect) );
}
else if( config_notify_width > config_notify_height * aspect ) {
force_resize = 1;
XResizeWindow( dpy, win,
(int)(config_notify_height * aspect),
config_notify_height );
}
}
else {
force_resize = 0;
}
if( !force_resize ) {
config_notify = 1;
}
break;
#endif
case MapNotify:
if( _windowed_mouse->value ) {
XGrabPointer( dpy, win, True, 0, GrabModeAsync,
GrabModeAsync, win, None, CurrentTime);
}
break;
case UnmapNotify:
if( _windowed_mouse->value ) {
XUngrabPointer( dpy, CurrentTime );
}
break;
default:
;
}
if( old_windowed_mouse != _windowed_mouse->value ) {
old_windowed_mouse = _windowed_mouse->value;
if( !_windowed_mouse->value ) {
/* ungrab the pointer */
XUngrabPointer( dpy, CurrentTime );
} else {
/* grab the pointer */
XGrabPointer( dpy, win, True, 0, GrabModeAsync,
GrabModeAsync, win, None, CurrentTime );
}
}
}
Key_Event_fp_t Key_Event_fp;
void KBD_Init(Key_Event_fp_t fp)
{
Key_Event_fp = fp;
}
void KBD_Update(void)
{
// get events from x server
if( dpy ) {
while( XPending( dpy ) ) {
GetEvent();
}
while( keyq_head != keyq_tail ) {
Key_Event_fp(keyq[keyq_tail].key, keyq[keyq_tail].down);
keyq_tail = (keyq_tail + 1) & 63;
}
}
}
void KBD_Close(void)
{
}
/*****************************************************************************/
static qboolean GLimp_SwitchFullscreen( int width, int height );
qboolean GLimp_InitGL (void);
static void signal_handler(int sig)
{
printf("Received signal %d, exiting...\n", sig);
GLimp_Shutdown();
_exit(0);
}
static void InitSig(void)
{
signal(SIGHUP, 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);
}
/*
** GLimp_SetMode
*/
int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
{
int width, height;
int attrib[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
GLX_DEPTH_SIZE, 1,
GLX_STENCIL_SIZE, 1,
None
};
int attrib_nostencil[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
GLX_DEPTH_SIZE, 1,
None
};
Window root;
XVisualInfo *visinfo;
XSetWindowAttributes attr;
unsigned long mask;
int MajorVersion, MinorVersion;
int actualWidth, actualHeight;
int i;
r_fakeFullscreen = ri.Cvar_Get( "r_fakeFullscreen", "0", CVAR_ARCHIVE);
ri.Con_Printf( PRINT_ALL, "Initializing OpenGL display\n");
if (fullscreen)
ri.Con_Printf (PRINT_ALL, "...setting fullscreen mode %d:", mode );
else
ri.Con_Printf (PRINT_ALL, "...setting mode %d:", mode );
if ( !ri.Vid_GetModeInfo( &width, &height, mode ) )
{
ri.Con_Printf( PRINT_ALL, " invalid mode\n" );
return rserr_invalid_mode;
}
ri.Con_Printf( PRINT_ALL, " %d %d\n", width, height );
window_width = width;
window_height = height;
// destroy the existing window
GLimp_Shutdown ();
if (!(dpy = XOpenDisplay(NULL))) {
fprintf(stderr, "Error couldn't open the X display\n");
return rserr_invalid_mode;
}
scrnum = DefaultScreen(dpy);
root = RootWindow(dpy, scrnum);
// Get video mode list
MajorVersion = MinorVersion = 0;
visinfo = qglXChooseVisual(dpy, scrnum, attrib);
if (!visinfo) {
fprintf(stderr, "Error couldn't get an RGBA, DOUBLEBUFFER, DEPTH, STENCIL visual\n");
visinfo = qglXChooseVisual(dpy, scrnum, attrib_nostencil);
if (!visinfo) {
fprintf(stderr, "E: couldn't get an RGBA, DOUBLEBUFFER, DEPTH visual\n");
return rserr_invalid_mode;
}
}
/* do some pantsness */
if ( qglXGetConfig )
{
int red_bits, blue_bits, green_bits, depth_bits, alpha_bits;
qglXGetConfig(dpy, visinfo, GLX_RED_SIZE, &red_bits);
qglXGetConfig(dpy, visinfo, GLX_BLUE_SIZE, &blue_bits);
qglXGetConfig(dpy, visinfo, GLX_GREEN_SIZE, &green_bits);
qglXGetConfig(dpy, visinfo, GLX_DEPTH_SIZE, &depth_bits);
qglXGetConfig(dpy, visinfo, GLX_ALPHA_SIZE, &alpha_bits);
ri.Con_Printf(PRINT_ALL, "I: got %d bits of red\n", red_bits);
ri.Con_Printf(PRINT_ALL, "I: got %d bits of blue\n", blue_bits);
ri.Con_Printf(PRINT_ALL, "I: got %d bits of green\n", green_bits);
ri.Con_Printf(PRINT_ALL, "I: got %d bits of depth\n", depth_bits);
ri.Con_Printf(PRINT_ALL, "I: got %d bits of alpha\n", alpha_bits);
}
/* stencilbuffer shadows */
if ( qglXGetConfig )
{
int stencil_bits;
if (!qglXGetConfig(dpy, visinfo, GLX_STENCIL_SIZE, &stencil_bits)) {
ri.Con_Printf(PRINT_ALL, "I: got %d bits of stencil\n", stencil_bits);
if (stencil_bits >= 1) {
have_stencil = true;
}
}
}
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attr.event_mask = X_MASK;
puts("DEBUG: GLimp_SetMode() IS setting X_MASK");
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(dpy, root, 0, 0, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
XMapWindow(dpy, win);
XFlush(dpy);
ctx = qglXCreateContext(dpy, visinfo, NULL, True);
qglXMakeCurrent(dpy, win, ctx);
*pwidth = width;
*pheight = height;
// let the sound and input subsystems know about the new window
ri.Vid_NewWindow (width, height);
qglXMakeCurrent(dpy, win, ctx);
// inviso cursor
XDefineCursor( dpy, win, CreateNullCursor( dpy, win ) );
return rserr_ok;
}
/*
** GLimp_Shutdown
**
** This routine does all OS specific shutdown procedures for the OpenGL
** subsystem. Under OpenGL this means NULLing out the current DC and
** HGLRC, deleting the rendering context, and releasing the DC acquired
** for the window. The state structure is also nulled out.
**
*/
void GLimp_Shutdown( void )
{
if (dpy) {
if (ctx)
qglXDestroyContext(dpy, ctx);
if (win)
XDestroyWindow(dpy, win);
XCloseDisplay(dpy);
}
ctx = NULL;
dpy = NULL;
win = 0;
ctx = NULL;
}
/*
** GLimp_Init
**
** This routine is responsible for initializing the OS specific portions
** of OpenGL.
*/
int GLimp_Init( void *hinstance, void *wndproc )
{
InitSig();
if ( glw_state.OpenGLLib) {
#define GPA( a ) dlsym( glw_state.OpenGLLib, a )
qglXChooseVisual = GPA("glXChooseVisual");
qglXCreateContext = GPA("glXCreateContext");
qglXDestroyContext = GPA("glXDestroyContext");
qglXMakeCurrent = GPA("glXMakeCurrent");
qglXCopyContext = GPA("glXCopyContext");
qglXSwapBuffers = GPA("glXSwapBuffers");
qglXGetConfig = GPA("glXGetConfig");
return true;
}
return false;
}
/*
** GLimp_BeginFrame
*/
void GLimp_BeginFrame( float camera_seperation )
{
}
/*
** GLimp_EndFrame
**
** Responsible for doing a swapbuffers and possibly for other stuff
** as yet to be determined. Probably better not to make this a GLimp
** function and instead do a call to GLimp_SwapBuffers.
*/
void GLimp_EndFrame (void)
{
qglFlush();
qglXSwapBuffers(dpy, win);
}
/*
** GLimp_AppActivate
*/
void GLimp_AppActivate( qboolean active )
{
}
/*------------------------------------------------*/
/* X11 Input Stuff */
/*------------------------------------------------*/

33
solaris/gl_glx.h Normal file
View file

@ -0,0 +1,33 @@
/*
Copyright (C) 1997-2001 Id Software, 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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GL_GLX_SOLARIS_H__
#define __GL_GLX_SOLARIS_H__
//GLX Functions
XVisualInfo * (APIENTRY * qglXChooseVisual)( Display *dpy, int screen, int *attribList );
GLXContext (APIENTRY * qglXCreateContext)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct );
void (APIENTRY * qglXDestroyContext)( Display *dpy, GLXContext ctx );
Bool (APIENTRY * qglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx);
void (APIENTRY * qglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, GLuint mask );
void (APIENTRY * qglXSwapBuffers)( Display *dpy, GLXDrawable drawable );
int (APIENTRY * qglXGetConfig) (Display *dpy, XVisualInfo *vis, int attrib, int *value);
#endif

View file

@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include "../linux/glob.h"
#include "../solaris/glob.h"
/* Like glob_match, but match PATTERN against any final segment of TEXT. */
static int glob_match_after_star(char *pattern, char *text)

33
solaris/glw_solaris.h Normal file
View file

@ -0,0 +1,33 @@
/*
Copyright (C) 1997-2001 Id Software, 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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GLW_SOLARIS_H__
#define __GLW_SOLARIS_H__
typedef struct
{
void *OpenGLLib; // instance of OpenGL library
FILE *log_fp;
} glwstate_t;
extern glwstate_t glw_state; /* declared in gl_glx.c */
#endif

554
solaris/ndga.c Normal file
View file

@ -0,0 +1,554 @@
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stropts.h>
#include <poll.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include "nvsession.h"
#define NDGA_IMPLEMENTATION 1
#include "NRegion.h"
#include "ndga.h"
/*
* newt equivalent of DGA
*
* Written by: Jim Hanko
*/
#define NS_PER_SEC (1000LL * 1000LL * 1000LL)
/* #define DEBUG */
#ifdef DEBUG
#define DBG(x) x
#else
#define DBG(x)
#endif
int
ndga_get_eventmask(void)
{
return (VisibilityChangeMask | ExposureMask | StructureNotifyMask);
}
void
ndga_destroy(struct ndga_state * sp)
{
if (sp) {
if (sp->session && sp->sent_clip) {
sp->sent_clip = 0;
nvSessionClipRegion(sp->session, NULL);
}
NDestroyRegion(sp->region);
NDestroyRegion(sp->clip);
NDestroyRegion(sp->lastclip);
NDestroyRegion(sp->screenArea);
free(sp);
}
}
struct ndga_state *
ndga_new(Display *display, Window window, nvSession session,
int xalign, int yalign)
{
struct ndga_state *sp;
Window *children;
int nchildren;
XWindowAttributes attr;
int retval;
sp = (struct ndga_state *) malloc(sizeof(*sp));
if (sp == NULL)
return (NULL);
memset(sp, 0, sizeof(*sp));
sp->display = display;
sp->window = window;
sp->xalign = xalign;
sp->yalign = yalign;
sp->is_visible = 1;
sp->is_unobscured = 1;
sp->is_open = 1;
sp->was_open = 1;
sp->was_unobscured = 0;
sp->is_changed = 1;
sp->new_clip = 1;
sp->busy = 0;
sp->clipEvent = 1;
sp->session = session;
XQueryTree(sp->display, sp->window, &sp->root, &sp->parent,
&children, &nchildren);
retval = XGetWindowAttributes(sp->display, sp->root, &attr);
if (retval == 0) {
fprintf(stderr, "Can't get window attributes\n");
free(sp);
return (NULL);
}
sp->region = NCreateRegion();
sp->clip = NCreateRegion();
sp->lastclip = NCreateRegion();
sp->screenArea = NCreateRegion();
sp->screenRect.x = attr.x;
sp->screenRect.y = attr.y;
sp->screenRect.width = attr.width;
sp->screenRect.height = attr.height;
DBG(fprintf(stderr, "screen %d,%d %dx%d\n",
sp->screenRect.x, sp->screenRect.y,
sp->screenRect.width, sp->screenRect.height));
NUnionRectWithRegion(&sp->screenRect, sp->screenArea, sp->screenArea);
return (sp);
}
static void
get_win_info(struct ndga_state * sp)
{
int depth;
int xr, yr, wr, hr, border;
Window w, root, parent, *children;
int nchildren;
int x, y;
XWindowAttributes attr;
int retval;
DBG(fprintf(stderr, "get_win_info()\n"));
retval = XGetWindowAttributes(sp->display, sp->window, &attr);
if (retval == 0) {
fprintf(stderr, "Can't get window attributes\n");
exit(1);
}
sp->is_open = (attr.map_state == IsViewable);
DBG(fprintf(stderr, "ismapped %d\n", sp->is_open));
x = attr.x + attr.border_width;
y = attr.y + attr.border_width;
sp->w = attr.width;
sp->h = attr.height;
if (sp->xalign > 1)
sp->w -= (sp->w % sp->xalign);
if (sp->yalign > 1)
sp->h -= (sp->h % sp->yalign);
w = sp->parent;
while (w && w != sp->root) {
XGetGeometry(sp->display, w, &root, &xr, &yr, &wr, &hr,
&border, &depth);
x += xr + border;
y += yr + border;
XQueryTree(sp->display, w, &root, &w, &children, &nchildren);
}
sp->x = x;
sp->y = y;
sp->visRect.x = sp->x;
sp->visRect.y = sp->y;
sp->visRect.width = sp->w;
sp->visRect.height = sp->h;
DBG(fprintf(stderr, "X %d Y %d W %d H %d\n", sp->x, sp->y,
sp->w, sp->h));
}
static void
rdump(void *a, int x, int y, int w, int h)
{
struct ndga_state *s = (struct ndga_state *) a;
fprintf(stderr, "%d,%d %dx%d\n", x, y, w, h);
}
static void
ndga_handle_change(struct ndga_state *sp)
{
NRectangle rectangle;
get_win_info(sp);
if (sp->is_open && sp->is_unobscured && !sp->was_unobscured) {
rectangle.x = 0;
rectangle.y = 0;
rectangle.width = sp->w;
rectangle.height = sp->h;
NDestroyRegion(sp->region);
sp->region = NCreateRegion();
NUnionRectWithRegion(&rectangle, sp->region,
sp->region);
DBG(fprintf(stderr, "Full clip\n"));
} else if (!sp->is_open || !sp->is_visible) {
NDestroyRegion(sp->region);
sp->region = NCreateRegion();
}
NUnionRegion(sp->region, sp->region, sp->clip);
NOffsetRegion(sp->clip, sp->x, sp->y);
NIntersectRegion(sp->clip, sp->screenArea, sp->clip);
if (sp->xalign > 1 || sp->yalign > 1) {
NAlignRegion(sp->clip, sp->clip, sp->x, sp->xalign, sp->y,
sp->yalign);
}
if (sp->x < sp->screenRect.x ||
sp->y < sp->screenRect.y ||
sp->x + sp->w > sp->screenRect.x + sp->screenRect.width ||
sp->y + sp->h > sp->screenRect.y + sp->screenRect.height) {
(void) NClipBox(sp->clip, &sp->visRect);
} else {
sp->visRect.x = sp->x;
sp->visRect.y = sp->y;
sp->visRect.width = sp->w;
sp->visRect.height = sp->h;
}
sp->new_clip = 1;
sp->clipEvent++;
sp->was_unobscured = sp->is_unobscured;
DBG(fprintf(stderr, "\n%s: %d - Clip \n", __FILE__, __LINE__));
DBG(NWalkRegion(sp->clip, rdump, sp));
}
/*
* Keep the session manager informed
*/
static void
update_clip(struct ndga_state *sp)
{
if (!NEqualRegion(sp->clip, sp->lastclip)) {
NUnionRegion(sp->clip, sp->clip, sp->lastclip);
if (sp->session && sp->sent_clip) {
nvSessionClipRegion(sp->session, sp->clip);
}
}
sp->new_clip = 0;
}
#ifdef X_VISIBILITY_BUG
int fix_visibility = -1;
/*
* The current X server will not report visibility events if the
* window was partially obscured and it become more obscured. So,
* we periodically poll to get an accurate clip list.
*
* Expected to be fixed by Solaris 2.8
*/
static void
ndga_workaround(struct ndga_state * sp)
{
char *s;
if (fix_visibility == -1) {
if ((s = getenv("CORONA_VISIBILITY_FIX")) != NULL &&
(*s == 'T' || *s == 't' || *s == '1')) {
fix_visibility = 1;
} else {
fix_visibility = 0;
}
}
if (fix_visibility != 1)
return;
if (sp->is_visible && !sp->is_unobscured && sp->sent_clip) {
hrtime_t now;
static hrtime_t last;
now = gethrtime();
if (now - last > NS_PER_SEC) {
Window w;
DBG(fprintf(stderr, "Poll for clip\n"));
w = XCreateSimpleWindow(sp->display, sp->window,
0, 0, 30000, 30000, 0, 0, 0);
XMapWindow(sp->display, w);
XFlush(sp->display);
XDestroyWindow(sp->display, w);
XFlush(sp->display);
/*
* No need for sync here
*/
sp->clearOnExpose = 1;
last = gethrtime();
}
}
}
#endif /* X_VISIBILITY_BUG */
/*
* attempt to start direct io; returns 1 if visible and sets the
* window's location in xp, yp, wp, hp. is_obscured is set if all
* parts of the window are visible. clipEvent contains an event
* counter for changes in the clip list. When a caller observes
* a change in the counter, it should obtain the new clip.
*
* Returns 0 if the window is not visible.
*/
int
ndga_start(struct ndga_state * sp,
int *xp, /* x */
int *yp, /* y */
int *wp, /* width */
int *hp, /* height */
int *is_unobscured, /* 1 if clipped, 0 if not */
int *clipEvent /* clip event count */)
{
char *loc;
if (!sp)
return (0);
if (sp->is_changed) {
ndga_handle_change(sp);
sp->is_changed = 0;
}
if (sp->new_clip) {
update_clip(sp);
}
/*
* If fully visible or if partially visible and the client is
* expecting to handle clipping, allow it to go through
*/
if (sp->is_open && sp->is_visible &&
(sp->is_unobscured ||
(clipEvent != NULL && is_unobscured != NULL))) {
if (sp->session && sp->sent_clip == 0) {
nvSessionClipRegion(sp->session, sp->clip);
sp->sent_clip = 1;
}
*xp = sp->visRect.x;
*wp = sp->visRect.width;
*yp = sp->visRect.y;
*hp = sp->visRect.height;
sp->busy = 1;
if (clipEvent)
*clipEvent = sp->clipEvent;
if (is_unobscured)
*is_unobscured = sp->is_unobscured;
DBG(fprintf(stderr, "ndga_start() = 1\n"));
return (1);
}
if (sp->is_open && sp->is_visible) {
/*
* Assume it will just go through X; slow it down
*/
poll(0, 0, sp->w * sp->h / 450);
}
/*
* not OK
*/
if (sp->session && sp->sent_clip) {
sp->sent_clip = 0;
nvSessionClipRegion(sp->session, NULL);
}
if (clipEvent)
*clipEvent = sp->clipEvent;
if (is_unobscured)
*is_unobscured = 0;
return (0);
}
/*
* update the argument to hold the current clip-list and and return
* it. If the clip argument is NULL, a new region is allocated. It
* is the responsibility of the caller to free the clip.
*/
NRegion
ndga_clip(struct ndga_state * sp, NRegion clip)
{
if (!clip)
clip = NCreateRegion();
/*
* Use union as copy
*/
(void) NUnionRegion(sp->clip, sp->clip, clip);
return(clip);
}
void
ndga_done(struct ndga_state * sp)
{
if (!sp)
return;
if (sp->is_changed) {
ndga_handle_change(sp);
sp->is_changed = 0;
}
if (sp->new_clip) {
update_clip(sp);
}
sp->busy = 0;
#ifdef X_VISIBILITY_BUG
ndga_workaround(sp);
#endif /* X_VISIBILITY_BUG */
}
void
ndga_process_event(struct ndga_state * sp, XEvent * event)
{
NRectangle rectangle;
if (!sp)
return;
if (event->xany.type == Expose) {
#ifdef X_VISIBILITY_BUG
if (sp->clearOnExpose) {
NDestroyRegion(sp->region);
sp->region = NCreateRegion();
sp->clearOnExpose = 0;
}
#endif /* X_VISIBILITY_BUG */
rectangle.x = event->xexpose.x;
rectangle.y = event->xexpose.y;
rectangle.width = event->xexpose.width;
rectangle.height = event->xexpose.height;
NUnionRectWithRegion(&rectangle, sp->region, sp->region);
DBG(fprintf(stderr, "Expose: %d,%d %dx%d\n",
event->xexpose.x,
event->xexpose.y,
event->xexpose.width,
event->xexpose.height));
if (event->xexpose.count == 0) {
/*
* Handle the last in a sequence of expose events.
*/
sp->is_changed = 1;
}
} else if (event->xany.type == VisibilityNotify) {
sp->is_visible =
(event->xvisibility.state != VisibilityFullyObscured);
sp->is_unobscured =
(event->xvisibility.state == VisibilityUnobscured);
sp->is_changed = 1;
DBG(fprintf(stderr, "Visiblility: %s\n",
(event->xvisibility.state == VisibilityUnobscured) ?
"Unobscured" :
((event->xvisibility.state == VisibilityFullyObscured) ?
"FullyObscured" : "PartuallyObscured")));
if (event->xvisibility.state == VisibilityPartiallyObscured) {
Window w;
DBG(fprintf(stderr, "Request full clip\n"));
NDestroyRegion(sp->region);
sp->region = NCreateRegion();
w = XCreateSimpleWindow(sp->display, sp->window,
0, 0, 30000, 30000, 0, 0, 0);
XMapWindow(sp->display, w);
XFlush(sp->display);
XDestroyWindow(sp->display, w);
XFlush(sp->display);
/*
* sync so we will get expose events all together
*/
XSync(sp->display, False);
}
} else if (event->xany.type == UnmapNotify) {
DBG(fprintf(stderr, "Unmap\n"));
sp->is_changed = 1;
NDestroyRegion(sp->region);
sp->region = NCreateRegion();
} else if (event->xany.type == ConfigureNotify) {
DBG(fprintf(stderr, "Configure\n"));
sp->is_changed = 1;
} else if (event->xany.type == CirculateNotify) {
DBG(fprintf(stderr, "Circulate\n"));
} else if (event->xany.type == MapNotify) {
DBG(fprintf(stderr, "Map\n"));
} else {
DBG(fprintf(stderr, "Event %d\n", event->xany.type));
}
if (XPending(sp->display) != 0)
return;
DBG(fprintf(stderr, "Last Event\n\n"));
if ((sp->on_open || sp->on_close) && sp->is_changed) {
if (sp->is_open != sp->was_open) {
if (!sp->is_open) {
DBG(fprintf(stderr, "I-CLOSED\n"));
if (sp->on_close)
(*sp->on_close) ();
} else {
DBG(fprintf(stderr, "I-OPEN\n"));
if (sp->on_open)
(*sp->on_open) ();
}
sp->was_open = sp->is_open;
}
}
if (sp->is_changed) {
ndga_handle_change(sp);
if (!sp->busy)
sp->is_changed = 0;
}
if (!sp->busy && sp->new_clip) {
update_clip(sp);
}
}
int
ndga_isvisible(ndga_t sp)
{
if (!sp) {
/*
* Safest to say yes?
*/
return (1);
}
if (!sp->busy && sp->is_changed) {
ndga_handle_change(sp);
sp->is_changed = 0;
}
if (!sp->busy && sp->new_clip) {
update_clip(sp);
}
#ifdef X_VISIBILITY_BUG
ndga_workaround(sp);
#endif /* X_VISIBILITY_BUG */
DBG(fprintf(stderr, "is_visible %d\n", sp->is_open && sp->is_visible));
return (sp->is_open && sp->is_visible);
}

93
solaris/ndga.h Normal file
View file

@ -0,0 +1,93 @@
#ifndef NDGA_H
#define NDGA_H
#include "nvsession.h"
#ifndef NDGA_IMPLEMENTATION
/*
* For public consumption, this is an opaque pointer
*/
typedef void *ndga_t;
#else
/*
* This is implementaion private
*
* Newt DGA state record
*/
struct ndga_state {
/*
* all private
*/
int is_visible;
int is_unobscured;
int is_open;
int is_changed;
int new_clip;
int sent_clip;
int busy;
int was_open;
int was_unobscured;
int x, y;
int w, h;
int xalign;
int yalign;
nvSession session;
void (* on_open)();
void (* on_close)();
Display *display;
Window window;
Window parent;
Window root;
NRegion region;
NRegion clip;
NRegion lastclip;
NRegion screenArea;
NRectangle screenRect;
NRectangle visRect;
int clipEvent;
int clearOnExpose;
};
typedef struct ndga_state *ndga_t;
#endif /* NDGA_IMPLEMENTATION */
ndga_t ndga_new(Display *display, Window window, nvSession session,
int xalign, int yalign);
void ndga_destroy(ndga_t sp);
int ndga_start(ndga_t sp,
int *xp, /* x */
int *yp, /* y */
int *wp, /* width */
int *hp, /* height */
int *is_unobscured, /* 1 if unobscured 0 if clipped */
int *clipEvent /* clip event number */
);
/*
* update the argument to hold the current clip-list and and return
* it. If the clip argument is NULL, a new region is allocated. It
* is the responsibility of the caller to free the clip.
*/
NRegion ndga_clip(ndga_t sp, NRegion clip);
void ndga_done(ndga_t sp);
int ndga_isvisible(ndga_t sp);
int ndga_get_eventmask(void);
void ndga_process_event(ndga_t sp, XEvent *event);
#endif

320
solaris/newt.c Normal file
View file

@ -0,0 +1,320 @@
/*
* Brian Schmidt
*
* File: newt.c
* Date: 03/18/99
* Revision: 1.9
*
* This file contains the routines necessary to send Quake video to
* a NewT.
*/
#pragma ident "@(#)File: newt.c, Rev: 1.9, Date: 99/03/18 13:12:08, Author: Brian Schmidt"
/*============================== INCLUDE FILES ==============================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <newtvideo.h>
#include <nvsession.h>
#include <macros.h>
#include <signal.h>
#include <thread.h>
#include <sched.h>
#include "newt.h"
/*================================ CONSTANTS ================================*/
/*================================= MACROS ==================================*/
/*============================ EXPORTED GLOBALS =============================*/
int yuv_dpcm = FALSE; /* use 4-bit DPCM on luma vals */
int yuv_subx = DEF_YUV_XSUBSAMP; /* horizontal chroma subsample */
int yuv_suby = DEF_YUV_YSUBSAMP; /* vertical chroma subsample */
int req_max_bw = TRUE; /* request max BW to NewT */
int newt_initialize_next = 1;
/*============================= STATIC GLOBALS ==============================*/
static ndga_t *ndga = NULL; /* NewT DGA interface */
static char *target = NULL; /* NewT target */
static nvSession nvsession = NULL; /* NewT session */
static nv_t newtnv = NULL; /* NewT video conn */
static u_char *line = NULL; /* line of pixels */
static struct { /* video state info */
int x, y; /* location */
int dw, dh; /* destination width/height */
int sw, sh; /* source width/height */
int clipEvent; /* clip event type */
NRegion clip; /* clip info */
} vinfo;
static u_char ymap[256]; /* color maps */
static u_char umap[256];
static u_char vmap[256];
/*============================= PREDECLARATIONS =============================*/
static void setup_video(Display *disp, Window win);
static void nvSessionCheck(nvSession sess);
extern char display_name[];
/*============================ EXPORTED ROUTINES ============================*/
void newt_set_palette( unsigned char *palette )
{
int i, j;
int y, u, v;
int r, g, b;
for (i = j = 0 ; i < 256 ; i++) {
/* get the RGB pixel values */
b = palette[i*4 + 2];
g = palette[i*4 + 1];
r = palette[i*4 + 0];
/* convert to YUV */
y = (77*r + 150*g + 29*b)/256;
u = (-44*r - 87*g + 131*b)/256 + 128;
v = (131*r - 110*g - 21*b)/256 + 128;
/* clamp the values */
ymap[i] = CLAMP(y);
umap[i] = CLAMP(u);
vmap[i] = CLAMP(v);
}
}
/*========================= newt_process_event =========================
* Process events to watch for window changes.
*/
void newt_process_event(XEvent *xev)
{
if (ndga != NULL) ndga_process_event(ndga, xev);
}
/*========================= send_newt_video =========================
* Given an image consisting of 8-bit color index pixels, convert to
* YUV format and send to a NewT for scaling and display. The width
* and height are for the source image. Return 1 on success,
* 0 if we could not blast straight to the NewT screen.
*/
int send_newt_video(Display *disp, Window win,
void *data, int sw, int sh)
{
int x, y, w, h; /* window coordinates */
register int i, j, k, l, m; /* loop indexes */
u_char *frame = (u_char *)data; /* 8-bit pix for frame */
tile_t tile; /* video tile */
u_char *ydata, *udata, *vdata; /* yuv data */
int tx, ty, tw, th; /* tile location/size */
int ret = 1; /* return code */
int is_unobscured; /* true if window is unobscured */
int clipEvent; /* clip event type */
/* Set things up on the first time through */
if( newt_initialize_next ) {
newt_initialize_next = FALSE;
if( ndga != NULL ) {
ndga_destroy( ndga );
ndga = NULL;
}
memset( &vinfo, 0, sizeof( vinfo ) );
setup_video( disp, win );
}
/* make sure we have a conn to the NewT and can
* draw straight to the screen.
*/
nvSessionCheck(nvsession);
if ((target == NULL) ||
(!ndga_start(ndga, &x, &y, &w, &h, &is_unobscured, &clipEvent))) {
return 0;
}
if ((newtnv == NULL) ||
(vinfo.x != x) || (vinfo.y != y) ||
(vinfo.dw != w) || (vinfo.dh != h) ||
(vinfo.sw != sw) || (vinfo.sh != sh)) {
vinfo.x = x;
vinfo.y = y;
vinfo.sw = sw;
vinfo.sh = sh;
vinfo.dw = w;
vinfo.dh = h;
if (line != NULL) free(line);
if ((line = (u_char *)malloc(sw)) == NULL) {
fprintf(stderr, "send_newt_video: malloc faild\n");
ret = 0;
goto send_done;
}
if (newtnv != NULL) nv_destroy(newtnv);
if ((newtnv = nv_new(target, x, y, w, h, yuv_dpcm)) == NULL) {
ret = 0;
goto send_done;
}
}
/* set up the clip region if necessary */
if (clipEvent != vinfo.clipEvent) {
vinfo.clip = ndga_clip(ndga, vinfo.clip);
nv_set_clip(newtnv, vinfo.clip);
}
/* Set up the video tiles */
if (nv_setup(newtnv, sw, sh, yuv_subx, yuv_suby) == 0) {
ret = 0;
goto send_done;
}
if (req_max_bw) nv_bwreq(newtnv, sw * sh * 3 * 40);
/* Convert 8-bit colormap data to yuv data. Copy or compress
* data into each tile
*/
tile = nv_next_tile(newtnv, TRUE,
&ydata, &udata, &vdata, &tx, &ty, &tw, &th);
while (tile != NULL) {
/* luma data */
for (j = 0 ; j < th ; j++) {
if (yuv_dpcm) {
int ywidth = (tw + 1) / 2;
for (i = 0 ; i < tw ; i++) {
line[i] = ymap[frame[(ty + j)*sw + tx + i]];
}
nv_compress(ydata, line, ywidth);
ydata += ywidth;
} else {
for (i = 0 ; i < tw ; i++) {
ydata[j*tw + i] =
ymap[frame[(ty + j)*sw + tx + i]];
}
}
}
/* chroma data */
if ((yuv_subx > 0) && (yuv_suby > 0)) {
int uvx = tx/yuv_subx, uvy = ty/yuv_suby,
uvw = (tw + yuv_subx - 1)/yuv_subx,
uvh = (th + yuv_suby - 1)/yuv_suby;
for (i = j = 0 ; j < uvh ; j++) {
for (k = 0 ; k < uvw ; k++) {
u_int u = 0, v = 0;
for (l = 0 ; l < yuv_suby ; l++) {
for (m = 0 ; m < yuv_subx ; m++) {
u_int pel = frame[(ty + j*yuv_suby + l)*sw +
tx + k*yuv_subx + m];
u += umap[pel];
v += vmap[pel];
}
}
udata[i] = u / (yuv_subx * yuv_suby);
vdata[i] = v / (yuv_subx * yuv_suby);
i++;
}
}
}
/* ship it off */
nv_send_tile(newtnv, tile);
/* get next tile */
tile = nv_next_tile(newtnv, FALSE,
&ydata, &udata, &vdata, &tx, &ty, &tw, &th);
}
send_done: /* leave */
ndga_done(ndga);
return ret;
}
/*============================= LOCAL ROUTINES ==============================*/
/*========================= setup_video =========================
* Setup a connection to a NewT so we can send video.
*/
static void setup_video(Display *disp, Window win)
{
char *session;
printf("Using NewT video: %d-bit luma, chroma subsamp W/%d H/%d\n",
yuv_dpcm ? 4 : 8, yuv_subx, yuv_suby);
/* Get the NewT target */
session = nvGetSessionId( display_name );
if ((session != NULL) && ((nvsession = nvSessionSetup(session)) != NULL)) {
struct sigaction sa;
target = NULL;
sa.sa_handler = exit;
if ((sigaction(SIGINT, &sa, NULL) < 0) ||
(sigaction(SIGHUP, &sa, NULL) < 0) ||
(sigaction(SIGTERM, &sa, NULL) < 0)) {
perror("sigaction");
newt_cleanup();
exit(1);
}
/* atexit(newt_cleanup);*/
} else {
nvsession = NULL;
target = getenv("NEWT_TARGET");
}
if ((nvsession == NULL) && (target == NULL)) {
Sys_Error("Could not open connection to NewT");
}
/* Create NewT DGA context */
ndga = ndga_new(disp, win, nvsession, 1, 1);
}
/*========================= newt_cleanup =========================
* Clean up on exit. Kill the NewT video session.
*/
void newt_cleanup( void )
{
if( ndga != NULL ) {
ndga_destroy( ndga );
}
if( newtnv != NULL ) {
nv_destroy(newtnv);
newtnv = NULL;
}
}
/*========================= nvSessionCheck =========================
* Check the status of the given NewT session and set the target.
*/
static void nvSessionCheck(nvSession sess)
{
char *new_target;
register int i;
if (sess == NULL) return;
new_target = nvSessionTarget(sess);
/* Status has changed; break everything down and start again */
if ((new_target==NULL) || (target==NULL) || strcmp(new_target,target)) {
if (newtnv != NULL) {
/* Lost the connection. Destroy it */
nv_destroy(newtnv);
newtnv = NULL;
}
/* Set new target */
if (target) {
free(target);
target = NULL;
}
if (new_target) target = strdup(new_target);
}
}

51
solaris/newt.h Normal file
View file

@ -0,0 +1,51 @@
/*
* Brian Schmidt
*
* File: newt.h
* Date: 03/16/99
* Revision: 1.4
*
* Header file for NewT Quake routines and variables.
*/
#pragma ident "@(#)File: newt.h, Rev: 1.4, Date: 99/03/16 12:04:16, Author: Brian Schmidt"
#ifndef _NEWT_H_
#define _NEWT_H_
/*============================== INCLUDE FILES ==============================*/
#include "ndga.h"
/*================================ CONSTANTS ================================*/
#define DEF_YUV_XSUBSAMP (2) /* default horiz chroma subsamp */
#define DEF_YUV_YSUBSAMP (1) /* default vert chroma subsamp */
#ifndef TRUE
#define TRUE (1) /* boolean vals */
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#define CLAMP(c) ((c) < 0 ? 0 : ((c) > 255 ? 255 : (c)))
/*================================= MACROS ==================================*/
/*============================= DATA STRUCTURES =============================*/
/*============================ EXPORTED GLOBALS =============================*/
extern int yuv_dpcm; /* use 4-bit DPCM on luma vals */
extern int yuv_subx; /* horizontal chroma subsample */
extern int yuv_suby; /* vertical chroma subsample */
extern int yuv_scale; /* image scale factor */
extern int req_max_bw; /* request max BW to NewT */
/*============================= PREDECLARATIONS =============================*/
/*============================= LOCAL ROUTINES ==============================*/
/*============================ EXPORTED ROUTINES ============================*/
int send_newt_video(Display *disp, Window win,
void *data, int width, int height);
void newt_process_event(XEvent *xev);
void load_newt_cmaps(u_char *rgb_map);
void newt_cleanup( void );
#endif /* _NEWT_H_ */

View file

@ -0,0 +1,87 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

View file

@ -0,0 +1,2 @@
P SUNWxilrl XIL Runtime Environment
P SFWsdl SDL - Simple DirectMedia Layer library

View file

@ -0,0 +1,12 @@
CLASSES=none
BASEDIR=/usr/local/share/games
TZ=PST
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
PKG=iDquake2
NAME=ID Software Quake2 3.21 for Solaris 8 (X11,XIL,GLX,SDL)
VERSION=r0.14.1
CATEGORY=application,graphics,opengl
DESC=ID Software Quake2 3.21+rCVS for Solaris 8 (http://www.icculus.org/quake2)
VENDOR=http://www.icculus.org/quake2
EMAIL=coyote@step.polymtl.ca
PKGSAV=/var/sadm/pkg/iDquake2/save

View file

@ -0,0 +1,12 @@
CLASSES=none
BASEDIR=/usr/local/share/games
TZ=PST
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
PKG=iDquake2
NAME=ID Software Quake2 3.21 for Solaris 8 (X11,XIL,GLX,SDL)
VERSION=
CATEGORY=application,graphics,opengl
DESC=ID Software Quake2 3.21+rCVS for Solaris 8 (http://www.icculus.org/quake2)
VENDOR=http://www.icculus.org/quake2
EMAIL=coyote@step.polymtl.ca
PKGSAV=/var/sadm/pkg/iDquake2/save

View file

@ -0,0 +1,10 @@
#!/bin/sh
#
# @(#)postinstall $Id$
#
# postinstall script for quake2
quake2_dir=$BASEDIR
exit 0

View file

@ -0,0 +1,10 @@
#!/bin/sh
#
# @(#)postinstall $Id$
#
# postinstall script for quake2
quake2_dir=$BASEDIR
exit 0

View file

@ -0,0 +1,10 @@
#!/bin/sh
#
# @(#)postinstall $Id$
#
# postinstall script for quake2
quake2_dir=$BASEDIR
exit 0

View file

@ -0,0 +1,10 @@
#!/bin/sh
#
# @(#)postinstall $Id$
#
# postinstall script for quake2
quake2_dir=$BASEDIR
exit 0

View file

@ -0,0 +1,23 @@
!default 0755 root bin
i pkginfo
i copyright
i depend
i postinstall
i postremove
i preinstall
i preremove
d none quake2 0755
d none quake2/baseq2 0755
f none quake2/baseq2/gamesparc.so=/tmp/quake2-build/quake2-iDquake2-release/baseq2/gamesparc.so 0755
f none quake2/README=/tmp/quake2-build/quake2-iDquake2-release/README 0644
f none quake2/README.Solaris=/tmp/quake2-build/quake2-iDquake2-release/README.Solaris 0644
d none quake2/ctf 0755
f none quake2/ctf/gamesparc.so=/tmp/quake2-build/quake2-iDquake2-release/ctf/gamesparc.so 0755
f none quake2/quake2=/tmp/quake2-build/quake2-iDquake2-release/quake2 0755
f none quake2/q2ded=/tmp/quake2-build/quake2-iDquake2-release/q2ded 0755
f none quake2/sdlquake2=/tmp/quake2-build/quake2-iDquake2-release/sdlquake2 0755
f none quake2/ref_softx.so=/tmp/quake2-build/quake2-iDquake2-release/ref_softx.so 0755
f none quake2/ref_glx.so=/tmp/quake2-build/quake2-iDquake2-release/ref_glx.so 0755
f none quake2/ref_softsdl.so=/tmp/quake2-build/quake2-iDquake2-release/ref_softsdl.so 0755
f none quake2/ref_sdlgl.so=/tmp/quake2-build/quake2-iDquake2-release/ref_sdlgl.so 0755
f none quake2/ref_xil.so=/tmp/quake2-build/quake2-iDquake2-release/ref_xil.so 0755

View file

@ -0,0 +1,8 @@
!default 0755 root bin
i pkginfo
i copyright
i depend
i postinstall
i postremove
i preinstall
i preremove

View file

@ -0,0 +1 @@
/usr/local/share 20000 1

View file

@ -0,0 +1,87 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

View file

@ -0,0 +1,3 @@
P SUNWxilrl XIL Runtime Environment
P SFWsdl SDL - Simple DirectMedia Layer library
P iDquake2 ID Software Quake2 3.21 for Solaris 8 (X11,XIL,GLX,SDL)

View file

@ -0,0 +1,12 @@
CLASSES=none
BASEDIR=/usr/local/share/games
TZ=PST
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
PKG=iDquake2d
NAME=ID Software Quake2 game data files for Solaris 8 (X11,XIL,GLX,SDL)
VERSION=r0.14.1
CATEGORY=application,graphics,opengl
DESC=ID Software Quake2 game data files for Solaris 8 (http://www.icculus.org/quake2)
VENDOR=http://www.icculus.org/quake2
EMAIL=coyote@step.polymtl.ca
PKGSAV=/var/sadm/pkg/iDquake2d/save

View file

@ -0,0 +1,12 @@
CLASSES=none
BASEDIR=/usr/local/share/games
TZ=PST
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
PKG=iDquake2d
NAME=ID Software Quake2 game data files for Solaris 8 (X11,XIL,GLX,SDL)
VERSION=
CATEGORY=application,graphics,opengl
DESC=ID Software Quake2 game data files for Solaris 8 (http://www.icculus.org/quake2)
VENDOR=http://www.icculus.org/quake2
EMAIL=coyote@step.polymtl.ca
PKGSAV=/var/sadm/pkg/iDquake2d/save

View file

@ -0,0 +1,10 @@
#!/bin/sh
#
# @(#)postinstall $Id$
#
# postinstall script for quake2
quake2_dir=$BASEDIR
exit 0

View file

@ -0,0 +1,10 @@
#!/bin/sh
#
# @(#)postinstall $Id$
#
# postinstall script for quake2
quake2_dir=$BASEDIR
exit 0

View file

@ -0,0 +1,10 @@
#!/bin/sh
#
# @(#)postinstall $Id$
#
# postinstall script for quake2
quake2_dir=$BASEDIR
exit 0

View file

@ -0,0 +1,10 @@
#!/bin/sh
#
# @(#)postinstall $Id$
#
# postinstall script for quake2
quake2_dir=$BASEDIR
exit 0

View file

@ -0,0 +1,73 @@
!default 0755 root bin
i pkginfo
i copyright
i depend
i postinstall
i postremove
i preinstall
i preremove
d none quake2 0755
d none quake2/baseq2 0755
f none quake2/baseq2/pak0.pak=/usr/local/src/quake2-data/quake2/baseq2/pak0.pak 0644
d none quake2/baseq2/players 0755
d none quake2/baseq2/players/female 0755
f none quake2/baseq2/players/female/athena.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/athena.pcx 0644
f none quake2/baseq2/players/female/athena_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/athena_i.pcx 0644
f none quake2/baseq2/players/female/brianna.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/brianna.pcx 0644
f none quake2/baseq2/players/female/brianna_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/brianna_i.pcx 0644
f none quake2/baseq2/players/female/cobalt.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/cobalt.pcx 0644
f none quake2/baseq2/players/female/cobalt_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/cobalt_i.pcx 0644
f none quake2/baseq2/players/female/doomgal.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/doomgal.pcx 0644
f none quake2/baseq2/players/female/doomgal_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/doomgal_i.pcx 0644
f none quake2/baseq2/players/female/ensign.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/ensign.pcx 0644
f none quake2/baseq2/players/female/ensign_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/ensign_i.pcx 0644
f none quake2/baseq2/players/female/jezebel.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/jezebel.pcx 0644
f none quake2/baseq2/players/female/jezebel_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/jezebel_i.pcx 0644
f none quake2/baseq2/players/female/jungle.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/jungle.pcx 0644
f none quake2/baseq2/players/female/jungle_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/jungle_i.pcx 0644
f none quake2/baseq2/players/female/lotus.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/lotus.pcx 0644
f none quake2/baseq2/players/female/lotus_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/lotus_i.pcx 0644
f none quake2/baseq2/players/female/stiletto.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/stiletto.pcx 0644
f none quake2/baseq2/players/female/stiletto_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/stiletto_i.pcx 0644
f none quake2/baseq2/players/female/tris.md2=/usr/local/src/quake2-data/quake2/baseq2/players/female/tris.md2 0644
f none quake2/baseq2/players/female/venus.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/venus.pcx 0644
f none quake2/baseq2/players/female/venus_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/venus_i.pcx 0644
f none quake2/baseq2/players/female/voodoo.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/voodoo.pcx 0644
f none quake2/baseq2/players/female/voodoo_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/voodoo_i.pcx 0644
f none quake2/baseq2/players/female/weapon.md2=/usr/local/src/quake2-data/quake2/baseq2/players/female/weapon.md2 0644
f none quake2/baseq2/players/female/weapon.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/female/weapon.pcx 0644
d none quake2/baseq2/players/male 0755
f none quake2/baseq2/players/male/cipher.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/cipher.pcx 0644
f none quake2/baseq2/players/male/cipher_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/cipher_i.pcx 0644
f none quake2/baseq2/players/male/claymore.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/claymore.pcx 0644
f none quake2/baseq2/players/male/claymore_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/claymore_i.pcx 0644
f none quake2/baseq2/players/male/flak.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/flak.pcx 0644
f none quake2/baseq2/players/male/flak_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/flak_i.pcx 0644
f none quake2/baseq2/players/male/grunt.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/grunt.pcx 0644
f none quake2/baseq2/players/male/grunt_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/grunt_i.pcx 0644
f none quake2/baseq2/players/male/howitzer.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/howitzer.pcx 0644
f none quake2/baseq2/players/male/howitzer_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/howitzer_i.pcx 0644
f none quake2/baseq2/players/male/major.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/major.pcx 0644
f none quake2/baseq2/players/male/major_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/major_i.pcx 0644
f none quake2/baseq2/players/male/nightops.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/nightops.pcx 0644
f none quake2/baseq2/players/male/nightops_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/nightops_i.pcx 0644
f none quake2/baseq2/players/male/pointman.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/pointman.pcx 0644
f none quake2/baseq2/players/male/pointman_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/pointman_i.pcx 0644
f none quake2/baseq2/players/male/psycho.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/psycho.pcx 0644
f none quake2/baseq2/players/male/psycho_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/psycho_i.pcx 0644
f none quake2/baseq2/players/male/rampage.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/rampage.pcx 0644
f none quake2/baseq2/players/male/rampage_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/rampage_i.pcx 0644
f none quake2/baseq2/players/male/razor.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/razor.pcx 0644
f none quake2/baseq2/players/male/razor_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/razor_i.pcx 0644
f none quake2/baseq2/players/male/recon.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/recon.pcx 0644
f none quake2/baseq2/players/male/recon_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/recon_i.pcx 0644
f none quake2/baseq2/players/male/scout.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/scout.pcx 0644
f none quake2/baseq2/players/male/scout_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/scout_i.pcx 0644
f none quake2/baseq2/players/male/skin.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/skin.pcx 0644
f none quake2/baseq2/players/male/sniper.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/sniper.pcx 0644
f none quake2/baseq2/players/male/sniper_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/sniper_i.pcx 0644
f none quake2/baseq2/players/male/tris.md2=/usr/local/src/quake2-data/quake2/baseq2/players/male/tris.md2 0644
f none quake2/baseq2/players/male/viper.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/viper.pcx 0644
f none quake2/baseq2/players/male/viper_i.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/viper_i.pcx 0644
f none quake2/baseq2/players/male/weapon.md2=/usr/local/src/quake2-data/quake2/baseq2/players/male/weapon.md2 0644
f none quake2/baseq2/players/male/weapon.pcx=/usr/local/src/quake2-data/quake2/baseq2/players/male/weapon.pcx 0644

View file

@ -0,0 +1,8 @@
!default 0755 root bin
i pkginfo
i copyright
i depend
i postinstall
i postremove
i preinstall
i preremove

View file

@ -0,0 +1 @@
/usr/local/share 20000 1

12
solaris/q2.xbm Normal file
View file

@ -0,0 +1,12 @@
#define q2_width 32
#define q2_height 32
static unsigned char q2_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,
0x01,0x00,0x00,0x00,0x01,0x20,0x00,0x00,0x02,0x20,0x00,0x00,0x02,0x30,0x00,
0x00,0x04,0x30,0x00,0x00,0x04,0x10,0x00,0x00,0x04,0x30,0x00,0x00,0x06,0x10,
0x00,0x00,0x06,0x30,0x00,0x00,0x06,0x70,0x00,0x00,0x02,0x60,0xf0,0x07,0x03,
0xe0,0x60,0x83,0x03,0xc0,0x61,0x83,0x01,0xc0,0x63,0xe3,0x01,0x00,0x67,0x73,
0x00,0x00,0xff,0x7f,0x00,0x00,0xfc,0x1f,0x00,0x00,0xf0,0x07,0x00,0x00,0x60,
0x03,0x00,0x00,0x60,0x03,0x00,0x00,0x60,0x03,0x00,0x00,0x60,0x03,0x00,0x00,
0x60,0x03,0x00,0x00,0x60,0x03,0x00,0x00,0x20,0x02,0x00,0x00,0x40,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

View file

@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <sys/mman.h>
#include <sys/time.h>
#include "../linux/glob.h"
#include "../solaris/glob.h"
#include "../qcommon/qcommon.h"
@ -42,6 +42,9 @@ void *Hunk_Begin (int maxsize)
maxhunksize = maxsize;
curhunksize = 0;
membase = malloc(maxhunksize);
/* DEBUG: eliasm */
memset( membase, 0, maxhunksize );
/* DEBUG: eliasm */
if (membase == NULL)
Sys_Error(ERR_FATAL, "unable to allocate %d bytes", maxsize);
@ -87,7 +90,7 @@ Sys_Milliseconds
================
*/
int curtime;
int Sys_Milliseconds (void)
int xSys_Milliseconds (void)
{
struct timeval tp;
struct timezone tzp;
@ -106,6 +109,20 @@ int Sys_Milliseconds (void)
return curtime;
}
extern hrtime_t base_hrtime;
int Sys_Milliseconds( void )
{
hrtime_t curr_hrtime;
curr_hrtime = gethrtime();
curtime = (curr_hrtime - base_hrtime) / 1000000LL;
return curtime;
}
void Sys_Mkdir (char *path)
{
mkdir (path, 0777);
@ -136,7 +153,8 @@ static qboolean CompareAttributes(char *path, char *name,
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
return false;
sprintf(fn, "%s/%s", path, name);
return true;
//sprintf(fn, "%s/%s", path, name);
if (stat(fn, &st) == -1)
return false; // shouldn't happen
@ -169,7 +187,8 @@ char *Sys_FindFirst (char *path, unsigned musthave, unsigned canhave)
if (strcmp(findpattern, "*.*") == 0)
strcpy(findpattern, "*");
if ((fdir = opendir(path)) == NULL)
/* if ((fdir = opendir(path)) == NULL)*/
if ((fdir = opendir(findbase)) == NULL)
return NULL;
while ((d = readdir(fdir)) != NULL) {
if (!*findpattern || glob_match(findpattern, d->d_name)) {

3413
solaris/qgl_solaris.c Normal file

File diff suppressed because it is too large Load diff

690
solaris/qgl_solaris.h Normal file
View file

@ -0,0 +1,690 @@
#ifndef QGL_SOLARIS_H
#define QGL_SOLARIS_H
void ( APIENTRY * qglAccum )(GLenum op, GLfloat value);
void ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref);
GLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);
void ( APIENTRY * qglArrayElement )(GLint i);
void ( APIENTRY * qglBegin )(GLenum mode);
void ( APIENTRY * qglBindTexture )(GLenum target, GLuint texture);
void ( APIENTRY * qglBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);
void ( APIENTRY * qglBlendFunc )(GLenum sfactor, GLenum dfactor);
void ( APIENTRY * qglCallList )(GLuint list);
void ( APIENTRY * qglCallLists )(GLsizei n, GLenum type, const GLvoid *lists);
void ( APIENTRY * qglClear )(GLbitfield mask);
void ( APIENTRY * qglClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void ( APIENTRY * qglClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void ( APIENTRY * qglClearDepth )(GLclampd depth);
void ( APIENTRY * qglClearIndex )(GLfloat c);
void ( APIENTRY * qglClearStencil )(GLint s);
void ( APIENTRY * qglClipPlane )(GLenum plane, const GLdouble *equation);
void ( APIENTRY * qglColor3b )(GLbyte red, GLbyte green, GLbyte blue);
void ( APIENTRY * qglColor3bv )(const GLbyte *v);
void ( APIENTRY * qglColor3d )(GLdouble red, GLdouble green, GLdouble blue);
void ( APIENTRY * qglColor3dv )(const GLdouble *v);
void ( APIENTRY * qglColor3f )(GLfloat red, GLfloat green, GLfloat blue);
void ( APIENTRY * qglColor3fv )(const GLfloat *v);
void ( APIENTRY * qglColor3i )(GLint red, GLint green, GLint blue);
void ( APIENTRY * qglColor3iv )(const GLint *v);
void ( APIENTRY * qglColor3s )(GLshort red, GLshort green, GLshort blue);
void ( APIENTRY * qglColor3sv )(const GLshort *v);
void ( APIENTRY * qglColor3ub )(GLubyte red, GLubyte green, GLubyte blue);
void ( APIENTRY * qglColor3ubv )(const GLubyte *v);
void ( APIENTRY * qglColor3ui )(GLuint red, GLuint green, GLuint blue);
void ( APIENTRY * qglColor3uiv )(const GLuint *v);
void ( APIENTRY * qglColor3us )(GLushort red, GLushort green, GLushort blue);
void ( APIENTRY * qglColor3usv )(const GLushort *v);
void ( APIENTRY * qglColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);
void ( APIENTRY * qglColor4bv )(const GLbyte *v);
void ( APIENTRY * qglColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
void ( APIENTRY * qglColor4dv )(const GLdouble *v);
void ( APIENTRY * qglColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void ( APIENTRY * qglColor4fv )(const GLfloat *v);
void ( APIENTRY * qglColor4i )(GLint red, GLint green, GLint blue, GLint alpha);
void ( APIENTRY * qglColor4iv )(const GLint *v);
void ( APIENTRY * qglColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);
void ( APIENTRY * qglColor4sv )(const GLshort *v);
void ( APIENTRY * qglColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
void ( APIENTRY * qglColor4ubv )(const GLubyte *v);
void ( APIENTRY * qglColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);
void ( APIENTRY * qglColor4uiv )(const GLuint *v);
void ( APIENTRY * qglColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);
void ( APIENTRY * qglColor4usv )(const GLushort *v);
void ( APIENTRY * qglColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void ( APIENTRY * qglColorMaterial )(GLenum face, GLenum mode);
void ( APIENTRY * qglColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void ( APIENTRY * qglCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
void ( APIENTRY * qglCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);
void ( APIENTRY * qglCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
void ( APIENTRY * qglCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
void ( APIENTRY * qglCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
void ( APIENTRY * qglCullFace )(GLenum mode);
void ( APIENTRY * qglDeleteLists )(GLuint list, GLsizei range);
void ( APIENTRY * qglDeleteTextures )(GLsizei n, const GLuint *textures);
void ( APIENTRY * qglDepthFunc )(GLenum func);
void ( APIENTRY * qglDepthMask )(GLboolean flag);
void ( APIENTRY * qglDepthRange )(GLclampd zNear, GLclampd zFar);
void ( APIENTRY * qglDisable )(GLenum cap);
void ( APIENTRY * qglDisableClientState )(GLenum array);
void ( APIENTRY * qglDrawArrays )(GLenum mode, GLint first, GLsizei count);
void ( APIENTRY * qglDrawBuffer )(GLenum mode);
void ( APIENTRY * qglDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
void ( APIENTRY * qglDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
void ( APIENTRY * qglEdgeFlag )(GLboolean flag);
void ( APIENTRY * qglEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);
void ( APIENTRY * qglEdgeFlagv )(const GLboolean *flag);
void ( APIENTRY * qglEnable )(GLenum cap);
void ( APIENTRY * qglEnableClientState )(GLenum array);
void ( APIENTRY * qglEnd )(void);
void ( APIENTRY * qglEndList )(void);
void ( APIENTRY * qglEvalCoord1d )(GLdouble u);
void ( APIENTRY * qglEvalCoord1dv )(const GLdouble *u);
void ( APIENTRY * qglEvalCoord1f )(GLfloat u);
void ( APIENTRY * qglEvalCoord1fv )(const GLfloat *u);
void ( APIENTRY * qglEvalCoord2d )(GLdouble u, GLdouble v);
void ( APIENTRY * qglEvalCoord2dv )(const GLdouble *u);
void ( APIENTRY * qglEvalCoord2f )(GLfloat u, GLfloat v);
void ( APIENTRY * qglEvalCoord2fv )(const GLfloat *u);
void ( APIENTRY * qglEvalMesh1 )(GLenum mode, GLint i1, GLint i2);
void ( APIENTRY * qglEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
void ( APIENTRY * qglEvalPoint1 )(GLint i);
void ( APIENTRY * qglEvalPoint2 )(GLint i, GLint j);
void ( APIENTRY * qglFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);
void ( APIENTRY * qglFinish )(void);
void ( APIENTRY * qglFlush )(void);
void ( APIENTRY * qglFogf )(GLenum pname, GLfloat param);
void ( APIENTRY * qglFogfv )(GLenum pname, const GLfloat *params);
void ( APIENTRY * qglFogi )(GLenum pname, GLint param);
void ( APIENTRY * qglFogiv )(GLenum pname, const GLint *params);
void ( APIENTRY * qglFrontFace )(GLenum mode);
void ( APIENTRY * qglFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
GLuint ( APIENTRY * qglGenLists )(GLsizei range);
void ( APIENTRY * qglGenTextures )(GLsizei n, GLuint *textures);
void ( APIENTRY * qglGetBooleanv )(GLenum pname, GLboolean *params);
void ( APIENTRY * qglGetClipPlane )(GLenum plane, GLdouble *equation);
void ( APIENTRY * qglGetDoublev )(GLenum pname, GLdouble *params);
GLenum ( APIENTRY * qglGetError )(void);
void ( APIENTRY * qglGetFloatv )(GLenum pname, GLfloat *params);
void ( APIENTRY * qglGetIntegerv )(GLenum pname, GLint *params);
void ( APIENTRY * qglGetLightfv )(GLenum light, GLenum pname, GLfloat *params);
void ( APIENTRY * qglGetLightiv )(GLenum light, GLenum pname, GLint *params);
void ( APIENTRY * qglGetMapdv )(GLenum target, GLenum query, GLdouble *v);
void ( APIENTRY * qglGetMapfv )(GLenum target, GLenum query, GLfloat *v);
void ( APIENTRY * qglGetMapiv )(GLenum target, GLenum query, GLint *v);
void ( APIENTRY * qglGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);
void ( APIENTRY * qglGetMaterialiv )(GLenum face, GLenum pname, GLint *params);
void ( APIENTRY * qglGetPixelMapfv )(GLenum map, GLfloat *values);
void ( APIENTRY * qglGetPixelMapuiv )(GLenum map, GLuint *values);
void ( APIENTRY * qglGetPixelMapusv )(GLenum map, GLushort *values);
void ( APIENTRY * qglGetPointerv )(GLenum pname, GLvoid* *params);
void ( APIENTRY * qglGetPolygonStipple )(GLubyte *mask);
const GLubyte * ( APIENTRY * qglGetString )(GLenum name);
void ( APIENTRY * qglGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);
void ( APIENTRY * qglGetTexEnviv )(GLenum target, GLenum pname, GLint *params);
void ( APIENTRY * qglGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);
void ( APIENTRY * qglGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);
void ( APIENTRY * qglGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);
void ( APIENTRY * qglGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
void ( APIENTRY * qglGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);
void ( APIENTRY * qglGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);
void ( APIENTRY * qglGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);
void ( APIENTRY * qglGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);
void ( APIENTRY * qglHint )(GLenum target, GLenum mode);
void ( APIENTRY * qglIndexMask )(GLuint mask);
void ( APIENTRY * qglIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);
void ( APIENTRY * qglIndexd )(GLdouble c);
void ( APIENTRY * qglIndexdv )(const GLdouble *c);
void ( APIENTRY * qglIndexf )(GLfloat c);
void ( APIENTRY * qglIndexfv )(const GLfloat *c);
void ( APIENTRY * qglIndexi )(GLint c);
void ( APIENTRY * qglIndexiv )(const GLint *c);
void ( APIENTRY * qglIndexs )(GLshort c);
void ( APIENTRY * qglIndexsv )(const GLshort *c);
void ( APIENTRY * qglIndexub )(GLubyte c);
void ( APIENTRY * qglIndexubv )(const GLubyte *c);
void ( APIENTRY * qglInitNames )(void);
void ( APIENTRY * qglInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);
GLboolean ( APIENTRY * qglIsEnabled )(GLenum cap);
GLboolean ( APIENTRY * qglIsList )(GLuint list);
GLboolean ( APIENTRY * qglIsTexture )(GLuint texture);
void ( APIENTRY * qglLightModelf )(GLenum pname, GLfloat param);
void ( APIENTRY * qglLightModelfv )(GLenum pname, const GLfloat *params);
void ( APIENTRY * qglLightModeli )(GLenum pname, GLint param);
void ( APIENTRY * qglLightModeliv )(GLenum pname, const GLint *params);
void ( APIENTRY * qglLightf )(GLenum light, GLenum pname, GLfloat param);
void ( APIENTRY * qglLightfv )(GLenum light, GLenum pname, const GLfloat *params);
void ( APIENTRY * qglLighti )(GLenum light, GLenum pname, GLint param);
void ( APIENTRY * qglLightiv )(GLenum light, GLenum pname, const GLint *params);
void ( APIENTRY * qglLineStipple )(GLint factor, GLushort pattern);
void ( APIENTRY * qglLineWidth )(GLfloat width);
void ( APIENTRY * qglListBase )(GLuint base);
void ( APIENTRY * qglLoadIdentity )(void);
void ( APIENTRY * qglLoadMatrixd )(const GLdouble *m);
void ( APIENTRY * qglLoadMatrixf )(const GLfloat *m);
void ( APIENTRY * qglLoadName )(GLuint name);
void ( APIENTRY * qglLogicOp )(GLenum opcode);
void ( APIENTRY * qglMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
void ( APIENTRY * qglMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
void ( APIENTRY * qglMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
void ( APIENTRY * qglMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
void ( APIENTRY * qglMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);
void ( APIENTRY * qglMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);
void ( APIENTRY * qglMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
void ( APIENTRY * qglMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
void ( APIENTRY * qglMaterialf )(GLenum face, GLenum pname, GLfloat param);
void ( APIENTRY * qglMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);
void ( APIENTRY * qglMateriali )(GLenum face, GLenum pname, GLint param);
void ( APIENTRY * qglMaterialiv )(GLenum face, GLenum pname, const GLint *params);
void ( APIENTRY * qglMatrixMode )(GLenum mode);
void ( APIENTRY * qglMultMatrixd )(const GLdouble *m);
void ( APIENTRY * qglMultMatrixf )(const GLfloat *m);
void ( APIENTRY * qglNewList )(GLuint list, GLenum mode);
void ( APIENTRY * qglNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);
void ( APIENTRY * qglNormal3bv )(const GLbyte *v);
void ( APIENTRY * qglNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);
void ( APIENTRY * qglNormal3dv )(const GLdouble *v);
void ( APIENTRY * qglNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);
void ( APIENTRY * qglNormal3fv )(const GLfloat *v);
void ( APIENTRY * qglNormal3i )(GLint nx, GLint ny, GLint nz);
void ( APIENTRY * qglNormal3iv )(const GLint *v);
void ( APIENTRY * qglNormal3s )(GLshort nx, GLshort ny, GLshort nz);
void ( APIENTRY * qglNormal3sv )(const GLshort *v);
void ( APIENTRY * qglNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);
void ( APIENTRY * qglOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
void ( APIENTRY * qglPassThrough )(GLfloat token);
void ( APIENTRY * qglPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);
void ( APIENTRY * qglPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);
void ( APIENTRY * qglPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);
void ( APIENTRY * qglPixelStoref )(GLenum pname, GLfloat param);
void ( APIENTRY * qglPixelStorei )(GLenum pname, GLint param);
void ( APIENTRY * qglPixelTransferf )(GLenum pname, GLfloat param);
void ( APIENTRY * qglPixelTransferi )(GLenum pname, GLint param);
void ( APIENTRY * qglPixelZoom )(GLfloat xfactor, GLfloat yfactor);
void ( APIENTRY * qglPointSize )(GLfloat size);
void ( APIENTRY * qglPolygonMode )(GLenum face, GLenum mode);
void ( APIENTRY * qglPolygonOffset )(GLfloat factor, GLfloat units);
void ( APIENTRY * qglPolygonStipple )(const GLubyte *mask);
void ( APIENTRY * qglPopAttrib )(void);
void ( APIENTRY * qglPopClientAttrib )(void);
void ( APIENTRY * qglPopMatrix )(void);
void ( APIENTRY * qglPopName )(void);
void ( APIENTRY * qglPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);
void ( APIENTRY * qglPushAttrib )(GLbitfield mask);
void ( APIENTRY * qglPushClientAttrib )(GLbitfield mask);
void ( APIENTRY * qglPushMatrix )(void);
void ( APIENTRY * qglPushName )(GLuint name);
void ( APIENTRY * qglRasterPos2d )(GLdouble x, GLdouble y);
void ( APIENTRY * qglRasterPos2dv )(const GLdouble *v);
void ( APIENTRY * qglRasterPos2f )(GLfloat x, GLfloat y);
void ( APIENTRY * qglRasterPos2fv )(const GLfloat *v);
void ( APIENTRY * qglRasterPos2i )(GLint x, GLint y);
void ( APIENTRY * qglRasterPos2iv )(const GLint *v);
void ( APIENTRY * qglRasterPos2s )(GLshort x, GLshort y);
void ( APIENTRY * qglRasterPos2sv )(const GLshort *v);
void ( APIENTRY * qglRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);
void ( APIENTRY * qglRasterPos3dv )(const GLdouble *v);
void ( APIENTRY * qglRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);
void ( APIENTRY * qglRasterPos3fv )(const GLfloat *v);
void ( APIENTRY * qglRasterPos3i )(GLint x, GLint y, GLint z);
void ( APIENTRY * qglRasterPos3iv )(const GLint *v);
void ( APIENTRY * qglRasterPos3s )(GLshort x, GLshort y, GLshort z);
void ( APIENTRY * qglRasterPos3sv )(const GLshort *v);
void ( APIENTRY * qglRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
void ( APIENTRY * qglRasterPos4dv )(const GLdouble *v);
void ( APIENTRY * qglRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void ( APIENTRY * qglRasterPos4fv )(const GLfloat *v);
void ( APIENTRY * qglRasterPos4i )(GLint x, GLint y, GLint z, GLint w);
void ( APIENTRY * qglRasterPos4iv )(const GLint *v);
void ( APIENTRY * qglRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);
void ( APIENTRY * qglRasterPos4sv )(const GLshort *v);
void ( APIENTRY * qglReadBuffer )(GLenum mode);
void ( APIENTRY * qglReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
void ( APIENTRY * qglRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
void ( APIENTRY * qglRectdv )(const GLdouble *v1, const GLdouble *v2);
void ( APIENTRY * qglRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
void ( APIENTRY * qglRectfv )(const GLfloat *v1, const GLfloat *v2);
void ( APIENTRY * qglRecti )(GLint x1, GLint y1, GLint x2, GLint y2);
void ( APIENTRY * qglRectiv )(const GLint *v1, const GLint *v2);
void ( APIENTRY * qglRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
void ( APIENTRY * qglRectsv )(const GLshort *v1, const GLshort *v2);
GLint ( APIENTRY * qglRenderMode )(GLenum mode);
void ( APIENTRY * qglRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
void ( APIENTRY * qglRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
void ( APIENTRY * qglScaled )(GLdouble x, GLdouble y, GLdouble z);
void ( APIENTRY * qglScalef )(GLfloat x, GLfloat y, GLfloat z);
void ( APIENTRY * qglScissor )(GLint x, GLint y, GLsizei width, GLsizei height);
void ( APIENTRY * qglSelectBuffer )(GLsizei size, GLuint *buffer);
void ( APIENTRY * qglShadeModel )(GLenum mode);
void ( APIENTRY * qglStencilFunc )(GLenum func, GLint ref, GLuint mask);
void ( APIENTRY * qglStencilMask )(GLuint mask);
void ( APIENTRY * qglStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);
void ( APIENTRY * qglTexCoord1d )(GLdouble s);
void ( APIENTRY * qglTexCoord1dv )(const GLdouble *v);
void ( APIENTRY * qglTexCoord1f )(GLfloat s);
void ( APIENTRY * qglTexCoord1fv )(const GLfloat *v);
void ( APIENTRY * qglTexCoord1i )(GLint s);
void ( APIENTRY * qglTexCoord1iv )(const GLint *v);
void ( APIENTRY * qglTexCoord1s )(GLshort s);
void ( APIENTRY * qglTexCoord1sv )(const GLshort *v);
void ( APIENTRY * qglTexCoord2d )(GLdouble s, GLdouble t);
void ( APIENTRY * qglTexCoord2dv )(const GLdouble *v);
void ( APIENTRY * qglTexCoord2f )(GLfloat s, GLfloat t);
void ( APIENTRY * qglTexCoord2fv )(const GLfloat *v);
void ( APIENTRY * qglTexCoord2i )(GLint s, GLint t);
void ( APIENTRY * qglTexCoord2iv )(const GLint *v);
void ( APIENTRY * qglTexCoord2s )(GLshort s, GLshort t);
void ( APIENTRY * qglTexCoord2sv )(const GLshort *v);
void ( APIENTRY * qglTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);
void ( APIENTRY * qglTexCoord3dv )(const GLdouble *v);
void ( APIENTRY * qglTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);
void ( APIENTRY * qglTexCoord3fv )(const GLfloat *v);
void ( APIENTRY * qglTexCoord3i )(GLint s, GLint t, GLint r);
void ( APIENTRY * qglTexCoord3iv )(const GLint *v);
void ( APIENTRY * qglTexCoord3s )(GLshort s, GLshort t, GLshort r);
void ( APIENTRY * qglTexCoord3sv )(const GLshort *v);
void ( APIENTRY * qglTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);
void ( APIENTRY * qglTexCoord4dv )(const GLdouble *v);
void ( APIENTRY * qglTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);
void ( APIENTRY * qglTexCoord4fv )(const GLfloat *v);
void ( APIENTRY * qglTexCoord4i )(GLint s, GLint t, GLint r, GLint q);
void ( APIENTRY * qglTexCoord4iv )(const GLint *v);
void ( APIENTRY * qglTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);
void ( APIENTRY * qglTexCoord4sv )(const GLshort *v);
void ( APIENTRY * qglTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void ( APIENTRY * qglTexEnvf )(GLenum target, GLenum pname, GLfloat param);
void ( APIENTRY * qglTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);
void ( APIENTRY * qglTexEnvi )(GLenum target, GLenum pname, GLint param);
void ( APIENTRY * qglTexEnviv )(GLenum target, GLenum pname, const GLint *params);
void ( APIENTRY * qglTexGend )(GLenum coord, GLenum pname, GLdouble param);
void ( APIENTRY * qglTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);
void ( APIENTRY * qglTexGenf )(GLenum coord, GLenum pname, GLfloat param);
void ( APIENTRY * qglTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);
void ( APIENTRY * qglTexGeni )(GLenum coord, GLenum pname, GLint param);
void ( APIENTRY * qglTexGeniv )(GLenum coord, GLenum pname, const GLint *params);
void ( APIENTRY * qglTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void ( APIENTRY * qglTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void ( APIENTRY * qglTexParameterf )(GLenum target, GLenum pname, GLfloat param);
void ( APIENTRY * qglTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);
void ( APIENTRY * qglTexParameteri )(GLenum target, GLenum pname, GLint param);
void ( APIENTRY * qglTexParameteriv )(GLenum target, GLenum pname, const GLint *params);
void ( APIENTRY * qglTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
void ( APIENTRY * qglTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
void ( APIENTRY * qglTranslated )(GLdouble x, GLdouble y, GLdouble z);
void ( APIENTRY * qglTranslatef )(GLfloat x, GLfloat y, GLfloat z);
void ( APIENTRY * qglVertex2d )(GLdouble x, GLdouble y);
void ( APIENTRY * qglVertex2dv )(const GLdouble *v);
void ( APIENTRY * qglVertex2f )(GLfloat x, GLfloat y);
void ( APIENTRY * qglVertex2fv )(const GLfloat *v);
void ( APIENTRY * qglVertex2i )(GLint x, GLint y);
void ( APIENTRY * qglVertex2iv )(const GLint *v);
void ( APIENTRY * qglVertex2s )(GLshort x, GLshort y);
void ( APIENTRY * qglVertex2sv )(const GLshort *v);
void ( APIENTRY * qglVertex3d )(GLdouble x, GLdouble y, GLdouble z);
void ( APIENTRY * qglVertex3dv )(const GLdouble *v);
void ( APIENTRY * qglVertex3f )(GLfloat x, GLfloat y, GLfloat z);
void ( APIENTRY * qglVertex3fv )(const GLfloat *v);
void ( APIENTRY * qglVertex3i )(GLint x, GLint y, GLint z);
void ( APIENTRY * qglVertex3iv )(const GLint *v);
void ( APIENTRY * qglVertex3s )(GLshort x, GLshort y, GLshort z);
void ( APIENTRY * qglVertex3sv )(const GLshort *v);
void ( APIENTRY * qglVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
void ( APIENTRY * qglVertex4dv )(const GLdouble *v);
void ( APIENTRY * qglVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void ( APIENTRY * qglVertex4fv )(const GLfloat *v);
void ( APIENTRY * qglVertex4i )(GLint x, GLint y, GLint z, GLint w);
void ( APIENTRY * qglVertex4iv )(const GLint *v);
void ( APIENTRY * qglVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);
void ( APIENTRY * qglVertex4sv )(const GLshort *v);
void ( APIENTRY * qglVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height);
void ( APIENTRY * qglLockArraysEXT)( int, int);
void ( APIENTRY * qglUnlockArraysEXT) ( void );
void ( APIENTRY * qglPointParameterfEXT)( GLenum param, GLfloat value );
void ( APIENTRY * qglPointParameterfvEXT)( GLenum param, const GLfloat *value );
void ( APIENTRY * qglColorTableEXT)( GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid * );
void ( APIENTRY * qgl3DfxSetPaletteEXT)( GLuint * );
void ( APIENTRY * qglSelectTextureSGIS)( GLenum );
void ( APIENTRY * qglMTexCoord2fSGIS)( GLenum, GLfloat, GLfloat );
void ( APIENTRY * qglActiveTextureARB) ( GLenum );
void ( APIENTRY * qglClientActiveTextureARB) ( GLenum );
static void ( APIENTRY * dllAccum )(GLenum op, GLfloat value);
static void ( APIENTRY * dllAlphaFunc )(GLenum func, GLclampf ref);
GLboolean ( APIENTRY * dllAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);
static void ( APIENTRY * dllArrayElement )(GLint i);
static void ( APIENTRY * dllBegin )(GLenum mode);
static void ( APIENTRY * dllBindTexture )(GLenum target, GLuint texture);
static void ( APIENTRY * dllBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);
static void ( APIENTRY * dllBlendFunc )(GLenum sfactor, GLenum dfactor);
static void ( APIENTRY * dllCallList )(GLuint list);
static void ( APIENTRY * dllCallLists )(GLsizei n, GLenum type, const GLvoid *lists);
static void ( APIENTRY * dllClear )(GLbitfield mask);
static void ( APIENTRY * dllClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
static void ( APIENTRY * dllClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
static void ( APIENTRY * dllClearDepth )(GLclampd depth);
static void ( APIENTRY * dllClearIndex )(GLfloat c);
static void ( APIENTRY * dllClearStencil )(GLint s);
static void ( APIENTRY * dllClipPlane )(GLenum plane, const GLdouble *equation);
static void ( APIENTRY * dllColor3b )(GLbyte red, GLbyte green, GLbyte blue);
static void ( APIENTRY * dllColor3bv )(const GLbyte *v);
static void ( APIENTRY * dllColor3d )(GLdouble red, GLdouble green, GLdouble blue);
static void ( APIENTRY * dllColor3dv )(const GLdouble *v);
static void ( APIENTRY * dllColor3f )(GLfloat red, GLfloat green, GLfloat blue);
static void ( APIENTRY * dllColor3fv )(const GLfloat *v);
static void ( APIENTRY * dllColor3i )(GLint red, GLint green, GLint blue);
static void ( APIENTRY * dllColor3iv )(const GLint *v);
static void ( APIENTRY * dllColor3s )(GLshort red, GLshort green, GLshort blue);
static void ( APIENTRY * dllColor3sv )(const GLshort *v);
static void ( APIENTRY * dllColor3ub )(GLubyte red, GLubyte green, GLubyte blue);
static void ( APIENTRY * dllColor3ubv )(const GLubyte *v);
static void ( APIENTRY * dllColor3ui )(GLuint red, GLuint green, GLuint blue);
static void ( APIENTRY * dllColor3uiv )(const GLuint *v);
static void ( APIENTRY * dllColor3us )(GLushort red, GLushort green, GLushort blue);
static void ( APIENTRY * dllColor3usv )(const GLushort *v);
static void ( APIENTRY * dllColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);
static void ( APIENTRY * dllColor4bv )(const GLbyte *v);
static void ( APIENTRY * dllColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
static void ( APIENTRY * dllColor4dv )(const GLdouble *v);
static void ( APIENTRY * dllColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
static void ( APIENTRY * dllColor4fv )(const GLfloat *v);
static void ( APIENTRY * dllColor4i )(GLint red, GLint green, GLint blue, GLint alpha);
static void ( APIENTRY * dllColor4iv )(const GLint *v);
static void ( APIENTRY * dllColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha);
static void ( APIENTRY * dllColor4sv )(const GLshort *v);
static void ( APIENTRY * dllColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
static void ( APIENTRY * dllColor4ubv )(const GLubyte *v);
static void ( APIENTRY * dllColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha);
static void ( APIENTRY * dllColor4uiv )(const GLuint *v);
static void ( APIENTRY * dllColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha);
static void ( APIENTRY * dllColor4usv )(const GLushort *v);
static void ( APIENTRY * dllColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
static void ( APIENTRY * dllColorMaterial )(GLenum face, GLenum mode);
static void ( APIENTRY * dllColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
static void ( APIENTRY * dllCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
static void ( APIENTRY * dllCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);
static void ( APIENTRY * dllCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
static void ( APIENTRY * dllCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
static void ( APIENTRY * dllCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
static void ( APIENTRY * dllCullFace )(GLenum mode);
static void ( APIENTRY * dllDeleteLists )(GLuint list, GLsizei range);
static void ( APIENTRY * dllDeleteTextures )(GLsizei n, const GLuint *textures);
static void ( APIENTRY * dllDepthFunc )(GLenum func);
static void ( APIENTRY * dllDepthMask )(GLboolean flag);
static void ( APIENTRY * dllDepthRange )(GLclampd zNear, GLclampd zFar);
static void ( APIENTRY * dllDisable )(GLenum cap);
static void ( APIENTRY * dllDisableClientState )(GLenum array);
static void ( APIENTRY * dllDrawArrays )(GLenum mode, GLint first, GLsizei count);
static void ( APIENTRY * dllDrawBuffer )(GLenum mode);
static void ( APIENTRY * dllDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
static void ( APIENTRY * dllDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
static void ( APIENTRY * dllEdgeFlag )(GLboolean flag);
static void ( APIENTRY * dllEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer);
static void ( APIENTRY * dllEdgeFlagv )(const GLboolean *flag);
static void ( APIENTRY * dllEnable )(GLenum cap);
static void ( APIENTRY * dllEnableClientState )(GLenum array);
static void ( APIENTRY * dllEnd )(void);
static void ( APIENTRY * dllEndList )(void);
static void ( APIENTRY * dllEvalCoord1d )(GLdouble u);
static void ( APIENTRY * dllEvalCoord1dv )(const GLdouble *u);
static void ( APIENTRY * dllEvalCoord1f )(GLfloat u);
static void ( APIENTRY * dllEvalCoord1fv )(const GLfloat *u);
static void ( APIENTRY * dllEvalCoord2d )(GLdouble u, GLdouble v);
static void ( APIENTRY * dllEvalCoord2dv )(const GLdouble *u);
static void ( APIENTRY * dllEvalCoord2f )(GLfloat u, GLfloat v);
static void ( APIENTRY * dllEvalCoord2fv )(const GLfloat *u);
static void ( APIENTRY * dllEvalMesh1 )(GLenum mode, GLint i1, GLint i2);
static void ( APIENTRY * dllEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
static void ( APIENTRY * dllEvalPoint1 )(GLint i);
static void ( APIENTRY * dllEvalPoint2 )(GLint i, GLint j);
static void ( APIENTRY * dllFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer);
static void ( APIENTRY * dllFinish )(void);
static void ( APIENTRY * dllFlush )(void);
static void ( APIENTRY * dllFogf )(GLenum pname, GLfloat param);
static void ( APIENTRY * dllFogfv )(GLenum pname, const GLfloat *params);
static void ( APIENTRY * dllFogi )(GLenum pname, GLint param);
static void ( APIENTRY * dllFogiv )(GLenum pname, const GLint *params);
static void ( APIENTRY * dllFrontFace )(GLenum mode);
static void ( APIENTRY * dllFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
GLuint ( APIENTRY * dllGenLists )(GLsizei range);
static void ( APIENTRY * dllGenTextures )(GLsizei n, GLuint *textures);
static void ( APIENTRY * dllGetBooleanv )(GLenum pname, GLboolean *params);
static void ( APIENTRY * dllGetClipPlane )(GLenum plane, GLdouble *equation);
static void ( APIENTRY * dllGetDoublev )(GLenum pname, GLdouble *params);
GLenum ( APIENTRY * dllGetError )(void);
static void ( APIENTRY * dllGetFloatv )(GLenum pname, GLfloat *params);
static void ( APIENTRY * dllGetIntegerv )(GLenum pname, GLint *params);
static void ( APIENTRY * dllGetLightfv )(GLenum light, GLenum pname, GLfloat *params);
static void ( APIENTRY * dllGetLightiv )(GLenum light, GLenum pname, GLint *params);
static void ( APIENTRY * dllGetMapdv )(GLenum target, GLenum query, GLdouble *v);
static void ( APIENTRY * dllGetMapfv )(GLenum target, GLenum query, GLfloat *v);
static void ( APIENTRY * dllGetMapiv )(GLenum target, GLenum query, GLint *v);
static void ( APIENTRY * dllGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params);
static void ( APIENTRY * dllGetMaterialiv )(GLenum face, GLenum pname, GLint *params);
static void ( APIENTRY * dllGetPixelMapfv )(GLenum map, GLfloat *values);
static void ( APIENTRY * dllGetPixelMapuiv )(GLenum map, GLuint *values);
static void ( APIENTRY * dllGetPixelMapusv )(GLenum map, GLushort *values);
static void ( APIENTRY * dllGetPointerv )(GLenum pname, GLvoid* *params);
static void ( APIENTRY * dllGetPolygonStipple )(GLubyte *mask);
const GLubyte * ( APIENTRY * dllGetString )(GLenum name);
static void ( APIENTRY * dllGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params);
static void ( APIENTRY * dllGetTexEnviv )(GLenum target, GLenum pname, GLint *params);
static void ( APIENTRY * dllGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params);
static void ( APIENTRY * dllGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params);
static void ( APIENTRY * dllGetTexGeniv )(GLenum coord, GLenum pname, GLint *params);
static void ( APIENTRY * dllGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
static void ( APIENTRY * dllGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params);
static void ( APIENTRY * dllGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params);
static void ( APIENTRY * dllGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params);
static void ( APIENTRY * dllGetTexParameteriv )(GLenum target, GLenum pname, GLint *params);
static void ( APIENTRY * dllHint )(GLenum target, GLenum mode);
static void ( APIENTRY * dllIndexMask )(GLuint mask);
static void ( APIENTRY * dllIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);
static void ( APIENTRY * dllIndexd )(GLdouble c);
static void ( APIENTRY * dllIndexdv )(const GLdouble *c);
static void ( APIENTRY * dllIndexf )(GLfloat c);
static void ( APIENTRY * dllIndexfv )(const GLfloat *c);
static void ( APIENTRY * dllIndexi )(GLint c);
static void ( APIENTRY * dllIndexiv )(const GLint *c);
static void ( APIENTRY * dllIndexs )(GLshort c);
static void ( APIENTRY * dllIndexsv )(const GLshort *c);
static void ( APIENTRY * dllIndexub )(GLubyte c);
static void ( APIENTRY * dllIndexubv )(const GLubyte *c);
static void ( APIENTRY * dllInitNames )(void);
static void ( APIENTRY * dllInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer);
GLboolean ( APIENTRY * dllIsEnabled )(GLenum cap);
GLboolean ( APIENTRY * dllIsList )(GLuint list);
GLboolean ( APIENTRY * dllIsTexture )(GLuint texture);
static void ( APIENTRY * dllLightModelf )(GLenum pname, GLfloat param);
static void ( APIENTRY * dllLightModelfv )(GLenum pname, const GLfloat *params);
static void ( APIENTRY * dllLightModeli )(GLenum pname, GLint param);
static void ( APIENTRY * dllLightModeliv )(GLenum pname, const GLint *params);
static void ( APIENTRY * dllLightf )(GLenum light, GLenum pname, GLfloat param);
static void ( APIENTRY * dllLightfv )(GLenum light, GLenum pname, const GLfloat *params);
static void ( APIENTRY * dllLighti )(GLenum light, GLenum pname, GLint param);
static void ( APIENTRY * dllLightiv )(GLenum light, GLenum pname, const GLint *params);
static void ( APIENTRY * dllLineStipple )(GLint factor, GLushort pattern);
static void ( APIENTRY * dllLineWidth )(GLfloat width);
static void ( APIENTRY * dllListBase )(GLuint base);
static void ( APIENTRY * dllLoadIdentity )(void);
static void ( APIENTRY * dllLoadMatrixd )(const GLdouble *m);
static void ( APIENTRY * dllLoadMatrixf )(const GLfloat *m);
static void ( APIENTRY * dllLoadName )(GLuint name);
static void ( APIENTRY * dllLogicOp )(GLenum opcode);
static void ( APIENTRY * dllMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
static void ( APIENTRY * dllMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
static void ( APIENTRY * dllMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
static void ( APIENTRY * dllMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
static void ( APIENTRY * dllMapGrid1d )(GLint un, GLdouble u1, GLdouble u2);
static void ( APIENTRY * dllMapGrid1f )(GLint un, GLfloat u1, GLfloat u2);
static void ( APIENTRY * dllMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
static void ( APIENTRY * dllMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
static void ( APIENTRY * dllMaterialf )(GLenum face, GLenum pname, GLfloat param);
static void ( APIENTRY * dllMaterialfv )(GLenum face, GLenum pname, const GLfloat *params);
static void ( APIENTRY * dllMateriali )(GLenum face, GLenum pname, GLint param);
static void ( APIENTRY * dllMaterialiv )(GLenum face, GLenum pname, const GLint *params);
static void ( APIENTRY * dllMatrixMode )(GLenum mode);
static void ( APIENTRY * dllMultMatrixd )(const GLdouble *m);
static void ( APIENTRY * dllMultMatrixf )(const GLfloat *m);
static void ( APIENTRY * dllNewList )(GLuint list, GLenum mode);
static void ( APIENTRY * dllNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz);
static void ( APIENTRY * dllNormal3bv )(const GLbyte *v);
static void ( APIENTRY * dllNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz);
static void ( APIENTRY * dllNormal3dv )(const GLdouble *v);
static void ( APIENTRY * dllNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz);
static void ( APIENTRY * dllNormal3fv )(const GLfloat *v);
static void ( APIENTRY * dllNormal3i )(GLint nx, GLint ny, GLint nz);
static void ( APIENTRY * dllNormal3iv )(const GLint *v);
static void ( APIENTRY * dllNormal3s )(GLshort nx, GLshort ny, GLshort nz);
static void ( APIENTRY * dllNormal3sv )(const GLshort *v);
static void ( APIENTRY * dllNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer);
static void ( APIENTRY * dllOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
static void ( APIENTRY * dllPassThrough )(GLfloat token);
static void ( APIENTRY * dllPixelMapfv )(GLenum map, GLsizei mapsize, const GLfloat *values);
static void ( APIENTRY * dllPixelMapuiv )(GLenum map, GLsizei mapsize, const GLuint *values);
static void ( APIENTRY * dllPixelMapusv )(GLenum map, GLsizei mapsize, const GLushort *values);
static void ( APIENTRY * dllPixelStoref )(GLenum pname, GLfloat param);
static void ( APIENTRY * dllPixelStorei )(GLenum pname, GLint param);
static void ( APIENTRY * dllPixelTransferf )(GLenum pname, GLfloat param);
static void ( APIENTRY * dllPixelTransferi )(GLenum pname, GLint param);
static void ( APIENTRY * dllPixelZoom )(GLfloat xfactor, GLfloat yfactor);
static void ( APIENTRY * dllPointSize )(GLfloat size);
static void ( APIENTRY * dllPolygonMode )(GLenum face, GLenum mode);
static void ( APIENTRY * dllPolygonOffset )(GLfloat factor, GLfloat units);
static void ( APIENTRY * dllPolygonStipple )(const GLubyte *mask);
static void ( APIENTRY * dllPopAttrib )(void);
static void ( APIENTRY * dllPopClientAttrib )(void);
static void ( APIENTRY * dllPopMatrix )(void);
static void ( APIENTRY * dllPopName )(void);
static void ( APIENTRY * dllPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities);
static void ( APIENTRY * dllPushAttrib )(GLbitfield mask);
static void ( APIENTRY * dllPushClientAttrib )(GLbitfield mask);
static void ( APIENTRY * dllPushMatrix )(void);
static void ( APIENTRY * dllPushName )(GLuint name);
static void ( APIENTRY * dllRasterPos2d )(GLdouble x, GLdouble y);
static void ( APIENTRY * dllRasterPos2dv )(const GLdouble *v);
static void ( APIENTRY * dllRasterPos2f )(GLfloat x, GLfloat y);
static void ( APIENTRY * dllRasterPos2fv )(const GLfloat *v);
static void ( APIENTRY * dllRasterPos2i )(GLint x, GLint y);
static void ( APIENTRY * dllRasterPos2iv )(const GLint *v);
static void ( APIENTRY * dllRasterPos2s )(GLshort x, GLshort y);
static void ( APIENTRY * dllRasterPos2sv )(const GLshort *v);
static void ( APIENTRY * dllRasterPos3d )(GLdouble x, GLdouble y, GLdouble z);
static void ( APIENTRY * dllRasterPos3dv )(const GLdouble *v);
static void ( APIENTRY * dllRasterPos3f )(GLfloat x, GLfloat y, GLfloat z);
static void ( APIENTRY * dllRasterPos3fv )(const GLfloat *v);
static void ( APIENTRY * dllRasterPos3i )(GLint x, GLint y, GLint z);
static void ( APIENTRY * dllRasterPos3iv )(const GLint *v);
static void ( APIENTRY * dllRasterPos3s )(GLshort x, GLshort y, GLshort z);
static void ( APIENTRY * dllRasterPos3sv )(const GLshort *v);
static void ( APIENTRY * dllRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
static void ( APIENTRY * dllRasterPos4dv )(const GLdouble *v);
static void ( APIENTRY * dllRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
static void ( APIENTRY * dllRasterPos4fv )(const GLfloat *v);
static void ( APIENTRY * dllRasterPos4i )(GLint x, GLint y, GLint z, GLint w);
static void ( APIENTRY * dllRasterPos4iv )(const GLint *v);
static void ( APIENTRY * dllRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w);
static void ( APIENTRY * dllRasterPos4sv )(const GLshort *v);
static void ( APIENTRY * dllReadBuffer )(GLenum mode);
static void ( APIENTRY * dllReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
static void ( APIENTRY * dllRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
static void ( APIENTRY * dllRectdv )(const GLdouble *v1, const GLdouble *v2);
static void ( APIENTRY * dllRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
static void ( APIENTRY * dllRectfv )(const GLfloat *v1, const GLfloat *v2);
static void ( APIENTRY * dllRecti )(GLint x1, GLint y1, GLint x2, GLint y2);
static void ( APIENTRY * dllRectiv )(const GLint *v1, const GLint *v2);
static void ( APIENTRY * dllRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
static void ( APIENTRY * dllRectsv )(const GLshort *v1, const GLshort *v2);
GLint ( APIENTRY * dllRenderMode )(GLenum mode);
static void ( APIENTRY * dllRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
static void ( APIENTRY * dllRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
static void ( APIENTRY * dllScaled )(GLdouble x, GLdouble y, GLdouble z);
static void ( APIENTRY * dllScalef )(GLfloat x, GLfloat y, GLfloat z);
static void ( APIENTRY * dllScissor )(GLint x, GLint y, GLsizei width, GLsizei height);
static void ( APIENTRY * dllSelectBuffer )(GLsizei size, GLuint *buffer);
static void ( APIENTRY * dllShadeModel )(GLenum mode);
static void ( APIENTRY * dllStencilFunc )(GLenum func, GLint ref, GLuint mask);
static void ( APIENTRY * dllStencilMask )(GLuint mask);
static void ( APIENTRY * dllStencilOp )(GLenum fail, GLenum zfail, GLenum zpass);
static void ( APIENTRY * dllTexCoord1d )(GLdouble s);
static void ( APIENTRY * dllTexCoord1dv )(const GLdouble *v);
static void ( APIENTRY * dllTexCoord1f )(GLfloat s);
static void ( APIENTRY * dllTexCoord1fv )(const GLfloat *v);
static void ( APIENTRY * dllTexCoord1i )(GLint s);
static void ( APIENTRY * dllTexCoord1iv )(const GLint *v);
static void ( APIENTRY * dllTexCoord1s )(GLshort s);
static void ( APIENTRY * dllTexCoord1sv )(const GLshort *v);
static void ( APIENTRY * dllTexCoord2d )(GLdouble s, GLdouble t);
static void ( APIENTRY * dllTexCoord2dv )(const GLdouble *v);
static void ( APIENTRY * dllTexCoord2f )(GLfloat s, GLfloat t);
static void ( APIENTRY * dllTexCoord2fv )(const GLfloat *v);
static void ( APIENTRY * dllTexCoord2i )(GLint s, GLint t);
static void ( APIENTRY * dllTexCoord2iv )(const GLint *v);
static void ( APIENTRY * dllTexCoord2s )(GLshort s, GLshort t);
static void ( APIENTRY * dllTexCoord2sv )(const GLshort *v);
static void ( APIENTRY * dllTexCoord3d )(GLdouble s, GLdouble t, GLdouble r);
static void ( APIENTRY * dllTexCoord3dv )(const GLdouble *v);
static void ( APIENTRY * dllTexCoord3f )(GLfloat s, GLfloat t, GLfloat r);
static void ( APIENTRY * dllTexCoord3fv )(const GLfloat *v);
static void ( APIENTRY * dllTexCoord3i )(GLint s, GLint t, GLint r);
static void ( APIENTRY * dllTexCoord3iv )(const GLint *v);
static void ( APIENTRY * dllTexCoord3s )(GLshort s, GLshort t, GLshort r);
static void ( APIENTRY * dllTexCoord3sv )(const GLshort *v);
static void ( APIENTRY * dllTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q);
static void ( APIENTRY * dllTexCoord4dv )(const GLdouble *v);
static void ( APIENTRY * dllTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q);
static void ( APIENTRY * dllTexCoord4fv )(const GLfloat *v);
static void ( APIENTRY * dllTexCoord4i )(GLint s, GLint t, GLint r, GLint q);
static void ( APIENTRY * dllTexCoord4iv )(const GLint *v);
static void ( APIENTRY * dllTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q);
static void ( APIENTRY * dllTexCoord4sv )(const GLshort *v);
static void ( APIENTRY * dllTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
static void ( APIENTRY * dllTexEnvf )(GLenum target, GLenum pname, GLfloat param);
static void ( APIENTRY * dllTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params);
static void ( APIENTRY * dllTexEnvi )(GLenum target, GLenum pname, GLint param);
static void ( APIENTRY * dllTexEnviv )(GLenum target, GLenum pname, const GLint *params);
static void ( APIENTRY * dllTexGend )(GLenum coord, GLenum pname, GLdouble param);
static void ( APIENTRY * dllTexGendv )(GLenum coord, GLenum pname, const GLdouble *params);
static void ( APIENTRY * dllTexGenf )(GLenum coord, GLenum pname, GLfloat param);
static void ( APIENTRY * dllTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params);
static void ( APIENTRY * dllTexGeni )(GLenum coord, GLenum pname, GLint param);
static void ( APIENTRY * dllTexGeniv )(GLenum coord, GLenum pname, const GLint *params);
static void ( APIENTRY * dllTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
static void ( APIENTRY * dllTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
static void ( APIENTRY * dllTexParameterf )(GLenum target, GLenum pname, GLfloat param);
static void ( APIENTRY * dllTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params);
static void ( APIENTRY * dllTexParameteri )(GLenum target, GLenum pname, GLint param);
static void ( APIENTRY * dllTexParameteriv )(GLenum target, GLenum pname, const GLint *params);
static void ( APIENTRY * dllTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
static void ( APIENTRY * dllTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
static void ( APIENTRY * dllTranslated )(GLdouble x, GLdouble y, GLdouble z);
static void ( APIENTRY * dllTranslatef )(GLfloat x, GLfloat y, GLfloat z);
static void ( APIENTRY * dllVertex2d )(GLdouble x, GLdouble y);
static void ( APIENTRY * dllVertex2dv )(const GLdouble *v);
static void ( APIENTRY * dllVertex2f )(GLfloat x, GLfloat y);
static void ( APIENTRY * dllVertex2fv )(const GLfloat *v);
static void ( APIENTRY * dllVertex2i )(GLint x, GLint y);
static void ( APIENTRY * dllVertex2iv )(const GLint *v);
static void ( APIENTRY * dllVertex2s )(GLshort x, GLshort y);
static void ( APIENTRY * dllVertex2sv )(const GLshort *v);
static void ( APIENTRY * dllVertex3d )(GLdouble x, GLdouble y, GLdouble z);
static void ( APIENTRY * dllVertex3dv )(const GLdouble *v);
static void ( APIENTRY * dllVertex3f )(GLfloat x, GLfloat y, GLfloat z);
static void ( APIENTRY * dllVertex3fv )(const GLfloat *v);
static void ( APIENTRY * dllVertex3i )(GLint x, GLint y, GLint z);
static void ( APIENTRY * dllVertex3iv )(const GLint *v);
static void ( APIENTRY * dllVertex3s )(GLshort x, GLshort y, GLshort z);
static void ( APIENTRY * dllVertex3sv )(const GLshort *v);
static void ( APIENTRY * dllVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
static void ( APIENTRY * dllVertex4dv )(const GLdouble *v);
static void ( APIENTRY * dllVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
static void ( APIENTRY * dllVertex4fv )(const GLfloat *v);
static void ( APIENTRY * dllVertex4i )(GLint x, GLint y, GLint z, GLint w);
static void ( APIENTRY * dllVertex4iv )(const GLint *v);
static void ( APIENTRY * dllVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w);
static void ( APIENTRY * dllVertex4sv )(const GLshort *v);
static void ( APIENTRY * dllVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
static void ( APIENTRY * dllViewport )(GLint x, GLint y, GLsizei width, GLsizei height);
#endif // QGL_SOLARIS_H

932
solaris/rw_corona.c Normal file
View file

@ -0,0 +1,932 @@
/*
** rw_xil.c
**
** This file contains the Corona version of the X11 renderer.
*/
#include <ctype.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/ipc.h>
#include <xil/xil.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/Sunkeysym.h>
#include "../ref_soft/r_local.h"
#include "../client/keys.h"
#include "../solaris/rw_solaris.h"
#include "newt.h"
#include "q2.xbm"
/*****************************************************************************/
extern char display_name[];
static Display *x_disp;
static Window x_win;
static GC x_gc;
#define STD_EVENT_MASK (StructureNotifyMask | KeyPressMask \
| KeyReleaseMask | ExposureMask | PointerMotionMask | \
ButtonPressMask | ButtonReleaseMask | \
VisibilityChangeMask)
static qboolean X11_active = false;
struct
{
int key;
int down;
} keyq[64];
static int keyq_head=0;
static int keyq_tail=0;
static int config_notify = 0;
static int config_notify_width;
static int config_notify_height;
static int is_double_buffered;
typedef unsigned short PIXEL;
// Console variables that we need to access from this module
/*****************************************************************************/
/* MOUSE */
/*****************************************************************************/
// this is inside the renderer shared lib, so these are called from vid_so
static qboolean mouse_avail;
static int mouse_buttonstate;
static int mouse_oldbuttonstate;
static int mouse_x, mouse_y;
static int old_mouse_x, old_mouse_y;
static int mx, my;
static int old_windowed_mouse;
static int p_mouse_x, p_mouse_y;
static cvar_t *_windowed_mouse;
static cvar_t *m_filter;
static cvar_t *in_mouse;
static qboolean mlooking;
// state struct passed in Init
static in_state_t *in_state;
static cvar_t *sensitivity;
static cvar_t *lookstrafe;
static cvar_t *m_side;
static cvar_t *m_yaw;
static cvar_t *m_pitch;
static cvar_t *m_forward;
static cvar_t *freelook;
static cvar_t *xil_keepaspect;
/**************************************************************
* NewT stuff
**************************************************************/
static unsigned char *video_buffer = NULL;
static int window_width;
static int window_height;
static int force_resize = 0;
static unsigned char ymap[256];
static unsigned char umap[256];
static unsigned char vmap[256];
extern int newt_initialize_next;
static void Set_Window_Position_f( void );
static void Set_Window_Size_f( void );
static void Force_CenterView_f (void)
{
in_state->viewangles[PITCH] = 0;
}
static void RW_IN_MLookDown (void)
{
mlooking = true;
}
static void RW_IN_MLookUp (void)
{
mlooking = false;
in_state->IN_CenterView_fp ();
}
void RW_IN_Init(in_state_t *in_state_p)
{
int mtype;
int i;
in_state = in_state_p;
// mouse variables
_windowed_mouse = ri.Cvar_Get( "_windowed_mouse", "0", CVAR_ARCHIVE );
m_filter = ri.Cvar_Get( "m_filter", "0", 0 );
in_mouse = ri.Cvar_Get( "in_mouse", "1", CVAR_ARCHIVE );
freelook = ri.Cvar_Get( "freelook", "0", 0 );
lookstrafe = ri.Cvar_Get( "lookstrafe", "0", 0 );
sensitivity = ri.Cvar_Get( "sensitivity", "3", 0 );
m_pitch = ri.Cvar_Get( "m_pitch", "0.022", 0 );
m_yaw = ri.Cvar_Get( "m_yaw", "0.022", 0 );
m_forward = ri.Cvar_Get( "m_forward", "1", 0 );
m_side = ri.Cvar_Get( "m_side", "0.8", 0 );
xil_keepaspect = ri.Cvar_Get( "xil_keepaspect", "1", CVAR_ARCHIVE );
ri.Cmd_AddCommand( "+mlook", RW_IN_MLookDown );
ri.Cmd_AddCommand( "-mlook", RW_IN_MLookUp );
ri.Cmd_AddCommand( "force_centerview", Force_CenterView_f );
ri.Cmd_AddCommand( "xil_set_window_position", Set_Window_Position_f );
ri.Cmd_AddCommand( "xil_set_window_size", Set_Window_Size_f );
mouse_x = mouse_y = 0.0;
mouse_avail = true;
}
void RW_IN_Shutdown(void)
{
mouse_avail = false;
ri.Cmd_RemoveCommand( "+mlook" );
ri.Cmd_RemoveCommand( "-mlook" );
ri.Cmd_RemoveCommand( "force_centerview" );
ri.Cmd_RemoveCommand( "xil_set_window_position" );
ri.Cmd_RemoveCommand( "xil_set_window_size" );
}
/*
===========
IN_Commands
===========
*/
void RW_IN_Commands (void)
{
int i;
if (!mouse_avail)
return;
for( i = 0 ; i < 3 ; i++ ) {
if( (mouse_buttonstate & (1<<i)) && !(mouse_oldbuttonstate & (1<<i)) ) {
in_state->Key_Event_fp (K_MOUSE1 + i, true);
}
if( !(mouse_buttonstate & (1<<i)) && (mouse_oldbuttonstate & (1<<i)) ) {
in_state->Key_Event_fp (K_MOUSE1 + i, false);
}
}
mouse_oldbuttonstate = mouse_buttonstate;
}
/*
===========
IN_Move
===========
*/
void RW_IN_Move (usercmd_t *cmd)
{
if( !mouse_avail ) {
return;
}
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;
if( !mouse_x && !mouse_y ) {
return;
}
mouse_x *= sensitivity->value;
mouse_y *= sensitivity->value;
// add mouse X/Y movement to cmd
if( (*in_state->in_strafe_state & 1) ||
(lookstrafe->value && mlooking) ) {
cmd->sidemove += m_side->value * mouse_x;
}
else {
in_state->viewangles[YAW] -= m_yaw->value * mouse_x;
}
if( (mlooking || freelook->value) &&
!(*in_state->in_strafe_state & 1) ) {
in_state->viewangles[PITCH] += m_pitch->value * mouse_y;
}
else {
cmd->forwardmove -= m_forward->value * mouse_y;
}
mx = 0;
my = 0;
}
void RW_IN_Frame (void)
{
}
void RW_IN_Activate(void)
{
}
// ========================================================================
// makes a null cursor
// ========================================================================
static Cursor CreateNullCursor(Display *display, Window root)
{
Pixmap cursormask;
XGCValues xgc;
GC gc;
XColor dummycolour;
Cursor cursor;
cursormask = XCreatePixmap( display, root, 1, 1, 1 );
xgc.function = GXclear;
gc = XCreateGC( display, cursormask, GCFunction, &xgc );
XFillRectangle( display, cursormask, gc, 0, 0, 1, 1 );
dummycolour.pixel = 0;
dummycolour.red = 0;
dummycolour.flags = DoRed;
cursor = XCreatePixmapCursor( display, cursormask, cursormask,
&dummycolour, &dummycolour, 0,0 );
XFreePixmap( display, cursormask );
XFreeGC( display, gc );
return cursor;
}
void ResetNEWTFrameBuffers( void )
{
newt_cleanup();
video_buffer = malloc( vid.width * vid.height );
if( video_buffer == NULL ) {
Sys_Error( "Can't allocate video buffer memory" );
}
vid.buffer = video_buffer;
vid.rowbytes = vid.width;
newt_initialize_next = 1;
}
static void create_xil_window( void )
{
/* TODO */
}
// ========================================================================
// Tragic death handler
// ========================================================================
void TragicDeath(int signal_num)
{
XCloseDisplay(x_disp);
Sys_Error( "This death brought to you by the number %d\n", signal_num );
}
int XLateKey(XKeyEvent *ev)
{
int key;
char buf[64];
KeySym keysym;
key = 0;
XLookupString( ev, buf, sizeof buf, &keysym, 0 );
switch( keysym ) {
case XK_KP_9:
case XK_F29:
case XK_KP_Page_Up: key = K_KP_PGUP; break;
case XK_Page_Up: key = K_PGUP; break;
case XK_KP_3:
case XK_F35:
case XK_KP_Page_Down: key = K_KP_PGDN; break;
case XK_Page_Down: key = K_PGDN; break;
case XK_KP_7:
case XK_F27:
case XK_KP_Home: key = K_KP_HOME; break;
case XK_Home: key = K_HOME; break;
case XK_KP_1:
case XK_F33:
case XK_KP_End: key = K_KP_END; break;
case XK_End: key = K_END; break;
case XK_KP_4:
case XK_KP_Left: key = K_KP_LEFTARROW; break;
case XK_Left: key = K_LEFTARROW; break;
case XK_KP_6:
case XK_KP_Right: key = K_KP_RIGHTARROW; break;
case XK_Right: key = K_RIGHTARROW; break;
case XK_KP_2:
case XK_KP_Down: key = K_KP_DOWNARROW; break;
case XK_Down: key = K_DOWNARROW; break;
case XK_KP_8:
case XK_KP_Up: key = K_KP_UPARROW; break;
case XK_Up: key = K_UPARROW; break;
case XK_Escape: key = K_ESCAPE; break;
case XK_KP_Enter: key = K_KP_ENTER; break;
case XK_Return: key = K_ENTER; break;
case XK_Tab: key = K_TAB; break;
case XK_F1: key = K_F1; break;
case XK_F2: key = K_F2; break;
case XK_F3: key = K_F3; break;
case XK_F4: key = K_F4; break;
case XK_F5: key = K_F5; break;
case XK_F6: key = K_F6; break;
case XK_F7: key = K_F7; break;
case XK_F8: key = K_F8; break;
case XK_F9: key = K_F9; break;
case XK_F10: key = K_F10; break;
case SunXK_F36: key = K_F11; break;
case SunXK_F37: key = K_F12; break;
case XK_BackSpace: key = K_BACKSPACE; break;
case XK_KP_Separator:
case XK_KP_Delete: key = K_KP_DEL; break;
case XK_Delete: key = K_DEL; break;
case XK_Pause: key = K_PAUSE; break;
case XK_Shift_L:
case XK_Shift_R: key = K_SHIFT; break;
case XK_Execute:
case XK_Control_L:
case XK_Control_R: key = K_CTRL; break;
case XK_Alt_L:
case XK_Meta_L:
case XK_Alt_R:
case XK_Meta_R: key = K_ALT; break;
case XK_KP_5:
case XK_F31: key = K_KP_5; break;
case XK_Insert: key = K_INS; break;
case XK_KP_0:
case XK_KP_Insert: key = K_KP_INS; break;
case XK_F26:
case XK_KP_Multiply: key = '*'; break;
case XK_KP_Add: key = K_KP_PLUS; break;
case XK_F24:
case XK_KP_Subtract: key = K_KP_MINUS; break;
case XK_F25:
case XK_KP_Divide: key = K_KP_SLASH; break;
case XK_F11:
if( ev->type == KeyPress ) {
if( _windowed_mouse->value ) {
Cvar_SetValue( "_windowed_mouse", 0 );
}
else {
Cvar_SetValue( "_windowed_mouse", 1 );
}
}
break;
#if 0
case 0x021: key = '1';break;/* [!] */
case 0x040: key = '2';break;/* [@] */
case 0x023: key = '3';break;/* [#] */
case 0x024: key = '4';break;/* [$] */
case 0x025: key = '5';break;/* [%] */
case 0x05e: key = '6';break;/* [^] */
case 0x026: key = '7';break;/* [&] */
case 0x02a: key = '8';break;/* [*] */
case 0x028: key = '9';;break;/* [(] */
case 0x029: key = '0';break;/* [)] */
case 0x05f: key = '-';break;/* [_] */
case 0x02b: key = '=';break;/* [+] */
case 0x07c: key = '\'';break;/* [|] */
case 0x07d: key = '[';break;/* [}] */
case 0x07b: key = ']';break;/* [{] */
case 0x022: key = '\'';break;/* ["] */
case 0x03a: key = ';';break;/* [:] */
case 0x03f: key = '/';break;/* [?] */
case 0x03e: key = '.';break;/* [>] */
case 0x03c: key = ',';break;/* [<] */
#endif
default:
key = *(unsigned char*)buf;
if (key >= 'A' && key <= 'Z')
key = key - 'A' + 'a';
break;
}
return key;
}
void GetEvent(void)
{
XEvent x_event;
int b;
XNextEvent(x_disp, &x_event);
switch(x_event.type) {
case KeyPress:
keyq[keyq_head].key = XLateKey(&x_event.xkey);
keyq[keyq_head].down = true;
keyq_head = (keyq_head + 1) & 63;
break;
case KeyRelease:
/*
* This is a hack in order to avoid disabling key repeat, which
* would cause a lot of problems when changing to other windows
* or when the program crashes.
*
* Whenever a key release event occurs, we check to see if the
* next event in the queue is a press event of the same key
* with the same time stamp. If it is, we simply discard this
* and the next event.
*/
if( XPending( x_disp ) > 0 ) {
XEvent tmp_event;
XPeekEvent( x_disp, &tmp_event );
if( tmp_event.type == KeyPress &&
tmp_event.xkey.keycode == x_event.xkey.keycode &&
tmp_event.xkey.time == x_event.xkey.time ) {
XNextEvent( x_disp, &tmp_event );
break;
}
}
keyq[keyq_head].key = XLateKey(&x_event.xkey);
keyq[keyq_head].down = false;
keyq_head = (keyq_head + 1) & 63;
break;
case MotionNotify:
if( _windowed_mouse->value ) {
int xoffset = ((int)x_event.xmotion.x - (int)(window_width / 2));
int yoffset = ((int)x_event.xmotion.y - (int)(window_height / 2));
if( xoffset != 0 || yoffset != 0 ) {
mx += xoffset;
my += yoffset;
/* move the mouse to the window center again */
XSelectInput( x_disp, x_win, STD_EVENT_MASK & ~PointerMotionMask );
XWarpPointer( x_disp, None, x_win, 0, 0, 0, 0,
(window_width / 2), (window_height / 2) );
XSelectInput( x_disp,x_win, STD_EVENT_MASK );
}
}
else {
mx = ((int)x_event.xmotion.x - (int)p_mouse_x);
my = ((int)x_event.xmotion.y - (int)p_mouse_y);
p_mouse_x = x_event.xmotion.x;
p_mouse_y = x_event.xmotion.y;
}
break;
case ButtonPress:
b = -1;
if( x_event.xbutton.button == 1 ) {
b = 0;
}
else if( x_event.xbutton.button == 2 ) {
b = 2;
}
else if( x_event.xbutton.button == 3 ) {
b = 1;
}
if( b >= 0 ) {
mouse_buttonstate |= 1 << b;
}
break;
case ButtonRelease:
b = -1;
if( x_event.xbutton.button == 1 ) {
b = 0;
}
else if( x_event.xbutton.button == 2 ) {
b = 2;
}
else if( x_event.xbutton.button == 3 ) {
b = 1;
}
if( b >= 0 ) {
mouse_buttonstate &= ~(1 << b);
}
break;
case ConfigureNotify:
config_notify_width = x_event.xconfigure.width;
config_notify_height = x_event.xconfigure.height;
if( xil_keepaspect->value && !force_resize ) {
double aspect = (double)vid.width / vid.height;
if( config_notify_height > config_notify_width / aspect ) {
force_resize = 1;
XResizeWindow( x_disp, x_win,
config_notify_width,
(int)(config_notify_width / aspect) );
}
else if( config_notify_width > config_notify_height * aspect ) {
force_resize = 1;
XResizeWindow( x_disp, x_win,
(int)(config_notify_height * aspect),
config_notify_height );
}
}
else {
force_resize = 0;
}
if( !force_resize ) {
window_width = config_notify_width;
window_height = config_notify_height;
newt_initialize_next = 1;
}
break;
case MapNotify:
if( _windowed_mouse->value ) {
XGrabPointer( x_disp, x_win, True, 0, GrabModeAsync,
GrabModeAsync, x_win, None, CurrentTime);
}
break;
case UnmapNotify:
if( _windowed_mouse->value ) {
XUngrabPointer( x_disp, CurrentTime );
}
break;
case VisibilityNotify:
puts("visibility");
newt_initialize_next = 1;
break;
default:
;
}
if( old_windowed_mouse != _windowed_mouse->value ) {
old_windowed_mouse = _windowed_mouse->value;
if( !_windowed_mouse->value ) {
/* ungrab the pointer */
XUngrabPointer( x_disp, CurrentTime );
} else {
/* grab the pointer */
XGrabPointer( x_disp, x_win, True, 0, GrabModeAsync,
GrabModeAsync, x_win, None, CurrentTime );
}
}
}
/*****************************************************************************/
/*
** SWimp_Init
**
** This routine is responsible for initializing the implementation
** specific stuff in a software rendering subsystem.
*/
int SWimp_Init( void *hInstance, void *wndProc )
{
// open the display
x_disp = XOpenDisplay( display_name );
if( !x_disp ) {
if( display_name != NULL ) {
Sys_Error( "VID: Could not open display [%s]\n", display_name );
}
else {
Sys_Error( "VID: Could not open local display\n" );
}
}
// catch signals so i can turn on auto-repeat
{
struct sigaction sa;
sigaction( SIGINT, 0, &sa );
sa.sa_handler = TragicDeath;
sigaction( SIGINT, &sa, 0 );
sigaction( SIGTERM, &sa, 0 );
}
return true;
}
/*
** SWimp_InitGraphics
**
** This initializes the software refresh's implementation specific
** graphics subsystem. In the case of Windows it creates DIB or
** DDRAW surfaces.
**
** The necessary width and height parameters are grabbed from
** vid.width and vid.height.
*/
static qboolean SWimp_InitGraphics( qboolean fullscreen )
{
int pnum, i;
long template_mask;
srandom(getpid());
// free resources in use
SWimp_Shutdown ();
// let the sound and input subsystems know about the new window
ri.Vid_NewWindow (vid.width, vid.height);
// for debugging only
// XSynchronize(x_disp, True);
// check for command-line window size
template_mask = 0;
// setup attributes for main window
{
int attribmask = CWEventMask | CWBorderPixel;
XSetWindowAttributes attribs;
window_width = vid.width;
window_height = vid.height;
attribs.event_mask = STD_EVENT_MASK;
attribs.border_pixel = 0;
// create the main window
x_win = XCreateWindow( x_disp,
XRootWindow( x_disp, DefaultScreen( x_disp ) ),
0, 0, // x, y
window_width, window_height,
0, // borderwidth
CopyFromParent,
InputOutput,
CopyFromParent,
attribmask,
&attribs );
XStoreName( x_disp, x_win, "Quake II" );
}
// inviso cursor
XDefineCursor( x_disp, x_win, CreateNullCursor( x_disp, x_win ) );
// create the GC
{
XGCValues xgcvalues;
int valuemask = GCGraphicsExposures;
xgcvalues.graphics_exposures = False;
x_gc = XCreateGC( x_disp, x_win, valuemask, &xgcvalues );
}
/* set the icon */
{
Pixmap icon;
XWMHints hints;
icon = XCreateBitmapFromData( x_disp, DefaultRootWindow( x_disp ),
q2_bits, q2_width, q2_height );
/* BlackPixel( x_disp, DefaultScreen( x_disp ) ),
WhitePixel( x_disp, DefaultScreen( x_disp ) ),
1 );*/
hints.icon_pixmap = icon;
hints.flags = IconPixmapHint;
XSetWMHints( x_disp, x_win, &hints );
}
// map the window
XMapWindow( x_disp, x_win );
// wait for first exposure event
{
XEvent event;
do {
XNextEvent( x_disp, &event );
} while( event.type != Expose || event.xexpose.count != 0 );
}
// now safe to draw
ResetNEWTFrameBuffers();
// XSynchronize(x_disp, False);
old_windowed_mouse = 0;
X11_active = true;
return true;
}
/*
** SWimp_EndFrame
**
** This does an implementation specific copy from the backbuffer to the
** front buffer. In the Win32 case it uses BitBlt or BltFast depending
** on whether we're using DIB sections/GDI or DDRAW.
*/
void SWimp_EndFrame (void)
{
send_newt_video( x_disp, x_win, vid.buffer, vid.width, vid.height );
}
/*
** SWimp_SetMode
*/
rserr_t SWimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
{
rserr_t retval = rserr_ok;
ri.Con_Printf (PRINT_ALL, "setting mode %d:", mode );
if( !ri.Vid_GetModeInfo( pwidth, pheight, mode ) ) {
ri.Con_Printf( PRINT_ALL, " invalid mode\n" );
return rserr_invalid_mode;
}
ri.Con_Printf( PRINT_ALL, " %d %d\n", *pwidth, *pheight );
if( !SWimp_InitGraphics( false ) ) {
// failed to set a valid mode in windowed mode
return rserr_invalid_mode;
}
R_GammaCorrectAndSetPalette( (const unsigned char *)d_8to24table );
return retval;
}
/*
** SWimp_SetPalette
**
** System specific palette setting routine. A NULL palette means
** to use the existing palette. The palette is expected to be in
** a padded 4-byte xRGB format.
*/
void SWimp_SetPalette( const unsigned char *palette )
{
newt_set_palette( palette );
}
/*
** SWimp_Shutdown
**
** System specific graphics subsystem shutdown routine. Destroys
** DIBs or DDRAW surfaces as appropriate.
*/
void SWimp_Shutdown( void )
{
newt_cleanup();
if( X11_active ) {
XDestroyWindow( x_disp, x_win );
XSync( x_disp, False );
}
if( video_buffer != NULL ) {
free( video_buffer );
}
}
/*
** SWimp_AppActivate
*/
void SWimp_AppActivate( qboolean active )
{
}
/*****************************************************************************/
/* KEYBOARD */
/*****************************************************************************/
Key_Event_fp_t Key_Event_fp;
void KBD_Init(Key_Event_fp_t fp)
{
Key_Event_fp = fp;
}
void KBD_Update(void)
{
// get events from x server
if (x_disp)
{
while (XPending(x_disp))
GetEvent();
while (keyq_head != keyq_tail)
{
Key_Event_fp(keyq[keyq_tail].key, keyq[keyq_tail].down);
keyq_tail = (keyq_tail + 1) & 63;
}
}
}
void KBD_Close(void)
{
}
/*** User commands *******************************************************/
static void Set_Window_Position_f( void )
{
int x, y;
char *arg;
char *endnum;
if( Cmd_Argc() != 3 ) {
Com_Printf( "usage: xil_set_window_position x y\n" );
return;
}
arg = Cmd_Argv( 1 );
x = strtol( arg, &endnum, 10 );
if( endnum != arg && *endnum != 0 ) {
Com_Printf( "illegal x position\n" );
return;
}
arg = Cmd_Argv( 2 );
y = strtol( arg, &endnum, 10 );
if( endnum != arg && *endnum != 0 ) {
Com_Printf( "illegal y position\n" );
return;
}
XMoveWindow( x_disp, x_win, x, y );
}
static void Set_Window_Size_f( void )
{
int width, height;
char *arg;
char *endnum;
if( Cmd_Argc() != 3 ) {
Com_Printf( "usage: xil_set_window_size width height\n" );
return;
}
arg = Cmd_Argv( 1 );
width = strtol( arg, &endnum, 10 );
if( endnum != arg && *endnum != 0 ) {
Com_Printf( "illegal width\n" );
return;
}
arg = Cmd_Argv( 2 );
height = strtol( arg, &endnum, 10 );
if( endnum != arg && *endnum != 0 ) {
Com_Printf( "illegal height\n" );
return;
}
XResizeWindow( x_disp, x_win, width, height );
}

948
solaris/rw_sdl.c Normal file
View file

@ -0,0 +1,948 @@
/*
** RW_SDL.C
**
** This file contains ALL Solaris specific stuff having to do with the
** software refresh. When a port is being made the following functions
** must be implemented by the port:
**
** SWimp_EndFrame
** SWimp_Init
** SWimp_InitGraphics
** SWimp_SetPalette
** SWimp_Shutdown
** SWimp_SwitchFullscreen
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <SDL.h>
#ifdef OPENGL
#include <GL/gl.h>
#endif
#ifdef OPENGL
#include "../ref_gl/gl_local.h"
#include "../solaris/glw_solaris.h"
#else
#include "../ref_soft/r_local.h"
#endif
#include "../client/keys.h"
#include "../solaris/rw_solaris.h"
/*****************************************************************************/
static qboolean X11_active = false;
static SDL_Surface *surface;
#ifndef OPENGL
static unsigned int sdl_palettemode;
#endif
struct
{
int key;
int down;
} keyq[64];
int keyq_head=0;
int keyq_tail=0;
int config_notify=0;
int config_notify_width;
int config_notify_height;
#ifdef OPENGL
glwstate_t glw_state;
#endif
// Console variables that we need to access from this module
/*****************************************************************************/
/* MOUSE */
/*****************************************************************************/
// this is inside the renderer shared lib, so these are called from vid_so
static qboolean mouse_avail;
static int mouse_buttonstate;
static int mouse_oldbuttonstate;
static int mouse_x, mouse_y;
static int old_mouse_x, old_mouse_y;
static int mx, my;
static float old_windowed_mouse;
static cvar_t *_windowed_mouse;
static cvar_t *m_filter;
static cvar_t *in_mouse;
static qboolean mlooking;
// stencilbuffer shadows
qboolean have_stencil = false;
// state struct passed in Init
static in_state_t *in_state;
static cvar_t *sensitivity;
static cvar_t *my_lookstrafe;
static cvar_t *m_side;
static cvar_t *m_yaw;
static cvar_t *m_pitch;
static cvar_t *m_forward;
static cvar_t *my_freelook;
static void Force_CenterView_f (void)
{
in_state->viewangles[PITCH] = 0;
}
static void RW_IN_MLookDown (void)
{
mlooking = true;
}
static void RW_IN_MLookUp (void)
{
mlooking = false;
in_state->IN_CenterView_fp ();
}
void RW_IN_Init(in_state_t *in_state_p)
{
in_state = in_state_p;
// mouse variables
_windowed_mouse = ri.Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE);
m_filter = ri.Cvar_Get ("m_filter", "0", 0);
in_mouse = ri.Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
my_freelook = ri.Cvar_Get( "freelook", "0", 0);
my_lookstrafe = ri.Cvar_Get ("lookstrafe", "0", 0);
sensitivity = ri.Cvar_Get ("sensitivity", "3", 0);
m_pitch = ri.Cvar_Get ("m_pitch", "0.022", 0);
m_yaw = ri.Cvar_Get ("m_yaw", "0.022", 0);
m_forward = ri.Cvar_Get ("m_forward", "1", 0);
m_side = ri.Cvar_Get ("m_side", "0.8", 0);
ri.Cmd_AddCommand ("+mlook", RW_IN_MLookDown);
ri.Cmd_AddCommand ("-mlook", RW_IN_MLookUp);
ri.Cmd_AddCommand ("force_centerview", Force_CenterView_f);
mouse_x = mouse_y = 0.0;
mouse_avail = true;
}
void RW_IN_Shutdown(void)
{
if (mouse_avail) {
mouse_avail = false;
ri.Cmd_RemoveCommand ("+mlook");
ri.Cmd_RemoveCommand ("-mlook");
ri.Cmd_RemoveCommand ("force_centerview");
}
}
/*
===========
IN_Commands
===========
*/
void RW_IN_Commands (void)
{
int i;
if (!mouse_avail)
return;
for (i=0 ; i<3 ; i++) {
if ( (mouse_buttonstate & (1<<i)) && !(mouse_oldbuttonstate & (1<<i)) )
in_state->Key_Event_fp (K_MOUSE1 + i, true);
if ( !(mouse_buttonstate & (1<<i)) && (mouse_oldbuttonstate & (1<<i)) )
in_state->Key_Event_fp (K_MOUSE1 + i, false);
}
if ( (mouse_buttonstate & (1<<3)) && !(mouse_oldbuttonstate & (1<<3)) )
in_state->Key_Event_fp (K_MOUSE4, true);
if ( !(mouse_buttonstate & (1<<3)) && (mouse_oldbuttonstate & (1<<3)) )
in_state->Key_Event_fp (K_MOUSE4, false);
if ( (mouse_buttonstate & (1<<4)) && !(mouse_oldbuttonstate & (1<<4)) )
in_state->Key_Event_fp (K_MOUSE5, true);
if ( !(mouse_buttonstate & (1<<4)) && (mouse_oldbuttonstate & (1<<4)) )
in_state->Key_Event_fp (K_MOUSE5, false);
mouse_oldbuttonstate = mouse_buttonstate;
}
/*
===========
IN_Move
===========
*/
void RW_IN_Move (usercmd_t *cmd)
{
if (!mouse_avail)
return;
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;
if (!mouse_x && !mouse_y)
return;
mouse_x *= sensitivity->value;
mouse_y *= sensitivity->value;
// add mouse X/Y movement to cmd
if ( (*in_state->in_strafe_state & 1) ||
(my_lookstrafe->value && mlooking ))
cmd->sidemove += m_side->value * mouse_x;
else
in_state->viewangles[YAW] -= m_yaw->value * mouse_x;
if ( (mlooking || my_freelook->value) &&
!(*in_state->in_strafe_state & 1))
{
in_state->viewangles[PITCH] += m_pitch->value * mouse_y;
}
else
{
cmd->forwardmove -= m_forward->value * mouse_y;
}
mx = my = 0;
}
#if 0
static void IN_DeactivateMouse( void )
{
if (!mouse_avail)
return;
if (mouse_active) {
/* uninstall_grabs(); */
mouse_active = false;
}
}
static void IN_ActivateMouse( void )
{
if (!mouse_avail)
return;
if (!mouse_active) {
mx = my = 0; // don't spazz
/* install_grabs(); */
mouse_active = true;
}
}
#endif
void RW_IN_Frame (void)
{
}
void RW_IN_Activate(qboolean active)
{
#if 0
if (active || vidmode_active)
IN_ActivateMouse();
else
IN_DeactivateMouse();
#endif
}
/*****************************************************************************/
#if 0 /* SDL parachute should catch everything... */
// ========================================================================
// Tragic death handler
// ========================================================================
void TragicDeath(int signal_num)
{
/* SDL_Quit(); */
Sys_Error("This death brought to you by the number %d\n", signal_num);
}
#endif
int XLateKey(unsigned int keysym)
{
int key;
key = 0;
switch(keysym) {
case SDLK_KP9: key = K_KP_PGUP; break;
case SDLK_PAGEUP: key = K_PGUP; break;
case SDLK_KP3: key = K_KP_PGDN; break;
case SDLK_PAGEDOWN: key = K_PGDN; break;
case SDLK_KP7: key = K_KP_HOME; break;
case SDLK_HOME: key = K_HOME; break;
case SDLK_KP1: key = K_KP_END; break;
case SDLK_END: key = K_END; break;
case SDLK_KP4: key = K_KP_LEFTARROW; break;
case SDLK_LEFT: key = K_LEFTARROW; break;
case SDLK_KP6: key = K_KP_RIGHTARROW; break;
case SDLK_RIGHT: key = K_RIGHTARROW; break;
case SDLK_KP2: key = K_KP_DOWNARROW; break;
case SDLK_DOWN: key = K_DOWNARROW; break;
case SDLK_KP8: key = K_KP_UPARROW; break;
case SDLK_UP: key = K_UPARROW; break;
case SDLK_ESCAPE: key = K_ESCAPE; break;
case SDLK_KP_ENTER: key = K_KP_ENTER; break;
case SDLK_RETURN: key = K_ENTER; break;
case SDLK_TAB: key = K_TAB; break;
case SDLK_F1: key = K_F1; break;
case SDLK_F2: key = K_F2; break;
case SDLK_F3: key = K_F3; break;
case SDLK_F4: key = K_F4; break;
case SDLK_F5: key = K_F5; break;
case SDLK_F6: key = K_F6; break;
case SDLK_F7: key = K_F7; break;
case SDLK_F8: key = K_F8; break;
case SDLK_F9: key = K_F9; break;
case SDLK_F10: key = K_F10; break;
case SDLK_F11: key = K_F11; break;
case SDLK_F12: key = K_F12; break;
case SDLK_BACKSPACE: key = K_BACKSPACE; break;
case SDLK_KP_PERIOD: key = K_KP_DEL; break;
case SDLK_DELETE: key = K_DEL; break;
case SDLK_PAUSE: key = K_PAUSE; break;
case SDLK_LSHIFT:
case SDLK_RSHIFT: key = K_SHIFT; break;
case SDLK_LCTRL:
case SDLK_RCTRL: key = K_CTRL; break;
case SDLK_LMETA:
case SDLK_RMETA:
case SDLK_LALT:
case SDLK_RALT: key = K_ALT; break;
case SDLK_KP5: key = K_KP_5; break;
case SDLK_INSERT: key = K_INS; break;
case SDLK_KP0: key = K_KP_INS; break;
case SDLK_KP_MULTIPLY: key = '*'; break;
case SDLK_KP_PLUS: key = K_KP_PLUS; break;
case SDLK_KP_MINUS: key = K_KP_MINUS; break;
case SDLK_KP_DIVIDE: key = K_KP_SLASH; break;
/* suggestions on how to handle this better would be appreciated */
case SDLK_WORLD_7: key = '`'; break;
default: /* assuming that the other sdl keys are mapped to ascii */
if (keysym < 128)
key = keysym;
break;
}
return key;
}
static unsigned char KeyStates[SDLK_LAST];
void GetEvent(SDL_Event *event)
{
unsigned int key;
switch(event->type) {
case SDL_MOUSEBUTTONDOWN:
if (event->button.button == 4) {
keyq[keyq_head].key = K_MWHEELUP;
keyq[keyq_head].down = true;
keyq_head = (keyq_head + 1) & 63;
keyq[keyq_head].key = K_MWHEELUP;
keyq[keyq_head].down = false;
keyq_head = (keyq_head + 1) & 63;
} else if (event->button.button == 5) {
keyq[keyq_head].key = K_MWHEELDOWN;
keyq[keyq_head].down = true;
keyq_head = (keyq_head + 1) & 63;
keyq[keyq_head].key = K_MWHEELDOWN;
keyq[keyq_head].down = false;
keyq_head = (keyq_head + 1) & 63;
}
break;
case SDL_MOUSEBUTTONUP:
break;
case SDL_KEYDOWN:
if ( (KeyStates[SDLK_LALT] || KeyStates[SDLK_RALT]) &&
(event->key.keysym.sym == SDLK_RETURN) ) {
cvar_t *fullscreen;
SDL_WM_ToggleFullScreen(surface);
if (surface->flags & SDL_FULLSCREEN) {
ri.Cvar_SetValue( "vid_fullscreen", 1 );
} else {
ri.Cvar_SetValue( "vid_fullscreen", 0 );
}
fullscreen = ri.Cvar_Get( "vid_fullscreen", "0", 0 );
fullscreen->modified = false; /* we just changed it with SDL. */
break; /* ignore this key */
}
if ( (KeyStates[SDLK_LCTRL] || KeyStates[SDLK_RCTRL]) &&
(event->key.keysym.sym == SDLK_g) ) {
SDL_GrabMode gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
/*
SDL_WM_GrabInput((gm == SDL_GRAB_ON) ? SDL_GRAB_OFF : SDL_GRAB_ON);
gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
*/
ri.Cvar_SetValue( "_windowed_mouse", (gm == SDL_GRAB_ON) ? /*1*/ 0 : /*0*/ 1 );
break; /* ignore this key */
}
KeyStates[event->key.keysym.sym] = 1;
key = XLateKey(event->key.keysym.sym);
if (key) {
keyq[keyq_head].key = key;
keyq[keyq_head].down = true;
keyq_head = (keyq_head + 1) & 63;
}
break;
case SDL_KEYUP:
if (KeyStates[event->key.keysym.sym]) {
KeyStates[event->key.keysym.sym] = 0;
key = XLateKey(event->key.keysym.sym);
if (key) {
keyq[keyq_head].key = key;
keyq[keyq_head].down = false;
keyq_head = (keyq_head + 1) & 63;
}
}
break;
case SDL_QUIT:
ri.Cmd_ExecuteText(EXEC_NOW, "quit");
break;
}
}
/*****************************************************************************/
/*
** SWimp_Init
**
** This routine is responsible for initializing the implementation
** specific stuff in a software rendering subsystem.
*/
int SWimp_Init( void *hInstance, void *wndProc )
{
if (SDL_WasInit(SDL_INIT_AUDIO|SDL_INIT_CDROM|SDL_INIT_VIDEO) == 0) {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
Sys_Error("SDL Init failed: %s\n", SDL_GetError());
return false;
}
} else if (SDL_WasInit(SDL_INIT_VIDEO) == 0) {
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
Sys_Error("SDL Init failed: %s\n", SDL_GetError());
return false;
}
}
// SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
// catch signals so i can turn on auto-repeat
#if 0
{
struct sigaction sa;
sigaction(SIGINT, 0, &sa);
sa.sa_handler = TragicDeath;
sigaction(SIGINT, &sa, 0);
sigaction(SIGTERM, &sa, 0);
}
#endif
return true;
}
#ifdef OPENGL
void *GLimp_GetProcAddress(const char *func)
{
return SDL_GL_GetProcAddress(func);
}
int GLimp_Init( void *hInstance, void *wndProc )
{
return SWimp_Init(hInstance, wndProc);
}
#endif
static void SetSDLIcon()
{
#include "q2.xbm"
SDL_Surface *icon;
SDL_Color color;
Uint8 *ptr;
int i, mask;
icon = SDL_CreateRGBSurface(SDL_SWSURFACE, q2_width, q2_height, 8, 0, 0, 0, 0);
if (icon == NULL)
return; /* oh well... */
SDL_SetColorKey(icon, SDL_SRCCOLORKEY, 0);
color.r = 255;
color.g = 255;
color.b = 255;
SDL_SetColors(icon, &color, 0, 1); /* just in case */
color.r = 0;
color.g = 16;
color.b = 0;
SDL_SetColors(icon, &color, 1, 1);
ptr = (Uint8 *)icon->pixels;
for (i = 0; i < sizeof(q2_bits); i++) {
for (mask = 1; mask != 0x100; mask <<= 1) {
*ptr = (q2_bits[i] & mask) ? 1 : 0;
ptr++;
}
}
SDL_WM_SetIcon(icon, NULL);
SDL_FreeSurface(icon);
}
/*
** SWimp_InitGraphics
**
** This initializes the software refresh's implementation specific
** graphics subsystem. In the case of Windows it creates DIB or
** DDRAW surfaces.
**
** The necessary width and height parameters are grabbed from
** vid.width and vid.height.
*/
#ifndef OPENGL
static qboolean SWimp_InitGraphics( qboolean fullscreen )
{
const SDL_VideoInfo *vinfo;
int flags;
/* Just toggle fullscreen if that's all that has been changed */
if (surface && (surface->w == vid.width) && (surface->h == vid.height)) {
int isfullscreen = (surface->flags & SDL_FULLSCREEN) ? 1 : 0;
if (fullscreen != isfullscreen)
SDL_WM_ToggleFullScreen(surface);
isfullscreen = (surface->flags & SDL_FULLSCREEN) ? 1 : 0;
if (fullscreen == isfullscreen)
return true;
}
srandom(getpid());
// free resources in use
if (surface)
SDL_FreeSurface(surface);
// let the sound and input subsystems know about the new window
ri.Vid_NewWindow (vid.width, vid.height);
/*
Okay, I am going to query SDL for the "best" pixel format.
If the depth is not 8, use SetPalette with logical pal,
else use SetColors.
Hopefully this works all the time.
*/
vinfo = SDL_GetVideoInfo();
sdl_palettemode = (vinfo->vfmt->BitsPerPixel == 8) ? (SDL_PHYSPAL|SDL_LOGPAL) : SDL_LOGPAL;
flags = /*SDL_DOUBLEBUF|*/SDL_SWSURFACE|SDL_HWPALETTE;
if (fullscreen)
flags |= SDL_FULLSCREEN;
SetSDLIcon(); /* currently uses q2.xbm data */
if ((surface = SDL_SetVideoMode(vid.width, vid.height, 8, flags)) == NULL) {
Sys_Error("(SOFTSDL) SDL SetVideoMode failed: %s\n", SDL_GetError());
return false;
}
SDL_WM_SetCaption("Quake II", "Quake II");
SDL_ShowCursor(0);
vid.rowbytes = surface->pitch;
vid.buffer = surface->pixels;
X11_active = true;
return true;
}
#else
static qboolean GLimp_InitGraphics( qboolean fullscreen )
{
int flags;
/* Just toggle fullscreen if that's all that has been changed */
if (surface && (surface->w == vid.width) && (surface->h == vid.height)) {
int isfullscreen = (surface->flags & SDL_FULLSCREEN) ? 1 : 0;
if (fullscreen != isfullscreen)
SDL_WM_ToggleFullScreen(surface);
isfullscreen = (surface->flags & SDL_FULLSCREEN) ? 1 : 0;
if (fullscreen == isfullscreen)
return true;
}
srandom(getpid());
// free resources in use
if (surface)
SDL_FreeSurface(surface);
// let the sound and input subsystems know about the new window
ri.Vid_NewWindow (vid.width, vid.height);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
flags = SDL_OPENGL;
if (fullscreen)
flags |= SDL_FULLSCREEN;
SetSDLIcon(); /* currently uses q2.xbm data */
if ((surface = SDL_SetVideoMode(vid.width, vid.height, 0, flags)) == NULL) {
Sys_Error("(SDLGL) SDL SetVideoMode failed: %s\n", SDL_GetError());
return false;
}
// stencilbuffer shadows
{
int stencil_bits;
have_stencil = false;
if (!SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits)) {
ri.Con_Printf(PRINT_ALL, "I: got %d bits of stencil\n", stencil_bits);
if (stencil_bits >= 1) {
have_stencil = true;
}
}
}
SDL_WM_SetCaption("Quake II", "Quake II");
SDL_ShowCursor(0);
X11_active = true;
return true;
}
#endif
#ifdef OPENGL
void GLimp_BeginFrame( float camera_seperation )
{
}
#endif
/*
** SWimp_EndFrame
**
** This does an implementation specific copy from the backbuffer to the
** front buffer. In the Win32 case it uses BitBlt or BltFast depending
** on whether we're using DIB sections/GDI or DDRAW.
*/
#ifndef OPENGL
void SWimp_EndFrame (void)
{
/* SDL_Flip(surface); */
SDL_UpdateRect(surface, 0, 0, 0, 0);
}
#else
void GLimp_EndFrame (void)
{
SDL_GL_SwapBuffers();
}
#endif
/*
** SWimp_SetMode
*/
#ifndef OPENGL
rserr_t SWimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
{
rserr_t retval = rserr_ok;
ri.Con_Printf (PRINT_ALL, "setting mode %d:", mode );
if ( !ri.Vid_GetModeInfo( pwidth, pheight, mode ) )
{
ri.Con_Printf( PRINT_ALL, " invalid mode\n" );
return rserr_invalid_mode;
}
ri.Con_Printf( PRINT_ALL, " %d %d\n", *pwidth, *pheight);
if ( !SWimp_InitGraphics( fullscreen ) ) {
// failed to set a valid mode in windowed mode
return rserr_invalid_mode;
}
R_GammaCorrectAndSetPalette( ( const unsigned char * ) d_8to24table );
return retval;
}
#else
int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
{
ri.Con_Printf (PRINT_ALL, "setting mode %d:", mode );
if ( !ri.Vid_GetModeInfo( pwidth, pheight, mode ) )
{
ri.Con_Printf( PRINT_ALL, " invalid mode\n" );
return rserr_invalid_mode;
}
ri.Con_Printf( PRINT_ALL, " %d %d\n", *pwidth, *pheight);
if ( !GLimp_InitGraphics( fullscreen ) ) {
// failed to set a valid mode in windowed mode
return rserr_invalid_mode;
}
return rserr_ok;
}
#endif
/*
** SWimp_SetPalette
**
** System specific palette setting routine. A NULL palette means
** to use the existing palette. The palette is expected to be in
** a padded 4-byte xRGB format.
*/
#ifndef OPENGL
void SWimp_SetPalette( const unsigned char *palette )
{
SDL_Color colors[256];
int i;
if (!X11_active)
return;
if ( !palette )
palette = ( const unsigned char * ) sw_state.currentpalette;
for (i = 0; i < 256; i++) {
colors[i].r = palette[i*4+0];
colors[i].g = palette[i*4+1];
colors[i].b = palette[i*4+2];
}
SDL_SetPalette(surface, sdl_palettemode, colors, 0, 256);
}
#endif
/*
** SWimp_Shutdown
**
** System specific graphics subsystem shutdown routine. Destroys
** DIBs or DDRAW surfaces as appropriate.
*/
void SWimp_Shutdown( void )
{
if (surface)
SDL_FreeSurface(surface);
surface = NULL;
if (SDL_WasInit(SDL_INIT_EVERYTHING) == SDL_INIT_VIDEO)
SDL_Quit();
else
SDL_QuitSubSystem(SDL_INIT_VIDEO);
X11_active = false;
}
#ifdef OPENGL
void GLimp_Shutdown( void )
{
SWimp_Shutdown();
}
#endif
/*
** SWimp_AppActivate
*/
#ifndef OPENGL
void SWimp_AppActivate( qboolean active )
{
}
#else
void GLimp_AppActivate( qboolean active )
{
}
#endif
//===============================================================================
/*
================
Sys_MakeCodeWriteable
================
*/
void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
{
int r;
unsigned long addr;
int psize = getpagesize();
addr = (startaddr & ~(psize-1)) - psize;
// fprintf(stderr, "writable code %lx(%lx)-%lx, length=%lx\n", startaddr,
// addr, startaddr+length, length);
r = mprotect((char*)addr, length + startaddr - addr + psize, 7);
if (r < 0)
Sys_Error("Protection change failed\n");
}
/*****************************************************************************/
/* KEYBOARD */
/*****************************************************************************/
Key_Event_fp_t Key_Event_fp;
void KBD_Init(Key_Event_fp_t fp)
{
Key_Event_fp = fp;
}
void KBD_Update(void)
{
SDL_Event event;
static int KBD_Update_Flag;
if (KBD_Update_Flag == 1)
return;
KBD_Update_Flag = 1;
// get events from x server
if (X11_active)
{
int bstate;
while (SDL_PollEvent(&event))
GetEvent(&event);
if (!mx && !my)
SDL_GetRelativeMouseState(&mx, &my);
mouse_buttonstate = 0;
bstate = SDL_GetMouseState(NULL, NULL);
if (SDL_BUTTON(1) & bstate)
mouse_buttonstate |= (1 << 0);
if (SDL_BUTTON(3) & bstate) /* quake2 has the right button be mouse2 */
mouse_buttonstate |= (1 << 1);
if (SDL_BUTTON(2) & bstate) /* quake2 has the middle button be mouse3 */
mouse_buttonstate |= (1 << 2);
if (SDL_BUTTON(6) & bstate)
mouse_buttonstate |= (1 << 3);
if (SDL_BUTTON(7) & bstate)
mouse_buttonstate |= (1 << 4);
if (old_windowed_mouse != _windowed_mouse->value) {
old_windowed_mouse = _windowed_mouse->value;
if (!_windowed_mouse->value) {
/* ungrab the pointer */
SDL_WM_GrabInput(SDL_GRAB_OFF);
} else {
/* grab the pointer */
SDL_WM_GrabInput(SDL_GRAB_ON);
}
}
while (keyq_head != keyq_tail)
{
Key_Event_fp(keyq[keyq_tail].key, keyq[keyq_tail].down);
keyq_tail = (keyq_tail + 1) & 63;
}
}
KBD_Update_Flag = 0;
}
void KBD_Close(void)
{
keyq_head = 0;
keyq_tail = 0;
memset(keyq, 0, sizeof(keyq));
}
#ifdef OPENGL
void Fake_glColorTableEXT( GLenum target, GLenum internalformat,
GLsizei width, GLenum format, GLenum type,
const GLvoid *table )
{
byte temptable[256][4];
byte *intbl;
int i;
for (intbl = (byte *)table, i = 0; i < 256; i++) {
temptable[i][2] = *intbl++;
temptable[i][1] = *intbl++;
temptable[i][0] = *intbl++;
temptable[i][3] = 255;
}
qgl3DfxSetPaletteEXT((GLuint *)temptable);
}
#endif

1241
solaris/rw_x11.c Normal file

File diff suppressed because it is too large Load diff

1155
solaris/rw_xil.c Normal file

File diff suppressed because it is too large Load diff

184
solaris/snd_sdl.c Normal file
View file

@ -0,0 +1,184 @@
/*
snd_sdl.c
Sound code taken from SDLQuake and modified to work with Quake2
Robert Bäuml 2001-12-25
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 "SDL.h"
#include "../client/client.h"
#include "../client/snd_loc.h"
static int snd_inited;
static dma_t *shm;
static void
paint_audio (void *unused, Uint8 * stream, int len)
{
if (shm) {
shm->buffer = stream;
shm->samplepos += len / (shm->samplebits / 4);
// Check for samplepos overflow?
S_PaintChannels (shm->samplepos);
}
}
qboolean
SNDDMA_Init (void)
{
SDL_AudioSpec desired, obtained;
int desired_bits, freq;
if (SDL_WasInit(SDL_INIT_EVERYTHING) == 0) {
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
Com_Printf ("Couldn't init SDL audio: %s\n", SDL_GetError ());
return 0;
}
} else if (SDL_WasInit(SDL_INIT_AUDIO) == 0) {
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
Com_Printf ("Couldn't init SDL audio: %s\n", SDL_GetError ());
return 0;
}
}
snd_inited = 0;
desired_bits = (Cvar_Get("sndbits", "16", CVAR_ARCHIVE))->value;
/* Set up the desired format */
freq = (Cvar_Get("s_khz", "0", CVAR_ARCHIVE))->value;
if (freq == 44)
desired.freq = 44100;
else if (freq == 22)
desired.freq = 22050;
else
desired.freq = 11025;
switch (desired_bits) {
case 8:
desired.format = AUDIO_U8;
break;
case 16:
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
desired.format = AUDIO_S16MSB;
else
desired.format = AUDIO_S16LSB;
break;
default:
Com_Printf ("Unknown number of audio bits: %d\n", desired_bits);
return 0;
}
desired.channels = (Cvar_Get("sndchannels", "2", CVAR_ARCHIVE))->value;
if (desired.freq == 44100)
desired.samples = 2048;
else if (desired.freq == 22050)
desired.samples = 1024;
else
desired.samples = 512;
desired.callback = paint_audio;
/* Open the audio device */
if (SDL_OpenAudio (&desired, &obtained) < 0) {
Com_Printf ("Couldn't open SDL audio: %s\n", SDL_GetError ());
return 0;
}
/* Make sure we can support the audio format */
switch (obtained.format) {
case AUDIO_U8:
/* Supported */
break;
case AUDIO_S16LSB:
case AUDIO_S16MSB:
if (((obtained.format == AUDIO_S16LSB) &&
(SDL_BYTEORDER == SDL_LIL_ENDIAN)) ||
((obtained.format == AUDIO_S16MSB) &&
(SDL_BYTEORDER == SDL_BIG_ENDIAN))) {
/* Supported */
break;
}
/* Unsupported, fall through */ ;
default:
/* Not supported -- force SDL to do our bidding */
SDL_CloseAudio ();
if (SDL_OpenAudio (&desired, NULL) < 0) {
Com_Printf ("Couldn't open SDL audio: %s\n", SDL_GetError ());
return 0;
}
memcpy (&obtained, &desired, sizeof (desired));
break;
}
SDL_PauseAudio (0);
/* Fill the audio DMA information block */
shm = &dma;
shm->samplebits = (obtained.format & 0xFF);
shm->speed = obtained.freq;
shm->channels = obtained.channels;
shm->samples = obtained.samples * shm->channels;
shm->samplepos = 0;
shm->submission_chunk = 1;
shm->buffer = NULL;
snd_inited = 1;
return 1;
}
int
SNDDMA_GetDMAPos (void)
{
return shm->samplepos;
}
void
SNDDMA_Shutdown (void)
{
if (snd_inited) {
SDL_CloseAudio ();
snd_inited = 0;
}
if (SDL_WasInit(SDL_INIT_EVERYTHING) == SDL_INIT_AUDIO)
SDL_Quit();
else
SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
/*
SNDDMA_Submit
Send sound to device if buffer isn't really the dma buffer
*/
void
SNDDMA_Submit (void)
{
}
void SNDDMA_BeginPainting(void)
{
}

286
solaris/snd_solaris.c Normal file
View file

@ -0,0 +1,286 @@
/*
Copyright (C) 1997-2001 Id Software, 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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stropts.h>
#include <sys/types.h>
#include <sys/audioio.h>
#include "../client/client.h"
#include "../client/snd_loc.h"
#define SND_DEBUG 0
#if SND_DEBUG
#define DPRINTF(...) printf(__VA_ARGS__)
#else
#define DPRINTF(...) /**/
#endif
static int audio_fd = -1;
static int snd_inited;
static cvar_t *sndbits;
static cvar_t *sndspeed;
static cvar_t *sndchannels;
static cvar_t *snddevice;
static int tryrates[] = { 11025, 22051, 44100, 8000 };
#define QSND_NUM_CHUNKS 2
/*
==================
SNDDMA_Init
Try to find a sound device to mix for.
Returns false if nothing is found.
Returns true and fills in the "dma" structure with information for the mixer.
==================
*/
qboolean SNDDMA_Init(void)
{
int i;
int samples;
audio_info_t au_info;
if (snd_inited)
return 1;
if (!snddevice) {
sndbits = Cvar_Get("sndbits", "16", CVAR_ARCHIVE);
sndspeed = Cvar_Get("sndspeed", "0", CVAR_ARCHIVE);
sndchannels = Cvar_Get("sndchannels", "2", CVAR_ARCHIVE);
snddevice = Cvar_Get("snddevice", "/dev/audio", CVAR_ARCHIVE);
}
// open /dev/audio
if (audio_fd < 0) {
audio_fd = open(snddevice->string, O_WRONLY);
if (audio_fd < 0) {
Com_Printf("Could not open %s: %s\n", snddevice->string, strerror(errno));
return 0;
}
}
// set sample bits & speed
if ((int)sndspeed->value > 0) {
AUDIO_INITINFO(&au_info);
au_info.play.precision = (int)sndbits->value;
au_info.play.encoding =
( au_info.play.precision == 8
? AUDIO_ENCODING_LINEAR8
: AUDIO_ENCODING_LINEAR );
au_info.play.sample_rate = (int)sndspeed->value;
au_info.play.channels = (int)sndchannels->value;
if (ioctl(audio_fd, AUDIO_SETINFO, &au_info) == -1) {
Com_Printf("AUDIO_SETINFO failed: %s\n", strerror(errno));
return 0;
}
} else {
for (i=0 ; i<sizeof(tryrates)/sizeof(tryrates[0]) ; i++) {
AUDIO_INITINFO(&au_info);
au_info.play.precision = (int)sndbits->value;
au_info.play.encoding =
( au_info.play.precision == 8
? AUDIO_ENCODING_LINEAR8
: AUDIO_ENCODING_LINEAR );
au_info.play.sample_rate = tryrates[i];
au_info.play.channels = (int)sndchannels->value;
if (ioctl(audio_fd, AUDIO_SETINFO, &au_info) == 0)
break;
Com_Printf("AUDIO_SETINFO failed: %s\n", strerror(errno));
}
if (i >= sizeof(tryrates)/sizeof(tryrates[0]))
return 0;
}
dma.samplebits = au_info.play.precision;
dma.channels = au_info.play.channels;
dma.speed = au_info.play.sample_rate;
/*
* submit some sound data every ~ 0.1 seconds, and try to buffer 2*0.1
* seconds in sound driver
*/
samples = dma.channels * dma.speed / 10;
for (i = 0; (1 << i) < samples; i++)
;
dma.submission_chunk = 1 << (i-1);
DPRINTF("channels %d, speed %d, log2(samples) %d, submission chunk %d\n",
dma.channels, dma.speed, i-1,
dma.submission_chunk);
dma.samples = QSND_NUM_CHUNKS * dma.submission_chunk;
dma.buffer = calloc(dma.samples, dma.samplebits/8);
if (dma.buffer == NULL) {
Com_Printf("Could not alloc sound buffer\n");
return 0;
}
AUDIO_INITINFO(&au_info);
au_info.play.eof = 0;
au_info.play.samples = 0;
ioctl(audio_fd, AUDIO_SETINFO, &au_info);
dma.samplepos = 0;
snd_inited = 1;
return 1;
}
/*
==============
SNDDMA_GetDMAPos
return the current sample position (in mono samples, not stereo)
inside the recirculating dma buffer, so the mixing code will know
how many sample are required to fill it up.
===============
*/
int SNDDMA_GetDMAPos(void)
{
int s_pos;
audio_info_t au_info;
if (!snd_inited)
return 0;
if (ioctl(audio_fd, AUDIO_GETINFO, &au_info) == -1) {
Com_Printf("AUDIO_GETINFO failed: %s\n", strerror(errno));
return 0;
}
s_pos = au_info.play.samples * dma.channels;
return s_pos & (dma.samples - 1);
}
/*
==============
SNDDMA_Shutdown
Reset the sound device for exiting
===============
*/
void SNDDMA_Shutdown(void)
{
if (snd_inited) {
if (audio_fd >= 0) {
ioctl(audio_fd, I_FLUSH, FLUSHW);
close(audio_fd);
audio_fd = -1;
}
snd_inited = 0;
}
}
/*
==============
SNDDMA_Submit
Send sound to device if buffer isn't really the dma buffer
===============
*/
void SNDDMA_Submit(void)
{
int samplebytes = dma.samplebits/8;
audio_info_t au_info;
int s_pos;
int chunk_idx;
static int last_chunk_idx = -1;
if (!snd_inited)
return;
if (last_chunk_idx == -1) {
if (write(audio_fd, dma.buffer, dma.samples * samplebytes) != dma.samples * samplebytes)
Com_Printf("initial write on audio device failed\n");
last_chunk_idx = 0;
dma.samplepos = 0;
return;
}
if (ioctl(audio_fd, AUDIO_GETINFO, &au_info) == -1) {
Com_Printf("AUDIO_GETINFO failed: %s\n", strerror(errno));
return;
}
if (au_info.play.error) {
/*
* underflow? clear the error flag and reset the HW sample counter
* and send the whole dma_buffer, to get sound output working again
*/
DPRINTF("audio data underflow\n");
AUDIO_INITINFO(&au_info);
au_info.play.error = 0;
au_info.play.samples = 0;
ioctl(audio_fd, AUDIO_SETINFO, &au_info);
if (write(audio_fd, dma.buffer, dma.samples * samplebytes) != dma.samples * samplebytes)
Com_Printf("refill sound driver after underflow failed\n");
last_chunk_idx = 0;
dma.samplepos = 0;
return;
}
s_pos = au_info.play.samples * dma.channels;
chunk_idx = (s_pos % dma.samples) / dma.submission_chunk;
DPRINTF("HW DMA Pos=%u (%u), dma.samplepos=%u, play in=%d, last=%d\n",
au_info.play.samples, s_pos, dma.samplepos,
chunk_idx, last_chunk_idx);
while (chunk_idx != last_chunk_idx) {
if (write(audio_fd,
dma.buffer + dma.samplepos * samplebytes,
dma.submission_chunk * samplebytes) != dma.submission_chunk * samplebytes) {
Com_Printf("write error on audio device\n");
}
if ((dma.samplepos += dma.submission_chunk) >= dma.samples)
dma.samplepos = 0;
if (++last_chunk_idx >= QSND_NUM_CHUNKS)
last_chunk_idx = 0;
}
}
void SNDDMA_BeginPainting (void)
{
}

138
solaris/sndtest.c Normal file
View file

@ -0,0 +1,138 @@
/**
*
* TODO: change printf to output things on the Quake console instead
*/
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <stropts.h>
#include <pthread.h>
#include <sys/audioio.h>
#include <unistd.h>
#include <errno.h>
#include "../client/client.h"
#include "../client/snd_loc.h"
#define BLOCK_SIZE 1024
#define CHUNKS 2
static int audio_fd = 0;
static int audioctl_fd = 0;
static char audio_buf[BLOCK_SIZE * 16] = "";
static int audio_bps = 0;
dma_t dma;
qboolean SNDDMA_Init( void )
{
audio_info_t info;
/* set up audio device */
if( (audio_fd = open ("/dev/audio", O_WRONLY|O_NDELAY)) == -1 ) {
perror( "can't open audio device" );
return 0;
}
if( (audioctl_fd = open ("/dev/audioctl", O_RDWR)) == -1 ) {
perror( "can't open audio control device" );
close( audio_fd );
return 0;
}
if( ioctl( audio_fd, AUDIO_GETINFO, &info ) == -1 ) {
perror( "Could not get audio info" );
close( audio_fd );
close( audioctl_fd );
return 0;
}
info.play.encoding = AUDIO_ENCODING_LINEAR;
info.play.sample_rate = 11025;
info.play.channels = 2;
info.play.precision = 16;
if (ioctl(audio_fd, AUDIO_SETINFO, &info) == -1) {
perror("Could not set audio device info");
close( audio_fd );
close( audioctl_fd );
return 0;
}
// these need to be set up
dma.speed = 11025;
dma.samplebits = 16;
dma.channels = 2;
dma.samples = sizeof(audio_buf) / (dma.samplebits / 8);
dma.samplepos = 0;
dma.submission_chunk = BLOCK_SIZE / (dma.samplebits / 8);
dma.buffer = (unsigned char *)audio_buf;
// other useful precalculated variables
audio_bps = (dma.samplebits / 8) * dma.channels;
/* DEBUG set up buffer with a lovely tone */
// for (n = 0; n < sizeof(audio_buf); n++)
// audio_buf[n] = n*2;
// dma.buffer = (unsigned char*)audio_xxx;
return 1;
}
int SNDDMA_GetDMAPos(void)
{
/* dma.samplepos = (audio_ptr / audio_bps);*/
/*return dma.samplepos; */
return 0;
}
void SNDDMA_Shutdown( void )
{
}
void SNDDMA_BeginPainting (void)
{
}
void SNDDMA_Submit (void)
{
}
int main( void )
{
sigset_t sigs;
sigemptyset( &sigs );
sigaddset( &sigs, SIGPOLL );
pthread_sigmask( SIG_BLOCK, &sigs, NULL );
SNDDMA_Init();
for( ;; ) {
char str[ 1024 ];
int length;
int pos;
int c;
short *p;
int b;
printf( "tone length: " );
fflush( stdout );
gets( str );
length = strtol( str, NULL, 0 );
b = BLOCK_SIZE / (dma.samplebits / 8);
pos = SNDDMA_GetDMAPos();
printf( "MAIN: pos=%d\n", pos );
if( length > 0 ) {
pos = (pos | (b-1)) + 1;
printf( "MAIN: submitting %d,%d\n", pos );
for( c = 0 ; c < length ; c++ ) {
((short *)dma.buffer)[ pos ] = sin( (double)c / 10 ) * 30000;
if( ++pos >= dma.samples ) {
pos -= dma.samples;
}
}
}
}
return 0;
}

View file

@ -36,16 +36,43 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <sys/mman.h>
#include <errno.h>
#include <sys/file.h>
#include <dlfcn.h>
#include "../qcommon/qcommon.h"
#include "../solaris/rw_solaris.h"
#if defined(SOL8_XIL_WORKAROUND) && !defined(DEDICATED_ONLY)
#include <xil/xil.h>
typedef struct
{
qboolean restart_sound;
int s_rate;
int s_width;
int s_channels;
int width;
int height;
byte *pic;
byte *pic_pending;
// order 1 huffman stuff
int *hnodes1; // [256][256][2];
int numhnodes1[256];
int h_used[512];
int h_count[512];
} cinematics_t;
#endif
cvar_t *nostdout;
unsigned sys_frame_time;
uid_t saved_euid;
qboolean stdin_active = true;
hrtime_t base_hrtime;
char display_name[ 1024 ];
// =======================================================================
// General routines
@ -66,7 +93,7 @@ void Sys_Printf (char *fmt, ...)
unsigned char *p;
va_start (argptr,fmt);
vsprintf (text,fmt,argptr);
vsnprintf (text,1024,fmt,argptr);
va_end (argptr);
if (strlen(text) > sizeof(text))
@ -89,33 +116,37 @@ void Sys_Quit (void)
CL_Shutdown ();
Qcommon_Shutdown ();
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
_exit(0);
}
void Sys_Init(void)
{
/*
#if id386
// Sys_SetFPCW();
#endif
*/
}
void Sys_Error (char *error, ...)
{
/* DEBUG: matt */
/* exit(0); */
/* DEBUG */
va_list argptr;
char string[1024];
// change stdin to non blocking
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
CL_Shutdown ();
Qcommon_Shutdown ();
va_start (argptr,error);
vsprintf (string,error,argptr);
vsnprintf (string,1024,error,argptr);
va_end (argptr);
fprintf(stderr, "Error: %s\n", string);
CL_Shutdown ();
Qcommon_Shutdown ();
_exit (1);
}
@ -126,7 +157,7 @@ void Sys_Warn (char *warning, ...)
char string[1024];
va_start (argptr,warning);
vsprintf (string,warning,argptr);
vsnprintf (string,1024,warning,argptr);
va_end (argptr);
fprintf(stderr, "Warning: %s", string);
}
@ -179,6 +210,7 @@ char *Sys_ConsoleInput(void)
stdin_active = false;
return NULL;
}
if (len < 1)
return NULL;
text[len-1] = 0; // rip off the /n and terminate
@ -213,13 +245,14 @@ void *Sys_GetGameAPI (void *parms)
{
void *(*GetGameAPI) (void *);
FILE *fp;
char name[MAX_OSPATH];
char curpath[MAX_OSPATH];
char *path;
char *str_p;
#ifdef __i386__
const char *gamename = "gamei386.so";
#elif defined __sun__
#elif defined(__sun__) || defined(sun)
const char *gamename = "gamesparc.so";
#else
#error Unknown arch
@ -230,7 +263,7 @@ void *Sys_GetGameAPI (void *parms)
getcwd(curpath, sizeof(curpath));
Com_Printf("------- Loading %s -------", gamename);
Com_Printf("------- Loading %s -------\n", gamename);
// now run through the search paths
path = NULL;
@ -239,28 +272,39 @@ void *Sys_GetGameAPI (void *parms)
path = FS_NextPath (path);
if (!path)
return NULL; // couldn't find one anywhere
sprintf (name, "%s/%s/%s", curpath, path, gamename);
game_library = dlopen (name, RTLD_NOW );
snprintf (name, MAX_OSPATH, "%s/%s", path, gamename);
/* skip it if it just doesn't exist */
fp = fopen(name, "rb");
if (fp == NULL)
continue;
fclose(fp);
game_library = dlopen (name, RTLD_NOW);
if (game_library)
{
Com_MDPrintf ("LoadLibrary (%s)\n", name);
Com_MDPrintf ("LoadLibrary (%s)\n",name);
break;
} else {
Com_MPrintf("error: %s\n", dlerror());
str_p = strchr(dlerror(), ':'); // skip the path (already shown)
if (str_p != NULL)
}
else
{
Com_MDPrintf (" **");
while (*str_p)
Com_MDPrintf ("%c", *(++str_p));
Com_MDPrintf ("\n");
}
Com_Printf ("LoadLibrary (%s):", name);
path = dlerror();
str_p = strchr(path, ':'); // skip the path (already shown)
if (str_p == NULL)
str_p = path;
else
str_p++;
Com_Printf ("%s\n", str_p);
return NULL;
}
}
GetGameAPI = (void *)dlsym (game_library, "GetGameAPI");
if (!GetGameAPI)
{
Sys_UnloadGame ();
@ -278,25 +322,74 @@ void Sys_AppActivate (void)
void Sys_SendKeyEvents (void)
{
#ifndef DEDICATED_ONLY
if (KBD_Update_fp)
KBD_Update_fp();
#endif
// grab frame time
sys_frame_time = Sys_Milliseconds();
}
/*****************************************************************************/
char *Sys_GetClipboardData(void)
char *Sys_GetClipboardData( void )
{
return NULL;
}
#if defined(SOL8_XIL_WORKAROUND) && !defined(DEDICATED_ONLY)
XilSystemState xil_state;
#endif
int main (int argc, char **argv)
int main( int argc, char **argv )
{
int time, oldtime, newtime;
#if 0
#ifdef DEDICATED_ONLY
int newargc;
char **newargv;
int i;
#endif
int time, oldtime, newtime;
sigset_t sigs;
#if defined(SOL8_XIL_WORKAROUND) && !defined(DEDICATED_ONLY)
{
extern cinematics_t cin;
if( (xil_state = xil_open()) == NULL ) {
fprintf( stderr, "can't open XIL\n" );
exit( 1 );
}
memset( &cin, 0, sizeof( cin ) );
}
#endif
/*
* Save the contents of the DISPLAY environment variable.
* if we don't, it gets overwritten after reloading the
* renderer libraries.
*/
{
char *tmp_name = getenv( "DISPLAY" );
if( tmp_name == NULL ) {
display_name[ 0 ] = 0;
}
else {
strncpy( display_name, tmp_name, sizeof( display_name ) );
}
}
/* block the SIGPOLL signal so that only the audio thread gets it */
sigemptyset( &sigs );
sigaddset( &sigs, SIGPOLL );
pthread_sigmask( SIG_BLOCK, &sigs, NULL );
// go back to real user for config loads
saved_euid = geteuid();
seteuid( getuid() );
base_hrtime = gethrtime();
#ifdef DEDICATED_ONLY
// force dedicated
newargc = argc;
@ -320,7 +413,7 @@ int main (int argc, char **argv)
if (!nostdout->value) {
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
// printf ("Linux Quake -- Version %0.3f\n", LINUX_VERSION);
// printf ("Solaris Quake 2 -- Version %0.3f\n", SOLARIS_VERSION);
}
oldtime = Sys_Milliseconds ();
@ -368,3 +461,46 @@ void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
}
#endif
size_t verify_fread( void *ptr, size_t size, size_t nitems, FILE *fp )
{
size_t ret;
int err;
clearerr( fp );
ret = fread( ptr, size, nitems, fp );
err = errno;
if( ret != nitems ) {
printf( "verify_fread(...,%d,%d,...): return value: %d\n",
size, nitems, ret );
if( ret == 0 && ferror( fp ) ) {
printf( " error: %s\n", strerror( err ) );
printf( " fileno=%d\n", fileno( fp ) );
}
/* sleep( 5 );*/
}
return ret;
}
size_t verify_fwrite( void *ptr, size_t size, size_t nitems, FILE *fp )
{
size_t ret;
int err;
clearerr( fp );
ret = fwrite( ptr, size, nitems, fp );
err = errno;
if( ret != nitems ) {
printf( "verify_fwrite(...,%d,%d,...): return value: %d\n",
size, nitems, ret );
if( ret == 0 && ferror( fp ) ) {
printf( " error: %s\n", strerror( err ) );
printf( " fileno=%d\n", fileno( fp ) );
}
/* sleep( 5 );*/
}
return ret;
}

571
solaris/vid_menu.c Normal file
View file

@ -0,0 +1,571 @@
#include "../client/client.h"
#include "../client/qmenu.h"
/*
====================================================================
REF stuff ...
Used to dynamically load the menu with only those vid_ref's that
are present on this system
====================================================================
*/
/* this will have to be updated if ref's are added/removed from ref_t */
#define NUMBER_OF_REFS 6
/* all the refs should be initially set to 0 */
static char *refs[NUMBER_OF_REFS+1] = { 0 };
/* make all these have illegal values, as they will be redefined */
static int REF_XIL = NUMBER_OF_REFS;
static int REF_SOFTX11 = NUMBER_OF_REFS;
static int REF_CORONA = NUMBER_OF_REFS;
static int REF_SOFTSDL = NUMBER_OF_REFS;
static int REF_GLX = NUMBER_OF_REFS;
static int REF_SDLGL = NUMBER_OF_REFS;
static int GL_REF_START = NUMBER_OF_REFS;
typedef struct
{
char menuname[32];
char realname[32];
int *pointer;
} ref_t;
static const ref_t possible_refs[NUMBER_OF_REFS] =
{
{ "[software XIL ]", "xil", &REF_XIL },
{ "[software X11 ]", "softx", &REF_SOFTX11 },
{ "[soft SunRAY ]", "corona", &REF_CORONA },
{ "[software SDL ]", "softsdl", &REF_SOFTSDL },
{ "[OpenGL GLX ]", "glx", &REF_GLX },
{ "[SDL OpenGL ]", "sdlgl", &REF_SDLGL }
};
/*
====================================================================
*/
extern cvar_t *vid_ref;
extern cvar_t *vid_fullscreen;
extern cvar_t *vid_gamma;
extern cvar_t *scr_viewsize;
static cvar_t *gl_mode;
static cvar_t *gl_driver;
static cvar_t *gl_picmip;
static cvar_t *gl_ext_palettedtexture;
static cvar_t *sw_mode;
static cvar_t *sw_stipplealpha;
static cvar_t *_windowed_mouse;
extern void M_ForceMenuOff( void );
extern qboolean VID_CheckRefExists( const char *name );
/*
====================================================================
MENU INTERACTION
====================================================================
*/
#define SOFTWARE_MENU 0
#define OPENGL_MENU 1
static menuframework_s s_software_menu;
static menuframework_s s_opengl_menu;
static menuframework_s *s_current_menu;
static int s_current_menu_index;
static menulist_s s_mode_list[2];
static menulist_s s_ref_list[2];
static menuslider_s s_tq_slider;
static menuslider_s s_screensize_slider[2];
static menuslider_s s_brightness_slider[2];
static menulist_s s_fs_box[2];
static menulist_s s_stipple_box;
static menulist_s s_paletted_texture_box;
static menulist_s s_windowed_mouse;
static menuaction_s s_apply_action[2];
static menuaction_s s_defaults_action[2];
static void DriverCallback( void *unused )
{
s_ref_list[!s_current_menu_index].curvalue = s_ref_list[s_current_menu_index].curvalue;
if ( s_ref_list[s_current_menu_index].curvalue < GL_REF_START )
{
s_current_menu = &s_software_menu;
s_current_menu_index = 0;
}
else
{
s_current_menu = &s_opengl_menu;
s_current_menu_index = 1;
}
}
static void ScreenSizeCallback( void *s )
{
menuslider_s *slider = ( menuslider_s * ) s;
Cvar_SetValue( "viewsize", slider->curvalue * 10 );
}
static void BrightnessCallback( void *s )
{
menuslider_s *slider = ( menuslider_s * ) s;
if ( s_current_menu_index == 0)
s_brightness_slider[1].curvalue = s_brightness_slider[0].curvalue;
else
s_brightness_slider[0].curvalue = s_brightness_slider[1].curvalue;
if( stricmp( vid_ref->string, "xil" ) == 0 ||
stricmp( vid_ref->string, "softx" ) == 0 ||
stricmp( vid_ref->string, "corona" ) == 0 ||
stricmp( vid_ref->string, "softsdl" ) == 0 ||
stricmp( vid_ref->string, "glx" ) == 0 ||
stricmp( vid_ref->string, "sdlgl" ) == 0 ) {
float gamma = ( 0.8 - ( slider->curvalue/10.0 - 0.5 ) ) + 0.5;
Cvar_SetValue( "vid_gamma", gamma );
}
}
static void ResetDefaults( void *unused )
{
VID_MenuInit();
}
static void ApplyChanges( void *unused )
{
float gamma;
int ref;
/*
** make values consistent
*/
s_fs_box[!s_current_menu_index].curvalue = s_fs_box[s_current_menu_index].curvalue;
s_brightness_slider[!s_current_menu_index].curvalue = s_brightness_slider[s_current_menu_index].curvalue;
s_ref_list[!s_current_menu_index].curvalue = s_ref_list[s_current_menu_index].curvalue;
/*
** invert sense so greater = brighter, and scale to a range of 0.5 to 1.3
*/
gamma = ( 0.8 - ( s_brightness_slider[s_current_menu_index].curvalue/10.0 - 0.5 ) ) + 0.5;
Cvar_SetValue( "vid_gamma", gamma );
Cvar_SetValue( "sw_stipplealpha", s_stipple_box.curvalue );
Cvar_SetValue( "gl_picmip", 3 - s_tq_slider.curvalue );
Cvar_SetValue( "vid_fullscreen", s_fs_box[s_current_menu_index].curvalue );
Cvar_SetValue( "gl_ext_palettedtexture", s_paletted_texture_box.curvalue );
Cvar_SetValue( "sw_mode", s_mode_list[SOFTWARE_MENU].curvalue );
Cvar_SetValue( "gl_mode", s_mode_list[OPENGL_MENU].curvalue );
Cvar_SetValue( "_windowed_mouse", s_windowed_mouse.curvalue);
/*
** must use an if here (instead of a switch), since the REF_'s are now variables
** and not #DEFINE's (constants)
*/
ref = s_ref_list[s_current_menu_index].curvalue;
if ( ref == REF_XIL )
{
Cvar_Set( "vid_ref", "xil" );
}
else if ( ref == REF_SOFTX11 )
{
Cvar_Set( "vid_ref", "softx" );
}
else if ( ref == REF_CORONA )
{
Cvar_Set( "vid_ref", "corona" );
}
else if ( ref == REF_SOFTSDL )
{
Cvar_Set( "vid_ref", "softsdl" );
}
else if ( ref == REF_GLX )
{
Cvar_Set( "vid_ref", "glx" );
Cvar_Set( "gl_driver", "libGL.so" );
}
else if ( ref == REF_SDLGL )
{
Cvar_Set( "vid_ref", "sdlgl" );
Cvar_Set( "gl_driver", "libGL.so" );
}
#if 0
/*
** update appropriate stuff if we're running OpenGL and gamma
** has been modified
*/
if ( stricmp( vid_ref->string, "gl" ) == 0 )
{
if ( vid_gamma->modified )
{
vid_ref->modified = true;
if ( stricmp( gl_driver->string, "3dfxgl" ) == 0 )
{
char envbuffer[1024];
float g;
vid_ref->modified = true;
g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F;
Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g );
putenv( envbuffer );
vid_gamma->modified = false;
}
}
}
#endif
M_ForceMenuOff();
}
/*
** VID_MenuInit
*/
void VID_MenuInit( void )
{
int i, counter;
static const char *resolutions[] =
{
"[320 240 ]",
"[400 300 ]",
"[512 384 ]",
"[640 480 ]",
"[800 600 ]",
"[960 720 ]",
"[1024 768 ]",
"[1152 864 ]",
"[1280 1024]",
"[1600 1200]",
"[700 384 ]",
"[1000 400 ]",
"[2400 950 ]",
0
};
static const char *yesno_names[] =
{
"no",
"yes",
0
};
/* make sure these are invalided before showing the menu again */
REF_XIL = NUMBER_OF_REFS;
REF_SOFTX11 = NUMBER_OF_REFS;
REF_CORONA = NUMBER_OF_REFS;
REF_SOFTSDL = NUMBER_OF_REFS;
REF_GLX = NUMBER_OF_REFS;
REF_SDLGL = NUMBER_OF_REFS;
GL_REF_START = NUMBER_OF_REFS;
/* now test to see which ref's are present */
i = counter = 0;
while ( i < NUMBER_OF_REFS )
{
if ( VID_CheckRefExists( possible_refs[i].realname ) )
{
*(possible_refs[i].pointer) = counter;
/* free any previous string */
if ( refs[i] )
free ( refs[i] );
refs[counter] = strdup(possible_refs[i].menuname);
/*
** if we reach the 3rd item in the list, this indicates that a
** GL ref has been found; this will change if more software
** modes are added to the possible_ref's array
*/
if ( i == 3 )
GL_REF_START = counter;
counter++;
}
i++;
}
refs[counter] = (char*) 0;
if ( !gl_driver )
gl_driver = Cvar_Get( "gl_driver", "libGL.so", 0 );
if ( !gl_picmip )
gl_picmip = Cvar_Get( "gl_picmip", "0", 0 );
if ( !gl_mode )
gl_mode = Cvar_Get( "gl_mode", "3", 0 );
if ( !sw_mode )
sw_mode = Cvar_Get( "sw_mode", "0", 0 );
if ( !gl_ext_palettedtexture )
gl_ext_palettedtexture = Cvar_Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE );
if ( !sw_stipplealpha )
sw_stipplealpha = Cvar_Get( "sw_stipplealpha", "0", CVAR_ARCHIVE );
if ( !_windowed_mouse)
_windowed_mouse = Cvar_Get( "_windowed_mouse", "0", CVAR_ARCHIVE );
s_mode_list[SOFTWARE_MENU].curvalue = sw_mode->value;
s_mode_list[OPENGL_MENU].curvalue = gl_mode->value;
if ( !scr_viewsize )
scr_viewsize = Cvar_Get ("viewsize", "100", CVAR_ARCHIVE);
s_screensize_slider[SOFTWARE_MENU].curvalue = scr_viewsize->value/10;
s_screensize_slider[OPENGL_MENU].curvalue = scr_viewsize->value/10;
if ( strcmp( vid_ref->string, "xil" ) == 0)
{
s_current_menu_index = SOFTWARE_MENU;
s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_XIL;
}
else if (strcmp( vid_ref->string, "softx" ) == 0 )
{
s_current_menu_index = SOFTWARE_MENU;
s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_SOFTX11;
}
else if (strcmp( vid_ref->string, "softsdl" ) == 0 )
{
s_current_menu_index = SOFTWARE_MENU;
s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_SOFTSDL;
}
else if ( strcmp( vid_ref->string, "glx" ) == 0 )
{
s_current_menu_index = OPENGL_MENU;
s_ref_list[s_current_menu_index].curvalue = REF_GLX;
#if 0
if ( strcmp( gl_driver->string, "3dfxgl" ) == 0 )
s_ref_list[s_current_menu_index].curvalue = REF_3DFX;
else if ( strcmp( gl_driver->string, "pvrgl" ) == 0 )
s_ref_list[s_current_menu_index].curvalue = REF_POWERVR;
else if ( strcmp( gl_driver->string, "opengl32" ) == 0 )
s_ref_list[s_current_menu_index].curvalue = REF_OPENGL;
else
s_ref_list[s_current_menu_index].curvalue = REF_VERITE;
#endif
}
else if ( strcmp( vid_ref->string, "sdlgl" ) == 0 )
{
s_current_menu_index = OPENGL_MENU;
s_ref_list[s_current_menu_index].curvalue = REF_SDLGL;
#if 0
if ( strcmp( gl_driver->string, "3dfxgl" ) == 0 )
s_ref_list[s_current_menu_index].curvalue = REF_3DFX;
else if ( strcmp( gl_driver->string, "pvrgl" ) == 0 )
s_ref_list[s_current_menu_index].curvalue = REF_POWERVR;
else if ( strcmp( gl_driver->string, "opengl32" ) == 0 )
s_ref_list[s_current_menu_index].curvalue = REF_OPENGL;
else
s_ref_list[s_current_menu_index].curvalue = REF_VERITE;
#endif
}
s_software_menu.x = viddef.width * 0.50;
s_software_menu.nitems = 0;
s_opengl_menu.x = viddef.width * 0.50;
s_opengl_menu.nitems = 0;
for ( i = 0; i < 2; i++ )
{
s_ref_list[i].generic.type = MTYPE_SPINCONTROL;
s_ref_list[i].generic.name = "driver";
s_ref_list[i].generic.x = 0;
s_ref_list[i].generic.y = 0;
s_ref_list[i].generic.callback = DriverCallback;
s_ref_list[i].itemnames = (const char **) refs;
s_mode_list[i].generic.type = MTYPE_SPINCONTROL;
s_mode_list[i].generic.name = "video mode";
s_mode_list[i].generic.x = 0;
s_mode_list[i].generic.y = 10;
s_mode_list[i].itemnames = resolutions;
s_screensize_slider[i].generic.type = MTYPE_SLIDER;
s_screensize_slider[i].generic.x = 0;
s_screensize_slider[i].generic.y = 20;
s_screensize_slider[i].generic.name = "screen size";
s_screensize_slider[i].minvalue = 3;
s_screensize_slider[i].maxvalue = 12;
s_screensize_slider[i].generic.callback = ScreenSizeCallback;
s_brightness_slider[i].generic.type = MTYPE_SLIDER;
s_brightness_slider[i].generic.x = 0;
s_brightness_slider[i].generic.y = 30;
s_brightness_slider[i].generic.name = "brightness";
s_brightness_slider[i].generic.callback = BrightnessCallback;
s_brightness_slider[i].minvalue = 5;
s_brightness_slider[i].maxvalue = 13;
s_brightness_slider[i].curvalue = ( 1.3 - vid_gamma->value + 0.5 ) * 10;
s_fs_box[i].generic.type = MTYPE_SPINCONTROL;
s_fs_box[i].generic.x = 0;
s_fs_box[i].generic.y = 40;
s_fs_box[i].generic.name = "fullscreen";
s_fs_box[i].itemnames = yesno_names;
s_fs_box[i].curvalue = vid_fullscreen->value;
s_defaults_action[i].generic.type = MTYPE_ACTION;
s_defaults_action[i].generic.name = "reset to default";
s_defaults_action[i].generic.x = 0;
s_defaults_action[i].generic.y = 90;
s_defaults_action[i].generic.callback = ResetDefaults;
s_apply_action[i].generic.type = MTYPE_ACTION;
s_apply_action[i].generic.name = "apply";
s_apply_action[i].generic.x = 0;
s_apply_action[i].generic.y = 100;
s_apply_action[i].generic.callback = ApplyChanges;
}
s_stipple_box.generic.type = MTYPE_SPINCONTROL;
s_stipple_box.generic.x = 0;
s_stipple_box.generic.y = 60;
s_stipple_box.generic.name = "stipple alpha";
s_stipple_box.curvalue = sw_stipplealpha->value;
s_stipple_box.itemnames = yesno_names;
s_windowed_mouse.generic.type = MTYPE_SPINCONTROL;
s_windowed_mouse.generic.x = 0;
s_windowed_mouse.generic.y = 72;
s_windowed_mouse.generic.name = "windowed mouse";
s_windowed_mouse.curvalue = _windowed_mouse->value;
s_windowed_mouse.itemnames = yesno_names;
s_tq_slider.generic.type = MTYPE_SLIDER;
s_tq_slider.generic.x = 0;
s_tq_slider.generic.y = 60;
s_tq_slider.generic.name = "texture quality";
s_tq_slider.minvalue = 0;
s_tq_slider.maxvalue = 3;
s_tq_slider.curvalue = 3-gl_picmip->value;
s_paletted_texture_box.generic.type = MTYPE_SPINCONTROL;
s_paletted_texture_box.generic.x = 0;
s_paletted_texture_box.generic.y = 70;
s_paletted_texture_box.generic.name = "8-bit textures";
s_paletted_texture_box.itemnames = yesno_names;
s_paletted_texture_box.curvalue = gl_ext_palettedtexture->value;
Menu_AddItem( &s_software_menu, ( void * ) &s_ref_list[SOFTWARE_MENU] );
Menu_AddItem( &s_software_menu, ( void * ) &s_mode_list[SOFTWARE_MENU] );
Menu_AddItem( &s_software_menu, ( void * ) &s_screensize_slider[SOFTWARE_MENU] );
Menu_AddItem( &s_software_menu, ( void * ) &s_brightness_slider[SOFTWARE_MENU] );
/* Menu_AddItem( &s_software_menu, ( void * ) &s_fs_box[SOFTWARE_MENU] );*/
Menu_AddItem( &s_software_menu, ( void * ) &s_stipple_box );
Menu_AddItem( &s_software_menu, ( void * ) &s_windowed_mouse );
Menu_AddItem( &s_opengl_menu, ( void * ) &s_ref_list[OPENGL_MENU] );
Menu_AddItem( &s_opengl_menu, ( void * ) &s_mode_list[OPENGL_MENU] );
Menu_AddItem( &s_opengl_menu, ( void * ) &s_screensize_slider[OPENGL_MENU] );
Menu_AddItem( &s_opengl_menu, ( void * ) &s_brightness_slider[OPENGL_MENU] );
Menu_AddItem( &s_opengl_menu, ( void * ) &s_fs_box[OPENGL_MENU] );
Menu_AddItem( &s_opengl_menu, ( void * ) &s_tq_slider );
Menu_AddItem( &s_opengl_menu, ( void * ) &s_paletted_texture_box );
Menu_AddItem( &s_software_menu, ( void * ) &s_defaults_action[SOFTWARE_MENU] );
Menu_AddItem( &s_software_menu, ( void * ) &s_apply_action[SOFTWARE_MENU] );
Menu_AddItem( &s_opengl_menu, ( void * ) &s_defaults_action[OPENGL_MENU] );
Menu_AddItem( &s_opengl_menu, ( void * ) &s_apply_action[OPENGL_MENU] );
Menu_Center( &s_software_menu );
Menu_Center( &s_opengl_menu );
s_opengl_menu.x -= 8;
s_software_menu.x -= 8;
}
/*
================
VID_MenuShutdown
================
*/
void VID_MenuShutdown( void )
{
int i;
for ( i = 0; i < NUMBER_OF_REFS; i++ )
{
if ( refs[i] )
free ( refs[i] );
}
}
/*
================
VID_MenuDraw
================
*/
void VID_MenuDraw (void)
{
int w, h;
if ( s_current_menu_index == 0 )
s_current_menu = &s_software_menu;
else
s_current_menu = &s_opengl_menu;
/*
** draw the banner
*/
re.DrawGetPicSize( &w, &h, "m_banner_video" );
re.DrawPic( viddef.width / 2 - w / 2, viddef.height /2 - 110, "m_banner_video" );
/*
** move cursor to a reasonable starting position
*/
Menu_AdjustCursor( s_current_menu, 1 );
/*
** draw the menu
*/
Menu_Draw( s_current_menu );
}
/*
================
VID_MenuKey
================
*/
const char *VID_MenuKey( int key )
{
extern void M_PopMenu( void );
menuframework_s *m = s_current_menu;
static const char *sound = "misc/menu1.wav";
switch ( key )
{
case K_ESCAPE:
M_PopMenu();
return NULL;
case K_UPARROW:
m->cursor--;
Menu_AdjustCursor( m, -1 );
break;
case K_DOWNARROW:
m->cursor++;
Menu_AdjustCursor( m, 1 );
break;
case K_LEFTARROW:
Menu_SlideItem( m, -1 );
break;
case K_RIGHTARROW:
Menu_SlideItem( m, 1 );
break;
case K_ENTER:
Menu_SelectItem( m );
break;
}
return sound;
}

540
solaris/vid_so.c Normal file
View file

@ -0,0 +1,540 @@
/*
Copyright (C) 1997-2001 Id Software, 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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Main windowed and fullscreen graphics interface module. This module
// is used for both the software and OpenGL rendering versions of the
// Quake refresh engine.
#include <assert.h>
#include <dlfcn.h> // ELF dl loader
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include "../client/client.h"
#include "../solaris/rw_solaris.h"
// Structure containing functions exported from refresh DLL
refexport_t re;
// Console variables that we need to access from this module
cvar_t *vid_gamma;
cvar_t *vid_ref; // Name of Refresh DLL loaded
cvar_t *vid_xpos; // X coordinate of window position
cvar_t *vid_ypos; // Y coordinate of window position
cvar_t *vid_fullscreen;
// Global variables used internally by this module
viddef_t viddef; // global video state; used by other modules
void *reflib_library; // Handle to refresh DLL
qboolean reflib_active = 0;
#define VID_NUM_MODES ( sizeof( vid_modes ) / sizeof( vid_modes[0] ) )
/** KEYBOARD **************************************************************/
void Do_Key_Event(int key, qboolean down);
void (*KBD_Update_fp)(void);
void (*KBD_Init_fp)(Key_Event_fp_t fp);
void (*KBD_Close_fp)(void);
/** MOUSE *****************************************************************/
in_state_t in_state;
void (*RW_IN_Init_fp)(in_state_t *in_state_p);
void (*RW_IN_Shutdown_fp)(void);
void (*RW_IN_Activate_fp)(qboolean active);
void (*RW_IN_Commands_fp)(void);
void (*RW_IN_Move_fp)(usercmd_t *cmd);
void (*RW_IN_Frame_fp)(void);
void Real_IN_Init (void);
/*
==========================================================================
DLL GLUE
==========================================================================
*/
#define MAXPRINTMSG 4096
void VID_Printf (int print_level, char *fmt, ...)
{
va_list argptr;
char msg[MAXPRINTMSG];
va_start (argptr,fmt);
vsnprintf (msg,MAXPRINTMSG,fmt,argptr);
va_end (argptr);
if (print_level == PRINT_ALL)
Com_Printf ("%s", msg);
else
Com_DPrintf ("%s", msg);
}
void VID_Error (int err_level, char *fmt, ...)
{
va_list argptr;
char msg[MAXPRINTMSG];
va_start (argptr,fmt);
vsnprintf (msg,MAXPRINTMSG,fmt,argptr);
va_end (argptr);
Com_Error (err_level,"%s", msg);
}
//==========================================================================
/*
============
VID_Restart_f
Console command to re-start the video mode and refresh DLL. We do this
simply by setting the modified flag for the vid_ref variable, which will
cause the entire video mode and refresh DLL to be reset on the next frame.
============
*/
void VID_Restart_f (void)
{
vid_ref->modified = true;
}
/*
** VID_GetModeInfo
*/
typedef struct vidmode_s
{
const char *description;
int width, height;
int mode;
} vidmode_t;
vidmode_t vid_modes[] =
{
{ "Mode 0: 320x240", 320, 240, 0 },
{ "Mode 1: 400x300", 400, 300, 1 },
{ "Mode 2: 512x384", 512, 384, 2 },
{ "Mode 3: 640x480", 640, 480, 3 },
{ "Mode 4: 800x600", 800, 600, 4 },
{ "Mode 5: 960x720", 960, 720, 5 },
{ "Mode 6: 1024x768", 1024, 768, 6 },
{ "Mode 7: 1152x864", 1152, 864, 7 },
{ "Mode 8: 1280x1024", 1280, 1024, 8 },
{ "Mode 9: 1600x1200", 1600, 1200, 9 },
{ "Mode 10: 2048x1536", 2048, 1536, 10 }
};
qboolean VID_GetModeInfo( int *width, int *height, int mode )
{
if ( mode < 0 || mode >= VID_NUM_MODES )
return false;
*width = vid_modes[mode].width;
*height = vid_modes[mode].height;
return true;
}
/*
** VID_NewWindow
*/
void VID_NewWindow ( int width, int height)
{
viddef.width = width;
viddef.height = height;
}
void VID_FreeReflib (void)
{
if (reflib_library) {
if (KBD_Close_fp)
KBD_Close_fp();
if (RW_IN_Shutdown_fp)
RW_IN_Shutdown_fp();
dlclose(reflib_library);
}
KBD_Init_fp = NULL;
KBD_Update_fp = NULL;
KBD_Close_fp = NULL;
RW_IN_Init_fp = NULL;
RW_IN_Shutdown_fp = NULL;
RW_IN_Activate_fp = NULL;
RW_IN_Commands_fp = NULL;
RW_IN_Move_fp = NULL;
RW_IN_Frame_fp = NULL;
memset (&re, 0, sizeof(re));
reflib_library = NULL;
reflib_active = false;
}
/*
==============
VID_LoadRefresh
==============
*/
qboolean VID_LoadRefresh( char *name )
{
refimport_t ri;
GetRefAPI_t GetRefAPI;
char fn[MAX_OSPATH];
char *path;
struct stat st;
extern uid_t saved_euid;
if ( reflib_active )
{
if (KBD_Close_fp)
KBD_Close_fp();
if (RW_IN_Shutdown_fp)
RW_IN_Shutdown_fp();
KBD_Close_fp = NULL;
RW_IN_Shutdown_fp = NULL;
re.Shutdown();
VID_FreeReflib ();
}
Com_Printf( "------- Loading %s -------\n", name );
//regain root
seteuid(saved_euid);
path = Cvar_Get ("basedir", ".", CVAR_NOSET)->string;
snprintf (fn, MAX_OSPATH, "%s/%s", path, name );
if (stat(fn, &st) == -1) {
Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name, strerror(errno));
return false;
}
// permission checking
if (strstr(fn, "softx") == NULL &&
strstr(fn, "glx") == NULL &&
strstr(fn, "softsdl") == NULL &&
strstr(fn, "sdlgl") == NULL) { // softx doesn't require root
#if 0
if (st.st_uid != 0) {
Com_Printf( "LoadLibrary(\"%s\") failed: ref is not owned by root\n", name);
return false;
}
if ((st.st_mode & 0777) & ~0700) {
Com_Printf( "LoadLibrary(\"%s\") failed: invalid permissions, must be 700 for security considerations\n", name);
return false;
}
#endif
} else {
// softx requires we give up root now
setreuid(getuid(), getuid());
setegid(getgid());
}
if ( ( reflib_library = dlopen( fn, RTLD_LAZY ) ) == 0 )
{
Com_Printf( "LoadLibrary(\"%s\") failed: %s\n", name , dlerror());
return false;
}
Com_Printf( "LoadLibrary(\"%s\")\n", fn );
ri.Cmd_AddCommand = Cmd_AddCommand;
ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
ri.Cmd_Argc = Cmd_Argc;
ri.Cmd_Argv = Cmd_Argv;
ri.Cmd_ExecuteText = Cbuf_ExecuteText;
ri.Con_Printf = VID_Printf;
ri.Sys_Error = VID_Error;
ri.FS_LoadFile = FS_LoadFile;
ri.FS_FreeFile = FS_FreeFile;
ri.FS_Gamedir = FS_Gamedir;
ri.Cvar_Get = Cvar_Get;
ri.Cvar_Set = Cvar_Set;
ri.Cvar_SetValue = Cvar_SetValue;
ri.Vid_GetModeInfo = VID_GetModeInfo;
ri.Vid_MenuInit = VID_MenuInit;
ri.Vid_NewWindow = VID_NewWindow;
if ( ( GetRefAPI = (void *) dlsym( reflib_library, "GetRefAPI" ) ) == 0 )
Com_Error( ERR_FATAL, "dlsym failed on %s", name );
re = GetRefAPI( ri );
if (re.api_version != API_VERSION)
{
VID_FreeReflib ();
Com_Error (ERR_FATAL, "%s has incompatible api_version", name);
}
/* Init IN (Mouse) */
in_state.IN_CenterView_fp = IN_CenterView;
in_state.Key_Event_fp = Do_Key_Event;
in_state.viewangles = cl.viewangles;
in_state.in_strafe_state = &in_strafe.state;
if ((RW_IN_Init_fp = dlsym(reflib_library, "RW_IN_Init")) == NULL ||
(RW_IN_Shutdown_fp = dlsym(reflib_library, "RW_IN_Shutdown")) == NULL ||
(RW_IN_Activate_fp = dlsym(reflib_library, "RW_IN_Activate")) == NULL ||
(RW_IN_Commands_fp = dlsym(reflib_library, "RW_IN_Commands")) == NULL ||
(RW_IN_Move_fp = dlsym(reflib_library, "RW_IN_Move")) == NULL ||
(RW_IN_Frame_fp = dlsym(reflib_library, "RW_IN_Frame")) == NULL)
Sys_Error("No RW_IN functions in REF.\n");
Real_IN_Init();
if ( re.Init( 0, 0 ) == -1 )
{
re.Shutdown();
VID_FreeReflib ();
return false;
}
/* Init KBD */
#if 1
if ((KBD_Init_fp = dlsym(reflib_library, "KBD_Init")) == NULL ||
(KBD_Update_fp = dlsym(reflib_library, "KBD_Update")) == NULL ||
(KBD_Close_fp = dlsym(reflib_library, "KBD_Close")) == NULL)
Sys_Error("No KBD functions in REF.\n");
#else
{
void KBD_Init(void);
void KBD_Update(void);
void KBD_Close(void);
KBD_Init_fp = KBD_Init;
KBD_Update_fp = KBD_Update;
KBD_Close_fp = KBD_Close;
}
#endif
KBD_Init_fp(Do_Key_Event);
Key_ClearStates();
// give up root now
setreuid(getuid(), getuid());
setegid(getgid());
Com_Printf( "------------------------------------\n");
reflib_active = true;
return true;
}
/*
============
VID_CheckChanges
This function gets called once just before drawing each frame, and it's sole purpose in life
is to check to see if any of the video mode parameters have changed, and if they have to
update the rendering DLL and/or video mode to match.
============
*/
void VID_CheckChanges (void)
{
char name[100];
cvar_t *sw_mode;
if ( vid_ref->modified )
{
S_StopAllSounds();
}
while (vid_ref->modified)
{
/*
** refresh has changed
*/
vid_ref->modified = false;
vid_fullscreen->modified = true;
cl.refresh_prepped = false;
cls.disable_screen = true;
sprintf( name, "ref_%s.so", vid_ref->string );
if ( !VID_LoadRefresh( name ) )
{
if ( strcmp (vid_ref->string, "soft") == 0 ||
strcmp (vid_ref->string, "softx") == 0 ) {
Com_Printf("Refresh failed\n");
sw_mode = Cvar_Get( "sw_mode", "0", 0 );
if (sw_mode->value != 0) {
Com_Printf("Trying mode 0\n");
Cvar_SetValue("sw_mode", 0);
if ( !VID_LoadRefresh( name ) )
Com_Error (ERR_FATAL, "Couldn't fall back to software refresh!");
} else
Com_Error (ERR_FATAL, "Couldn't fall back to software refresh!");
}
/* prefer to fall back on X if active */
if (getenv("DISPLAY"))
Cvar_Set( "vid_ref", "softx" );
else
Cvar_Set( "vid_ref", "soft" );
/*
** drop the console if we fail to load a refresh
*/
if ( cls.key_dest != key_console )
{
Con_ToggleConsole_f();
}
}
cls.disable_screen = false;
}
}
/*
============
VID_Init
============
*/
void VID_Init (void)
{
/* Create the video variables so we know how to start the graphics drivers */
// if DISPLAY is defined, try X
if (getenv("DISPLAY"))
vid_ref = Cvar_Get ("vid_ref", "softx", CVAR_ARCHIVE);
else
vid_ref = Cvar_Get ("vid_ref", "soft", CVAR_ARCHIVE);
vid_xpos = Cvar_Get ("vid_xpos", "3", CVAR_ARCHIVE);
vid_ypos = Cvar_Get ("vid_ypos", "22", CVAR_ARCHIVE);
vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE);
vid_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE );
/* Add some console commands that we want to handle */
Cmd_AddCommand ("vid_restart", VID_Restart_f);
/* Disable the 3Dfx splash screen */
putenv("FX_GLIDE_NO_SPLASH=0");
/* Start the graphics mode and load refresh DLL */
VID_CheckChanges();
}
/*
============
VID_Shutdown
============
*/
void VID_Shutdown (void)
{
if ( reflib_active )
{
if (KBD_Close_fp)
KBD_Close_fp();
if (RW_IN_Shutdown_fp)
RW_IN_Shutdown_fp();
KBD_Close_fp = NULL;
RW_IN_Shutdown_fp = NULL;
re.Shutdown ();
VID_FreeReflib ();
}
VID_MenuShutdown();
}
/*
============
VID_CheckRefExists
Checks to see if the given ref_NAME.so exists.
Placed here to avoid complicating other code if the library .so files
ever have their names changed.
============
*/
qboolean VID_CheckRefExists (const char *ref)
{
char fn[MAX_OSPATH];
char *path;
struct stat st;
path = Cvar_Get ("basedir", ".", CVAR_NOSET)->string;
snprintf (fn, MAX_OSPATH, "%s/ref_%s.so", path, ref );
if (stat(fn, &st) == 0)
return true;
else
return false;
}
/*****************************************************************************/
/* INPUT */
/*****************************************************************************/
cvar_t *in_joystick;
// This is fake, it's acutally done by the Refresh load
void IN_Init (void)
{
in_joystick = Cvar_Get ("in_joystick", "0", CVAR_ARCHIVE);
}
void Real_IN_Init (void)
{
if (RW_IN_Init_fp)
RW_IN_Init_fp(&in_state);
}
void IN_Shutdown (void)
{
if (RW_IN_Shutdown_fp)
RW_IN_Shutdown_fp();
}
void IN_Commands (void)
{
if (RW_IN_Commands_fp)
RW_IN_Commands_fp();
}
void IN_Move (usercmd_t *cmd)
{
if (RW_IN_Move_fp)
RW_IN_Move_fp(cmd);
}
void IN_Frame (void)
{
if (RW_IN_Activate_fp)
{
if ( !cl.refresh_prepped || cls.key_dest == key_console || cls.key_dest == key_menu)
RW_IN_Activate_fp(false);
else
RW_IN_Activate_fp(true);
}
if (RW_IN_Frame_fp)
RW_IN_Frame_fp();
}
void IN_Activate (qboolean active)
{
}
void Do_Key_Event(int key, qboolean down)
{
Key_Event(key, down, Sys_Milliseconds());
}

View file

@ -2,7 +2,7 @@
SUBDIRS = . baseq2 ctf xatrix rogue
std_cflags = -Wall -Werror -pipe @OPT_CFLAGS@
std_cflags = -Wall -pipe @OPT_CFLAGS@
module_ldflags = -module -avoid-version -rpath $(pkglibdir)
bin_PROGRAMS = quake2
@ -44,34 +44,44 @@ else
QUAKE2_ASM=
endif
if BUILD_SDLQUAKE2
SOUND = cd_sdl.c snd_sdl.c snd_dma.c snd_mix.c snd_mem.c
else
SOUND = cd.c snd.c snd_dma.c snd_mix.c snd_mem.c
endif
quake2_SOURCES = main.c q_sh.c vid_menu.c vid_so.c q_glob.c net_udp.c \
\
cl_cin.c cl_ents.c cl_fx.c cl_input.c cl_inv.c \
cl_main.c cl_parse.c cl_pred.c cl_tent.c cl_scrn.c \
cl_view.c cl_newfx.c console.c keys.c menu.c qmenu.c \
\
snd_dma.c snd_mix.c snd_mem.c \
\
checksum.c cmd.c cmodel.c common.c crc.c cvar.c \
files.c mdfour.c net_chan.c \
\
sv_ccmds.c sv_ents.c sv_game.c sv_init.c sv_main.c \
sv_send.c sv_user.c sv_world.c \
\
cd.c snd.c \
\
q_shared.c pmove.c \
\
m_flash.c \
\
$(QUAKE2_ASM)
$(QUAKE2_ASM) $(SOUND)
if BUILD_SDLQUAKE2
quake2_CFLAGS = $(std_cflags) @INCLTDL@ @PTHREAD_CFLAGS@ @SDL_CFLAGS@
else
quake2_CFLAGS = $(std_cflags) @INCLTDL@ @PTHREAD_CFLAGS@
endif
# the macro puts -pthread into cflags, but we want to link
# with this flag too, so stick it into the ldflags if it's there...
# extra cflags at link time can't hurt
quake2_LDFLAGS = @PTHREAD_CFLAGS@
quake2_LDADD = @PTHREAD_LIBS@ @LIBLTDL@ @OSS_LIBS@ -lm
if BUILD_SDLQUAKE2
quake2_LDADD = @PTHREAD_LIBS@ @LIBLTDL@ @OSS_LIBS@ @SDL_LIBS@ @SYSTEM_LIBS@ -lm
else
quake2_LDADD = @PTHREAD_LIBS@ @LIBLTDL@ @OSS_LIBS@ @SYSTEM_LIBS@ -lm
endif
# ref_glx
if BUILD_GLX

View file

@ -27,8 +27,8 @@
*/
#include <stdio.h>
#include "SDL.h"
#include "../client/client.h"
#include <SDL.h>
#include "client.h"
static qboolean cdValid = false;
static qboolean initialized = false;

64
src/cd_solaris.c Normal file
View file

@ -0,0 +1,64 @@
/*
Copyright (C) 1997-2001 Id Software, 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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <sys/types.h>
#include "../client/client.h"
void CDAudio_Play(int track, qboolean looping)
{
// Com_Printf("XXX - CDAudio_Play %i (%i)\n", track, looping);
}
void CDAudio_RandomPlay(void)
{
// Com_Printf("XXX - CDAudio_RandomPlay\n");
}
void CDAudio_Stop(void)
{
// Com_Printf("XXX - CDAudio_Stop\n");
}
void CDAudio_Resume(void)
{
// Com_Printf("XXX - CDAudio_Resume\n");
}
void CDAudio_Update(void)
{
// Com_Printf("XXX - CDAudio_Update\n");
}
int CDAudio_Init(void)
{
// Com_Printf("XXX - CDAudio_Init\n");
return 0;
}
void CDAudio_Shutdown(void)
{
// Com_Printf("XXX - CDAudio_Shutdown\n");
}

View file

@ -1798,7 +1798,7 @@ void CL_Init (void)
// all archived variables will now be loaded
Con_Init ();
#if defined __linux__ || defined __FreeBSD__ || defined __sgi
#if defined (__linux__) || defined (__FreeBSD__) || defined (__sgi) || defined (__sun__)
S_Init ();
VID_Init ();
#else

View file

@ -64,8 +64,12 @@
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#ifdef HAVE_XF86_DGA
#include <X11/extensions/xf86dga.h>
#endif // HAVE_XF86_DGA
#ifdef HAVE_XF86_VIDMODE
#include <X11/extensions/xf86vmode.h>
#endif // HAVE_XF86_VIDMODE
#ifdef HAVE_JOYSTICK
#include <sys/types.h>
@ -81,6 +85,8 @@ static int scrnum;
static Window win;
static GLXContext ctx = NULL;
static Atom wmDeleteWindow;
static int window_width;
static int window_height;
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | \
@ -94,6 +100,7 @@ static void (*qglXDestroyContext)( Display *dpy, GLXContext ctx );
static Bool (*qglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx);
static void (*qglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, GLuint mask );
static void (*qglXSwapBuffers)( Display *dpy, GLXDrawable drawable );
static int (*qglXGetConfig)( Display *dpy, XVisualInfo *vis, int attrib, int *value);
/* JOYSTICK */
#ifdef HAVE_JOYSTICK
@ -147,25 +154,32 @@ void init_joystick() {
// this is inside the renderer shared lib, so these are called from vid_so
static qboolean mouse_avail;
static int mouse_buttonstate, mouse_oldbuttonstate;
static int mouse_buttonstate;
static int mouse_oldbuttonstate;
static int mx, my;
static int old_mouse_x, old_mouse_y;
static int old_windowed_mouse;
static int win_x, win_y;
static cvar_t *_windowed_mouse;
static cvar_t *m_filter;
static cvar_t *in_mouse;
static cvar_t *in_dgamouse;
static cvar_t *r_fakeFullscreen;
#ifdef HAVE_XF86_VIDMODE
static XF86VidModeModeInfo **vidmodes;
#endif // HAVE_XF86_VIDMODE
//static int default_dotclock_vidmode;
static int num_vidmodes;
static qboolean vidmode_active = false;
/* hardware gamma */
#ifdef HAVE_XF86_VIDMODE
static XF86VidModeGamma oldgamma;
#endif // HAVE_XF86_VIDMODE
static qboolean mlooking;
@ -225,6 +239,7 @@ static void install_grabs(void)
None,
CurrentTime);
#ifdef HAVE_XF86_DGA
if (in_dgamouse->value) {
int MajorVersion, MinorVersion;
@ -237,7 +252,9 @@ static void install_grabs(void)
XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
}
} else {
} else
#endif // HAVE_XF86_DGA
{
XWarpPointer(dpy, None, win,
0, 0, 0, 0,
vid.width / 2, vid.height / 2);
@ -258,10 +275,12 @@ static void uninstall_grabs(void)
if (!dpy || !win)
return;
#ifdef HAVE_XF86_DGA
if (dgamouse) {
dgamouse = false;
XF86DGADirectVideo(dpy, DefaultScreen(dpy), 0);
}
#endif // HAVE_XF86_DGA
XUngrabPointer(dpy, CurrentTime);
XUngrabKeyboard(dpy, CurrentTime);
@ -298,6 +317,7 @@ void RW_IN_Init(in_state_t *in_state_p)
#endif
// mouse variables
_windowed_mouse = ri.Cvar_Get( "_windowed_mouse", "0", CVAR_ARCHIVE );
m_filter = ri.Cvar_Get ("m_filter", "0", 0);
in_mouse = ri.Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
in_dgamouse = ri.Cvar_Get ("in_dgamouse", "1", CVAR_ARCHIVE);
@ -555,7 +575,14 @@ static int XLateKey(XKeyEvent *ev)
case XK_F10: key = K_F10; break;
case XK_F11: key = K_F11; break;
case XK_F11:
if( ev->type == KeyPress ) {
if( _windowed_mouse->value ) {
Cvar_SetValue( "_windowed_mouse", 0 );
} else {
Cvar_SetValue( "_windowed_mouse", 1 );
}
} break;
case XK_F12: key = K_F12; break;
@ -653,6 +680,22 @@ static void HandleEvents(void)
mx += (event.xmotion.x + win_x) * 2;
my += (event.xmotion.y + win_y) * 2;
}
else if( _windowed_mouse->value ) {
int xoffset = ((int)event.xmotion.x - (int)(window_width / 2));
int yoffset = ((int)event.xmotion.y - (int)(window_height / 2));
if( xoffset != 0 || yoffset != 0 ) {
mx += xoffset;
my += yoffset;
/* move the mouse to the window center again */
XSelectInput( dpy, win, X_MASK & ~PointerMotionMask );
XWarpPointer( dpy, None, win, 0, 0, 0, 0,
(window_width / 2), (window_height / 2) );
XSelectInput( dpy, win, X_MASK );
}
}
else
{
mx += ((int)event.xmotion.x - mwx) * 2;
@ -715,6 +758,32 @@ static void HandleEvents(void)
if (event.xclient.data.l[0] == wmDeleteWindow)
ri.Cmd_ExecuteText(EXEC_NOW, "quit");
break;
case MapNotify:
if( _windowed_mouse->value ) {
XGrabPointer( dpy, win, True, 0, GrabModeAsync,
GrabModeAsync, win, None, CurrentTime);
}
break;
case UnmapNotify:
if( _windowed_mouse->value ) {
XUngrabPointer( dpy, CurrentTime );
}
break;
}
}
if( old_windowed_mouse != _windowed_mouse->value ) {
old_windowed_mouse = _windowed_mouse->value;
if( !_windowed_mouse->value ) {
/* ungrab the pointer */
XUngrabPointer( dpy, CurrentTime );
} else {
/* grab the pointer */
XGrabPointer( dpy, win, True, 0, GrabModeAsync,
GrabModeAsync, win, None, CurrentTime );
}
}
@ -862,6 +931,9 @@ int GLimp_SetMode( unsigned int *pwidth, unsigned int *pheight, int mode, qboole
ri.Con_Printf( PRINT_ALL, " %d %d\n", width, height );
window_width = width;
window_height = height;
// destroy the existing window
GLimp_Shutdown ();
@ -883,6 +955,7 @@ int GLimp_SetMode( unsigned int *pwidth, unsigned int *pheight, int mode, qboole
// Get video mode list
MajorVersion = MinorVersion = 0;
#ifdef HAVE_XF86_VIDMODE
if (!XF86VidModeQueryVersion(dpy, &MajorVersion, &MinorVersion)) {
vidmode_ext = false;
} else {
@ -890,6 +963,7 @@ int GLimp_SetMode( unsigned int *pwidth, unsigned int *pheight, int mode, qboole
MajorVersion, MinorVersion);
vidmode_ext = true;
}
#endif // HAVE_XF86_VIDMODE
visinfo = qglXChooseVisual(dpy, scrnum, attrib);
if (!visinfo) {
@ -903,16 +977,16 @@ int GLimp_SetMode( unsigned int *pwidth, unsigned int *pheight, int mode, qboole
gl_state.hwgamma = false;
#if 0
/* do some pantsness */
if ( qglXGetConfig )
{
int red_bits, blue_bits, green_bits, depth_bits, alpha_bits;
glXGetConfig(dpy, visinfo, GLX_RED_SIZE, &red_bits);
glXGetConfig(dpy, visinfo, GLX_BLUE_SIZE, &blue_bits);
glXGetConfig(dpy, visinfo, GLX_GREEN_SIZE, &green_bits);
glXGetConfig(dpy, visinfo, GLX_DEPTH_SIZE, &depth_bits);
glXGetConfig(dpy, visinfo, GLX_ALPHA_SIZE, &alpha_bits);
qglXGetConfig(dpy, visinfo, GLX_RED_SIZE, &red_bits);
qglXGetConfig(dpy, visinfo, GLX_BLUE_SIZE, &blue_bits);
qglXGetConfig(dpy, visinfo, GLX_GREEN_SIZE, &green_bits);
qglXGetConfig(dpy, visinfo, GLX_DEPTH_SIZE, &depth_bits);
qglXGetConfig(dpy, visinfo, GLX_ALPHA_SIZE, &alpha_bits);
ri.Con_Printf(PRINT_ALL, "I: got %d bits of red\n", red_bits);
ri.Con_Printf(PRINT_ALL, "I: got %d bits of blue\n", blue_bits);
@ -920,13 +994,13 @@ int GLimp_SetMode( unsigned int *pwidth, unsigned int *pheight, int mode, qboole
ri.Con_Printf(PRINT_ALL, "I: got %d bits of depth\n", depth_bits);
ri.Con_Printf(PRINT_ALL, "I: got %d bits of alpha\n", alpha_bits);
}
#endif
/* stencilbuffer shadows */
if ( qglXGetConfig )
{
int stencil_bits;
if (!glXGetConfig(dpy, visinfo, GLX_STENCIL_SIZE, &stencil_bits)) {
if (!qglXGetConfig(dpy, visinfo, GLX_STENCIL_SIZE, &stencil_bits)) {
ri.Con_Printf(PRINT_ALL, "I: got %d bits of stencil\n", stencil_bits);
if (stencil_bits >= 1) {
have_stencil = true;
@ -934,6 +1008,7 @@ int GLimp_SetMode( unsigned int *pwidth, unsigned int *pheight, int mode, qboole
}
}
#ifdef HAVE_XF86_VIDMODE
if (vidmode_ext) {
int best_fit, best_dist, dist, x, y;
@ -981,6 +1056,7 @@ int GLimp_SetMode( unsigned int *pwidth, unsigned int *pheight, int mode, qboole
fullscreen = 0;
}
}
#endif // HAVE_XF86_VIDMODE
/* window attributes */
attr.background_pixel = 0;
@ -1046,6 +1122,7 @@ int GLimp_SetMode( unsigned int *pwidth, unsigned int *pheight, int mode, qboole
XMapWindow(dpy, win);
#ifdef HAVE_XF86_VIDMODE
if (vidmode_active) {
XMoveWindow(dpy, win, 0, 0);
XRaiseWindow(dpy, win);
@ -1054,6 +1131,7 @@ int GLimp_SetMode( unsigned int *pwidth, unsigned int *pheight, int mode, qboole
// Move the viewport to top left
XF86VidModeSetViewPort(dpy, scrnum, 0, 0);
}
#endif // HAVE_XF86_VIDMODE
XFlush(dpy);
@ -1069,6 +1147,9 @@ int GLimp_SetMode( unsigned int *pwidth, unsigned int *pheight, int mode, qboole
qglXMakeCurrent(dpy, win, ctx);
// inviso cursor
XDefineCursor( dpy, win, CreateNullCursor( dpy, win ) );
return rserr_ok;
}
@ -1092,6 +1173,7 @@ void GLimp_Shutdown( void )
XDestroyWindow(dpy, win);
if (ctx)
qglXDestroyContext(dpy, ctx);
#ifdef HAVE_XF86_VIDMODE
if (gl_state.hwgamma) {
XF86VidModeSetGamma(dpy, scrnum, &oldgamma);
/* The gamma has changed, but SetMode will change it
@ -1101,6 +1183,7 @@ void GLimp_Shutdown( void )
}
if (vidmode_active)
XF86VidModeSwitchToMode(dpy, scrnum, vidmodes[0]);
#endif // HAVE_XF86_VIDMODE
XUngrabKeyboard(dpy, CurrentTime);
XCloseDisplay(dpy);
}
@ -1138,6 +1221,7 @@ int GLimp_Init( void *hinstance, void *wndproc )
qglXMakeCurrent = (Bool(*)(Display*, GLXDrawable, GLXContext)) GPA("glXMakeCurrent");
qglXCopyContext = (void(*)(Display*, GLXContext, GLXContext, GLuint)) GPA("glXCopyContext");
qglXSwapBuffers = (void(*)(Display*, GLXDrawable)) GPA("glXSwapBuffers");
qglXGetConfig = (int(*)(Display *dpy, XVisualInfo *vis, int attrib, int *value)) GPA("glXGetConfig");
return true;
}
@ -1174,6 +1258,7 @@ void GLimp_EndFrame (void)
* all.
*/
void UpdateHardwareGamma() {
#ifdef HAVE_XF86_VIDMODE
XF86VidModeGamma gamma;
float g;
@ -1184,6 +1269,7 @@ void UpdateHardwareGamma() {
gamma.blue = oldgamma.blue * g;
ri.Con_Printf(PRINT_ALL, "Setting gamma to %f\n", g);
XF86VidModeSetGamma(dpy, scrnum, &gamma);
#endif // HAVE_XF86_VIDMODE
}
/*

View file

@ -27,20 +27,20 @@
#include <stdio.h>
#include <GL/gl.h>
#ifdef HAVE_OPENGL_GLEXT
#include <GL/glext.h>
#endif // HAVE_OPENGL_GLEXT
#include <math.h>
#ifndef _WIN32
char *strlwr (char *s);
#endif
/*
#ifndef __linux__
#ifdef __sun__
# ifndef GL_COLOR_INDEX8_EXT
# define GL_COLOR_INDEX8_EXT GL_COLOR_INDEX
# endif
#endif
*/
#include "ref.h"

View file

@ -1320,7 +1320,7 @@ qboolean R_Init( void *hinstance, void *hWnd )
ri.Con_Printf( PRINT_ALL, "...GL_EXT_point_parameters not found\n" );
}
#if defined __linux__ || defined __FreeBSD__
#if defined (__linux__) || defined (__FreeBSD__)
if ( strstr( gl_config.extensions_string, "3DFX_set_global_palette" ))
{
if ( gl_ext_palettedtexture->value )

View file

@ -30,8 +30,7 @@
#ifndef __GLW_H__
#define __GLW_H__
/* This is getting silly -- q */
#if defined __linux__ || defined __bsd__ || defined __sgi || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
#if defined (__linux__) || defined (__bsd__) || defined (__sgi) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__sun__)
typedef struct
{

View file

@ -44,15 +44,14 @@
#include <sys/mman.h>
#include <errno.h>
/* merged from sys_*.c -- jaq
/* merged from sys_*.c -- jaq */
#if defined(__linux__) || defined(__sgi)
#include <mntent.h>
#elif defined(__FreeBSD__) || defined(__bsd__) || defined (__NetBSD__)
#include <fstab.h>
#elif defined(sun)
#elif defined(__sun__)
#include <sys/file.h>
#endif
*/
/* libtool dynamic loader */
#include <ltdl.h>

554
src/ndga.c Normal file
View file

@ -0,0 +1,554 @@
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stropts.h>
#include <poll.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include "nvsession.h"
#define NDGA_IMPLEMENTATION 1
#include "NRegion.h"
#include "ndga.h"
/*
* newt equivalent of DGA
*
* Written by: Jim Hanko
*/
#define NS_PER_SEC (1000LL * 1000LL * 1000LL)
/* #define DEBUG */
#ifdef DEBUG
#define DBG(x) x
#else
#define DBG(x)
#endif
int
ndga_get_eventmask(void)
{
return (VisibilityChangeMask | ExposureMask | StructureNotifyMask);
}
void
ndga_destroy(struct ndga_state * sp)
{
if (sp) {
if (sp->session && sp->sent_clip) {
sp->sent_clip = 0;
nvSessionClipRegion(sp->session, NULL);
}
NDestroyRegion(sp->region);
NDestroyRegion(sp->clip);
NDestroyRegion(sp->lastclip);
NDestroyRegion(sp->screenArea);
free(sp);
}
}
struct ndga_state *
ndga_new(Display *display, Window window, nvSession session,
int xalign, int yalign)
{
struct ndga_state *sp;
Window *children;
int nchildren;
XWindowAttributes attr;
int retval;
sp = (struct ndga_state *) malloc(sizeof(*sp));
if (sp == NULL)
return (NULL);
memset(sp, 0, sizeof(*sp));
sp->display = display;
sp->window = window;
sp->xalign = xalign;
sp->yalign = yalign;
sp->is_visible = 1;
sp->is_unobscured = 1;
sp->is_open = 1;
sp->was_open = 1;
sp->was_unobscured = 0;
sp->is_changed = 1;
sp->new_clip = 1;
sp->busy = 0;
sp->clipEvent = 1;
sp->session = session;
XQueryTree(sp->display, sp->window, &sp->root, &sp->parent,
&children, &nchildren);
retval = XGetWindowAttributes(sp->display, sp->root, &attr);
if (retval == 0) {
fprintf(stderr, "Can't get window attributes\n");
free(sp);
return (NULL);
}
sp->region = NCreateRegion();
sp->clip = NCreateRegion();
sp->lastclip = NCreateRegion();
sp->screenArea = NCreateRegion();
sp->screenRect.x = attr.x;
sp->screenRect.y = attr.y;
sp->screenRect.width = attr.width;
sp->screenRect.height = attr.height;
DBG(fprintf(stderr, "screen %d,%d %dx%d\n",
sp->screenRect.x, sp->screenRect.y,
sp->screenRect.width, sp->screenRect.height));
NUnionRectWithRegion(&sp->screenRect, sp->screenArea, sp->screenArea);
return (sp);
}
static void
get_win_info(struct ndga_state * sp)
{
int depth;
int xr, yr, wr, hr, border;
Window w, root, parent, *children;
int nchildren;
int x, y;
XWindowAttributes attr;
int retval;
DBG(fprintf(stderr, "get_win_info()\n"));
retval = XGetWindowAttributes(sp->display, sp->window, &attr);
if (retval == 0) {
fprintf(stderr, "Can't get window attributes\n");
exit(1);
}
sp->is_open = (attr.map_state == IsViewable);
DBG(fprintf(stderr, "ismapped %d\n", sp->is_open));
x = attr.x + attr.border_width;
y = attr.y + attr.border_width;
sp->w = attr.width;
sp->h = attr.height;
if (sp->xalign > 1)
sp->w -= (sp->w % sp->xalign);
if (sp->yalign > 1)
sp->h -= (sp->h % sp->yalign);
w = sp->parent;
while (w && w != sp->root) {
XGetGeometry(sp->display, w, &root, &xr, &yr, &wr, &hr,
&border, &depth);
x += xr + border;
y += yr + border;
XQueryTree(sp->display, w, &root, &w, &children, &nchildren);
}
sp->x = x;
sp->y = y;
sp->visRect.x = sp->x;
sp->visRect.y = sp->y;
sp->visRect.width = sp->w;
sp->visRect.height = sp->h;
DBG(fprintf(stderr, "X %d Y %d W %d H %d\n", sp->x, sp->y,
sp->w, sp->h));
}
static void
rdump(void *a, int x, int y, int w, int h)
{
struct ndga_state *s = (struct ndga_state *) a;
fprintf(stderr, "%d,%d %dx%d\n", x, y, w, h);
}
static void
ndga_handle_change(struct ndga_state *sp)
{
NRectangle rectangle;
get_win_info(sp);
if (sp->is_open && sp->is_unobscured && !sp->was_unobscured) {
rectangle.x = 0;
rectangle.y = 0;
rectangle.width = sp->w;
rectangle.height = sp->h;
NDestroyRegion(sp->region);
sp->region = NCreateRegion();
NUnionRectWithRegion(&rectangle, sp->region,
sp->region);
DBG(fprintf(stderr, "Full clip\n"));
} else if (!sp->is_open || !sp->is_visible) {
NDestroyRegion(sp->region);
sp->region = NCreateRegion();
}
NUnionRegion(sp->region, sp->region, sp->clip);
NOffsetRegion(sp->clip, sp->x, sp->y);
NIntersectRegion(sp->clip, sp->screenArea, sp->clip);
if (sp->xalign > 1 || sp->yalign > 1) {
NAlignRegion(sp->clip, sp->clip, sp->x, sp->xalign, sp->y,
sp->yalign);
}
if (sp->x < sp->screenRect.x ||
sp->y < sp->screenRect.y ||
sp->x + sp->w > sp->screenRect.x + sp->screenRect.width ||
sp->y + sp->h > sp->screenRect.y + sp->screenRect.height) {
(void) NClipBox(sp->clip, &sp->visRect);
} else {
sp->visRect.x = sp->x;
sp->visRect.y = sp->y;
sp->visRect.width = sp->w;
sp->visRect.height = sp->h;
}
sp->new_clip = 1;
sp->clipEvent++;
sp->was_unobscured = sp->is_unobscured;
DBG(fprintf(stderr, "\n%s: %d - Clip \n", __FILE__, __LINE__));
DBG(NWalkRegion(sp->clip, rdump, sp));
}
/*
* Keep the session manager informed
*/
static void
update_clip(struct ndga_state *sp)
{
if (!NEqualRegion(sp->clip, sp->lastclip)) {
NUnionRegion(sp->clip, sp->clip, sp->lastclip);
if (sp->session && sp->sent_clip) {
nvSessionClipRegion(sp->session, sp->clip);
}
}
sp->new_clip = 0;
}
#ifdef X_VISIBILITY_BUG
int fix_visibility = -1;
/*
* The current X server will not report visibility events if the
* window was partially obscured and it become more obscured. So,
* we periodically poll to get an accurate clip list.
*
* Expected to be fixed by Solaris 2.8
*/
static void
ndga_workaround(struct ndga_state * sp)
{
char *s;
if (fix_visibility == -1) {
if ((s = getenv("CORONA_VISIBILITY_FIX")) != NULL &&
(*s == 'T' || *s == 't' || *s == '1')) {
fix_visibility = 1;
} else {
fix_visibility = 0;
}
}
if (fix_visibility != 1)
return;
if (sp->is_visible && !sp->is_unobscured && sp->sent_clip) {
hrtime_t now;
static hrtime_t last;
now = gethrtime();
if (now - last > NS_PER_SEC) {
Window w;
DBG(fprintf(stderr, "Poll for clip\n"));
w = XCreateSimpleWindow(sp->display, sp->window,
0, 0, 30000, 30000, 0, 0, 0);
XMapWindow(sp->display, w);
XFlush(sp->display);
XDestroyWindow(sp->display, w);
XFlush(sp->display);
/*
* No need for sync here
*/
sp->clearOnExpose = 1;
last = gethrtime();
}
}
}
#endif /* X_VISIBILITY_BUG */
/*
* attempt to start direct io; returns 1 if visible and sets the
* window's location in xp, yp, wp, hp. is_obscured is set if all
* parts of the window are visible. clipEvent contains an event
* counter for changes in the clip list. When a caller observes
* a change in the counter, it should obtain the new clip.
*
* Returns 0 if the window is not visible.
*/
int
ndga_start(struct ndga_state * sp,
int *xp, /* x */
int *yp, /* y */
int *wp, /* width */
int *hp, /* height */
int *is_unobscured, /* 1 if clipped, 0 if not */
int *clipEvent /* clip event count */)
{
char *loc;
if (!sp)
return (0);
if (sp->is_changed) {
ndga_handle_change(sp);
sp->is_changed = 0;
}
if (sp->new_clip) {
update_clip(sp);
}
/*
* If fully visible or if partially visible and the client is
* expecting to handle clipping, allow it to go through
*/
if (sp->is_open && sp->is_visible &&
(sp->is_unobscured ||
(clipEvent != NULL && is_unobscured != NULL))) {
if (sp->session && sp->sent_clip == 0) {
nvSessionClipRegion(sp->session, sp->clip);
sp->sent_clip = 1;
}
*xp = sp->visRect.x;
*wp = sp->visRect.width;
*yp = sp->visRect.y;
*hp = sp->visRect.height;
sp->busy = 1;
if (clipEvent)
*clipEvent = sp->clipEvent;
if (is_unobscured)
*is_unobscured = sp->is_unobscured;
DBG(fprintf(stderr, "ndga_start() = 1\n"));
return (1);
}
if (sp->is_open && sp->is_visible) {
/*
* Assume it will just go through X; slow it down
*/
poll(0, 0, sp->w * sp->h / 450);
}
/*
* not OK
*/
if (sp->session && sp->sent_clip) {
sp->sent_clip = 0;
nvSessionClipRegion(sp->session, NULL);
}
if (clipEvent)
*clipEvent = sp->clipEvent;
if (is_unobscured)
*is_unobscured = 0;
return (0);
}
/*
* update the argument to hold the current clip-list and and return
* it. If the clip argument is NULL, a new region is allocated. It
* is the responsibility of the caller to free the clip.
*/
NRegion
ndga_clip(struct ndga_state * sp, NRegion clip)
{
if (!clip)
clip = NCreateRegion();
/*
* Use union as copy
*/
(void) NUnionRegion(sp->clip, sp->clip, clip);
return(clip);
}
void
ndga_done(struct ndga_state * sp)
{
if (!sp)
return;
if (sp->is_changed) {
ndga_handle_change(sp);
sp->is_changed = 0;
}
if (sp->new_clip) {
update_clip(sp);
}
sp->busy = 0;
#ifdef X_VISIBILITY_BUG
ndga_workaround(sp);
#endif /* X_VISIBILITY_BUG */
}
void
ndga_process_event(struct ndga_state * sp, XEvent * event)
{
NRectangle rectangle;
if (!sp)
return;
if (event->xany.type == Expose) {
#ifdef X_VISIBILITY_BUG
if (sp->clearOnExpose) {
NDestroyRegion(sp->region);
sp->region = NCreateRegion();
sp->clearOnExpose = 0;
}
#endif /* X_VISIBILITY_BUG */
rectangle.x = event->xexpose.x;
rectangle.y = event->xexpose.y;
rectangle.width = event->xexpose.width;
rectangle.height = event->xexpose.height;
NUnionRectWithRegion(&rectangle, sp->region, sp->region);
DBG(fprintf(stderr, "Expose: %d,%d %dx%d\n",
event->xexpose.x,
event->xexpose.y,
event->xexpose.width,
event->xexpose.height));
if (event->xexpose.count == 0) {
/*
* Handle the last in a sequence of expose events.
*/
sp->is_changed = 1;
}
} else if (event->xany.type == VisibilityNotify) {
sp->is_visible =
(event->xvisibility.state != VisibilityFullyObscured);
sp->is_unobscured =
(event->xvisibility.state == VisibilityUnobscured);
sp->is_changed = 1;
DBG(fprintf(stderr, "Visiblility: %s\n",
(event->xvisibility.state == VisibilityUnobscured) ?
"Unobscured" :
((event->xvisibility.state == VisibilityFullyObscured) ?
"FullyObscured" : "PartuallyObscured")));
if (event->xvisibility.state == VisibilityPartiallyObscured) {
Window w;
DBG(fprintf(stderr, "Request full clip\n"));
NDestroyRegion(sp->region);
sp->region = NCreateRegion();
w = XCreateSimpleWindow(sp->display, sp->window,
0, 0, 30000, 30000, 0, 0, 0);
XMapWindow(sp->display, w);
XFlush(sp->display);
XDestroyWindow(sp->display, w);
XFlush(sp->display);
/*
* sync so we will get expose events all together
*/
XSync(sp->display, False);
}
} else if (event->xany.type == UnmapNotify) {
DBG(fprintf(stderr, "Unmap\n"));
sp->is_changed = 1;
NDestroyRegion(sp->region);
sp->region = NCreateRegion();
} else if (event->xany.type == ConfigureNotify) {
DBG(fprintf(stderr, "Configure\n"));
sp->is_changed = 1;
} else if (event->xany.type == CirculateNotify) {
DBG(fprintf(stderr, "Circulate\n"));
} else if (event->xany.type == MapNotify) {
DBG(fprintf(stderr, "Map\n"));
} else {
DBG(fprintf(stderr, "Event %d\n", event->xany.type));
}
if (XPending(sp->display) != 0)
return;
DBG(fprintf(stderr, "Last Event\n\n"));
if ((sp->on_open || sp->on_close) && sp->is_changed) {
if (sp->is_open != sp->was_open) {
if (!sp->is_open) {
DBG(fprintf(stderr, "I-CLOSED\n"));
if (sp->on_close)
(*sp->on_close) ();
} else {
DBG(fprintf(stderr, "I-OPEN\n"));
if (sp->on_open)
(*sp->on_open) ();
}
sp->was_open = sp->is_open;
}
}
if (sp->is_changed) {
ndga_handle_change(sp);
if (!sp->busy)
sp->is_changed = 0;
}
if (!sp->busy && sp->new_clip) {
update_clip(sp);
}
}
int
ndga_isvisible(ndga_t sp)
{
if (!sp) {
/*
* Safest to say yes?
*/
return (1);
}
if (!sp->busy && sp->is_changed) {
ndga_handle_change(sp);
sp->is_changed = 0;
}
if (!sp->busy && sp->new_clip) {
update_clip(sp);
}
#ifdef X_VISIBILITY_BUG
ndga_workaround(sp);
#endif /* X_VISIBILITY_BUG */
DBG(fprintf(stderr, "is_visible %d\n", sp->is_open && sp->is_visible));
return (sp->is_open && sp->is_visible);
}

93
src/ndga.h Normal file
View file

@ -0,0 +1,93 @@
#ifndef NDGA_H
#define NDGA_H
#include "nvsession.h"
#ifndef NDGA_IMPLEMENTATION
/*
* For public consumption, this is an opaque pointer
*/
typedef void *ndga_t;
#else
/*
* This is implementaion private
*
* Newt DGA state record
*/
struct ndga_state {
/*
* all private
*/
int is_visible;
int is_unobscured;
int is_open;
int is_changed;
int new_clip;
int sent_clip;
int busy;
int was_open;
int was_unobscured;
int x, y;
int w, h;
int xalign;
int yalign;
nvSession session;
void (* on_open)();
void (* on_close)();
Display *display;
Window window;
Window parent;
Window root;
NRegion region;
NRegion clip;
NRegion lastclip;
NRegion screenArea;
NRectangle screenRect;
NRectangle visRect;
int clipEvent;
int clearOnExpose;
};
typedef struct ndga_state *ndga_t;
#endif /* NDGA_IMPLEMENTATION */
ndga_t ndga_new(Display *display, Window window, nvSession session,
int xalign, int yalign);
void ndga_destroy(ndga_t sp);
int ndga_start(ndga_t sp,
int *xp, /* x */
int *yp, /* y */
int *wp, /* width */
int *hp, /* height */
int *is_unobscured, /* 1 if unobscured 0 if clipped */
int *clipEvent /* clip event number */
);
/*
* update the argument to hold the current clip-list and and return
* it. If the clip argument is NULL, a new region is allocated. It
* is the responsibility of the caller to free the clip.
*/
NRegion ndga_clip(ndga_t sp, NRegion clip);
void ndga_done(ndga_t sp);
int ndga_isvisible(ndga_t sp);
int ndga_get_eventmask(void);
void ndga_process_event(ndga_t sp, XEvent *event);
#endif

View file

@ -35,7 +35,7 @@
#include <errno.h>
/* merged in from solaris/net_udp.c -- jaq */
#ifdef sun
#ifdef __sun__
#include <sys/filio.h>
#endif

320
src/newt.c Normal file
View file

@ -0,0 +1,320 @@
/*
* Brian Schmidt
*
* File: newt.c
* Date: 03/18/99
* Revision: 1.9
*
* This file contains the routines necessary to send Quake video to
* a NewT.
*/
#pragma ident "@(#)File: newt.c, Rev: 1.9, Date: 99/03/18 13:12:08, Author: Brian Schmidt"
/*============================== INCLUDE FILES ==============================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <newtvideo.h>
#include <nvsession.h>
#include <macros.h>
#include <signal.h>
#include <thread.h>
#include <sched.h>
#include "newt.h"
/*================================ CONSTANTS ================================*/
/*================================= MACROS ==================================*/
/*============================ EXPORTED GLOBALS =============================*/
int yuv_dpcm = FALSE; /* use 4-bit DPCM on luma vals */
int yuv_subx = DEF_YUV_XSUBSAMP; /* horizontal chroma subsample */
int yuv_suby = DEF_YUV_YSUBSAMP; /* vertical chroma subsample */
int req_max_bw = TRUE; /* request max BW to NewT */
int newt_initialize_next = 1;
/*============================= STATIC GLOBALS ==============================*/
static ndga_t *ndga = NULL; /* NewT DGA interface */
static char *target = NULL; /* NewT target */
static nvSession nvsession = NULL; /* NewT session */
static nv_t newtnv = NULL; /* NewT video conn */
static u_char *line = NULL; /* line of pixels */
static struct { /* video state info */
int x, y; /* location */
int dw, dh; /* destination width/height */
int sw, sh; /* source width/height */
int clipEvent; /* clip event type */
NRegion clip; /* clip info */
} vinfo;
static u_char ymap[256]; /* color maps */
static u_char umap[256];
static u_char vmap[256];
/*============================= PREDECLARATIONS =============================*/
static void setup_video(Display *disp, Window win);
static void nvSessionCheck(nvSession sess);
extern char display_name[];
/*============================ EXPORTED ROUTINES ============================*/
void newt_set_palette( unsigned char *palette )
{
int i, j;
int y, u, v;
int r, g, b;
for (i = j = 0 ; i < 256 ; i++) {
/* get the RGB pixel values */
b = palette[i*4 + 2];
g = palette[i*4 + 1];
r = palette[i*4 + 0];
/* convert to YUV */
y = (77*r + 150*g + 29*b)/256;
u = (-44*r - 87*g + 131*b)/256 + 128;
v = (131*r - 110*g - 21*b)/256 + 128;
/* clamp the values */
ymap[i] = CLAMP(y);
umap[i] = CLAMP(u);
vmap[i] = CLAMP(v);
}
}
/*========================= newt_process_event =========================
* Process events to watch for window changes.
*/
void newt_process_event(XEvent *xev)
{
if (ndga != NULL) ndga_process_event(ndga, xev);
}
/*========================= send_newt_video =========================
* Given an image consisting of 8-bit color index pixels, convert to
* YUV format and send to a NewT for scaling and display. The width
* and height are for the source image. Return 1 on success,
* 0 if we could not blast straight to the NewT screen.
*/
int send_newt_video(Display *disp, Window win,
void *data, int sw, int sh)
{
int x, y, w, h; /* window coordinates */
register int i, j, k, l, m; /* loop indexes */
u_char *frame = (u_char *)data; /* 8-bit pix for frame */
tile_t tile; /* video tile */
u_char *ydata, *udata, *vdata; /* yuv data */
int tx, ty, tw, th; /* tile location/size */
int ret = 1; /* return code */
int is_unobscured; /* true if window is unobscured */
int clipEvent; /* clip event type */
/* Set things up on the first time through */
if( newt_initialize_next ) {
newt_initialize_next = FALSE;
if( ndga != NULL ) {
ndga_destroy( ndga );
ndga = NULL;
}
memset( &vinfo, 0, sizeof( vinfo ) );
setup_video( disp, win );
}
/* make sure we have a conn to the NewT and can
* draw straight to the screen.
*/
nvSessionCheck(nvsession);
if ((target == NULL) ||
(!ndga_start(ndga, &x, &y, &w, &h, &is_unobscured, &clipEvent))) {
return 0;
}
if ((newtnv == NULL) ||
(vinfo.x != x) || (vinfo.y != y) ||
(vinfo.dw != w) || (vinfo.dh != h) ||
(vinfo.sw != sw) || (vinfo.sh != sh)) {
vinfo.x = x;
vinfo.y = y;
vinfo.sw = sw;
vinfo.sh = sh;
vinfo.dw = w;
vinfo.dh = h;
if (line != NULL) free(line);
if ((line = (u_char *)malloc(sw)) == NULL) {
fprintf(stderr, "send_newt_video: malloc faild\n");
ret = 0;
goto send_done;
}
if (newtnv != NULL) nv_destroy(newtnv);
if ((newtnv = nv_new(target, x, y, w, h, yuv_dpcm)) == NULL) {
ret = 0;
goto send_done;
}
}
/* set up the clip region if necessary */
if (clipEvent != vinfo.clipEvent) {
vinfo.clip = ndga_clip(ndga, vinfo.clip);
nv_set_clip(newtnv, vinfo.clip);
}
/* Set up the video tiles */
if (nv_setup(newtnv, sw, sh, yuv_subx, yuv_suby) == 0) {
ret = 0;
goto send_done;
}
if (req_max_bw) nv_bwreq(newtnv, sw * sh * 3 * 40);
/* Convert 8-bit colormap data to yuv data. Copy or compress
* data into each tile
*/
tile = nv_next_tile(newtnv, TRUE,
&ydata, &udata, &vdata, &tx, &ty, &tw, &th);
while (tile != NULL) {
/* luma data */
for (j = 0 ; j < th ; j++) {
if (yuv_dpcm) {
int ywidth = (tw + 1) / 2;
for (i = 0 ; i < tw ; i++) {
line[i] = ymap[frame[(ty + j)*sw + tx + i]];
}
nv_compress(ydata, line, ywidth);
ydata += ywidth;
} else {
for (i = 0 ; i < tw ; i++) {
ydata[j*tw + i] =
ymap[frame[(ty + j)*sw + tx + i]];
}
}
}
/* chroma data */
if ((yuv_subx > 0) && (yuv_suby > 0)) {
int uvx = tx/yuv_subx, uvy = ty/yuv_suby,
uvw = (tw + yuv_subx - 1)/yuv_subx,
uvh = (th + yuv_suby - 1)/yuv_suby;
for (i = j = 0 ; j < uvh ; j++) {
for (k = 0 ; k < uvw ; k++) {
u_int u = 0, v = 0;
for (l = 0 ; l < yuv_suby ; l++) {
for (m = 0 ; m < yuv_subx ; m++) {
u_int pel = frame[(ty + j*yuv_suby + l)*sw +
tx + k*yuv_subx + m];
u += umap[pel];
v += vmap[pel];
}
}
udata[i] = u / (yuv_subx * yuv_suby);
vdata[i] = v / (yuv_subx * yuv_suby);
i++;
}
}
}
/* ship it off */
nv_send_tile(newtnv, tile);
/* get next tile */
tile = nv_next_tile(newtnv, FALSE,
&ydata, &udata, &vdata, &tx, &ty, &tw, &th);
}
send_done: /* leave */
ndga_done(ndga);
return ret;
}
/*============================= LOCAL ROUTINES ==============================*/
/*========================= setup_video =========================
* Setup a connection to a NewT so we can send video.
*/
static void setup_video(Display *disp, Window win)
{
char *session;
printf("Using NewT video: %d-bit luma, chroma subsamp W/%d H/%d\n",
yuv_dpcm ? 4 : 8, yuv_subx, yuv_suby);
/* Get the NewT target */
session = nvGetSessionId( display_name );
if ((session != NULL) && ((nvsession = nvSessionSetup(session)) != NULL)) {
struct sigaction sa;
target = NULL;
sa.sa_handler = exit;
if ((sigaction(SIGINT, &sa, NULL) < 0) ||
(sigaction(SIGHUP, &sa, NULL) < 0) ||
(sigaction(SIGTERM, &sa, NULL) < 0)) {
perror("sigaction");
newt_cleanup();
exit(1);
}
/* atexit(newt_cleanup);*/
} else {
nvsession = NULL;
target = getenv("NEWT_TARGET");
}
if ((nvsession == NULL) && (target == NULL)) {
Sys_Error("Could not open connection to NewT");
}
/* Create NewT DGA context */
ndga = ndga_new(disp, win, nvsession, 1, 1);
}
/*========================= newt_cleanup =========================
* Clean up on exit. Kill the NewT video session.
*/
void newt_cleanup( void )
{
if( ndga != NULL ) {
ndga_destroy( ndga );
}
if( newtnv != NULL ) {
nv_destroy(newtnv);
newtnv = NULL;
}
}
/*========================= nvSessionCheck =========================
* Check the status of the given NewT session and set the target.
*/
static void nvSessionCheck(nvSession sess)
{
char *new_target;
register int i;
if (sess == NULL) return;
new_target = nvSessionTarget(sess);
/* Status has changed; break everything down and start again */
if ((new_target==NULL) || (target==NULL) || strcmp(new_target,target)) {
if (newtnv != NULL) {
/* Lost the connection. Destroy it */
nv_destroy(newtnv);
newtnv = NULL;
}
/* Set new target */
if (target) {
free(target);
target = NULL;
}
if (new_target) target = strdup(new_target);
}
}

51
src/newt.h Normal file
View file

@ -0,0 +1,51 @@
/*
* Brian Schmidt
*
* File: newt.h
* Date: 03/16/99
* Revision: 1.4
*
* Header file for NewT Quake routines and variables.
*/
#pragma ident "@(#)File: newt.h, Rev: 1.4, Date: 99/03/16 12:04:16, Author: Brian Schmidt"
#ifndef _NEWT_H_
#define _NEWT_H_
/*============================== INCLUDE FILES ==============================*/
#include "ndga.h"
/*================================ CONSTANTS ================================*/
#define DEF_YUV_XSUBSAMP (2) /* default horiz chroma subsamp */
#define DEF_YUV_YSUBSAMP (1) /* default vert chroma subsamp */
#ifndef TRUE
#define TRUE (1) /* boolean vals */
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#define CLAMP(c) ((c) < 0 ? 0 : ((c) > 255 ? 255 : (c)))
/*================================= MACROS ==================================*/
/*============================= DATA STRUCTURES =============================*/
/*============================ EXPORTED GLOBALS =============================*/
extern int yuv_dpcm; /* use 4-bit DPCM on luma vals */
extern int yuv_subx; /* horizontal chroma subsample */
extern int yuv_suby; /* vertical chroma subsample */
extern int yuv_scale; /* image scale factor */
extern int req_max_bw; /* request max BW to NewT */
/*============================= PREDECLARATIONS =============================*/
/*============================= LOCAL ROUTINES ==============================*/
/*============================ EXPORTED ROUTINES ============================*/
int send_newt_video(Display *disp, Window win,
void *data, int width, int height);
void newt_process_event(XEvent *xev);
void load_newt_cmaps(u_char *rgb_map);
void newt_cleanup( void );
#endif /* _NEWT_H_ */

View file

@ -55,7 +55,7 @@ void *Hunk_Begin (int maxsize)
membase = mmap(0, maxhunksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
#elif defined(__FreeBSD__) || defined(__bsd__) || defined(__NetBSD__)
membase = mmap(0, maxhunksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
#elif defined(sun) || defined(__sgi)
#elif defined(__sun__) || defined(__sgi)
membase = malloc(maxhunksize);
#endif
if (membase == NULL || membase == (byte *)-1)
@ -79,7 +79,7 @@ void *Hunk_Alloc (int size)
return buf;
}
#if defined(__linux__) || defined(sun)
#if defined(__linux__) || defined(__sun__)
int Hunk_End (void)
{
byte *n;
@ -104,7 +104,7 @@ int Hunk_End (void)
#ifdef __linux__
n = mremap(membase, maxhunksize, curhunksize + sizeof(int), 0);
#else /* sun */
#else /* __sun__ */
n = realloc(membase, curhunksize);
#endif
if (n != membase)
@ -147,9 +147,8 @@ void Hunk_Free (void *base)
if (base) {
/* merged in from q_shsolaris.c -- jaq */
#ifdef sun
/* FIXME: I'm not sure that 'sun' is the correct define -- jaq */
free(base);
#ifdef __sun__
/* free(base); FIXME: It segfaults here. doesn't happen with icculus. Coyote */
#else
m = ((byte *)base) - sizeof(int);
#ifdef __sgi
@ -158,7 +157,7 @@ void Hunk_Free (void *base)
if (munmap(m, *((int *)m)))
Sys_Error("Hunk_Free: munmap failed (%d:%s)", errno, strerror(errno));
#endif /* __sgi */
#endif /* sun */
#endif /* __sun__ */
}
}

View file

@ -45,7 +45,7 @@
#include <time.h>
/*
#if (defined _M_IX86 || defined __i386__) && !defined C_ONLY && !defined __sun__
#if (defined _M_IX86 || defined __i386__) && !defined C_ONLY && !defined (__sun__)
#define id386 1
#else
#define id386 0

View file

@ -70,7 +70,7 @@ static FILE * log_fp = NULL;
#endif
/* merged in from qgl_bsd.c -- jaq */
#if defined(__bsd__) || defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__bsd__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun__)
/*
//FX Mesa Functions
fxMesaContext (*qfxMesaCreateContext)(GLuint win, GrScreenResolution_t, GrScreenRefresh_t, const GLint attribList[]);
@ -90,6 +90,7 @@ void (*qglXDestroyContext)( Display *dpy, GLXContext ctx );
Bool (*qglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx);
void (*qglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, GLuint mask );
void (*qglXSwapBuffers)( Display *dpy, GLXDrawable drawable );
int (*qglXGetConfig)( Display *dpy, XVisualInfo *vis, int attrib, int *value);
#endif
void ( APIENTRY * qglAccum )(GLenum op, GLfloat value);
@ -3035,11 +3036,12 @@ void QGL_Shutdown( void )
qglXMakeCurrent = NULL;
qglXCopyContext = NULL;
qglXSwapBuffers = NULL;
qglXGetConfig = NULL;
#endif
}
/* merged in from qgl_bsd.c -- jaq */
#if defined(__linux__) || defined (__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__linux__) || defined (__FreeBSD__) || defined(__NetBSD__) || defined (__sun__)
#define GPA( a ) dlsym( glw_state.OpenGLLib, a )
void *qwglGetProcAddress(char *symbol)
@ -3438,7 +3440,7 @@ qboolean QGL_Init( const char *dllname )
qglVertexPointer = dllVertexPointer = GPA( "glVertexPointer" );
qglViewport = dllViewport = GPA( "glViewport" );
/* merged in from qgl_bsd.c -- jaq */
#if defined(__bsd__) || defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__bsd__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun__)
/*
qfxMesaCreateContext = GPA("fxMesaCreateContext");
qfxMesaCreateBestContext = GPA("fxMesaCreateBestContext");
@ -3454,6 +3456,7 @@ qboolean QGL_Init( const char *dllname )
qglXMakeCurrent = GPA("glXMakeCurrent");
qglXCopyContext = GPA("glXCopyContext");
qglXSwapBuffers = GPA("glXSwapBuffers");
qglXGetConfig = GPA("glXGetConfig");
#endif
qglLockArraysEXT = 0;

View file

@ -30,7 +30,9 @@
#endif
#include <GL/gl.h>
#ifdef HAVE_OPENGL_GLEXT
#include <GL/glext.h>
#endif // HAVE_OPENGL_GLEXT
qboolean QGL_Init( const char *dllname );
void QGL_Shutdown( void );
@ -461,8 +463,8 @@ extern void (*qgl3DfxSetPaletteEXT)(GLuint *);
#define GL_TEXTURE0_SGIS 0x835E
#define GL_TEXTURE1_SGIS 0x835F
/*
#if 0 // FIXME: these are in glext.h, delete after testing
#ifndef HAVE_OPENGL_GLEXT // FIXME: these are in glext.h, delete after testing
// extension constants
#define GL_POINT_SIZE_MIN_EXT 0x8126
#define GL_POINT_SIZE_MAX_EXT 0x8127
@ -475,11 +477,21 @@ extern void (*qgl3DfxSetPaletteEXT)(GLuint *);
#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
#endif
#define GL_TEXTURE0_ARB 0x84C0
#define GL_TEXTURE1_ARB 0x84C1
#ifdef __sun__
#ifdef GL_DISTANCE_ATTENUATION_ARB
#define GL_DISTANCE_ATTENUATION_EXT GL_DISTANCE_ATTENUATION_ARB
#endif // GL_DISTANCE_ATTENUATION_ARB
#endif // __sun__
#ifndef GL_TEXTURE0_ARB
#define GL_TEXTURE0_ARB 0x84C0
#endif
#ifndef GL_TEXTURE1_ARB
#define GL_TEXTURE1_ARB 0x84C1
#endif
#endif // HAVE_OPENGL_GLEXT, end of glext.h defines
#endif // FIXME: end of glext.h defines
*/
extern int GL_Texture0, GL_Texture1;

932
src/rw_corona.c Normal file
View file

@ -0,0 +1,932 @@
/*
** rw_xil.c
**
** This file contains the Corona version of the X11 renderer.
*/
#include <ctype.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/ipc.h>
#include <xil/xil.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/Sunkeysym.h>
#include "../ref_soft/r_local.h"
#include "../client/keys.h"
#include "../solaris/rw_solaris.h"
#include "newt.h"
#include "q2.xbm"
/*****************************************************************************/
extern char display_name[];
static Display *x_disp;
static Window x_win;
static GC x_gc;
#define STD_EVENT_MASK (StructureNotifyMask | KeyPressMask \
| KeyReleaseMask | ExposureMask | PointerMotionMask | \
ButtonPressMask | ButtonReleaseMask | \
VisibilityChangeMask)
static qboolean X11_active = false;
struct
{
int key;
int down;
} keyq[64];
static int keyq_head=0;
static int keyq_tail=0;
static int config_notify = 0;
static int config_notify_width;
static int config_notify_height;
static int is_double_buffered;
typedef unsigned short PIXEL;
// Console variables that we need to access from this module
/*****************************************************************************/
/* MOUSE */
/*****************************************************************************/
// this is inside the renderer shared lib, so these are called from vid_so
static qboolean mouse_avail;
static int mouse_buttonstate;
static int mouse_oldbuttonstate;
static int mouse_x, mouse_y;
static int old_mouse_x, old_mouse_y;
static int mx, my;
static int old_windowed_mouse;
static int p_mouse_x, p_mouse_y;
static cvar_t *_windowed_mouse;
static cvar_t *m_filter;
static cvar_t *in_mouse;
static qboolean mlooking;
// state struct passed in Init
static in_state_t *in_state;
static cvar_t *sensitivity;
static cvar_t *lookstrafe;
static cvar_t *m_side;
static cvar_t *m_yaw;
static cvar_t *m_pitch;
static cvar_t *m_forward;
static cvar_t *freelook;
static cvar_t *xil_keepaspect;
/**************************************************************
* NewT stuff
**************************************************************/
static unsigned char *video_buffer = NULL;
static int window_width;
static int window_height;
static int force_resize = 0;
static unsigned char ymap[256];
static unsigned char umap[256];
static unsigned char vmap[256];
extern int newt_initialize_next;
static void Set_Window_Position_f( void );
static void Set_Window_Size_f( void );
static void Force_CenterView_f (void)
{
in_state->viewangles[PITCH] = 0;
}
static void RW_IN_MLookDown (void)
{
mlooking = true;
}
static void RW_IN_MLookUp (void)
{
mlooking = false;
in_state->IN_CenterView_fp ();
}
void RW_IN_Init(in_state_t *in_state_p)
{
int mtype;
int i;
in_state = in_state_p;
// mouse variables
_windowed_mouse = ri.Cvar_Get( "_windowed_mouse", "0", CVAR_ARCHIVE );
m_filter = ri.Cvar_Get( "m_filter", "0", 0 );
in_mouse = ri.Cvar_Get( "in_mouse", "1", CVAR_ARCHIVE );
freelook = ri.Cvar_Get( "freelook", "0", 0 );
lookstrafe = ri.Cvar_Get( "lookstrafe", "0", 0 );
sensitivity = ri.Cvar_Get( "sensitivity", "3", 0 );
m_pitch = ri.Cvar_Get( "m_pitch", "0.022", 0 );
m_yaw = ri.Cvar_Get( "m_yaw", "0.022", 0 );
m_forward = ri.Cvar_Get( "m_forward", "1", 0 );
m_side = ri.Cvar_Get( "m_side", "0.8", 0 );
xil_keepaspect = ri.Cvar_Get( "xil_keepaspect", "1", CVAR_ARCHIVE );
ri.Cmd_AddCommand( "+mlook", RW_IN_MLookDown );
ri.Cmd_AddCommand( "-mlook", RW_IN_MLookUp );
ri.Cmd_AddCommand( "force_centerview", Force_CenterView_f );
ri.Cmd_AddCommand( "xil_set_window_position", Set_Window_Position_f );
ri.Cmd_AddCommand( "xil_set_window_size", Set_Window_Size_f );
mouse_x = mouse_y = 0.0;
mouse_avail = true;
}
void RW_IN_Shutdown(void)
{
mouse_avail = false;
ri.Cmd_RemoveCommand( "+mlook" );
ri.Cmd_RemoveCommand( "-mlook" );
ri.Cmd_RemoveCommand( "force_centerview" );
ri.Cmd_RemoveCommand( "xil_set_window_position" );
ri.Cmd_RemoveCommand( "xil_set_window_size" );
}
/*
===========
IN_Commands
===========
*/
void RW_IN_Commands (void)
{
int i;
if (!mouse_avail)
return;
for( i = 0 ; i < 3 ; i++ ) {
if( (mouse_buttonstate & (1<<i)) && !(mouse_oldbuttonstate & (1<<i)) ) {
in_state->Key_Event_fp (K_MOUSE1 + i, true);
}
if( !(mouse_buttonstate & (1<<i)) && (mouse_oldbuttonstate & (1<<i)) ) {
in_state->Key_Event_fp (K_MOUSE1 + i, false);
}
}
mouse_oldbuttonstate = mouse_buttonstate;
}
/*
===========
IN_Move
===========
*/
void RW_IN_Move (usercmd_t *cmd)
{
if( !mouse_avail ) {
return;
}
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;
if( !mouse_x && !mouse_y ) {
return;
}
mouse_x *= sensitivity->value;
mouse_y *= sensitivity->value;
// add mouse X/Y movement to cmd
if( (*in_state->in_strafe_state & 1) ||
(lookstrafe->value && mlooking) ) {
cmd->sidemove += m_side->value * mouse_x;
}
else {
in_state->viewangles[YAW] -= m_yaw->value * mouse_x;
}
if( (mlooking || freelook->value) &&
!(*in_state->in_strafe_state & 1) ) {
in_state->viewangles[PITCH] += m_pitch->value * mouse_y;
}
else {
cmd->forwardmove -= m_forward->value * mouse_y;
}
mx = 0;
my = 0;
}
void RW_IN_Frame (void)
{
}
void RW_IN_Activate(void)
{
}
// ========================================================================
// makes a null cursor
// ========================================================================
static Cursor CreateNullCursor(Display *display, Window root)
{
Pixmap cursormask;
XGCValues xgc;
GC gc;
XColor dummycolour;
Cursor cursor;
cursormask = XCreatePixmap( display, root, 1, 1, 1 );
xgc.function = GXclear;
gc = XCreateGC( display, cursormask, GCFunction, &xgc );
XFillRectangle( display, cursormask, gc, 0, 0, 1, 1 );
dummycolour.pixel = 0;
dummycolour.red = 0;
dummycolour.flags = DoRed;
cursor = XCreatePixmapCursor( display, cursormask, cursormask,
&dummycolour, &dummycolour, 0,0 );
XFreePixmap( display, cursormask );
XFreeGC( display, gc );
return cursor;
}
void ResetNEWTFrameBuffers( void )
{
newt_cleanup();
video_buffer = malloc( vid.width * vid.height );
if( video_buffer == NULL ) {
Sys_Error( "Can't allocate video buffer memory" );
}
vid.buffer = video_buffer;
vid.rowbytes = vid.width;
newt_initialize_next = 1;
}
static void create_xil_window( void )
{
/* TODO */
}
// ========================================================================
// Tragic death handler
// ========================================================================
void TragicDeath(int signal_num)
{
XCloseDisplay(x_disp);
Sys_Error( "This death brought to you by the number %d\n", signal_num );
}
int XLateKey(XKeyEvent *ev)
{
int key;
char buf[64];
KeySym keysym;
key = 0;
XLookupString( ev, buf, sizeof buf, &keysym, 0 );
switch( keysym ) {
case XK_KP_9:
case XK_F29:
case XK_KP_Page_Up: key = K_KP_PGUP; break;
case XK_Page_Up: key = K_PGUP; break;
case XK_KP_3:
case XK_F35:
case XK_KP_Page_Down: key = K_KP_PGDN; break;
case XK_Page_Down: key = K_PGDN; break;
case XK_KP_7:
case XK_F27:
case XK_KP_Home: key = K_KP_HOME; break;
case XK_Home: key = K_HOME; break;
case XK_KP_1:
case XK_F33:
case XK_KP_End: key = K_KP_END; break;
case XK_End: key = K_END; break;
case XK_KP_4:
case XK_KP_Left: key = K_KP_LEFTARROW; break;
case XK_Left: key = K_LEFTARROW; break;
case XK_KP_6:
case XK_KP_Right: key = K_KP_RIGHTARROW; break;
case XK_Right: key = K_RIGHTARROW; break;
case XK_KP_2:
case XK_KP_Down: key = K_KP_DOWNARROW; break;
case XK_Down: key = K_DOWNARROW; break;
case XK_KP_8:
case XK_KP_Up: key = K_KP_UPARROW; break;
case XK_Up: key = K_UPARROW; break;
case XK_Escape: key = K_ESCAPE; break;
case XK_KP_Enter: key = K_KP_ENTER; break;
case XK_Return: key = K_ENTER; break;
case XK_Tab: key = K_TAB; break;
case XK_F1: key = K_F1; break;
case XK_F2: key = K_F2; break;
case XK_F3: key = K_F3; break;
case XK_F4: key = K_F4; break;
case XK_F5: key = K_F5; break;
case XK_F6: key = K_F6; break;
case XK_F7: key = K_F7; break;
case XK_F8: key = K_F8; break;
case XK_F9: key = K_F9; break;
case XK_F10: key = K_F10; break;
case SunXK_F36: key = K_F11; break;
case SunXK_F37: key = K_F12; break;
case XK_BackSpace: key = K_BACKSPACE; break;
case XK_KP_Separator:
case XK_KP_Delete: key = K_KP_DEL; break;
case XK_Delete: key = K_DEL; break;
case XK_Pause: key = K_PAUSE; break;
case XK_Shift_L:
case XK_Shift_R: key = K_SHIFT; break;
case XK_Execute:
case XK_Control_L:
case XK_Control_R: key = K_CTRL; break;
case XK_Alt_L:
case XK_Meta_L:
case XK_Alt_R:
case XK_Meta_R: key = K_ALT; break;
case XK_KP_5:
case XK_F31: key = K_KP_5; break;
case XK_Insert: key = K_INS; break;
case XK_KP_0:
case XK_KP_Insert: key = K_KP_INS; break;
case XK_F26:
case XK_KP_Multiply: key = '*'; break;
case XK_KP_Add: key = K_KP_PLUS; break;
case XK_F24:
case XK_KP_Subtract: key = K_KP_MINUS; break;
case XK_F25:
case XK_KP_Divide: key = K_KP_SLASH; break;
case XK_F11:
if( ev->type == KeyPress ) {
if( _windowed_mouse->value ) {
Cvar_SetValue( "_windowed_mouse", 0 );
}
else {
Cvar_SetValue( "_windowed_mouse", 1 );
}
}
break;
#if 0
case 0x021: key = '1';break;/* [!] */
case 0x040: key = '2';break;/* [@] */
case 0x023: key = '3';break;/* [#] */
case 0x024: key = '4';break;/* [$] */
case 0x025: key = '5';break;/* [%] */
case 0x05e: key = '6';break;/* [^] */
case 0x026: key = '7';break;/* [&] */
case 0x02a: key = '8';break;/* [*] */
case 0x028: key = '9';;break;/* [(] */
case 0x029: key = '0';break;/* [)] */
case 0x05f: key = '-';break;/* [_] */
case 0x02b: key = '=';break;/* [+] */
case 0x07c: key = '\'';break;/* [|] */
case 0x07d: key = '[';break;/* [}] */
case 0x07b: key = ']';break;/* [{] */
case 0x022: key = '\'';break;/* ["] */
case 0x03a: key = ';';break;/* [:] */
case 0x03f: key = '/';break;/* [?] */
case 0x03e: key = '.';break;/* [>] */
case 0x03c: key = ',';break;/* [<] */
#endif
default:
key = *(unsigned char*)buf;
if (key >= 'A' && key <= 'Z')
key = key - 'A' + 'a';
break;
}
return key;
}
void GetEvent(void)
{
XEvent x_event;
int b;
XNextEvent(x_disp, &x_event);
switch(x_event.type) {
case KeyPress:
keyq[keyq_head].key = XLateKey(&x_event.xkey);
keyq[keyq_head].down = true;
keyq_head = (keyq_head + 1) & 63;
break;
case KeyRelease:
/*
* This is a hack in order to avoid disabling key repeat, which
* would cause a lot of problems when changing to other windows
* or when the program crashes.
*
* Whenever a key release event occurs, we check to see if the
* next event in the queue is a press event of the same key
* with the same time stamp. If it is, we simply discard this
* and the next event.
*/
if( XPending( x_disp ) > 0 ) {
XEvent tmp_event;
XPeekEvent( x_disp, &tmp_event );
if( tmp_event.type == KeyPress &&
tmp_event.xkey.keycode == x_event.xkey.keycode &&
tmp_event.xkey.time == x_event.xkey.time ) {
XNextEvent( x_disp, &tmp_event );
break;
}
}
keyq[keyq_head].key = XLateKey(&x_event.xkey);
keyq[keyq_head].down = false;
keyq_head = (keyq_head + 1) & 63;
break;
case MotionNotify:
if( _windowed_mouse->value ) {
int xoffset = ((int)x_event.xmotion.x - (int)(window_width / 2));
int yoffset = ((int)x_event.xmotion.y - (int)(window_height / 2));
if( xoffset != 0 || yoffset != 0 ) {
mx += xoffset;
my += yoffset;
/* move the mouse to the window center again */
XSelectInput( x_disp, x_win, STD_EVENT_MASK & ~PointerMotionMask );
XWarpPointer( x_disp, None, x_win, 0, 0, 0, 0,
(window_width / 2), (window_height / 2) );
XSelectInput( x_disp,x_win, STD_EVENT_MASK );
}
}
else {
mx = ((int)x_event.xmotion.x - (int)p_mouse_x);
my = ((int)x_event.xmotion.y - (int)p_mouse_y);
p_mouse_x = x_event.xmotion.x;
p_mouse_y = x_event.xmotion.y;
}
break;
case ButtonPress:
b = -1;
if( x_event.xbutton.button == 1 ) {
b = 0;
}
else if( x_event.xbutton.button == 2 ) {
b = 2;
}
else if( x_event.xbutton.button == 3 ) {
b = 1;
}
if( b >= 0 ) {
mouse_buttonstate |= 1 << b;
}
break;
case ButtonRelease:
b = -1;
if( x_event.xbutton.button == 1 ) {
b = 0;
}
else if( x_event.xbutton.button == 2 ) {
b = 2;
}
else if( x_event.xbutton.button == 3 ) {
b = 1;
}
if( b >= 0 ) {
mouse_buttonstate &= ~(1 << b);
}
break;
case ConfigureNotify:
config_notify_width = x_event.xconfigure.width;
config_notify_height = x_event.xconfigure.height;
if( xil_keepaspect->value && !force_resize ) {
double aspect = (double)vid.width / vid.height;
if( config_notify_height > config_notify_width / aspect ) {
force_resize = 1;
XResizeWindow( x_disp, x_win,
config_notify_width,
(int)(config_notify_width / aspect) );
}
else if( config_notify_width > config_notify_height * aspect ) {
force_resize = 1;
XResizeWindow( x_disp, x_win,
(int)(config_notify_height * aspect),
config_notify_height );
}
}
else {
force_resize = 0;
}
if( !force_resize ) {
window_width = config_notify_width;
window_height = config_notify_height;
newt_initialize_next = 1;
}
break;
case MapNotify:
if( _windowed_mouse->value ) {
XGrabPointer( x_disp, x_win, True, 0, GrabModeAsync,
GrabModeAsync, x_win, None, CurrentTime);
}
break;
case UnmapNotify:
if( _windowed_mouse->value ) {
XUngrabPointer( x_disp, CurrentTime );
}
break;
case VisibilityNotify:
puts("visibility");
newt_initialize_next = 1;
break;
default:
;
}
if( old_windowed_mouse != _windowed_mouse->value ) {
old_windowed_mouse = _windowed_mouse->value;
if( !_windowed_mouse->value ) {
/* ungrab the pointer */
XUngrabPointer( x_disp, CurrentTime );
} else {
/* grab the pointer */
XGrabPointer( x_disp, x_win, True, 0, GrabModeAsync,
GrabModeAsync, x_win, None, CurrentTime );
}
}
}
/*****************************************************************************/
/*
** SWimp_Init
**
** This routine is responsible for initializing the implementation
** specific stuff in a software rendering subsystem.
*/
int SWimp_Init( void *hInstance, void *wndProc )
{
// open the display
x_disp = XOpenDisplay( display_name );
if( !x_disp ) {
if( display_name != NULL ) {
Sys_Error( "VID: Could not open display [%s]\n", display_name );
}
else {
Sys_Error( "VID: Could not open local display\n" );
}
}
// catch signals so i can turn on auto-repeat
{
struct sigaction sa;
sigaction( SIGINT, 0, &sa );
sa.sa_handler = TragicDeath;
sigaction( SIGINT, &sa, 0 );
sigaction( SIGTERM, &sa, 0 );
}
return true;
}
/*
** SWimp_InitGraphics
**
** This initializes the software refresh's implementation specific
** graphics subsystem. In the case of Windows it creates DIB or
** DDRAW surfaces.
**
** The necessary width and height parameters are grabbed from
** vid.width and vid.height.
*/
static qboolean SWimp_InitGraphics( qboolean fullscreen )
{
int pnum, i;
long template_mask;
srandom(getpid());
// free resources in use
SWimp_Shutdown ();
// let the sound and input subsystems know about the new window
ri.Vid_NewWindow (vid.width, vid.height);
// for debugging only
// XSynchronize(x_disp, True);
// check for command-line window size
template_mask = 0;
// setup attributes for main window
{
int attribmask = CWEventMask | CWBorderPixel;
XSetWindowAttributes attribs;
window_width = vid.width;
window_height = vid.height;
attribs.event_mask = STD_EVENT_MASK;
attribs.border_pixel = 0;
// create the main window
x_win = XCreateWindow( x_disp,
XRootWindow( x_disp, DefaultScreen( x_disp ) ),
0, 0, // x, y
window_width, window_height,
0, // borderwidth
CopyFromParent,
InputOutput,
CopyFromParent,
attribmask,
&attribs );
XStoreName( x_disp, x_win, "Quake II" );
}
// inviso cursor
XDefineCursor( x_disp, x_win, CreateNullCursor( x_disp, x_win ) );
// create the GC
{
XGCValues xgcvalues;
int valuemask = GCGraphicsExposures;
xgcvalues.graphics_exposures = False;
x_gc = XCreateGC( x_disp, x_win, valuemask, &xgcvalues );
}
/* set the icon */
{
Pixmap icon;
XWMHints hints;
icon = XCreateBitmapFromData( x_disp, DefaultRootWindow( x_disp ),
q2_bits, q2_width, q2_height );
/* BlackPixel( x_disp, DefaultScreen( x_disp ) ),
WhitePixel( x_disp, DefaultScreen( x_disp ) ),
1 );*/
hints.icon_pixmap = icon;
hints.flags = IconPixmapHint;
XSetWMHints( x_disp, x_win, &hints );
}
// map the window
XMapWindow( x_disp, x_win );
// wait for first exposure event
{
XEvent event;
do {
XNextEvent( x_disp, &event );
} while( event.type != Expose || event.xexpose.count != 0 );
}
// now safe to draw
ResetNEWTFrameBuffers();
// XSynchronize(x_disp, False);
old_windowed_mouse = 0;
X11_active = true;
return true;
}
/*
** SWimp_EndFrame
**
** This does an implementation specific copy from the backbuffer to the
** front buffer. In the Win32 case it uses BitBlt or BltFast depending
** on whether we're using DIB sections/GDI or DDRAW.
*/
void SWimp_EndFrame (void)
{
send_newt_video( x_disp, x_win, vid.buffer, vid.width, vid.height );
}
/*
** SWimp_SetMode
*/
rserr_t SWimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
{
rserr_t retval = rserr_ok;
ri.Con_Printf (PRINT_ALL, "setting mode %d:", mode );
if( !ri.Vid_GetModeInfo( pwidth, pheight, mode ) ) {
ri.Con_Printf( PRINT_ALL, " invalid mode\n" );
return rserr_invalid_mode;
}
ri.Con_Printf( PRINT_ALL, " %d %d\n", *pwidth, *pheight );
if( !SWimp_InitGraphics( false ) ) {
// failed to set a valid mode in windowed mode
return rserr_invalid_mode;
}
R_GammaCorrectAndSetPalette( (const unsigned char *)d_8to24table );
return retval;
}
/*
** SWimp_SetPalette
**
** System specific palette setting routine. A NULL palette means
** to use the existing palette. The palette is expected to be in
** a padded 4-byte xRGB format.
*/
void SWimp_SetPalette( const unsigned char *palette )
{
newt_set_palette( palette );
}
/*
** SWimp_Shutdown
**
** System specific graphics subsystem shutdown routine. Destroys
** DIBs or DDRAW surfaces as appropriate.
*/
void SWimp_Shutdown( void )
{
newt_cleanup();
if( X11_active ) {
XDestroyWindow( x_disp, x_win );
XSync( x_disp, False );
}
if( video_buffer != NULL ) {
free( video_buffer );
}
}
/*
** SWimp_AppActivate
*/
void SWimp_AppActivate( qboolean active )
{
}
/*****************************************************************************/
/* KEYBOARD */
/*****************************************************************************/
Key_Event_fp_t Key_Event_fp;
void KBD_Init(Key_Event_fp_t fp)
{
Key_Event_fp = fp;
}
void KBD_Update(void)
{
// get events from x server
if (x_disp)
{
while (XPending(x_disp))
GetEvent();
while (keyq_head != keyq_tail)
{
Key_Event_fp(keyq[keyq_tail].key, keyq[keyq_tail].down);
keyq_tail = (keyq_tail + 1) & 63;
}
}
}
void KBD_Close(void)
{
}
/*** User commands *******************************************************/
static void Set_Window_Position_f( void )
{
int x, y;
char *arg;
char *endnum;
if( Cmd_Argc() != 3 ) {
Com_Printf( "usage: xil_set_window_position x y\n" );
return;
}
arg = Cmd_Argv( 1 );
x = strtol( arg, &endnum, 10 );
if( endnum != arg && *endnum != 0 ) {
Com_Printf( "illegal x position\n" );
return;
}
arg = Cmd_Argv( 2 );
y = strtol( arg, &endnum, 10 );
if( endnum != arg && *endnum != 0 ) {
Com_Printf( "illegal y position\n" );
return;
}
XMoveWindow( x_disp, x_win, x, y );
}
static void Set_Window_Size_f( void )
{
int width, height;
char *arg;
char *endnum;
if( Cmd_Argc() != 3 ) {
Com_Printf( "usage: xil_set_window_size width height\n" );
return;
}
arg = Cmd_Argv( 1 );
width = strtol( arg, &endnum, 10 );
if( endnum != arg && *endnum != 0 ) {
Com_Printf( "illegal width\n" );
return;
}
arg = Cmd_Argv( 2 );
height = strtol( arg, &endnum, 10 );
if( endnum != arg && *endnum != 0 ) {
Com_Printf( "illegal height\n" );
return;
}
XResizeWindow( x_disp, x_win, width, height );
}

View file

@ -19,7 +19,7 @@
#include <string.h>
#include <sys/mman.h>
#include "SDL.h"
#include <SDL.h>
#ifdef OPENGL
#include <GL/gl.h>

View file

@ -55,7 +55,9 @@
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/extensions/XShm.h>
#ifdef HAVE_XF86_DGA
#include <X11/extensions/xf86dga.h>
#endif
#ifdef HAVE_JOYSTICK
# include <sys/stat.h>
@ -542,6 +544,7 @@ static void install_grabs(void)
if (in_dgamouse->value) {
int MajorVersion, MinorVersion;
#ifdef HAVE_XF86_DGA
if (!XF86DGAQueryVersion(dpy, &MajorVersion, &MinorVersion)) {
// unable to query, probalby not supported
ri.Con_Printf( PRINT_ALL, "Failed to detect XF86DGA Mouse\n" );
@ -551,8 +554,10 @@ static void install_grabs(void)
XF86DGADirectVideo(dpy, DefaultScreen(dpy), XF86DGADirectMouse);
XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
}
} else
#endif // HAVE_XF86_DGA
} else {
XWarpPointer(dpy, None, win, 0, 0, 0, 0, vid.width / 2, vid.height / 2);
}
XGrabKeyboard(dpy, win,
False,
@ -573,7 +578,9 @@ static void uninstall_grabs(void)
if (dgamouse) {
dgamouse = false;
#ifdef HAVE_XF86_DGA
XF86DGADirectVideo(dpy, DefaultScreen(dpy), 0);
#endif // HAVE_XF86_DGA
}
XUngrabPointer(dpy, CurrentTime);

1155
src/rw_xil.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -25,10 +25,10 @@
$Id$
*/
#include "SDL.h"
#include <SDL.h>
#include "../client/client.h"
#include "../client/snd_loc.h"
#include "client.h"
#include "snd_loc.h"
static int snd_inited;
static dma_t *shm;

286
src/snd_solaris.c Normal file
View file

@ -0,0 +1,286 @@
/*
Copyright (C) 1997-2001 Id Software, 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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stropts.h>
#include <sys/types.h>
#include <sys/audioio.h>
#include "../client/client.h"
#include "../client/snd_loc.h"
#define SND_DEBUG 0
#if SND_DEBUG
#define DPRINTF(...) printf(__VA_ARGS__)
#else
#define DPRINTF(...) /**/
#endif
static int audio_fd = -1;
static int snd_inited;
static cvar_t *sndbits;
static cvar_t *sndspeed;
static cvar_t *sndchannels;
static cvar_t *snddevice;
static int tryrates[] = { 11025, 22051, 44100, 8000 };
#define QSND_NUM_CHUNKS 2
/*
==================
SNDDMA_Init
Try to find a sound device to mix for.
Returns false if nothing is found.
Returns true and fills in the "dma" structure with information for the mixer.
==================
*/
qboolean SNDDMA_Init(void)
{
int i;
int samples;
audio_info_t au_info;
if (snd_inited)
return 1;
if (!snddevice) {
sndbits = Cvar_Get("sndbits", "16", CVAR_ARCHIVE);
sndspeed = Cvar_Get("sndspeed", "0", CVAR_ARCHIVE);
sndchannels = Cvar_Get("sndchannels", "2", CVAR_ARCHIVE);
snddevice = Cvar_Get("snddevice", "/dev/audio", CVAR_ARCHIVE);
}
// open /dev/audio
if (audio_fd < 0) {
audio_fd = open(snddevice->string, O_WRONLY);
if (audio_fd < 0) {
Com_Printf("Could not open %s: %s\n", snddevice->string, strerror(errno));
return 0;
}
}
// set sample bits & speed
if ((int)sndspeed->value > 0) {
AUDIO_INITINFO(&au_info);
au_info.play.precision = (int)sndbits->value;
au_info.play.encoding =
( au_info.play.precision == 8
? AUDIO_ENCODING_LINEAR8
: AUDIO_ENCODING_LINEAR );
au_info.play.sample_rate = (int)sndspeed->value;
au_info.play.channels = (int)sndchannels->value;
if (ioctl(audio_fd, AUDIO_SETINFO, &au_info) == -1) {
Com_Printf("AUDIO_SETINFO failed: %s\n", strerror(errno));
return 0;
}
} else {
for (i=0 ; i<sizeof(tryrates)/sizeof(tryrates[0]) ; i++) {
AUDIO_INITINFO(&au_info);
au_info.play.precision = (int)sndbits->value;
au_info.play.encoding =
( au_info.play.precision == 8
? AUDIO_ENCODING_LINEAR8
: AUDIO_ENCODING_LINEAR );
au_info.play.sample_rate = tryrates[i];
au_info.play.channels = (int)sndchannels->value;
if (ioctl(audio_fd, AUDIO_SETINFO, &au_info) == 0)
break;
Com_Printf("AUDIO_SETINFO failed: %s\n", strerror(errno));
}
if (i >= sizeof(tryrates)/sizeof(tryrates[0]))
return 0;
}
dma.samplebits = au_info.play.precision;
dma.channels = au_info.play.channels;
dma.speed = au_info.play.sample_rate;
/*
* submit some sound data every ~ 0.1 seconds, and try to buffer 2*0.1
* seconds in sound driver
*/
samples = dma.channels * dma.speed / 10;
for (i = 0; (1 << i) < samples; i++)
;
dma.submission_chunk = 1 << (i-1);
DPRINTF("channels %d, speed %d, log2(samples) %d, submission chunk %d\n",
dma.channels, dma.speed, i-1,
dma.submission_chunk);
dma.samples = QSND_NUM_CHUNKS * dma.submission_chunk;
dma.buffer = calloc(dma.samples, dma.samplebits/8);
if (dma.buffer == NULL) {
Com_Printf("Could not alloc sound buffer\n");
return 0;
}
AUDIO_INITINFO(&au_info);
au_info.play.eof = 0;
au_info.play.samples = 0;
ioctl(audio_fd, AUDIO_SETINFO, &au_info);
dma.samplepos = 0;
snd_inited = 1;
return 1;
}
/*
==============
SNDDMA_GetDMAPos
return the current sample position (in mono samples, not stereo)
inside the recirculating dma buffer, so the mixing code will know
how many sample are required to fill it up.
===============
*/
int SNDDMA_GetDMAPos(void)
{
int s_pos;
audio_info_t au_info;
if (!snd_inited)
return 0;
if (ioctl(audio_fd, AUDIO_GETINFO, &au_info) == -1) {
Com_Printf("AUDIO_GETINFO failed: %s\n", strerror(errno));
return 0;
}
s_pos = au_info.play.samples * dma.channels;
return s_pos & (dma.samples - 1);
}
/*
==============
SNDDMA_Shutdown
Reset the sound device for exiting
===============
*/
void SNDDMA_Shutdown(void)
{
if (snd_inited) {
if (audio_fd >= 0) {
ioctl(audio_fd, I_FLUSH, FLUSHW);
close(audio_fd);
audio_fd = -1;
}
snd_inited = 0;
}
}
/*
==============
SNDDMA_Submit
Send sound to device if buffer isn't really the dma buffer
===============
*/
void SNDDMA_Submit(void)
{
int samplebytes = dma.samplebits/8;
audio_info_t au_info;
int s_pos;
int chunk_idx;
static int last_chunk_idx = -1;
if (!snd_inited)
return;
if (last_chunk_idx == -1) {
if (write(audio_fd, dma.buffer, dma.samples * samplebytes) != dma.samples * samplebytes)
Com_Printf("initial write on audio device failed\n");
last_chunk_idx = 0;
dma.samplepos = 0;
return;
}
if (ioctl(audio_fd, AUDIO_GETINFO, &au_info) == -1) {
Com_Printf("AUDIO_GETINFO failed: %s\n", strerror(errno));
return;
}
if (au_info.play.error) {
/*
* underflow? clear the error flag and reset the HW sample counter
* and send the whole dma_buffer, to get sound output working again
*/
DPRINTF("audio data underflow\n");
AUDIO_INITINFO(&au_info);
au_info.play.error = 0;
au_info.play.samples = 0;
ioctl(audio_fd, AUDIO_SETINFO, &au_info);
if (write(audio_fd, dma.buffer, dma.samples * samplebytes) != dma.samples * samplebytes)
Com_Printf("refill sound driver after underflow failed\n");
last_chunk_idx = 0;
dma.samplepos = 0;
return;
}
s_pos = au_info.play.samples * dma.channels;
chunk_idx = (s_pos % dma.samples) / dma.submission_chunk;
DPRINTF("HW DMA Pos=%u (%u), dma.samplepos=%u, play in=%d, last=%d\n",
au_info.play.samples, s_pos, dma.samplepos,
chunk_idx, last_chunk_idx);
while (chunk_idx != last_chunk_idx) {
if (write(audio_fd,
dma.buffer + dma.samplepos * samplebytes,
dma.submission_chunk * samplebytes) != dma.submission_chunk * samplebytes) {
Com_Printf("write error on audio device\n");
}
if ((dma.samplepos += dma.submission_chunk) >= dma.samples)
dma.samplepos = 0;
if (++last_chunk_idx >= QSND_NUM_CHUNKS)
last_chunk_idx = 0;
}
}
void SNDDMA_BeginPainting (void)
{
}