Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

tr_init.c File Reference

#include "tr_local.h"

Include dependency graph for tr_init.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  vidmode_s

Typedefs

typedef vidmode_s vidmode_t

Functions

void AssertCvarRange (cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral)
refexport_tGetRefAPI (int apiVersion, refimport_t *rimp)
void GfxInfo_f (void)
void GL_CheckErrors (void)
void GL_SetDefaultState (void)
void InitOpenGL (void)
qboolean R_GetModeInfo (int *width, int *height, float *windowAspect, int mode)
void R_Init (void)
void R_LevelShot (void)
void R_ModeList_f (void)
void R_Register (void)
void R_ScreenShot_f (void)
void R_ScreenshotFilename (int lastNumber, char *fileName)
void R_ScreenshotFilenameJPEG (int lastNumber, char *fileName)
void R_ScreenShotJPEG_f (void)
void R_TakeScreenshot (int x, int y, int width, int height, char *name, qboolean jpeg)
void RB_TakeScreenshot (int x, int y, int width, int height, char *fileName)
const void * RB_TakeScreenshotCmd (const void *data)
void RB_TakeScreenshotJPEG (int x, int y, int width, int height, char *fileName)
void RE_EndRegistration (void)
void RE_Shutdown (qboolean destroyWindow)
 void (APIENTRY *qglMultiTexCoord2fARB)(GLenum texture

Variables

glconfig_t glConfig
 GLint
glstate_t glState
int max_polys
int max_polyverts
cvar_tr_allowExtensions
cvar_tr_ambientScale
cvar_tr_clear
cvar_tr_colorbits
cvar_tr_colorMipLevels
cvar_tr_customaspect
cvar_tr_customheight
cvar_tr_customwidth
cvar_tr_debugLight
cvar_tr_debugSort
cvar_tr_debugSurface
cvar_tr_depthbits
cvar_tr_detailTextures
cvar_tr_directedScale
cvar_tr_displayRefresh
cvar_tr_dlightBacks
cvar_tr_drawBuffer
cvar_tr_drawentities
cvar_tr_drawSun
cvar_tr_drawworld
cvar_tr_dynamiclight
cvar_tr_ext_compiled_vertex_array
cvar_tr_ext_compressed_textures
cvar_tr_ext_gamma_control
cvar_tr_ext_multitexture
cvar_tr_ext_texture_env_add
cvar_tr_facePlaneCull
cvar_tr_fastsky
cvar_tr_finish
cvar_tr_flareFade
cvar_tr_flares
cvar_tr_flareSize
cvar_tr_fullbright
cvar_tr_fullscreen
cvar_tr_gamma
cvar_tr_glDriver
cvar_tr_ignore
cvar_tr_ignoreFastPath
cvar_tr_ignoreGLErrors
cvar_tr_ignorehwgamma
cvar_tr_inGameVideo
cvar_tr_intensity
cvar_tr_lightmap
cvar_tr_lockpvs
cvar_tr_lodbias
cvar_tr_lodCurveError
cvar_tr_lodscale
cvar_tr_logFile
cvar_tr_mapOverBrightBits
cvar_tr_maxpolys
cvar_tr_maxpolyverts
cvar_tr_measureOverdraw
cvar_tr_mode
cvar_tr_nobind
cvar_tr_nocull
cvar_tr_nocurves
cvar_tr_noportals
cvar_tr_norefresh
cvar_tr_novis
cvar_tr_offsetFactor
cvar_tr_offsetUnits
cvar_tr_overBrightBits
cvar_tr_picmip
cvar_tr_portalOnly
cvar_tr_primitives
cvar_tr_printShaders
cvar_tr_railCoreWidth
cvar_tr_railSegmentLength
cvar_tr_railWidth
cvar_tr_roundImagesDown
cvar_tr_saveFontData
cvar_tr_shadows
cvar_tr_showcluster
cvar_tr_showImages
cvar_tr_shownormals
cvar_tr_showsky
cvar_tr_showSmp
cvar_tr_showtris
cvar_tr_simpleMipMaps
cvar_tr_singleShader
cvar_tr_skipBackEnd
cvar_tr_smp
cvar_tr_speeds
cvar_tr_stencilbits
cvar_tr_stereo
cvar_tr_subdivisions
cvar_tr_swapInterval
cvar_tr_texturebits
cvar_tr_textureMode
cvar_tr_uiFullScreen
cvar_tr_verbose
cvar_tr_vertexLight
vidmode_t r_vidModes []
cvar_tr_znear
GLfloat s
int s_numVidModes = ( sizeof( r_vidModes ) / sizeof( r_vidModes[0] ) )
GLfloat GLfloat t


Typedef Documentation

typedef struct vidmode_s vidmode_t
 

Referenced by R_GetModeInfo().


Function Documentation

void AssertCvarRange cvar_t cv,
float  minVal,
float  maxVal,
qboolean  shouldBeIntegral
[static]
 

Definition at line 158 of file tr_init.c.

References refimport_t::Cvar_Set, cvar_t, cvar_s::integer, cvar_s::name, PRINT_WARNING, ri, va(), and cvar_s::value.

Referenced by R_Register().

00159 {
00160     if ( shouldBeIntegral )
00161     {
00162         if ( ( int ) cv->value != cv->integer )
00163         {
00164             ri.Printf( PRINT_WARNING, "WARNING: cvar '%s' must be integral (%f)\n", cv->name, cv->value );
00165             ri.Cvar_Set( cv->name, va( "%d", cv->integer ) );
00166         }
00167     }
00168 
00169     if ( cv->value < minVal )
00170     {
00171         ri.Printf( PRINT_WARNING, "WARNING: cvar '%s' out of range (%f < %f)\n", cv->name, cv->value, minVal );
00172         ri.Cvar_Set( cv->name, va( "%f", minVal ) );
00173     }
00174     else if ( cv->value > maxVal )
00175     {
00176         ri.Printf( PRINT_WARNING, "WARNING: cvar '%s' out of range (%f > %f)\n", cv->name, cv->value, maxVal );
00177         ri.Cvar_Set( cv->name, va( "%f", maxVal ) );
00178     }
00179 }

Here is the call graph for this function:

refexport_t* GetRefAPI int  apiVersion,
refimport_t rimp
 

Definition at line 1165 of file tr_init.c.

References refexport_t::AddAdditiveLightToScene, refexport_t::AddLightToScene, refexport_t::AddPolyToScene, refexport_t::AddRefEntityToScene, refexport_t::BeginFrame, refexport_t::BeginRegistration, refexport_t::ClearScene, Com_Memset(), refexport_t::DrawStretchPic, refexport_t::DrawStretchRaw, refexport_t::EndFrame, refexport_t::EndRegistration, refexport_t::GetEntityToken, refexport_t::inPVS, refexport_t::LerpTag, refexport_t::LightForPoint, refexport_t::LoadWorld, refexport_t::MarkFragments, refexport_t::ModelBounds, PRINT_ALL, re, REF_API_VERSION, refexport_t::RegisterFont, refexport_t::RegisterModel, refexport_t::RegisterShader, refexport_t::RegisterShaderNoMip, refexport_t::RegisterSkin, refexport_t::RemapShader, refexport_t::RenderScene, ri, refexport_t::SetColor, refexport_t::SetWorldVisData, refexport_t::Shutdown, and refexport_t::UploadCinematic.

Referenced by CL_InitRef().

01165                                                              {
01166     static refexport_t  re;
01167 
01168     ri = *rimp;
01169 
01170     Com_Memset( &re, 0, sizeof( re ) );
01171 
01172     if ( apiVersion != REF_API_VERSION ) {
01173         ri.Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", 
01174             REF_API_VERSION, apiVersion );
01175         return NULL;
01176     }
01177 
01178     // the RE_ functions are Renderer Entry points
01179 
01180     re.Shutdown = RE_Shutdown;
01181 
01182     re.BeginRegistration = RE_BeginRegistration;
01183     re.RegisterModel = RE_RegisterModel;
01184     re.RegisterSkin = RE_RegisterSkin;
01185     re.RegisterShader = RE_RegisterShader;
01186     re.RegisterShaderNoMip = RE_RegisterShaderNoMip;
01187     re.LoadWorld = RE_LoadWorldMap;
01188     re.SetWorldVisData = RE_SetWorldVisData;
01189     re.EndRegistration = RE_EndRegistration;
01190 
01191     re.BeginFrame = RE_BeginFrame;
01192     re.EndFrame = RE_EndFrame;
01193 
01194     re.MarkFragments = R_MarkFragments;
01195     re.LerpTag = R_LerpTag;
01196     re.ModelBounds = R_ModelBounds;
01197 
01198     re.ClearScene = RE_ClearScene;
01199     re.AddRefEntityToScene = RE_AddRefEntityToScene;
01200     re.AddPolyToScene = RE_AddPolyToScene;
01201     re.LightForPoint = R_LightForPoint;
01202     re.AddLightToScene = RE_AddLightToScene;
01203     re.AddAdditiveLightToScene = RE_AddAdditiveLightToScene;
01204     re.RenderScene = RE_RenderScene;
01205 
01206     re.SetColor = RE_SetColor;
01207     re.DrawStretchPic = RE_StretchPic;
01208     re.DrawStretchRaw = RE_StretchRaw;
01209     re.UploadCinematic = RE_UploadCinematic;
01210 
01211     re.RegisterFont = RE_RegisterFont;
01212     re.RemapShader = R_RemapShader;
01213     re.GetEntityToken = R_GetEntityToken;
01214     re.inPVS = R_inPVS;
01215 
01216     return &re;
01217 }

