Remove some old renderer specific files.

This commit is contained in:
Bill Currie 2012-07-14 07:32:53 +09:00
parent b1a0086dae
commit fcf7150c62
3 changed files with 0 additions and 657 deletions

View file

@ -1,231 +0,0 @@
/*
vid_glx.c
OpenGL GLX video driver
Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 2000 Marcus Sundberg [mackan@stacken.kth.se]
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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_DLOPEN
# include <dlfcn.h>
#endif
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/cursorfont.h>
#ifdef HAVE_DGA
# ifdef DGA_OLD_HEADERS
# include <X11/extensions/xf86dga.h>
# else
# include <X11/extensions/Xxf86dga.h>
# endif
#endif
#include "QF/cmd.h"
#include "QF/cvar.h"
#include "QF/input.h"
#include "QF/qargs.h"
#include "QF/qendian.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/vid.h"
#include "QF/GL/funcs.h"
#include "QF/GL/qf_vid.h"
#include "compat.h"
#include "context_x11.h"
#define WARP_WIDTH 320
#define WARP_HEIGHT 200
// GLXContext is a pointer to opaque data
typedef struct __GLXcontextRec *GLXContext;
#define GLX_RGBA 4 // true if RGBA mode
#define GLX_DOUBLEBUFFER 5 // double buffering supported
#define GLX_RED_SIZE 8 // number of red component bits
#define GLX_GREEN_SIZE 9 // number of green component bits
#define GLX_BLUE_SIZE 10 // number of blue component bits
#define GLX_DEPTH_SIZE 12 // number of depth bits
static GLXContext ctx = NULL;
typedef XID GLXDrawable;
void (*qfglXSwapBuffers) (Display *dpy, GLXDrawable drawable);
XVisualInfo* (*qfglXChooseVisual) (Display *dpy, int screen, int *attribList);
GLXContext (*qfglXCreateContext) (Display *dpy, XVisualInfo *vis,
GLXContext shareList, Bool direct);
Bool (*qfglXMakeCurrent) (Display *dpy, GLXDrawable drawable, GLXContext ctx);
// ============================================================================
static int use_gl_procaddress = 0;
#if defined(HAVE_DLOPEN)
void * (* glGetProcAddress) (const char *symbol) = NULL;
void *
QFGL_GetProcAddress (void *handle, const char *name)
{
void *glfunc = NULL;
if (use_gl_procaddress && glGetProcAddress)
glfunc = glGetProcAddress (name);
if (!glfunc)
glfunc = dlsym (handle, name);
return glfunc;
}
void *
QFGL_LoadLibrary (void)
{
void *handle;
int flags = RTLD_NOW;
#ifdef RTLD_GLOBAL
flags |= RTLD_GLOBAL;
#endif
if (!(handle = dlopen (gl_driver->string, flags))) {
Sys_Error ("Couldn't load OpenGL library %s: %s", gl_driver->string,
dlerror ());
}
glGetProcAddress = dlsym (handle, "glXGetProcAddress");
if (!glGetProcAddress)
glGetProcAddress = dlsym (handle, "glXGetProcAddressARB");
return handle;
}
#else
# error "Cannot load libraries: %s was not configured with DSO support"
// the following is to avoid other compiler errors
void *
QFGL_GetProcAddress (void *handle, const char *name)
{
return 0;
}
void *
QFGL_LoadLibrary (void)
{
return 0;
}
#endif // HAVE_DLOPEN
static void
glx_get_functions (void)
{
GLF_Init ();
qfglXSwapBuffers = QFGL_ProcAddress (libgl_handle, "glXSwapBuffers", true);
qfglXChooseVisual = QFGL_ProcAddress (libgl_handle, "glXChooseVisual",
true);
qfglXCreateContext = QFGL_ProcAddress (libgl_handle, "glXCreateContext",
true);
qfglXMakeCurrent = QFGL_ProcAddress (libgl_handle, "glXMakeCurrent", true);
use_gl_procaddress = 1;
}
static void
GL_Init (void)
{
GL_Init_Common ();
}
VISIBLE void
GL_EndRendering (void)
{
qfglFinish ();
qfglXSwapBuffers (x_disp, x_win);
}
static void
glx_choose_visual (void)
{
int attrib[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
GLX_DEPTH_SIZE, 1,
None
};
x_visinfo = qfglXChooseVisual (x_disp, x_screen, attrib);
if (!x_visinfo) {
Sys_Error ("Error couldn't get an RGB, Double-buffered, Depth visual");
}
x_vis = x_visinfo->visual;
}
static void
glx_create_context (void)
{
XSync (x_disp, 0);
ctx = qfglXCreateContext (x_disp, x_visinfo, NULL, True);
qfglXMakeCurrent (x_disp, x_win, ctx);
GL_Init ();
}
void
VID_Init (byte *palette, byte *colormap)
{
vid.maxwarpwidth = WARP_WIDTH;
vid.maxwarpheight = WARP_HEIGHT;
vid.colormap8 = vid_colormap = colormap;
vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES];
vid.numpages = 2;
glx_get_functions ();
VID_GetWindowSize (640, 480);
X11_OpenDisplay ();
glx_choose_visual ();
X11_SetVidMode (vid.width, vid.height);
X11_CreateWindow (vid.width, vid.height);
X11_CreateNullCursor (); // hide mouse pointer
glx_create_context ();
VID_InitGamma (palette);
VID_SetPalette (vid.palette);
Sys_MaskPrintf (SYS_VID, "Video mode %dx%d initialized.\n",
vid.width, vid.height);
vid.initialized = true;
vid.recalc_refdef = 1; // force a surface cache flush
}

View file

@ -1,238 +0,0 @@
/*
vid_sdl32.c
Video driver for Sam Lantinga's Simple DirectMedia Layer
Copyright (C) 1996-1997 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:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <SDL.h>
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/qendian.h"
#include "QF/sys.h"
#include "QF/vid.h"
#include "d_iface.h"
#include "d_local.h"
#ifdef _WIN32 // FIXME: evil hack to get full DirectSound support with SDL
#include <windows.h>
#include <SDL_syswm.h>
HWND mainwindow;
#endif
// The original defaults
#define BASEWIDTH 320
#define BASEHEIGHT 200
byte *VGA_pagebase;
int VGA_width, VGA_height, VGA_rowbytes, VGA_bufferrowbytes = 0;
SDL_Surface *screen = NULL;
static SDL_Surface *rendersurface = NULL;
void
VID_SetPalette (unsigned char *palette)
{
if (vid_bitdepth->int_val == 8) {
SDL_Color colors[256];
int i;
for (i = 0; i < 256; ++i) {
colors[i].r = *palette++;
colors[i].g = *palette++;
colors[i].b = *palette++;
}
SDL_SetColors (screen, colors, 0, 256);
}
}
static void
do_screen_buffer (void)
{
}
void
VID_Init (byte *palette, byte *colormap)
{
Uint32 flags;
// Load the SDL library
if (SDL_Init (SDL_INIT_VIDEO) < 0)
Sys_Error ("VID: Couldn't load SDL: %s", SDL_GetError ());
// Set up display mode (width and height)
VID_GetWindowSize (BASEWIDTH, BASEHEIGHT);
vid.maxwarpwidth = WARP_WIDTH;
vid.maxwarpheight = WARP_HEIGHT;
if (vid_bitdepth->int_val != 8 && vid_bitdepth->int_val != 16 &&
vid_bitdepth->int_val != 32)
Sys_Error("unsupported vid_bitdepth %i, must be 8, 16, or 32",
vid_bitdepth->int_val);
// Set video width, height and flags
flags = SDL_SWSURFACE;
if (vid_bitdepth->int_val == 8)
flags |= SDL_HWPALETTE;
if (vid_fullscreen->int_val)
flags |= SDL_FULLSCREEN;
// Initialize display
if (!(screen = SDL_SetVideoMode (vid.width, vid.height,
vid_bitdepth->int_val, flags)))
Sys_Error ("VID: Couldn't set video mode: %s", SDL_GetError ());
vid_colormap = colormap;
VID_InitGamma (palette);
VID_SetPalette (vid.palette);
switch (vid_bitdepth->int_val) {
case 8:
r_pixbytes = 1;
rendersurface = screen;
break;
case 16:
r_pixbytes = 2;
rendersurface = SDL_CreateRGBSurface
(SDL_SWSURFACE, vid.width, vid.height, 16, 0xF800, 0x07E0, 0x001F,
0x0000);
break;
case 32:
r_pixbytes = 4;
if (bigendien)
rendersurface = SDL_CreateRGBSurface
(SDL_SWSURFACE, vid.width, vid.height, 32, 0xFF000000,
0x00FF0000, 0x0000FF00, 0x00000000);
else
rendersurface = SDL_CreateRGBSurface
(SDL_SWSURFACE, vid.width, vid.height, 32, 0x000000FF,
0x0000FF00, 0x00FF0000, 0x00000000);
break;
default:
Sys_Error ("VID_Init: unsupported bit depth");
}
// now we know everything we need to know about the buffer
VGA_width = vid.width;
VGA_height = vid.height;
vid.numpages = 1;
if (vid_colormap)
VID_MakeColormaps(256 - vid_colormap[16384], vid.palette);
else
VID_MakeColormaps(224, vid.palette);
VGA_pagebase = vid.buffer = rendersurface->pixels;
VGA_rowbytes = vid.rowbytes = rendersurface->pitch;
vid.conbuffer = vid.buffer;
vid.conrowbytes = vid.rowbytes;
vid.direct = rendersurface->pixels;
vid.do_screen_buffer = do_screen_buffer;
VID_InitBuffers (); // allocate z buffer and surface cache
SDL_ShowCursor (0); // initialize the mouse
#ifdef _WIN32
// FIXME: EVIL thing - but needed for win32 until
// SDL_sound works better - without this DirectSound fails.
// SDL_GetWMInfo(&info);
// mainwindow=info.window;
mainwindow=GetActiveWindow();
#endif
vid.initialized = true;
}
VISIBLE void
VID_Update (vrect_t *rects)
{
while (rects) {
if (vid_bitdepth->int_val != 8) {
SDL_Rect sdlrect;
sdlrect.x = rects->x;
sdlrect.y = rects->y;
sdlrect.w = rects->width;
sdlrect.h = rects->height;
// blit internal framebuffer to display buffer
SDL_BlitSurface(rendersurface, &sdlrect, screen, &sdlrect);
}
// update display
SDL_UpdateRect (screen, rects->x, rects->y, rects->width,
rects->height);
rects = rects->next;
}
}
void
D_BeginDirectRect (int x, int y, byte * pbitmap, int width, int height)
{
Uint8 *offset;
if (!screen)
return;
if (x < 0)
x = screen->w + x - 1;
offset = (Uint8 *) screen->pixels + y * screen->pitch + x;
while (height--) {
memcpy (offset, pbitmap, width);
offset += screen->pitch;
pbitmap += width;
}
}
void
D_EndDirectRect (int x, int y, int width, int height)
{
if (!screen)
return;
if (x < 0)
x = screen->w + x - 1;
SDL_UpdateRect (screen, x, y, width, height);
}
VISIBLE void
VID_LockBuffer (void)
{
}
VISIBLE void
VID_UnlockBuffer (void)
{
}

View file

@ -1,188 +0,0 @@
/*
vid_sgl.c
Video driver for OpenGL-using versions of SDL
Copyright (C) 1996-1997 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:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include <SDL.h>
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/qargs.h"
#include "QF/qendian.h"
#include "QF/sys.h"
#include "QF/vid.h"
#include "QF/GL/funcs.h"
#include "QF/GL/qf_vid.h"
#include "compat.h"
#include "context_sdl.h"
#ifdef _WIN32 // FIXME: evil hack to get full DirectSound support with SDL
# include <windows.h>
# include <SDL_syswm.h>
HWND mainwindow;
#endif
#define WARP_WIDTH 320
#define WARP_HEIGHT 200
int VID_options_items = 1;
SDL_Surface *screen = NULL;
void *
QFGL_GetProcAddress (void *handle, const char *name)
{
return SDL_GL_GetProcAddress (name);
}
void *
QFGL_LoadLibrary (void)
{
if (SDL_GL_LoadLibrary (gl_driver->string) != 0)
Sys_Error ("Couldn't load OpenGL library %s!", gl_driver->string);
return NULL;
}
static void
GL_Init (void)
{
GL_Init_Common ();
}
VISIBLE void
GL_EndRendering (void)
{
qfglFinish ();
SDL_GL_SwapBuffers ();
}
void
VID_Init (byte *palette, byte *colormap)
{
Uint32 flags = SDL_OPENGL;
int i, j;
// Initialize the SDL library
if (SDL_Init (SDL_INIT_VIDEO) < 0)
Sys_Error ("Couldn't initialize SDL: %s", SDL_GetError ());
GLF_Init ();
VID_GetWindowSize (640, 480);
vid.maxwarpwidth = WARP_WIDTH;
vid.maxwarpheight = WARP_HEIGHT;
vid.colormap8 = vid_colormap = colormap;
vid.fullbright = 256 - vid.colormap8[256 * VID_GRADES];
// Check if we want fullscreen
if (vid_fullscreen->int_val) {
flags |= SDL_FULLSCREEN;
#ifndef _WIN32 // Don't annoy Mesa/3dfx folks
// FIXME: Maybe this could be put in a different spot, but I don't
// know where. Anyway, it's to work around a 3Dfx Glide bug.
// Cvar_SetValue (in_grab, 1); // Needs #include "QF/input.h"
putenv ((char *)"MESA_GLX_FX=fullscreen");
} else {
putenv ((char *)"MESA_GLX_FX=window");
#endif
}
// Setup GL Attributes
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
// SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE, 0); // Try for 0, 8
// SDL_GL_SetAttribute (SDL_GL_STEREO, 1); // Someday...
for (i = 0; i < 5; i++) {
int k;
int color[5] = {32, 24, 16, 15, 0};
int rgba[5][4] = {
{8, 8, 8, 0},
{8, 8, 8, 8},
{5, 6, 5, 0},
{5, 5, 5, 0},
{5, 5, 5, 1},
};
SDL_GL_SetAttribute (SDL_GL_RED_SIZE, rgba[i][0]);
SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, rgba[i][1]);
SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, rgba[i][2]);
SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, rgba[i][3]);
for (j = 0; j < 5; j++) {
for (k = 32; k >= 16; k -= 8) {
SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, k);
if ((screen = SDL_SetVideoMode (vid.width, vid.height,
color[j], flags)))
goto success;
}
}
}
Sys_Error ("Couldn't set video mode: %s", SDL_GetError ());
SDL_Quit ();
success:
vid.numpages = 2;
GL_Init ();
VID_SDL_GammaCheck ();
VID_InitGamma (palette);
VID_SetPalette (vid.palette);
VID_Init8bitPalette (); // Check for 3DFX Extensions and initialize them.
Sys_MaskPrintf (SYS_VID, "Video mode %dx%d initialized.\n",
vid.width, vid.height);
vid.initialized = true;
SDL_ShowCursor (0); // hide the mouse pointer
#ifdef _WIN32
// FIXME: EVIL thing - but needed for win32 until
// SDL_sound works better - without this DirectSound fails.
// SDL_GetWMInfo(&info);
// mainwindow=info.window;
mainwindow=GetActiveWindow();
#endif
vid.recalc_refdef = 1; // force a surface cache flush
}