create VID_GetWindowSize in vid.c and use it elsewhere for window size

selection.  in_x11.c just had refs to scr_width and scr_height removed.
This commit is contained in:
Bill Currie 2000-10-21 07:15:30 +00:00
parent afae879d2e
commit dcd1201131
8 changed files with 161 additions and 101 deletions

View file

@ -101,4 +101,6 @@ qboolean VID_Is8bit(void);
void VID_SetCaption(char *text);
// used to set window caption
void VID_GetWindowSize (int def_w, int def_h);
#endif // _VID_H

View file

@ -145,11 +145,10 @@ if ASM_ARCH
client_ASM= snd_mixa.S cl_math.S sys_x86.S
endif
client_SOURCES= cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c cl_input.c cl_main.c \
cl_misc.c cl_parse.c cl_pred.c cl_tent.c cl_cam.c teamplay.c \
r_view.c wad.c model_alias.c model_sprite.c \
console.c keys.c menu.c nonintel.c skin.c sbar.c \
cl_slist.c $(client_ASM)
client_SOURCES= cl_cam.c cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c cl_input.c \
cl_main.c cl_misc.c cl_parse.c cl_pred.c cl_slist.c cl_tent.c \
console.c keys.c menu.c model_alias.c model_sprite.c nonintel.c \
r_view.c sbar.c skin.c teamplay.c wad.c vid.c $(client_ASM)
#
# Software-rendering clients

View file