Here is the call graph for this function:

void GfxInfo_f void   )  [static]
 

Definition at line 758 of file tr_init.c.

References glconfig_t::colorBits, refimport_t::Cvar_Get, cvar_t, glconfig_t::depthBits, glconfig_t::deviceSupportsGamma, glconfig_t::displayFrequency, glconfig_t::extensions_string, glConfig, glconfig_t::hardwareType, cvar_s::integer, glconfig_t::maxActiveTextures, glconfig_t::maxTextureSize, trGlobals_t::overbrightBits, PRINT_ALL, qglActiveTextureARB, qglLockArraysEXT, r_finish, r_fullscreen, r_mode, r_picmip, r_primitives, r_texturebits, r_textureMode, r_vertexLight, glconfig_t::renderer_string, ri, glconfig_t::smpActive, glconfig_t::stencilBits, cvar_s::string, TC_NONE, glconfig_t::textureCompression, glconfig_t::textureEnvAddAvailable, tr, glconfig_t::vendor_string, glconfig_t::version_string, glconfig_t::vidHeight, and glconfig_t::vidWidth.

Referenced by InitOpenGL(), and R_Register().

00759 {
00760     cvar_t *sys_cpustring = ri.Cvar_Get( "sys_cpustring", "", 0 );
00761     const char *enablestrings[] =
00762     {
00763         "disabled",
00764         "enabled"
00765     };
00766     const char *fsstrings[] =
00767     {
00768         "windowed",
00769         "fullscreen"
00770     };
00771 
00772     ri.Printf( PRINT_ALL, "\nGL_VENDOR: %s\n", glConfig.vendor_string );
00773     ri.Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string );
00774     ri.Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string );
00775     ri.Printf( PRINT_ALL, "GL_EXTENSIONS: %s\n", glConfig.extensions_string );
00776     ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize );
00777     ri.Printf( PRINT_ALL, "GL_MAX_ACTIVE_TEXTURES_ARB: %d\n", glConfig.maxActiveTextures );
00778     ri.Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits );
00779     ri.Printf( PRINT_ALL, "MODE: %d, %d x %d %s hz:", r_mode->integer, glConfig.vidWidth, glConfig.vidHeight, fsstrings[r_fullscreen->integer == 1] );
00780     if ( glConfig.displayFrequency )
00781     {
00782         ri.Printf( PRINT_ALL, "%d\n", glConfig.displayFrequency );
00783     }
00784     else
00785     {
00786         ri.Printf( PRINT_ALL, "N/A\n" );
00787     }
00788     if ( glConfig.deviceSupportsGamma )
00789     {
00790         ri.Printf( PRINT_ALL, "GAMMA: hardware w/ %d overbright bits\n", tr.overbrightBits );
00791     }
00792     else
00793     {
00794         ri.Printf( PRINT_ALL, "GAMMA: software w/ %d overbright bits\n", tr.overbrightBits );
00795     }
00796     ri.Printf( PRINT_ALL, "CPU: %s\n", sys_cpustring->string );
00797 
00798     // rendering primitives
00799     {
00800         int     primitives;
00801 
00802         // default is to use triangles if compiled vertex arrays are present
00803         ri.Printf( PRINT_ALL, "rendering primitives: " );
00804         primitives = r_primitives->integer;
00805         if ( primitives == 0 ) {
00806             if ( qglLockArraysEXT ) {
00807                 primitives = 2;
00808             } else {
00809                 primitives = 1;
00810             }
00811         }
00812         if ( primitives == -1 ) {
00813             ri.Printf( PRINT_ALL, "none\n" );
00814         } else if ( primitives == 2 ) {
00815             ri.Printf( PRINT_ALL, "single glDrawElements\n" );
00816         } else if ( primitives == 1 ) {
00817             ri.Printf( PRINT_ALL, "multiple glArrayElement\n" );
00818         } else if ( primitives == 3 ) {
00819             ri.Printf( PRINT_ALL, "multiple glColor4ubv + glTexCoord2fv + glVertex3fv\n" );
00820         }
00821     }
00822 
00823     ri.Printf( PRINT_ALL, "texturemode: %s\n", r_textureMode->string );
00824     ri.Printf( PRINT_ALL, "picmip: %d\n", r_picmip->integer );
00825     ri.Printf( PRINT_ALL, "texture bits: %d\n", r_texturebits->integer );
00826     ri.Printf( PRINT_ALL, "multitexture: %s\n", enablestrings[qglActiveTextureARB != 0] );
00827     ri.Printf( PRINT_ALL, "compiled vertex arrays: %s\n", enablestrings[qglLockArraysEXT != 0 ] );
00828     ri.Printf( PRINT_ALL, "texenv add: %s\n", enablestrings[glConfig.textureEnvAddAvailable != 0] );
00829     ri.Printf( PRINT_ALL, "compressed textures: %s\n", enablestrings[glConfig.textureCompression!=TC_NONE] );
00830     if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 )
00831     {
00832         ri.Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" );
00833     }
00834     if ( glConfig.hardwareType == GLHW_RAGEPRO )
00835     {
00836         ri.Printf( PRINT_ALL, "HACK: ragePro approximations\n" );
00837     }
00838     if ( glConfig.hardwareType == GLHW_RIVA128 )
00839     {
00840         ri.Printf( PRINT_ALL, "HACK: riva128 approximations\n" );
00841     }
00842     if ( glConfig.smpActive ) {
00843         ri.Printf( PRINT_ALL, "Using dual processor acceleration\n" );
00844     }
00845     if ( r_finish->integer ) {
00846         ri.Printf( PRINT_ALL, "Forcing glFinish\n" );
00847     }
00848 }

