icculus quake2 doxygen  1.0 dev
vid.h File Reference

Go to the source code of this file.

Classes

struct  vrect_s
 
struct  viddef_t
 

Typedefs

typedef struct vrect_s vrect_t
 

Functions

void VID_Init (void)
 
void VID_Shutdown (void)
 
void VID_CheckChanges (void)
 
void VID_MenuInit (void)
 
void VID_MenuDraw (void)
 
const char * VID_MenuKey (int)
 

Variables

viddef_t viddef
 

Typedef Documentation

◆ vrect_t

typedef struct vrect_s vrect_t

Function Documentation

◆ VID_CheckChanges()

void VID_CheckChanges ( void  )

Definition at line 641 of file vid_dll.c.

642 {
643  char name[100];
644 
645  if ( win_noalttab->modified )
646  {
647  if ( win_noalttab->value )
648  {
650  }
651  else
652  {
654  }
655  win_noalttab->modified = false;
656  }
657 
658  if ( vid_ref->modified )
659  {
660  cl.force_refdef = true; // can't use a paused refdef
661  S_StopAllSounds();
662  }
663  while (vid_ref->modified)
664  {
665  /*
666  ** refresh has changed
667  */
668  vid_ref->modified = false;
669  vid_fullscreen->modified = true;
670  cl.refresh_prepped = false;
671  cls.disable_screen = true;
672 
673  Com_sprintf( name, sizeof(name), "ref_%s.dll", vid_ref->string );
674  if ( !VID_LoadRefresh( name ) )
675  {
676  if ( strcmp (vid_ref->string, "soft") == 0 )
677  Com_Error (ERR_FATAL, "Couldn't fall back to software refresh!");
678  Cvar_Set( "vid_ref", "soft" );
679 
680  /*
681  ** drop the console if we fail to load a refresh
682  */
683  if ( cls.key_dest != key_console )
684  {
686  }
687  }
688  cls.disable_screen = false;
689  }
690 
691  /*
692  ** update our window position
693  */
694  if ( vid_xpos->modified || vid_ypos->modified )
695  {
696  if (!vid_fullscreen->value)
698 
699  vid_xpos->modified = false;
700  vid_ypos->modified = false;
701  }
702 }

Referenced by CL_Frame(), and VID_Init().

◆ VID_Init()

void VID_Init ( void  )

Definition at line 709 of file vid_dll.c.

710 {
711  /* Create the video variables so we know how to start the graphics drivers */
712  vid_ref = Cvar_Get ("vid_ref", "soft", CVAR_ARCHIVE);
713  vid_xpos = Cvar_Get ("vid_xpos", "3", CVAR_ARCHIVE);
714  vid_ypos = Cvar_Get ("vid_ypos", "22", CVAR_ARCHIVE);
715  vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE);
716  vid_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE );
717  win_noalttab = Cvar_Get( "win_noalttab", "0", CVAR_ARCHIVE );
718 
719  /* Add some console commands that we want to handle */
720  Cmd_AddCommand ("vid_restart", VID_Restart_f);
721  Cmd_AddCommand ("vid_front", VID_Front_f);
722 
723  /*
724  ** this is a gross hack but necessary to clamp the mode for 3Dfx
725  */
726 #if 0
727  {
728  cvar_t *gl_driver = Cvar_Get( "gl_driver", "opengl32", 0 );
729  cvar_t *gl_mode = Cvar_Get( "gl_mode", "3", 0 );
730 
731  if ( stricmp( gl_driver->string, "3dfxgl" ) == 0 )
732  {
733  Cvar_SetValue( "gl_mode", 3 );
734  viddef.width = 640;
735  viddef.height = 480;
736  }
737  }
738 #endif
739 
740  /* Disable the 3Dfx splash screen */
741  putenv("FX_GLIDE_NO_SPLASH=0");
742 
743  /* Start the graphics mode and load refresh DLL */
745 }

Referenced by CL_Init().

◆ VID_MenuDraw()

void VID_MenuDraw ( void  )

Definition at line 405 of file vid_menu.c.

406 {
407  int w, h;
408 
409  if ( s_current_menu_index == 0 )
411  else
413 
414  /*
415  ** draw the banner
416  */
417  re.DrawGetPicSize( &w, &h, "m_banner_video" );
418  re.DrawPic( viddef.width / 2 - w / 2, viddef.height /2 - 110, "m_banner_video" );
419 
420  /*
421  ** move cursor to a reasonable starting position
422  */
424 
425  /*
426  ** draw the menu
427  */
429 }