@ -400,8 +400,6 @@ IN_Shutdown (void)
x11_close_display();
}
extern int scr_width, scr_height;
void
IN_Init (void)
{

119
source/vid.c Normal file
View file

@ -0,0 +1,119 @@
/*
vid.c
general video driver functions
Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 1999-2000 contributors of the QuakeForge project
Copyright (C) 2000 Marcus Sundberg [mackan@stacken.kth.se]
Copyright (C) 1999,2000 contributors of the QuakeForge project
Please see the file "AUTHORS" for a list of contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#define _BSD
#include <config.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/extensions/XShm.h>
#include "qendian.h"
#include "qargs.h"
#include "quakedef.h"
#include "d_local.h"
#include "keys.h"
#include "cvar.h"
#include "menu.h"
#include "sys.h"
#include "cmd.h"
#include "input.h"
#include "draw.h"
#include "console.h"
#include "client.h"
#include "input.h"
#include "context_x11.h"
#ifdef HAVE_VIDMODE
# include <X11/extensions/xf86vmode.h>
#endif
#include "dga_check.h"
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
extern viddef_t vid; // global video state
int scr_width, scr_height;
cvar_t *vid_width;
cvar_t *vid_height;
void VID_GetWindowSize (int def_w, int def_h)
{
int pnum;
vid_width = Cvar_Get ("vid_width", va("%d",def_w), CVAR_ROM, "screen width");
vid_height = Cvar_Get ("vid_height", va("%d",def_h), CVAR_ROM, "screen height");
if ((pnum=COM_CheckParm("-width"))) {
if (pnum >= com_argc-1)
Sys_Error("VID: -width <width>\n");
Cvar_SetROM (vid_width, com_argv[pnum+1]);
if (!vid_width->int_val)
Sys_Error("VID: Bad window width\n");
}
if ((pnum=COM_CheckParm("-height"))) {
if (pnum >= com_argc-1)
Sys_Error("VID: -height <height>\n");
Cvar_SetROM (vid_height, com_argv[pnum+1]);
if (!vid_height->int_val)
Sys_Error("VID: Bad window height\n");
}
if ((pnum=COM_CheckParm("-winsize"))) {
if (pnum >= com_argc-2)
Sys_Error("VID: -winsize <width> <height>\n");
Cvar_SetROM (vid_width, com_argv[pnum+1]);
Cvar_SetROM (vid_height, com_argv[pnum+2]);
if (!vid_width->int_val || !vid_height->int_val)
Sys_Error("VID: Bad window width/height\n");
}
scr_width = vid.width = vid_width->int_val;
scr_height = vid.height = vid_height->int_val;
}

View file

@ -72,7 +72,7 @@ static void *dlhand = NULL;
#endif
static fxMesaContext fc = NULL;
static int scr_width, scr_height;
extern int scr_width, scr_height;
static qboolean is8bit = 0;
int VID_options_items = 0;
@ -367,11 +367,6 @@ void GL_BeginRendering (int *x, int *y, int *width, int *height)
*x = *y = 0;
*width = scr_width;
*height = scr_height;
// if (!wglMakeCurrent( maindc, baseRC ))
// Sys_Error ("wglMakeCurrent failed");
// glViewport (*x, *y, *width, *height);
}
@ -533,6 +528,8 @@ void VID_Init(unsigned char *palette)
char gldir[MAX_OSPATH];
int width = 640, height = 480;
VID_GetWindowSize (640, 480);
vid.maxwarpwidth = WARP_WIDTH;
vid.maxwarpheight = WARP_HEIGHT;
vid.colormap = host_colormap;
@ -548,11 +545,6 @@ void VID_Init(unsigned char *palette)
attribs[4] = 1;
attribs[5] = FXMESA_NONE;
if ((i = COM_CheckParm("-width")) != 0)
width = atoi(com_argv[i+1]);
if ((i = COM_CheckParm("-height")) != 0)
height = atoi(com_argv[i+1]);
if ((i = COM_CheckParm("-conwidth")) != 0)
vid.conwidth = atoi(com_argv[i+1]);
else
@ -576,9 +568,6 @@ void VID_Init(unsigned char *palette)
if (!fc)
Sys_Error("Unable to create 3DFX context.\n");
scr_width = width;
scr_height = height;
fxMesaMakeCurrent(fc);
if (vid.conheight > height)

View file

@ -384,11 +384,6 @@ void GL_BeginRendering (int *x, int *y, int *width, int *height)
*x = *y = 0;
*width = scr_width;
*height = scr_height;
// if (!wglMakeCurrent( maindc, baseRC ))
// Sys_Error ("wglMakeCurrent failed");
// glViewport (*x, *y, *width, *height);
}
@ -440,7 +435,7 @@ void VID_Init8bitPalette(void)
void VID_Init(unsigned char *palette)
{
int i;
int attrib[] = {
static int attrib[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
@ -450,8 +445,8 @@ void VID_Init(unsigned char *palette)
None
};
char gldir[MAX_OSPATH];
int width = 640, height = 480;
VID_GetWindowSize (640, 480);
vid_mode = Cvar_Get ("vid_mode","0",0,"None");
vid.maxwarpwidth = WARP_WIDTH;
vid.maxwarpheight = WARP_HEIGHT;
@ -462,15 +457,11 @@ void VID_Init(unsigned char *palette)
*/
/* Set vid parameters */
if ((i = COM_CheckParm("-width")) != 0)
width = atoi(com_argv[i+1]);
if ((i = COM_CheckParm("-height")) != 0)
height = atoi(com_argv[i+1]);
if ((i = COM_CheckParm("-conwidth")) != 0)
vid.conwidth = atoi(com_argv[i+1]);
else
vid.conwidth = width;
vid.conwidth = scr_width;
vid.conwidth &= 0xfff8; // make it a multiple of eight
if (vid.conwidth < 320)
@ -536,8 +527,8 @@ void VID_Init(unsigned char *palette)
// hasdga = 0;
}
x11_set_vidmode(width, height);
x11_create_window(width, height);
x11_set_vidmode(scr_width, scr_height);
x11_create_window(scr_width, scr_height);
/* Invisible cursor */
x11_create_null_cursor();
@ -552,13 +543,10 @@ void VID_Init(unsigned char *palette)
glXMakeCurrent(x_disp, x_win, ctx);
scr_width = width;
scr_height = height;
if (vid.conheight > height)
vid.conheight = height;
if (vid.conwidth > width)
vid.conwidth = width;
if (vid.conheight > scr_height)
vid.conheight = scr_height;
if (vid.conwidth > scr_width)
vid.conwidth = scr_width;
vid.width = vid.conwidth;
vid.height = vid.conheight;
@ -579,7 +567,7 @@ void VID_Init(unsigned char *palette)
VID_Init8bitPalette();
Con_Printf ("Video mode %dx%d initialized.\n",
width, height);
scr_width, scr_height);
vid_initialized = true;