void GL_CheckErrors void   ) 
 

Definition at line 241 of file tr_init.c.

References Com_sprintf(), err(), ERR_FATAL, cvar_s::integer, qglGetError, r_ignoreGLErrors, ri, s, and strcpy().

Referenced by Upload32().

00241                             {
00242     int     err;
00243     char    s[64];
00244 
00245     err = qglGetError();
00246     if ( err == GL_NO_ERROR ) {
00247         return;
00248     }
00249     if ( r_ignoreGLErrors->integer ) {
00250         return;
00251     }
00252     switch( err ) {
00253         case GL_INVALID_ENUM:
00254             strcpy( s, "GL_INVALID_ENUM" );
00255             break;
00256         case GL_INVALID_VALUE:
00257             strcpy( s, "GL_INVALID_VALUE" );
00258             break;
00259         case GL_INVALID_OPERATION:
00260             strcpy( s, "GL_INVALID_OPERATION" );
00261             break;
00262         case GL_STACK_OVERFLOW:
00263             strcpy( s, "GL_STACK_OVERFLOW" );
00264             break;
00265         case GL_STACK_UNDERFLOW:
00266             strcpy( s, "GL_STACK_UNDERFLOW" );
00267             break;
00268         case GL_OUT_OF_MEMORY:
00269             strcpy( s, "GL_OUT_OF_MEMORY" );
00270             break;
00271         default:
00272             Com_sprintf( s, sizeof(s), "%i", err);
00273             break;
00274     }
00275 
00276     ri.Error( ERR_FATAL, "GL_CheckErrors: %s", s );
00277 }