Referenced by M_Menu_Video_f().

◆ VID_MenuInit()

void VID_MenuInit ( void  )

Definition at line 209 of file vid_menu.c.

210 {
211  static const char *resolutions[] =
212  {
213  "[320 240 ]",
214  "[400 300 ]",
215  "[512 384 ]",
216  "[640 480 ]",
217  "[800 600 ]",
218  "[960 720 ]",
219  "[1024 768 ]",
220  "[1152 864 ]",
221  "[1280 960 ]",
222  "[1600 1200]",
223  "[2048 1536]",
224  0
225  };
226  static const char *refs[] =
227  {
228  "[software ]",
229  "[default OpenGL]",
230  "[3Dfx OpenGL ]",
231  "[PowerVR OpenGL]",
232 // "[Rendition OpenGL]",
233  0
234  };
235  static const char *yesno_names[] =
236  {
237  "no",
238  "yes",
239  0
240  };
241  int i;
242 
243  if ( !gl_driver )
244  gl_driver = Cvar_Get( "gl_driver", "opengl32", 0 );
245  if ( !gl_picmip )
246  gl_picmip = Cvar_Get( "gl_picmip", "0", 0 );
247  if ( !gl_mode )
248  gl_mode = Cvar_Get( "gl_mode", "3", 0 );
249  if ( !sw_mode )
250  sw_mode = Cvar_Get( "sw_mode", "0", 0 );
251  if ( !gl_ext_palettedtexture )
252  gl_ext_palettedtexture = Cvar_Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE );
253  if ( !gl_finish )
254  gl_finish = Cvar_Get( "gl_finish", "0", CVAR_ARCHIVE );
255 
256  if ( !sw_stipplealpha )
257  sw_stipplealpha = Cvar_Get( "sw_stipplealpha", "0", CVAR_ARCHIVE );
258 
261 
262  if ( !scr_viewsize )
263  scr_viewsize = Cvar_Get ("viewsize", "100", CVAR_ARCHIVE);
264 
267 
268  if ( strcmp( vid_ref->string, "soft" ) == 0 )
269  {
272  }
273  else if ( strcmp( vid_ref->string, "gl" ) == 0 )
274  {
276  if ( strcmp( gl_driver->string, "3dfxgl" ) == 0 )
278  else if ( strcmp( gl_driver->string, "pvrgl" ) == 0 )
280  else if ( strcmp( gl_driver->string, "opengl32" ) == 0 )
282  else
283 // s_ref_list[s_current_menu_index].curvalue = REF_VERITE;
285  }
286 
287  s_software_menu.x = viddef.width * 0.50;
289  s_opengl_menu.x = viddef.width * 0.50;
290  s_opengl_menu.nitems = 0;
291 
292  for ( i = 0; i < 2; i++ )
293  {
295  s_ref_list[i].generic.name = "driver";
296  s_ref_list[i].generic.x = 0;
297  s_ref_list[i].generic.y = 0;
299  s_ref_list[i].itemnames = refs;
300 
302  s_mode_list[i].generic.name = "video mode";
303  s_mode_list[i].generic.x = 0;
304  s_mode_list[i].generic.y = 10;
305  s_mode_list[i].itemnames = resolutions;
306 
310  s_screensize_slider[i].generic.name = "screen size";
314 
318  s_brightness_slider[i].generic.name = "brightness";
322  s_brightness_slider[i].curvalue = ( 1.3 - vid_gamma->value + 0.5 ) * 10;
323 
325  s_fs_box[i].generic.x = 0;
326  s_fs_box[i].generic.y = 40;
327  s_fs_box[i].generic.name = "fullscreen";
328  s_fs_box[i].itemnames = yesno_names;
330 
332  s_defaults_action[i].generic.name = "reset to defaults";
336 
338  s_cancel_action[i].generic.name = "cancel";
339  s_cancel_action[i].generic.x = 0;
340  s_cancel_action[i].generic.y = 100;
342  }
343 
345  s_stipple_box.generic.x = 0;
346  s_stipple_box.generic.y = 60;
347  s_stipple_box.generic.name = "stipple alpha";
349  s_stipple_box.itemnames = yesno_names;
350 
352  s_tq_slider.generic.x = 0;
353  s_tq_slider.generic.y = 60;
354  s_tq_slider.generic.name = "texture quality";
355  s_tq_slider.minvalue = 0;
356  s_tq_slider.maxvalue = 3;
358 
362  s_paletted_texture_box.generic.name = "8-bit textures";
363  s_paletted_texture_box.itemnames = yesno_names;
365 
367  s_finish_box.generic.x = 0;
368  s_finish_box.generic.y = 80;
369  s_finish_box.generic.name = "sync every frame";
371  s_finish_box.itemnames = yesno_names;
372 
378  Menu_AddItem( &s_software_menu, ( void * ) &s_stipple_box );
379 
385  Menu_AddItem( &s_opengl_menu, ( void * ) &s_tq_slider );
387  Menu_AddItem( &s_opengl_menu, ( void * ) &s_finish_box );
388 
393 
396  s_opengl_menu.x -= 8;
397  s_software_menu.x -= 8;
398 }

