dirty, evil hacks, but gl rendering

This commit is contained in:
Bill Currie 2001-12-22 07:56:13 +00:00
parent 044af4903c
commit f71b23e88d
4 changed files with 221 additions and 8 deletions

2
linux/.gitignore vendored
View file

@ -1 +1,3 @@
*.d
debugi386
releasei386

View file

@ -40,8 +40,8 @@ SVGALDFLAGS=-lvga
XLDFLAGS=-L/usr/X11R6/lib -lX11 -lXext
XCFLAGS=
GLLDFLAGS=-L/usr/local/glide/lib -L/usr/X11/lib -L/usr/local/lib \
-L/usr/local/src/Mesa-2.6/lib -lMesaGL -lglide2x -lX11 -lXext -lvga
GLLDFLAGS=-L/usr/local/glide/lib -L/usr/X11R6/lib -L/usr/local/lib \
-lGL -lX11 -lXext -lvga
GLCFLAGS=-I/usr/local/src/Mesa-2.6/include -I/usr/local/glide/include
SHLIBEXT=so
@ -61,8 +61,8 @@ DO_SHLIB_AS=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -DELF -x assembler-with-cpp -o $@ -c
TARGETS=$(BUILDDIR)/quake2 \
$(BUILDDIR)/game$(ARCH).$(SHLIBEXT) \
$(BUILDDIR)/ref_softx.$(SHLIBEXT)
# $(BUILDDIR)/ref_gl.$(SHLIBEXT) \
$(BUILDDIR)/ref_softx.$(SHLIBEXT) \
$(BUILDDIR)/ref_gl.$(SHLIBEXT)
# $(BUILDDIR)/ctf/game$(ARCH).$(SHLIBEXT) \
# $(BUILDDIR)/ref_soft.$(SHLIBEXT) \
# $(BUILDDIR)/xatrix/game$(ARCH).$(SHLIBEXT)
@ -1002,7 +1002,7 @@ REF_GL_OBJS = \
$(BUILDDIR)/ref_gl/gl_warp.o \
\
$(BUILDDIR)/ref_gl/qgl_linux.o \
$(BUILDDIR)/ref_gl/gl_fxmesa.o \
$(BUILDDIR)/ref_gl/gl_glx.o \
$(BUILDDIR)/ref_gl/rw_in_svgalib.o \
$(BUILDDIR)/ref_gl/q_shared.o \
$(BUILDDIR)/ref_gl/q_shlinux.o \
@ -1041,7 +1041,7 @@ $(BUILDDIR)/ref_gl/gl_warp.o : $(REF_GL_DIR)/gl_warp.c
$(BUILDDIR)/ref_gl/qgl_linux.o : $(LINUX_DIR)/qgl_linux.c
$(DO_GL_SHLIB_CC)
$(BUILDDIR)/ref_gl/gl_fxmesa.o : $(LINUX_DIR)/gl_fxmesa.c
$(BUILDDIR)/ref_gl/gl_glx.o : $(LINUX_DIR)/gl_glx.c
$(DO_GL_SHLIB_CC)
$(BUILDDIR)/ref_gl/rw_in_svgalib.o : $(LINUX_DIR)/rw_in_svgalib.c

211
linux/gl_glx.c Normal file
View file

@ -0,0 +1,211 @@
/*
** GLW_IMP.C
**
** This file contains ALL Linux 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 <sys/vt.h>
#include <stdarg.h>
#include <stdio.h>
#include <signal.h>
#include "../ref_gl/gl_local.h"
#include "../client/keys.h"
#include "../linux/rw_linux.h"
#include <GL/gl.h>
#include <GL/glx.h>
/*****************************************************************************/
static qboolean GLimp_SwitchFullscreen( int width, int height );
qboolean GLimp_InitGL (void);
extern cvar_t *vid_fullscreen;
extern cvar_t *vid_ref;
static GLXContext fc = NULL;
/*
#define NUM_RESOLUTIONS 3
static resolutions[NUM_RESOLUTIONS][3]={
{ 512, 384, GR_RESOLUTION_512x384 },
{ 640, 400, GR_RESOLUTION_640x400 },
{ 640, 480, GR_RESOLUTION_640x480 }
};
static int findres(int *width, int *height)
{
int i;
for(i=0;i<NUM_RESOLUTIONS;i++)
if((*width<=resolutions[i][0]) && (*height<=resolutions[i][1])) {
*width = resolutions[i][0];
*height = resolutions[i][1];
return resolutions[i][2];
}
*width = 640;
*height = 480;
return GR_RESOLUTION_640x480;
}
*/
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);
}
extern Display *x_disp;
extern XVisualInfo *x_visinfo;
/*
** GLimp_SetMode
*/
int GLimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen )
{
int width, height;
GLint attribs[32];
*pwidth=640; *pheight=480;
ri.Con_Printf( PRINT_ALL, "Initializing OpenGL display\n");
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 );
// destroy the existing window
GLimp_Shutdown ();
/*
// set fx attribs
attribs[0] = FXMESA_DOUBLEBUFFER;
attribs[1] = FXMESA_ALPHA_SIZE;
attribs[2] = 1;
attribs[3] = FXMESA_DEPTH_SIZE;
attribs[4] = 1;
attribs[5] = FXMESA_NONE;
fc = fxMesaCreateContext(0, findres(&width, &height), GR_REFRESH_75Hz,
attribs);
*/
fc = glXCreateContext (x_disp, x_visinfo, NULL, True);
if (!fc)
return rserr_invalid_mode;
*pwidth = width;
*pheight = height;
// let the sound and input subsystems know about the new window
ri.Vid_NewWindow (width, height);
fxMesaMakeCurrent(fc);
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 (fc) {
fxMesaDestroyContext(fc);
fc = NULL;
}
}
/*
** GLimp_Init
**
** This routine is responsible for initializing the OS specific portions
** of OpenGL.
*/
int GLimp_Init( void *hinstance, void *wndproc )
{
InitSig();
return true;
}
/*
** 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)
{
glFlush();
fxMesaSwapBuffers();
}
/*
** GLimp_AppActivate
*/
void GLimp_AppActivate( qboolean active )
{
}
extern void gl3DfxSetPaletteEXT(GLuint *pal);
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;
}
gl3DfxSetPaletteEXT((GLuint *)temptable);
}

View file

@ -37,12 +37,12 @@
/*****************************************************************************/
static qboolean doShm;
static Display *x_disp;
Display *x_disp;
static Colormap x_cmap;
static Window x_win;
static GC x_gc;
static Visual *x_vis;
static XVisualInfo *x_visinfo;
XVisualInfo *x_visinfo;
//static XImage *x_image;
#define STD_EVENT_MASK (StructureNotifyMask | KeyPressMask \