Here is the call graph for this function:

void GL_SetDefaultState void   ) 
 

Definition at line 710 of file tr_init.c.

References f, GL_SelectTexture(), GL_TexEnv(), GL_TextureMode(), GLS_DEPTHTEST_DISABLE, glState, glstate_t::glStateBits, qglClearDepth, qglColor4f, qglCullFace, qglDepthFunc, qglDepthMask, qglDisable, qglEnable, qglEnableClientState, qglPolygonMode, qglShadeModel, r_textureMode, and cvar_s::string.

Referenced by InitOpenGL().

00711 {
00712     qglClearDepth( 1.0f );
00713 
00714     qglCullFace(GL_FRONT);
00715 
00716     qglColor4f (1,1,1,1);
00717 
00718     // initialize downstream texture unit if we're running
00719     // in a multitexture environment
00720     if ( qglActiveTextureARB ) {
00721         GL_SelectTexture( 1 );
00722         GL_TextureMode( r_textureMode->string );
00723         GL_TexEnv( GL_MODULATE );
00724         qglDisable( GL_TEXTURE_2D );
00725         GL_SelectTexture( 0 );
00726     }
00727 
00728     qglEnable(GL_TEXTURE_2D);
00729     GL_TextureMode( r_textureMode->string );
00730     GL_TexEnv( GL_MODULATE );
00731 
00732     qglShadeModel( GL_SMOOTH );
00733     qglDepthFunc( GL_LEQUAL );
00734 
00735     // the vertex array is always enabled, but the color and texture
00736     // arrays are enabled and disabled around the compiled vertex array call
00737     qglEnableClientState (GL_VERTEX_ARRAY);
00738 
00739     //
00740     // make sure our GL state vector is set correctly
00741     //
00742     glState.glStateBits = GLS_DEPTHTEST_DISABLE | GLS_DEPTHMASK_TRUE;
00743 
00744     qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
00745     qglDepthMask( GL_TRUE );
00746     qglDisable( GL_DEPTH_TEST );
00747     qglEnable( GL_SCISSOR_TEST );
00748     qglDisable( GL_CULL_FACE );
00749     qglDisable( GL_BLEND );
00750 }