Referenced by M_Menu_Video_f(), ResetDefaults(), and VID_LoadRefresh().

◆ VID_MenuKey()

const char* VID_MenuKey ( int  )

Definition at line 436 of file vid_menu.c.

437 {
439  static const char *sound = "misc/menu1.wav";
440 
441  switch ( key )
442  {
443  case K_ESCAPE:
444  ApplyChanges( 0 );
445  return NULL;
446  case K_KP_UPARROW:
447  case K_UPARROW:
448  m->cursor--;
449  Menu_AdjustCursor( m, -1 );
450  break;
451  case K_KP_DOWNARROW:
452  case K_DOWNARROW:
453  m->cursor++;
454  Menu_AdjustCursor( m, 1 );
455  break;
456  case K_KP_LEFTARROW:
457  case K_LEFTARROW:
458  Menu_SlideItem( m, -1 );
459  break;
460  case K_KP_RIGHTARROW:
461  case K_RIGHTARROW:
462  Menu_SlideItem( m, 1 );
463  break;
464  case K_KP_ENTER:
465  case K_ENTER:
466  if ( !Menu_SelectItem( m ) )
467  ApplyChanges( NULL );
468  break;
469  }
470 
471  return sound;
472 }

Referenced by M_Menu_Video_f().

◆ VID_Shutdown()

void VID_Shutdown ( void  )

Definition at line 752 of file vid_dll.c.

753 {
754  if ( reflib_active )
755  {
756  re.Shutdown ();
757  VID_FreeReflib ();
758  }
759 }

Referenced by CL_Shutdown().

Variable Documentation

◆ viddef