View file

@ -71,7 +71,7 @@ unsigned short d_8to16table[256];
unsigned int d_8to24table[256];
unsigned char d_15to8table[65536];
int scr_width, scr_height;
extern int scr_width, scr_height;
int VID_options_items = 1;
int texture_mode = GL_LINEAR;
@ -330,7 +330,8 @@ VID_Init (unsigned char *palette)
Uint32 flags = SDL_OPENGL;
int i;
char gldir[MAX_OSPATH];
int width = 640, height = 480;
VID_GetWindowSize (640, 480);
vid_fullscreen = Cvar_Get ("vid_fullscreen","0",0,"None");
@ -342,11 +343,6 @@ VID_Init (unsigned char *palette)
// Interpret command-line params
// Set vid parameters
if ((i = COM_CheckParm ("-width")) != 0)
width = atoi (com_argv[i+1]);
if ((i = COM_CheckParm ("-height")) != 0)
height = atoi (com_argv[i+1]);
if ((i = COM_CheckParm ("-conwidth")) != 0)
vid.conwidth = atoi(com_argv[i+1]);
else
@ -394,9 +390,6 @@ VID_Init (unsigned char *palette)
SDL_Quit ();
}
scr_width = width;
scr_height = height;
vid.height = vid.conheight = min (vid.conheight, height);
vid.width = vid.conwidth = min (vid.conwidth, width);

View file

@ -105,9 +105,8 @@ static int shiftmask_fl=0;
static long r_shift,g_shift,b_shift;
static unsigned long r_mask,g_mask,b_mask;
//static long X11_highhunkmark;
int scr_width, scr_height;
cvar_t *vid_width;
cvar_t *vid_height;
static void
shiftmask_init( void )
@ -468,19 +467,19 @@ void VID_Init (unsigned char *palette)
int num_visuals;
int template_mask;
VID_GetWindowSize (320, 200);
//plugin_load("in_x11.so");
// Cmd_AddCommand("gamma", VID_Gamma_f);
for (i=0; i < 256; i++) vid_gamma[i] = i;
vid.width = 320;
vid.height = 200;
vid.width = vid_width->int_val;
vid.height = vid_height->int_val;
vid.maxwarpwidth = WARP_WIDTH;
vid.maxwarpheight = WARP_HEIGHT;
vid.numpages = 2;
vid.colormap = host_colormap;
vid.fullbright = 256 - LittleLong (*((int *)vid.colormap + 2048));
//vid.cbits = VID_CBITS;
//vid.grades = VID_GRADES;
srandom(getpid());
@ -490,29 +489,6 @@ void VID_Init (unsigned char *palette)
x11_open_display();
// check for command-line window size
if ((pnum=COM_CheckParm("-winsize")))
{
if (pnum >= com_argc-2)
Sys_Error("VID: -winsize <width> <height>\n");
vid.width = atoi(com_argv[pnum+1]);
vid.height = atoi(com_argv[pnum+2]);
if (!vid.width || !vid.height)
Sys_Error("VID: Bad window width/height\n");
}
if ((pnum=COM_CheckParm("-width"))) {
if (pnum >= com_argc-1)
Sys_Error("VID: -width <width>\n");
vid.width = atoi(com_argv[pnum+1]);
if (!vid.width)
Sys_Error("VID: Bad window width\n");
}
if ((pnum=COM_CheckParm("-height"))) {
if (pnum >= com_argc-1)
Sys_Error("VID: -height <height>\n");
vid.height = atoi(com_argv[pnum+1]);
if (!vid.height)
Sys_Error("VID: Bad window height\n");
}
template_mask = 0;
@ -524,7 +500,6 @@ void VID_Init (unsigned char *palette)
template.visualid = atoi(com_argv[pnum+1]);
template_mask = VisualIDMask;
}
// If not specified, use default visual
else
{
@ -572,9 +547,6 @@ void VID_Init (unsigned char *palette)
/* Invisible cursor */
x11_create_null_cursor();
scr_width = vid.width;
scr_height = vid.height;
if (x_visinfo->depth == 8) {
/* Create and upload the palette */
if (x_visinfo->class == PseudoColor) {