Here is the call graph for this function:

void InitOpenGL void   )  [static]
 

Definition at line 190 of file tr_init.c.

References GfxInfo_f(), GL_SetDefaultState(), glConfig, GLimp_Init(), GLint, glconfig_t::maxTextureSize, Q_strlwr(), qglGetIntegerv, R_InitCommandBuffers(), glconfig_t::renderer_string, strcpy(), and glconfig_t::vidWidth.

Referenced by R_Init().

00191 {
00192     char renderer_buffer[1024];
00193 
00194     //
00195     // initialize OS specific portions of the renderer
00196     //
00197     // GLimp_Init directly or indirectly references the following cvars:
00198     //      - r_fullscreen
00199     //      - r_glDriver
00200     //      - r_mode
00201     //      - r_(color|depth|stencil)bits
00202     //      - r_ignorehwgamma
00203     //      - r_gamma
00204     //
00205     
00206     if ( glConfig.vidWidth == 0 )
00207     {
00208         GLint       temp;
00209         
00210         GLimp_Init();
00211 
00212         strcpy( renderer_buffer, glConfig.renderer_string );
00213         Q_strlwr( renderer_buffer );
00214 
00215         // OpenGL driver constants
00216         qglGetIntegerv( GL_MAX_TEXTURE_SIZE, &temp );
00217         glConfig.maxTextureSize = temp;
00218 
00219         // stubbed or broken drivers may have reported 0...
00220         if ( glConfig.maxTextureSize <= 0 ) 
00221         {
00222             glConfig.maxTextureSize = 0;
00223         }
00224     }
00225 
00226     // init command buffers and SMP
00227     R_InitCommandBuffers();
00228 
00229     // print info
00230     GfxInfo_f();
00231 
00232     // set default state
00233     GL_SetDefaultState();
00234 }

Here is the call graph for this function:

qboolean R_GetModeInfo int *  width,
int *  height,
float *  windowAspect,
int  mode
 

Definition at line 307 of file tr_init.c.

References height, vidmode_s::height, cvar_s::integer, mode, vidmode_s::pixelAspect, qboolean, r_customaspect, r_customheight, r_customwidth, r_vidModes, cvar_s::value, vidmode_t, width, and vidmode_s::width.