REF_SOFT
#define REF_SOFT
Definition: vid_menu.c:23
VID_Restart_f
void VID_Restart_f(void)
Definition: vid_dll.c:463
K_DOWNARROW
@ K_DOWNARROW
Definition: keys.h:34
REF_OPENGL
#define REF_OPENGL
Definition: vid_menu.c:24
K_KP_UPARROW
@ K_KP_UPARROW
Definition: keys.h:61
VID_Front_f
void VID_Front_f(void)
Definition: vid_dll.c:468
client_static_t::disable_screen
float disable_screen
Definition: client.h:232
reflib_active
qboolean reflib_active
Definition: vid_dll.c:51
menucommon_s::type
int type
Definition: qmenu.h:66
gl_driver
static cvar_t * gl_driver
Definition: vid_menu.c:35
cvar_s::modified
qboolean modified
Definition: q_shared.h:323
menuslider_s::generic
menucommon_s generic
Definition: qmenu.h:95
s_fs_box
static menulist_s s_fs_box[2]
Definition: vid_menu.c:65
VID_UpdateWindowPosAndSize
void VID_UpdateWindowPosAndSize(int x, int y)
Definition: vid_dll.c:513
SOFTWARE_MENU
#define SOFTWARE_MENU
Definition: vid_menu.c:52
s_paletted_texture_box
static menulist_s s_paletted_texture_box
Definition: vid_menu.c:67
cvar_s::string
char * string
Definition: q_shared.h:320
viddef_t::width
int width
Definition: vid.h:29
i
int i
Definition: q_shared.c:305
K_KP_LEFTARROW
@ K_KP_LEFTARROW
Definition: keys.h:63
scr_viewsize
cvar_t * scr_viewsize
Definition: cl_scrn.c:47
menucommon_s::x
int x
Definition: qmenu.h:68
Con_ToggleConsole_f
void Con_ToggleConsole_f(void)
Definition: console.c:75
viddef_t::height
int height
Definition: vid.h:29
vid_gamma
cvar_t * vid_gamma
Definition: vid_dll.c:42
menuaction_s::generic
menucommon_s generic
Definition: qmenu.h:115
Cvar_Get
cvar_t * Cvar_Get(char *var_name, char *var_value, int flags)
Definition: cvar.c:127
WIN_DisableAltTab
static void WIN_DisableAltTab(void)
Definition: vid_dll.c:68
Menu_Center
void Menu_Center(menuframework_s *menu)
Definition: qmenu.c:340
cvar_s
Definition: q_shared.h:317
K_ENTER
@ K_ENTER
Definition: keys.h:26
client_state_t::force_refdef
qboolean force_refdef
Definition: client.h:120
menuslider_s::minvalue
float minvalue
Definition: qmenu.h:97
viddef
viddef_t viddef
Definition: vid_dll.c:49
vid_fullscreen
cvar_t * vid_fullscreen
Definition: vid_dll.c:46
s_ref_list
static menulist_s s_ref_list[2]
Definition: vid_menu.c:61
DriverCallback
static void DriverCallback(void *unused)
Definition: vid_menu.c:72
K_LEFTARROW
@ K_LEFTARROW
Definition: keys.h:35
K_ESCAPE
@ K_ESCAPE
Definition: keys.h:27
Menu_Draw
void Menu_Draw(menuframework_s *menu)
Definition: qmenu.c:350
menucommon_s::y
int y
Definition: qmenu.h:68
s_mode_list
static menulist_s s_mode_list[2]
Definition: vid_menu.c:60
Menu_SelectItem
qboolean Menu_SelectItem(menuframework_s *s)
Definition: qmenu.c:486
gl_mode
static cvar_t * gl_mode
Definition: vid_menu.c:34
Menu_AdjustCursor
void Menu_AdjustCursor(menuframework_s *m, int dir)
Definition: qmenu.c:292
K_KP_RIGHTARROW
@ K_KP_RIGHTARROW
Definition: keys.h:65
Cmd_AddCommand
void Cmd_AddCommand(char *cmd_name, xcommand_t function)
Definition: cmd.c:691
menucommon_s::callback
void(* callback)(void *self)
Definition: qmenu.h:76
client_state_t::refresh_prepped
qboolean refresh_prepped
Definition: client.h:118
gl_picmip
static cvar_t * gl_picmip
Definition: vid_menu.c:36
s_stipple_box
static menulist_s s_stipple_box
Definition: vid_menu.c:66
menuslider_s::maxvalue
float maxvalue
Definition: qmenu.h:98
CVAR_ARCHIVE
#define CVAR_ARCHIVE
Definition: q_shared.h:309
_tag_menuframework::cursor
int cursor
Definition: qmenu.h:52
s_tq_slider
static menuslider_s s_tq_slider
Definition: vid_menu.c:62
cvar_s::value
float value
Definition: q_shared.h:324
Cvar_SetValue
void Cvar_SetValue(char *var_name, float value)
Definition: cvar.c:317
key_console
@ key_console
Definition: client.h:220
NULL
#define NULL
Definition: q_shared.h:60
refexport_t::DrawGetPicSize
void(* DrawGetPicSize)(int *w, int *h, char *name)
Definition: ref.h:195
s_current_menu_index
static int s_current_menu_index
Definition: vid_menu.c:58
s_brightness_slider
static menuslider_s s_brightness_slider[2]
Definition: vid_menu.c:64
BrightnessCallback
static void BrightnessCallback(void *s)
Definition: vid_menu.c:96
MTYPE_ACTION
#define MTYPE_ACTION
Definition: qmenu.h:27
CancelChanges
static void CancelChanges(void *unused)
Definition: vid_menu.c:199
Com_Error
void Com_Error(int code, char *fmt,...)
Definition: common.c:203
VID_FreeReflib
void VID_FreeReflib(void)
Definition: vid_dll.c:544
refexport_t::DrawPic
void(* DrawPic)(int x, int y, char *name)
Definition: ref.h:196
K_KP_ENTER
@ K_KP_ENTER
Definition: keys.h:69
name
cvar_t * name
Definition: cl_main.c:94
ApplyChanges
static void ApplyChanges(void *unused)
Definition: vid_menu.c:118
_tag_menuframework
Definition: qmenu.h:49
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:735
_tag_menuframework::nitems
int nitems
Definition: qmenu.h:54
menulist_s::curvalue
int curvalue
Definition: qmenu.h:108
REF_POWERVR
#define REF_POWERVR
Definition: vid_menu.c:26
gl_finish
static cvar_t * gl_finish
Definition: vid_menu.c:38
WIN_EnableAltTab
static void WIN_EnableAltTab(void)
Definition: vid_dll.c:87
re
refexport_t re
Definition: vid_dll.c:31
s_finish_box
static menulist_s s_finish_box
Definition: vid_menu.c:68
MTYPE_SLIDER
#define MTYPE_SLIDER
Definition: qmenu.h:25
ResetDefaults
static void ResetDefaults(void *unused)
Definition: vid_menu.c:113
s_software_menu
static menuframework_s s_software_menu
Definition: vid_menu.c:55
_tag_menuframework::x
int x
Definition: qmenu.h:51
menuslider_s::curvalue
float curvalue
Definition: qmenu.h:99
vid_ref
cvar_t * vid_ref
Definition: vid_dll.c:43
VID_CheckChanges
void VID_CheckChanges(void)
Definition: vid_dll.c:641
vid_gamma
cvar_t * vid_gamma
Definition: vid_dll.c:42
s_opengl_menu
static menuframework_s s_opengl_menu
Definition: vid_menu.c:56
menucommon_s::name
const char * name
Definition: qmenu.h:67
vid_fullscreen
cvar_t * vid_fullscreen
Definition: vid_dll.c:46
K_UPARROW
@ K_UPARROW
Definition: keys.h:33
s_current_menu
static menuframework_s * s_current_menu
Definition: vid_menu.c:57
menulist_s::itemnames
const char ** itemnames
Definition: qmenu.h:110
MTYPE_SPINCONTROL
#define MTYPE_SPINCONTROL
Definition: qmenu.h:28
gl_ext_palettedtexture
static cvar_t * gl_ext_palettedtexture
Definition: vid_menu.c:37
refexport_t::Shutdown
void(* Shutdown)(void)
Definition: ref.h:160
vid_xpos
cvar_t * vid_xpos
Definition: vid_dll.c:44
Menu_SlideItem
void Menu_SlideItem(menuframework_s *s, int dir)
Definition: qmenu.c:515
Cvar_Set
cvar_t * Cvar_Set(char *var_name, char *value)
Definition: cvar.c:278
S_StopAllSounds
void S_StopAllSounds(void)
Definition: snd_dma.c:795
vid_ref
cvar_t * vid_ref
Definition: vid_dll.c:43
client_static_t::key_dest
keydest_t key_dest
Definition: client.h:225
s_cancel_action
static menuaction_s s_cancel_action[2]
Definition: vid_menu.c:69
w
GLdouble GLdouble GLdouble w
Definition: qgl_win.c:291
sw_stipplealpha
static cvar_t * sw_stipplealpha
Definition: vid_menu.c:41
OPENGL_MENU
#define OPENGL_MENU
Definition: vid_menu.c:53
K_RIGHTARROW
@ K_RIGHTARROW
Definition: keys.h:36
cls
client_static_t cls
Definition: cl_main.c:105
REF_3DFX
#define REF_3DFX
Definition: vid_menu.c:25
s_defaults_action
static menuaction_s s_defaults_action[2]
Definition: vid_menu.c:70
VID_LoadRefresh
qboolean VID_LoadRefresh(char *name)
Definition: vid_dll.c:558
vid_ypos
cvar_t * vid_ypos
Definition: vid_dll.c:45
s_screensize_slider
static menuslider_s s_screensize_slider[2]
Definition: vid_menu.c:63
menulist_s::generic
menucommon_s generic
Definition: qmenu.h:106
Menu_AddItem
void Menu_AddItem(menuframework_s *menu, void *item)
Definition: qmenu.c:270
cl
client_state_t cl
Definition: cl_main.c:106
ScreenSizeCallback
static void ScreenSizeCallback(void *s)
Definition: vid_menu.c:89
K_KP_DOWNARROW
@ K_KP_DOWNARROW
Definition: keys.h:67
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1236
sw_mode
static cvar_t * sw_mode
Definition: vid_menu.c:40
win_noalttab
cvar_t * win_noalttab
Definition: vid_dll.c:33