4 OpenGL device driver for 3Dfx chipsets running Linux
6 Copyright (C) 1996-1997 Id Software, Inc.
7 Copyright (C) 1999,2000 Nelson Rush.
8 Copyright (C) 1999,2000 contributors of the QuakeForge project
9 Please see the file "AUTHORS" for a list of contributors
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 See the GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to:
25 Free Software Foundation, Inc.
26 59 Temple Place - Suite 330
27 Boston, MA 02111-1307, USA
45 #include <GL/fxmesa.h>
46 #include <glide/sst1vid.h>
49 viddef_t vid; // global video state
51 static void *dlhand = NULL;
53 static fxMesaContext fc = NULL;
54 static int scr_width, scr_height;
56 int VID_options_items = 0;
58 /*-----------------------------------------------------------------------*/
60 const char *gl_vendor;
61 const char *gl_renderer;
62 const char *gl_version;
63 const char *gl_extensions;
65 /*-----------------------------------------------------------------------*/
66 void D_BeginDirectRect (int x, int y, qbyte *pbitmap, int width, int height)
70 void D_EndDirectRect (int x, int y, int width, int height)
74 void VID_Shutdown(void)
79 fxMesaDestroyContext(fc);
82 void signal_handler(int sig)
84 printf("Received signal %d, exiting...\n", sig);
92 signal(SIGHUP, signal_handler);
93 signal(SIGINT, signal_handler);
94 signal(SIGQUIT, signal_handler);
95 signal(SIGILL, signal_handler);
96 signal(SIGTRAP, signal_handler);
97 signal(SIGBUS, signal_handler);
98 signal(SIGSEGV, signal_handler);
99 signal(SIGTERM, signal_handler);
102 typedef void (GLAPIENTRY *gl3DfxSetDitherModeEXT_FUNC) (GrDitherMode_t mode);
104 void VID_SetupDithering(void)
106 Con_Printf ("Dithering: ");
108 dlhand = dlopen (NULL, RTLD_LAZY);
110 if (dlhand == NULL) {
111 Con_SafePrintf ("unable to set.\n");
115 if (strstr(gl_extensions, "3DFX_set_dither_mode")) {
116 gl3DfxSetDitherModeEXT_FUNC dither_select = NULL;
118 dither_select = (void *) dlsym(dlhand, "gl3DfxSetDitherModeEXT");
120 if (COM_CheckParm ("-dither_2x2")) {
121 dither_select(GR_DITHER_2x2);
122 Con_Printf ("2x2.\n");
123 } else if (COM_CheckParm ("-dither_4x4")) {
124 dither_select(GR_DITHER_4x4);
125 Con_Printf ("4x4.\n");
127 qglDisable(GL_DITHER);
128 Con_Printf ("disabled.\n");
140 void VID_GetWindowSize (int *x, int *y, int *width, int *height)
144 *height = scr_height;
147 void VID_Finish (void)
149 if (r_render.integer)
156 static int resolutions[][3]={
157 { 320, 200, GR_RESOLUTION_320x200 },
158 { 320, 240, GR_RESOLUTION_320x240 },
159 { 400, 256, GR_RESOLUTION_400x256 },
160 { 400, 300, GR_RESOLUTION_400x300 },
161 { 512, 256, GR_RESOLUTION_512x256 },
162 { 512, 384, GR_RESOLUTION_512x384 },
163 { 640, 200, GR_RESOLUTION_640x200 },
164 { 640, 350, GR_RESOLUTION_640x350 },
165 { 640, 400, GR_RESOLUTION_640x400 },
166 { 640, 480, GR_RESOLUTION_640x480 },
167 { 800, 600, GR_RESOLUTION_800x600 },
168 { 856, 480, GR_RESOLUTION_856x480 },
169 { 960, 720, GR_RESOLUTION_960x720 },
170 #ifdef GR_RESOLUTION_1024x768
171 { 1024, 768, GR_RESOLUTION_1024x768 },
173 #ifdef GR_RESOLUTION_1152x864
174 { 1152, 864, GR_RESOLUTION_1152x864 },
176 #ifdef GR_RESOLUTION_1280x960
177 { 1280, 960, GR_RESOLUTION_1280x960 },
179 #ifdef GR_RESOLUTION_1280x1024
180 { 1280, 1024, GR_RESOLUTION_1280x1024 },
182 #ifdef GR_RESOLUTION_1600x1024
183 { 1600, 1024, GR_RESOLUTION_1600x1024 },
185 #ifdef GR_RESOLUTION_1600x1200
186 { 1600, 1200, GR_RESOLUTION_1600x1200 },
188 #ifdef GR_RESOLUTION_1792x1344
189 { 1792, 1344, GR_RESOLUTION_1792x1344 },
191 #ifdef GR_RESOLUTION_1856x1392
192 { 1856, 1392, GR_RESOLUTION_1856x1392 },
194 #ifdef GR_RESOLUTION_1920x1440
195 { 1920, 1440, GR_RESOLUTION_1920x1440 },
197 #ifdef GR_RESOLUTION_2048x1536
198 { 2048, 1536, GR_RESOLUTION_2048x1536 },
200 #ifdef GR_RESOLUTION_2048x2048
201 { 2048, 2048, GR_RESOLUTION_2048x2048 }
205 #define NUM_RESOLUTIONS (sizeof(resolutions)/(sizeof(int)*3))
209 findres(int *width, int *height)
213 for(i=0; i < NUM_RESOLUTIONS; i++) {
214 if((*width <= resolutions[i][0]) &&
215 (*height <= resolutions[i][1])) {
216 *width = resolutions[i][0];
217 *height = resolutions[i][1];
218 return resolutions[i][2];
224 return GR_RESOLUTION_640x480;
227 int VID_SetGamma(float prescale, float gamma, float scale, float base)
236 int width = 640, height = 480;
238 // set vid parameters
239 attribs[0] = FXMESA_DOUBLEBUFFER;
240 attribs[1] = FXMESA_ALPHA_SIZE;
242 attribs[3] = FXMESA_DEPTH_SIZE;
244 attribs[5] = FXMESA_NONE;
246 if ((i = COM_CheckParm("-width")) != 0)
247 width = atoi(com_argv[i+1]);
248 if ((i = COM_CheckParm("-height")) != 0)
249 height = atoi(com_argv[i+1]);
251 if ((i = COM_CheckParm("-conwidth")) != 0)
252 vid.conwidth = atoi(com_argv[i+1]);
256 vid.conwidth &= 0xfff8; // make it a multiple of eight
258 if (vid.conwidth < 320)
261 // pick a conheight that matches with correct aspect
262 vid.conheight = vid.conwidth*3 / 4;
264 if ((i = COM_CheckParm("-conheight")) != 0)
265 vid.conheight = atoi(com_argv[i+1]);
266 if (vid.conheight < 200)
269 fc = fxMesaCreateContext(0, findres(&width, &height), GR_REFRESH_75Hz,
272 Sys_Error("Unable to create 3DFX context.\n");
277 fxMesaMakeCurrent(fc);
279 if (vid.conheight > height)
280 vid.conheight = height;
281 if (vid.conwidth > width)
282 vid.conwidth = width;
284 InitSig(); // trap evil signals
288 VID_SetupDithering(); // 3DFX specific
290 Con_SafePrintf ("Video mode %dx%d initialized.\n", width, height);
293 void VID_ExtraOptionDraw(unsigned int options_draw_cursor)
297 void VID_ExtraOptionCmd(int option_cursor)
301 void VID_SetCaption (char *text)
305 void VID_HandlePause (qboolean pause)