Referenced by CreateGameWindow(), and GLW_SetMode().

00307                                                                                  {
00308     vidmode_t   *vm;
00309 
00310     if ( mode < -1 ) {
00311         return qfalse;
00312     }
00313     if ( mode >= s_numVidModes ) {
00314         return qfalse;
00315     }
00316 
00317     if ( mode == -1 ) {
00318         *width = r_customwidth->integer;
00319         *height = r_customheight->integer;
00320         *windowAspect = r_customaspect->value;
00321         return qtrue;
00322     }
00323 
00324     vm = &r_vidModes[mode];
00325 
00326     *width  = vm->width;
00327     *height = vm->height;
00328     *windowAspect = (float)vm->width / ( vm->height * vm->pixelAspect );
00329 
00330     return qtrue;
00331 }

void R_Init void   ) 
 

Definition at line 1013 of file tr_init.c.

References backEnd, backEndData, byte, Com_Memset(), Com_Printf(), shaderCommands_s::constantColor255, DEG2RAD, err(), f, FUNCTABLE_SIZE, h_low, refimport_t::Hunk_Alloc, i, InitOpenGL(), cvar_s::integer, trGlobals_t::inverseSawToothTable, max_polys, max_polyverts, backEndData_t::polys, backEndData_t::polyVerts, PRINT_ALL, ptr(), qglGetError, R_InitFogTable(), R_InitFreeType(), R_InitImages(), R_InitShaders(), R_InitSkins(), r_maxpolys, r_maxpolyverts, R_ModelInit(), R_NoiseInit(), R_Register(), r_smp, R_ToggleSmpFrame(), ri, trGlobals_t::sawToothTable, sin(), trGlobals_t::sinTable, trGlobals_t::squareTable, srfPoly_t, tess, tr, trGlobals_t::triangleTable, and shaderCommands_s::xyz.

Referenced by RE_BeginRegistration().

01013                     {   
01014     int err;
01015     int i;
01016     byte *ptr;
01017 
01018     ri.Printf( PRINT_ALL, "----- R_Init -----\n" );
01019 
01020     // clear all our internal state
01021     Com_Memset( &tr, 0, sizeof( tr ) );
01022     Com_Memset( &backEnd, 0, sizeof( backEnd ) );
01023     Com_Memset( &tess, 0, sizeof( tess ) );
01024 
01025 //  Swap_Init();
01026 
01027     if ( (int)tess.xyz & 15 ) {
01028         Com_Printf( "WARNING: tess.xyz not 16 byte aligned\n" );
01029     }
01030     Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) );
01031 
01032     //
01033     // init function tables
01034     //
01035     for ( i = 0; i < FUNCTABLE_SIZE; i++ )
01036     {
01037         tr.sinTable[i]      = sin( DEG2RAD( i * 360.0f / ( ( float ) ( FUNCTABLE_SIZE - 1 ) ) ) );
01038         tr.squareTable[i]   = ( i < FUNCTABLE_SIZE/2 ) ? 1.0f : -1.0f;
01039         tr.sawToothTable[i] = (float)i / FUNCTABLE_SIZE;
01040         tr.inverseSawToothTable[i] = 1.0f - tr.sawToothTable[i];
01041 
01042         if ( i < FUNCTABLE_SIZE / 2 )
01043         {
01044             if ( i < FUNCTABLE_SIZE / 4 )
01045             {
01046                 tr.triangleTable[i] = ( float ) i / ( FUNCTABLE_SIZE / 4 );
01047             }
01048             else
01049             {
01050                 tr.triangleTable[i] = 1.0f - tr.triangleTable[i-FUNCTABLE_SIZE / 4];
01051             }
01052         }
01053         else
01054         {
01055             tr.triangleTable[i] = -tr.triangleTable[i-FUNCTABLE_SIZE/2];
01056         }
01057     }
01058 
01059     R_InitFogTable();
01060 
01061     R_NoiseInit();
01062 
01063     R_Register();
01064 
01065     max_polys = r_maxpolys->integer;
01066     if (max_polys < MAX_POLYS)
01067         max_polys = MAX_POLYS;
01068 
01069     max_polyverts = r_maxpolyverts->integer;
01070     if (max_polyverts < MAX_POLYVERTS)
01071         max_polyverts = MAX_POLYVERTS;
01072 
01073     ptr = ri.Hunk_Alloc( sizeof( *backEndData[0] ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low);
01074     backEndData[0] = (backEndData_t *) ptr;
01075     backEndData[0]->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData[0] ));
01076     backEndData[0]->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData[0] ) + sizeof(srfPoly_t) * max_polys);
01077     if ( r_smp->integer ) {
01078         ptr = ri.Hunk_Alloc( sizeof( *backEndData[1] ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low);
01079         backEndData[1] = (backEndData_t *) ptr;
01080         backEndData[1]->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData[1] ));
01081         backEndData[1]->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData[1] ) + sizeof(srfPoly_t) * max_polys);
01082     } else {
01083         backEndData[1] = NULL;
01084     }
01085     R_ToggleSmpFrame();
01086 
01087     InitOpenGL();
01088 
01089     R_InitImages();
01090 
01091     R_InitShaders();
01092 
01093     R_InitSkins();
01094 
01095     R_ModelInit();
01096 
01097     R_InitFreeType();
01098 
01099 
01100     err = qglGetError();
01101     if ( err != GL_NO_ERROR )
01102         ri.Printf (PRINT_ALL, "glGetError() = 0x%x\n", err);
01103 
01104     ri.Printf( PRINT_ALL, "----- finished R_Init -----\n" );
01105 }

