cl_video.c

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 1997-2001 Id Software, Inc.
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018 See the GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 
00024 */
00025 
00026 #include "client.h"
00027 #include "battlescape/cl_view.h"
00028 #include "renderer/r_main.h"
00029 #include "renderer/r_sdl.h"
00030 #include "ui/ui_main.h"
00031 #include "cl_game.h"
00032 
00033 viddef_t viddef;    /* global video state; used by other modules */
00034 
00035 cvar_t *vid_strech;
00036 cvar_t *vid_fullscreen;
00037 cvar_t *vid_mode;
00038 cvar_t *vid_grabmouse;
00039 cvar_t *vid_gamma;
00040 cvar_t *vid_ignoregamma;
00041 static cvar_t *vid_height;
00042 static cvar_t *vid_width;
00043 
00047 static const vidmode_t vid_modes[] =
00048 {
00049     {  320,  240,  0 },
00050     {  400,  300,  1 },
00051     {  512,  384,  2 },
00052     {  640,  480,  3 },
00053     {  800,  600,  4 },
00054     {  960,  720,  5 },
00055     { 1024,  768,  6 },
00056     { 1152,  864,  7 },
00057     { 1280, 1024,  8 },
00058     { 1600, 1200,  9 },
00059     { 2048, 1536, 10 },
00060     { 1024,  480, 11 }, /* Sony VAIO Pocketbook */
00061     { 1152,  768, 12 }, /* Apple TiBook */
00062     { 1280,  854, 13 }, /* Apple TiBook */
00063     {  640,  400, 14 }, /* generic 16:10 widescreen*/
00064     {  800,  500, 15 }, /* as found modern */
00065     { 1024,  640, 16 }, /* notebooks */
00066     { 1280,  800, 17 },
00067     { 1680, 1050, 18 },
00068     { 1920, 1200, 19 },
00069     { 1400, 1050, 20 }, /* samsung x20 */
00070     { 1440,  900, 21 },
00071     { 1024,  600, 22 } /* EEE PC */
00072 };
00073 
00077 int VID_GetModeNums (void)
00078 {
00079     if (r_sdl_config.numModes > 0)
00080         return r_sdl_config.numModes;
00081     return lengthof(vid_modes);
00082 }
00083 
00084 qboolean VID_GetModeInfo (int modeIndex, vidmode_t *modeInfo)
00085 {
00086     if (modeIndex < 0) {
00087         modeInfo->width = vid_width->integer;
00088         modeInfo->height = vid_height->integer;
00089     } else if (modeIndex < VID_GetModeNums()) {
00090         int width, height;
00091         if (r_sdl_config.numModes > 0) {
00092             width = r_sdl_config.modes[modeIndex]->w;
00093             height = r_sdl_config.modes[modeIndex]->h;
00094         } else {
00095             width = vid_modes[modeIndex].width;
00096             height = vid_modes[modeIndex].height;
00097         }
00098         modeInfo->width = width;
00099         modeInfo->height = height;
00100     } else {
00101         return qfalse;
00102     }
00103 
00104     return qtrue;
00105 }
00106 
00110 void VID_Restart_f (void)
00111 {
00112     refdef.ready = qfalse;
00113 
00114     Com_Printf("renderer restart\n");
00115 
00116     R_Shutdown();
00117     R_Init();
00118     UI_Reinit();
00120     CL_ViewPrecacheModels();
00121 
00123     /*CL_ViewLoadMedia();*/
00124     GAME_ReloadMode();
00125 }
00126 
00127 static qboolean CL_CvarCheckVidGamma (cvar_t *cvar)
00128 {
00129     return Cvar_AssertValue(cvar, 0.1, 3.0, qfalse);
00130 }
00131 
00132 static qboolean CL_CvarCheckVidMode (cvar_t *cvar)
00133 {
00134     return Cvar_AssertValue(cvar, -1, VID_GetModeNums(), qtrue);
00135 }
00136 
00140 void VID_Init (void)
00141 {
00142     vid_strech = Cvar_Get("vid_strech", "0", CVAR_ARCHIVE, "Backward compatibility to stretch the screen with a 4:3 ratio");
00143     vid_fullscreen = Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE, "Run the game in fullscreen mode");
00144     vid_mode = Cvar_Get("vid_mode", "-1", CVAR_ARCHIVE, "The video mode - set to -1 and use vid_width and vid_height to use a custom resolution");
00145     Cvar_SetCheckFunction("vid_mode", CL_CvarCheckVidMode);
00146     vid_grabmouse = Cvar_Get("vid_grabmouse", "0", CVAR_ARCHIVE, "Grab the mouse in the game window - open the console to switch back to your desktop via Alt+Tab");
00147     vid_gamma = Cvar_Get("vid_gamma", "1", CVAR_ARCHIVE, "Controls the gamma settings");
00148     vid_ignoregamma = Cvar_Get("vid_ignoregamma", "0", CVAR_ARCHIVE, "Don't control the gamma settings if set to 1");
00149     Cvar_SetCheckFunction("vid_gamma", CL_CvarCheckVidGamma);
00150     vid_height = Cvar_Get("vid_height", "768", CVAR_ARCHIVE, "Custom video height - set vid_mode to -1 to use this");
00151     vid_width = Cvar_Get("vid_width", "1024", CVAR_ARCHIVE, "Custom video width - set vid_mode to -1 to use this");
00152 
00153     Cmd_AddCommand("vid_restart", VID_Restart_f, "Restart the renderer - or change the resolution");
00154 
00155     /* memory pools */
00156     vid_genericPool = Mem_CreatePool("Vid: Generic");
00157     vid_imagePool = Mem_CreatePool("Vid: Image system");
00158     vid_lightPool = Mem_CreatePool("Vid: Light system");
00159     vid_modelPool = Mem_CreatePool("Vid: Model system");
00160 
00161     /* Start the graphics mode */
00162     R_Init();
00163 }

Generated by  doxygen 1.6.2