Here is the call graph for this function:

void R_LevelShot void   ) 
 

Definition at line 530 of file tr_init.c.

References b, world_t::baseName, buffer, byte, Com_Memset(), glconfig_t::deviceSupportsGamma, refimport_t::FS_WriteFile, g(), glConfig, refimport_t::Hunk_AllocateTempMemory, refimport_t::Hunk_FreeTempMemory, trGlobals_t::overbrightBits, PRINT_ALL, qglReadPixels, r, R_GammaCorrect(), ri, source, sprintf(), src, tr, glconfig_t::vidHeight, glconfig_t::vidWidth, trGlobals_t::world, x, xx, y, and yy.

Referenced by R_ScreenShot_f(), and R_ScreenShotJPEG_f().

00530                          {
00531     char        checkname[MAX_OSPATH];
00532     byte        *buffer;
00533     byte        *source;
00534     byte        *src, *dst;
00535     int         x, y;
00536     int         r, g, b;
00537     float       xScale, yScale;
00538     int         xx, yy;
00539 
00540     sprintf( checkname, "levelshots/%s.tga", tr.world->baseName );
00541 
00542     source = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight * 3 );
00543 
00544     buffer = ri.Hunk_AllocateTempMemory( 128 * 128*3 + 18);
00545     Com_Memset (buffer, 0, 18);
00546     buffer[2] = 2;      // uncompressed type
00547     buffer[12] = 128;
00548     buffer[14] = 128;
00549     buffer[16] = 24;    // pixel size
00550 
00551     qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_RGB, GL_UNSIGNED_BYTE, source ); 
00552 
00553     // resample from source
00554     xScale = glConfig.vidWidth / 512.0f;
00555     yScale = glConfig.vidHeight / 384.0f;
00556     for ( y = 0 ; y < 128 ; y++ ) {
00557         for ( x = 0 ; x < 128 ; x++ ) {
00558             r = g = b = 0;
00559             for ( yy = 0 ; yy < 3 ; yy++ ) {
00560                 for ( xx = 0 ; xx < 4 ; xx++ ) {
00561                     src = source + 3 * ( glConfig.vidWidth * (int)( (y*3+yy)*yScale ) + (int)( (x*4+xx)*xScale ) );
00562                     r += src[0];
00563                     g += src[1];
00564                     b += src[2];
00565                 }
00566             }
00567             dst = buffer + 18 + 3 * ( y * 128 + x );
00568             dst[0] = b / 12;
00569             dst[1] = g / 12;
00570             dst[2] = r / 12;
00571         }
00572     }
00573 
00574     // gamma correct
00575     if ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) {
00576         R_GammaCorrect( buffer + 18, 128 * 128 * 3 );
00577     }
00578 
00579     ri.FS_WriteFile( checkname, buffer, 128 * 128*3 + 18 );
00580 
00581     ri.Hunk_FreeTempMemory( buffer );
00582     ri.Hunk_FreeTempMemory( source );
00583 
00584     ri.Printf( PRINT_ALL, "Wrote %s\n", checkname );
00585 }

Here is the call graph for this function:

void R_ModeList_f void   )  [static]
 

Definition at line 336 of file tr_init.c.

References i, PRINT_ALL, r_vidModes, and ri.

Referenced by R_Register().

00337 {
00338     int i;
00339 
00340     ri.Printf( PRINT_ALL, "\n" );
00341     for ( i = 0; i < s_numVidModes; i++ )
00342     {
00343         ri.Printf( PRINT_ALL, "%s\n", r_vidModes[i].description );
00344     }
00345     ri.Printf( PRINT_ALL, "\n" );
00346 }

void R_Register void   ) 
 

Definition at line 855 of file tr_init.c.

References AssertCvarRange(), refimport_t::Cmd_AddCommand, CVAR_ARCHIVE, CVAR_CHEAT, refimport_t::Cvar_Get, CVAR_LATCH, CVAR_TEMP, f, GfxInfo_f(), MAX_POLYS, MAX_POLYVERTS, OPENGL_DRIVER_NAME, qtrue, r_allowExtensions, r_ambientScale, r_clear, r_colorbits, r_colorMipLevels, r_customaspect, r_customheight, r_customwidth, r_debugLight, r_debugSort, r_debugSurface, r_depthbits, r_detailTextures, r_directedScale, r_displayRefresh, r_dlightBacks, r_drawBuffer, r_drawentities, r_drawSun, r_drawworld, r_dynamiclight, r_ext_compiled_vertex_array, r_ext_compressed_textures, r_ext_gamma_control, r_ext_multitexture, r_ext_texture_env_add, r_facePlaneCull, r_fastsky, r_finish, r_flareFade, r_flares, r_flareSize, r_fullbright, r_fullscreen, r_gamma, r_glDriver, r_ignore, r_ignoreFastPath, r_ignoreGLErrors, r_ignorehwgamma, R_ImageList_f(), r_inGameVideo, r_intensity, r_lightmap, r_lockpvs, r_lodbias, r_lodCurveError, r_lodscale, r_logFile, r_mapOverBrightBits, r_maxpolys, r_maxpolyverts, r_measureOverdraw, r_mode, R_ModeList_f(), R_Modellist_f(), r_nobind, r_nocull, r_nocurves, r_noportals, r_norefresh, r_novis, r_offsetFactor, r_offsetUnits, r_overBrightBits, r_picmip, r_portalOnly, r_primitives, r_printShaders, r_railCoreWidth, r_railSegmentLength, r_railWidth, r_roundImagesDown, r_saveFontData, R_ScreenShot_f(), R_ScreenShotJPEG_f(), R_ShaderList_f(), r_shadows, r_showcluster, r_showImages, r_shownormals, r_showsky, r_showSmp, r_showtris, r_simpleMipMaps, r_singleShader, R_SkinList_f(), r_skipBackEnd, r_smp, r_speeds, r_stencilbits, r_stereo, r_subdivisions, r_swapInterval, r_texturebits, r_textureMode, r_uiFullScreen, r_verbose, r_vertexLight, r_znear, ri, Sys_ProcessorCount(), and va().

Referenced by R_Init().

00856 {
00857     //
00858     // latched and archived variables
00859     //
00860     r_glDriver = ri.Cvar_Get( "r_glDriver", OPENGL_DRIVER_NAME, CVAR_ARCHIVE | CVAR_LATCH );
00861     r_allowExtensions = ri.Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH );
00862     r_ext_compressed_textures = ri.Cvar_Get( "r_ext_compressed_textures", "0", CVAR_ARCHIVE | CVAR_LATCH );
00863     r_ext_gamma_control = ri.Cvar_Get( "r_ext_gamma_control", "1", CVAR_ARCHIVE | CVAR_LATCH );
00864     r_ext_multitexture = ri.Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH );
00865     r_ext_compiled_vertex_array = ri.Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH);
00866 #ifdef __linux__ // broken on linux
00867     r_ext_texture_env_add = ri.Cvar_Get( "r_ext_texture_env_add", "0", CVAR_ARCHIVE | CVAR_LATCH);
00868 #else
00869     r_