29 Aug 2008
This commit is contained in:
parent
45c3a39941
commit
000c03a60b
|
@ -196,9 +196,14 @@ static void ParseShaderFile( char *filename )
|
|||
si->intensity = atoi( com_token );
|
||||
continue;
|
||||
}
|
||||
|
||||
// light intensity <value>
|
||||
if ( !stricmp( com_token, "sort" ))
|
||||
{
|
||||
Com_GetToken( false );
|
||||
continue;
|
||||
}
|
||||
// ignore all other com_tokens on the line
|
||||
while (Com_TryToken());
|
||||
while( Com_TryToken());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ Set a specific sky and rotation speed
|
|||
void CL_SetSky_f( void )
|
||||
{
|
||||
float rotate = 0;
|
||||
vec3_t axis;
|
||||
vec3_t axis = { 0, 0, 0 };
|
||||
|
||||
if(Cmd_Argc() < 2)
|
||||
{
|
||||
|
@ -172,11 +172,7 @@ void CL_SetSky_f( void )
|
|||
if( Cmd_Argc() > 2 ) rotate = com.atof(Cmd_Argv(2));
|
||||
if( Cmd_Argc() == 6 )
|
||||
{
|
||||
VectorSet(axis, com.atof(Cmd_Argv(3)), com.atof(Cmd_Argv(4)), com.atof(Cmd_Argv(5)));
|
||||
}
|
||||
else
|
||||
{
|
||||
VectorSet(axis, 0, 0, 1 );
|
||||
VectorSet( axis, com.atof(Cmd_Argv(3)), com.atof(Cmd_Argv(4)), com.atof(Cmd_Argv(5)));
|
||||
}
|
||||
re->SetSky( Cmd_Argv(1), rotate, axis );
|
||||
}
|
||||
|
|
|
@ -723,7 +723,6 @@ void CL_PrepVideo( void )
|
|||
return; // no map loaded
|
||||
|
||||
Msg( "CL_PrepRefresh: %s\n", cl.configstrings[CS_NAME] );
|
||||
V_ClearScene();
|
||||
|
||||
// let the render dll load the map
|
||||
FS_FileBase( cl.configstrings[CS_MODELS+1], mapname );
|
||||
|
|
|
@ -172,18 +172,19 @@ bool Cmd_GetFontList( const char *s, char *completedname, int length )
|
|||
string matchbuf;
|
||||
int i, numfonts;
|
||||
|
||||
t = FS_Search(va("gfx/fonts/%s*.dds", s ), true);
|
||||
t = FS_Search(va("gfx/fonts/%s*.*", s ), true);
|
||||
if(!t) return false;
|
||||
|
||||
FS_FileBase(t->filenames[0], matchbuf );
|
||||
if(completedname && length) com.strncpy( completedname, matchbuf, length );
|
||||
if(t->numfilenames == 1) return true;
|
||||
if( t->numfilenames == 1 ) return true;
|
||||
|
||||
for(i = 0, numfonts = 0; i < t->numfilenames; i++)
|
||||
{
|
||||
const char *ext = FS_FileExtension( t->filenames[i] );
|
||||
|
||||
if( com.stricmp(ext, "dds" )) continue;
|
||||
if( com.stricmp(ext, "png" ) && com.stricmp(ext, "dds" ) && com.stricmp(ext, "tga" ))
|
||||
continue;
|
||||
FS_FileBase(t->filenames[i], matchbuf );
|
||||
Msg("%16s\n", matchbuf );
|
||||
numfonts++;
|
||||
|
|
150
launch/memlib.c
150
launch/memlib.c
|
@ -14,6 +14,13 @@
|
|||
#define MEMHEADER_SENTINEL1 0xDEADF00D
|
||||
#define MEMHEADER_SENTINEL2 0xDF
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PREFETCH_READ, // prefetch assuming that buffer is used for reading only
|
||||
PREFETCH_WRITE, // prefetch assuming that buffer is used for writing only
|
||||
PREFETCH_READWRITE // prefetch assuming that buffer is used for both reading and writing
|
||||
} e_prefetch;
|
||||
|
||||
typedef struct memheader_s
|
||||
{
|
||||
struct memheader_s *next; // next and previous memheaders in chain belonging to pool
|
||||
|
@ -74,16 +81,147 @@ typedef struct memarray_s
|
|||
|
||||
mempool_t *poolchain = NULL; // critical stuff
|
||||
|
||||
void _mem_copy(void *dest, const void *src, size_t size, const char *filename, int fileline)
|
||||
void _mem_prefetch( const void *s, const uint bytes, e_prefetch type )
|
||||
{
|
||||
if (src == NULL || size <= 0) return; // nothing to copy
|
||||
if (dest == NULL) Sys_Error("Mem_Copy: dest == NULL (called at %s:%i)\n", filename, fileline);
|
||||
// write buffer prefetching is performed only if
|
||||
// the processor benefits from it. read and read/write
|
||||
// prefetching is always performed.
|
||||
|
||||
// copy block
|
||||
memcpy( dest, src, size );
|
||||
switch( type )
|
||||
{
|
||||
case PREFETCH_WRITE : break;
|
||||
case PREFETCH_READ:
|
||||
case PREFETCH_READWRITE:
|
||||
|
||||
__asm
|
||||
{
|
||||
mov ebx, s
|
||||
mov ecx, bytes
|
||||
cmp ecx, 4096 // clamp to 4kB
|
||||
jle skipClump
|
||||
mov ecx, 4096
|
||||
skipClump:
|
||||
add ecx, 0x1f
|
||||
shr ecx, 5 // number of cache lines
|
||||
jz skip
|
||||
jmp loopie
|
||||
|
||||
align 16
|
||||
loopie: test byte ptr [ebx], al
|
||||
add ebx, 32
|
||||
dec ecx
|
||||
jnz loopie
|
||||
skip:
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void *_mem_alloc(byte *poolptr, size_t size, const char *filename, int fileline)
|
||||
void _mem_copy( void *dest, const void *src, size_t count, const char *filename, int fileline )
|
||||
{
|
||||
if( src == NULL || count <= 0 ) return; // nothing to copy
|
||||
if( dest == NULL) Sys_Error("Mem_Copy: dest == NULL (called at %s:%i)\n", filename, fileline );
|
||||
|
||||
// copy block
|
||||
_mem_prefetch( src, count, PREFETCH_READ );
|
||||
__asm
|
||||
{
|
||||
push edi
|
||||
push esi
|
||||
mov ecx,count
|
||||
cmp ecx,0 // count = 0 check (just to be on the safe side)
|
||||
je outta
|
||||
mov edx,dest
|
||||
mov ebx,src
|
||||
cmp ecx,32 // padding only?
|
||||
jl padding
|
||||
|
||||
mov edi,ecx
|
||||
and edi,~31 // edi = count&~31
|
||||
sub edi,32
|
||||
|
||||
align 16
|
||||
loopMisAligned:
|
||||
mov eax,[ebx + edi + 0 + 0*8]
|
||||
mov esi,[ebx + edi + 4 + 0*8]
|
||||
mov [edx+edi+0 + 0*8],eax
|
||||
mov [edx+edi+4 + 0*8],esi
|
||||
mov eax,[ebx + edi + 0 + 1*8]
|
||||
mov esi,[ebx + edi + 4 + 1*8]
|
||||
mov [edx+edi+0 + 1*8],eax
|
||||
mov [edx+edi+4 + 1*8],esi
|
||||
mov eax,[ebx + edi + 0 + 2*8]
|
||||
mov esi,[ebx + edi + 4 + 2*8]
|
||||
mov [edx+edi+0 + 2*8],eax
|
||||
mov [edx+edi+4 + 2*8],esi
|
||||
mov eax,[ebx + edi + 0 + 3*8]
|
||||
mov esi,[ebx + edi + 4 + 3*8]
|
||||
mov [edx+edi+0 + 3*8],eax
|
||||
mov [edx+edi+4 + 3*8],esi
|
||||
sub edi,32
|
||||
jge loopMisAligned
|
||||
|
||||
mov edi,ecx
|
||||
and edi,~31
|
||||
add ebx,edi // increase src pointer
|
||||
add edx,edi // increase dst pointer
|
||||
and ecx,31 // new count
|
||||
jz outta // if count = 0, get outta here
|
||||
|
||||
padding:
|
||||
cmp ecx,16
|
||||
jl skip16
|
||||
mov eax,dword ptr [ebx]
|
||||
mov dword ptr [edx],eax
|
||||
mov eax,dword ptr [ebx+4]
|
||||
mov dword ptr [edx+4],eax
|
||||
mov eax,dword ptr [ebx+8]
|
||||
mov dword ptr [edx+8],eax
|
||||
mov eax,dword ptr [ebx+12]
|
||||
mov dword ptr [edx+12],eax
|
||||
sub ecx,16
|
||||
add ebx,16
|
||||
add edx,16
|
||||
skip16:
|
||||
cmp ecx,8
|
||||
jl skip8
|
||||
mov eax,dword ptr [ebx]
|
||||
mov dword ptr [edx],eax
|
||||
mov eax,dword ptr [ebx+4]
|
||||
sub ecx,8
|
||||
mov dword ptr [edx+4],eax
|
||||
add ebx,8
|
||||
add edx,8
|
||||
skip8:
|
||||
cmp ecx,4
|
||||
jl skip4
|
||||
mov eax,dword ptr [ebx] // here 4-7 bytes
|
||||
add ebx,4
|
||||
sub ecx,4
|
||||
mov dword ptr [edx],eax
|
||||
add edx,4
|
||||
skip4: // 0-3 remaining bytes
|
||||
cmp ecx,2
|
||||
jl skip2
|
||||
mov ax,word ptr [ebx] // two bytes
|
||||
cmp ecx,3 // less than 3?
|
||||
mov word ptr [edx],ax
|
||||
jl outta
|
||||
mov al,byte ptr [ebx+2] // last byte
|
||||
mov byte ptr [edx+2],al
|
||||
jmp outta
|
||||
skip2:
|
||||
cmp ecx,1
|
||||
jl outta
|
||||
mov al,byte ptr [ebx]
|
||||
mov byte ptr [edx],al
|
||||
outta:
|
||||
pop esi
|
||||
pop edi
|
||||
}
|
||||
}
|
||||
|
||||
void *_mem_alloc( byte *poolptr, size_t size, const char *filename, int fileline )
|
||||
{
|
||||
int i, j, k, needed, endbit, largest;
|
||||
memclump_t *clump, **clumpchainpointer;
|
||||
|
|
|
@ -567,23 +567,6 @@ _inline void Matrix4x4_FromVectors( matrix4x4 out, const float vx[3], const floa
|
|||
_inline void Matrix4x4_ToArrayFloatGL( const matrix4x4 in, float out[16] )
|
||||
{
|
||||
#ifdef OPENGL_STYLE
|
||||
out[ 0] = in[0][0];
|
||||
out[ 1] = in[0][1];
|
||||
out[ 2] = in[0][2];
|
||||
out[ 3] = in[0][3];
|
||||
out[ 4] = in[1][0];
|
||||
out[ 5] = in[1][1];
|
||||
out[ 6] = in[1][2];
|
||||
out[ 7] = in[1][3];
|
||||
out[ 8] = in[2][0];
|
||||
out[ 9] = in[2][1];
|
||||
out[10] = in[2][2];
|
||||
out[11] = in[2][3];
|
||||
out[12] = in[3][0];
|
||||
out[13] = in[3][1];
|
||||
out[14] = in[3][2];
|
||||
out[15] = in[3][3];
|
||||
#else
|
||||
out[ 0] = in[0][0];
|
||||
out[ 1] = in[1][0];
|
||||
out[ 2] = in[2][0];
|
||||
|
@ -600,29 +583,30 @@ _inline void Matrix4x4_ToArrayFloatGL( const matrix4x4 in, float out[16] )
|
|||
out[13] = in[1][3];
|
||||
out[14] = in[2][3];
|
||||
out[15] = in[3][3];
|
||||
#else
|
||||
out[ 0] = in[0][0];
|
||||
out[ 1] = in[0][1];
|
||||
out[ 2] = in[0][2];
|
||||
out[ 3] = in[0][3];
|
||||
out[ 4] = in[1][0];
|
||||
out[ 5] = in[1][1];
|
||||
out[ 6] = in[1][2];
|
||||
out[ 7] = in[1][3];
|
||||
out[ 8] = in[2][0];
|
||||
out[ 9] = in[2][1];
|
||||
out[10] = in[2][2];
|
||||
out[11] = in[2][3];
|
||||
out[12] = in[3][0];
|
||||
out[13] = in[3][1];
|
||||
out[14] = in[3][2];
|
||||
out[15] = in[3][3];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
_inline void Matrix4x4_FromArrayFloatGL( matrix4x4 out, const float in[16] )
|
||||
{
|
||||
#ifdef OPENGL_STYLE
|
||||
out[0][0] = in[0];
|
||||
out[0][1] = in[1];
|
||||
out[0][2] = in[2];
|
||||
out[0][3] = in[3];
|
||||
out[1][0] = in[4];
|
||||
out[1][1] = in[5];
|
||||
out[1][2] = in[6];
|
||||
out[1][3] = in[7];
|
||||
out[2][0] = in[8];
|
||||
out[2][1] = in[9];
|
||||
out[2][2] = in[10];
|
||||
out[2][3] = in[11];
|
||||
out[3][0] = in[12];
|
||||
out[3][1] = in[13];
|
||||
out[3][2] = in[14];
|
||||
out[3][3] = in[15];
|
||||
#else
|
||||
out[0][0] = in[0];
|
||||
out[1][0] = in[1];
|
||||
out[2][0] = in[2];
|
||||
|
@ -639,6 +623,24 @@ _inline void Matrix4x4_FromArrayFloatGL( matrix4x4 out, const float in[16] )
|
|||
out[1][3] = in[13];
|
||||
out[2][3] = in[14];
|
||||
out[3][3] = in[15];
|
||||
#else
|
||||
out[0][0] = in[0];
|
||||
out[0][1] = in[1];
|
||||
out[0][2] = in[2];
|
||||
out[0][3] = in[3];
|
||||
out[1][0] = in[4];
|
||||
out[1][1] = in[5];
|
||||
out[1][2] = in[6];
|
||||
out[1][3] = in[7];
|
||||
out[2][0] = in[8];
|
||||
out[2][1] = in[9];
|
||||
out[2][2] = in[10];
|
||||
out[2][3] = in[11];
|
||||
out[3][0] = in[12];
|
||||
out[3][1] = in[13];
|
||||
out[3][2] = in[14];
|
||||
out[3][3] = in[15];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -691,4 +693,24 @@ _inline void Matrix4x4_ConcatScale( matrix4x4 out, double x )
|
|||
Matrix4x4_Concat( out, base, temp );
|
||||
}
|
||||
|
||||
// FIXME: optimize
|
||||
_inline void Matrix4x4_ConcatTranslate( matrix4x4 out, double x, double y, double z )
|
||||
{
|
||||
matrix4x4 base, temp;
|
||||
|
||||
Matrix4x4_Copy( base, out );
|
||||
Matrix4x4_CreateTranslate( temp, x, y, z );
|
||||
Matrix4x4_Concat( out, base, temp );
|
||||
}
|
||||
|
||||
// FIXME: optimize
|
||||
_inline void Matrix4x4_ConcatRotate( matrix4x4 out, double angle, double x, double y, double z )
|
||||
{
|
||||
matrix4x4 base, temp;
|
||||
|
||||
Matrix4x4_Copy( base, out );
|
||||
Matrix4x4_CreateRotate( temp, angle, x, y, z );
|
||||
Matrix4x4_Concat( out, base, temp );
|
||||
}
|
||||
|
||||
#endif//BASEMATRIX_H
|
|
@ -522,8 +522,8 @@ void GL_UpdateGammaRamp( void )
|
|||
for( i = 0; i < 256; i++ )
|
||||
{
|
||||
v = 255 * pow((float)(i + 0.5) / 255, vid_gamma->value ) + 0.5;
|
||||
v = bound( v, 0, 255 );
|
||||
gl_state.gammaRamp[i] = ((word)v)<<8;
|
||||
v = bound( 0, v, 255 );
|
||||
gl_state.gammaRamp[i+0] = ((word)v)<<8;
|
||||
gl_state.gammaRamp[i+256] = ((word)v)<<8;
|
||||
gl_state.gammaRamp[i+512] = ((word)v)<<8;
|
||||
}
|
||||
|
@ -558,9 +558,6 @@ void GL_InitExtensions( void )
|
|||
}
|
||||
else gl_config.textureunits = 1;
|
||||
|
||||
gl_state.texNum = Mem_Alloc( r_temppool, sizeof(int) * gl_config.textureunits );
|
||||
gl_state.texEnv = Mem_Alloc( r_temppool, sizeof(int) * gl_config.textureunits );
|
||||
|
||||
// 3d texture support
|
||||
GL_CheckExtension( "GL_EXT_texture3D", texture3dextfuncs, "gl_texture_3d", R_TEXTURE_3D_EXT );
|
||||
if(GL_Support( R_TEXTURE_3D_EXT ))
|
||||
|
|
|
@ -176,15 +176,15 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
case RGBGEN_IDENTITY:
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
colorArray[i][0] = 255;
|
||||
colorArray[i][1] = 255;
|
||||
colorArray[i][2] = 255;
|
||||
colorArray[i][0] = 1.0f;
|
||||
colorArray[i][1] = 1.0f;
|
||||
colorArray[i][2] = 1.0f;
|
||||
}
|
||||
break;
|
||||
case RGBGEN_IDENTITYLIGHTING:
|
||||
if( gl_config.deviceSupportsGamma )
|
||||
r = g = b = 255>>r_overbrightbits->integer;
|
||||
else r = g = b = 255;
|
||||
r = g = b = 1>>r_overbrightbits->integer;
|
||||
else r = g = b = 1.0f;
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
|
@ -200,9 +200,9 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
|
||||
f = bound( 0.0, f, 1.0 );
|
||||
|
||||
r = 255 * f;
|
||||
g = 255 * f;
|
||||
b = 255 * f;
|
||||
r = 1.0f * f;
|
||||
g = 1.0f * f;
|
||||
b = 1.0f * f;
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
|
@ -218,9 +218,9 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
|
||||
f = bound(0.0, f, 1.0);
|
||||
|
||||
r = 255 * (rgbGen->params[0] * f);
|
||||
g = 255 * (rgbGen->params[1] * f);
|
||||
b = 255 * (rgbGen->params[2] * f);
|
||||
r = 1.0f * (rgbGen->params[0] * f);
|
||||
g = 1.0f * (rgbGen->params[1] * f);
|
||||
b = 1.0f * (rgbGen->params[2] * f);
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
|
@ -240,25 +240,25 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
case RGBGEN_ONEMINUSVERTEX:
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
colorArray[i][0] = 255 - inColorArray[i][0];
|
||||
colorArray[i][1] = 255 - inColorArray[i][1];
|
||||
colorArray[i][2] = 255 - inColorArray[i][2];
|
||||
colorArray[i][0] = 1.0f - inColorArray[i][0];
|
||||
colorArray[i][1] = 1.0f - inColorArray[i][1];
|
||||
colorArray[i][2] = 1.0f - inColorArray[i][2];
|
||||
}
|
||||
break;
|
||||
case RGBGEN_ENTITY:
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
colorArray[i][0] = m_pCurrentEntity->shaderRGBA.r;
|
||||
colorArray[i][1] = m_pCurrentEntity->shaderRGBA.g;
|
||||
colorArray[i][2] = m_pCurrentEntity->shaderRGBA.b;
|
||||
colorArray[i][0] = m_pCurrentEntity->shaderRGBA[0];
|
||||
colorArray[i][1] = m_pCurrentEntity->shaderRGBA[1];
|
||||
colorArray[i][2] = m_pCurrentEntity->shaderRGBA[2];
|
||||
}
|
||||
break;
|
||||
case RGBGEN_ONEMINUSENTITY:
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
colorArray[i][0] = 255 - m_pCurrentEntity->shaderRGBA.r;
|
||||
colorArray[i][1] = 255 - m_pCurrentEntity->shaderRGBA.g;
|
||||
colorArray[i][2] = 255 - m_pCurrentEntity->shaderRGBA.b;
|
||||
colorArray[i][0] = 1.0f - m_pCurrentEntity->shaderRGBA[0];
|
||||
colorArray[i][1] = 1.0f - m_pCurrentEntity->shaderRGBA[1];
|
||||
colorArray[i][2] = 1.0f - m_pCurrentEntity->shaderRGBA[2];
|
||||
}
|
||||
break;
|
||||
case RGBGEN_LIGHTINGAMBIENT:
|
||||
|
@ -268,9 +268,9 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
R_LightingDiffuse();
|
||||
break;
|
||||
case RGBGEN_CONST:
|
||||
r = 255 * rgbGen->params[0];
|
||||
g = 255 * rgbGen->params[1];
|
||||
b = 255 * rgbGen->params[2];
|
||||
r = 1.0f * rgbGen->params[0];
|
||||
g = 1.0f * rgbGen->params[1];
|
||||
b = 1.0f * rgbGen->params[2];
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
|
@ -287,14 +287,14 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
{
|
||||
case ALPHAGEN_IDENTITY:
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
colorArray[i][3] = 255;
|
||||
colorArray[i][3] = 1.0f;
|
||||
break;
|
||||
case ALPHAGEN_WAVE:
|
||||
table = RB_TableForFunc(&alphaGen->func);
|
||||
now = alphaGen->func.params[2] + alphaGen->func.params[3] * m_fShaderTime;
|
||||
f = table[((int)(now * TABLE_SIZE)) & TABLE_MASK] * alphaGen->func.params[1] + alphaGen->func.params[0];
|
||||
f = bound( 0.0, f, 1.0 );
|
||||
a = 255 * f;
|
||||
a = 1.0f * f;
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
colorArray[i][3] = a;
|
||||
|
@ -304,7 +304,7 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
now = alphaGen->func.params[2] + alphaGen->func.params[3] * m_fShaderTime;
|
||||
f = table[((int)(now * TABLE_SIZE)) & TABLE_MASK] * alphaGen->func.params[1] + alphaGen->func.params[0];
|
||||
f = bound( 0.0, f, 1.0 );
|
||||
a = 255 * (alphaGen->params[0] * f);
|
||||
a = 1.0f * (alphaGen->params[0] * f);
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
colorArray[i][3] = a;
|
||||
|
@ -315,38 +315,38 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
break;
|
||||
case ALPHAGEN_ONEMINUSVERTEX:
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
colorArray[i][3] = 255 - inColorArray[i][3];
|
||||
colorArray[i][3] = 1.0f - inColorArray[i][3];
|
||||
break;
|
||||
case ALPHAGEN_ENTITY:
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
colorArray[i][3] = m_pCurrentEntity->shaderRGBA.a;
|
||||
colorArray[i][3] = m_pCurrentEntity->shaderRGBA[3];
|
||||
break;
|
||||
case ALPHAGEN_ONEMINUSENTITY:
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
colorArray[i][3] = 255 - m_pCurrentEntity->shaderRGBA.a;
|
||||
colorArray[i][3] = 1.0f - m_pCurrentEntity->shaderRGBA[3];
|
||||
break;
|
||||
case ALPHAGEN_DOT:
|
||||
if(!Matrix4x4_CompareRotateOnly( m_pCurrentEntity->matrix, identitymatrix ))
|
||||
Matrix4x4_Rotate( m_pCurrentEntity->matrix, r_forward, vec );
|
||||
if( !AxisCompare( m_pCurrentEntity->axis, axisDefault ))
|
||||
VectorRotate( r_forward, m_pCurrentEntity->axis, vec );
|
||||
else VectorCopy( r_forward, vec );
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
f = DotProduct(vec, normalArray[i]);
|
||||
if( f < 0 ) f = -f;
|
||||
colorArray[i][3] = 255 * bound( alphaGen->params[0], f, alphaGen->params[1] );
|
||||
colorArray[i][3] = 1.0f * bound( alphaGen->params[0], f, alphaGen->params[1] );
|
||||
}
|
||||
break;
|
||||
case ALPHAGEN_ONEMINUSDOT:
|
||||
if(!Matrix4x4_CompareRotateOnly( m_pCurrentEntity->matrix, identitymatrix ))
|
||||
Matrix4x4_Rotate( m_pCurrentEntity->matrix, r_forward, vec );
|
||||
if( !AxisCompare( m_pCurrentEntity->axis, axisDefault ))
|
||||
VectorRotate( r_forward, m_pCurrentEntity->axis, vec );
|
||||
else VectorCopy( r_forward, vec );
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
f = DotProduct(vec, normalArray[i]);
|
||||
if( f < 0 ) f = -f;
|
||||
colorArray[i][3] = 255 * bound( alphaGen->params[0], 1.0 - f, alphaGen->params[1]);
|
||||
colorArray[i][3] = 1.0f * bound( alphaGen->params[0], 1.0 - f, alphaGen->params[1]);
|
||||
}
|
||||
break;
|
||||
case ALPHAGEN_FADE:
|
||||
|
@ -357,7 +357,7 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
|
||||
f = bound( alphaGen->params[0], f, alphaGen->params[1] ) - alphaGen->params[0];
|
||||
f = f * alphaGen->params[2];
|
||||
colorArray[i][3] = 255 * bound( 0.0, f, 1.0 );
|
||||
colorArray[i][3] = 1.0f * bound( 0.0, f, 1.0 );
|
||||
}
|
||||
break;
|
||||
case ALPHAGEN_ONEMINUSFADE:
|
||||
|
@ -368,16 +368,16 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
|
||||
f = bound( alphaGen->params[0], f, alphaGen->params[1] ) - alphaGen->params[0];
|
||||
f = f * alphaGen->params[2];
|
||||
colorArray[i][3] = 255 * bound( 0.0, 1.0 - f, 1.0 );
|
||||
colorArray[i][3] = 1.0f * bound( 0.0, 1.0 - f, 1.0 );
|
||||
}
|
||||
break;
|
||||
case ALPHAGEN_LIGHTINGSPECULAR:
|
||||
if(!Matrix4x4_CompareRotateOnly( m_pCurrentEntity->matrix, identitymatrix ))
|
||||
if( !AxisCompare( m_pCurrentEntity->axis, axisDefault ))
|
||||
{
|
||||
VectorSubtract( r_refdef.vieworg, m_pCurrentEntity->origin, dir );
|
||||
Matrix4x4_Rotate( m_pCurrentEntity->matrix, dir, vec );
|
||||
VectorSubtract( r_origin, m_pCurrentEntity->origin, dir );
|
||||
VectorRotate( dir, m_pCurrentEntity->axis, vec );
|
||||
}
|
||||
else VectorSubtract( r_refdef.vieworg, m_pCurrentEntity->origin, vec );
|
||||
else VectorSubtract( r_origin, m_pCurrentEntity->origin, vec );
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
|
@ -386,11 +386,11 @@ static void RB_CalcVertexColors( shaderStage_t *stage )
|
|||
|
||||
f = DotProduct( dir, normalArray[i] );
|
||||
f = pow( f, alphaGen->params[0] );
|
||||
colorArray[i][3] = 255 * bound( 0.0, f, 1.0 );
|
||||
colorArray[i][3] = 1.0f * bound( 0.0, f, 1.0 );
|
||||
}
|
||||
break;
|
||||
case ALPHAGEN_CONST:
|
||||
a = 255 * alphaGen->params[0];
|
||||
a = 1.0f * alphaGen->params[0];
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
colorArray[i][3] = a;
|
||||
|
@ -434,12 +434,12 @@ static void RB_CalcTextureCoords( stageBundle_t *bundle, uint unit )
|
|||
}
|
||||
break;
|
||||
case TCGEN_ENVIRONMENT:
|
||||
if(!Matrix4x4_CompareRotateOnly( m_pCurrentEntity->matrix, identitymatrix ))
|
||||
if (!AxisCompare( m_pCurrentEntity->axis, axisDefault ))
|
||||
{
|
||||
VectorSubtract( r_refdef.vieworg, m_pCurrentEntity->origin, dir);
|
||||
Matrix4x4_Rotate( m_pCurrentEntity->matrix, dir, vec );
|
||||
VectorSubtract( r_origin, m_pCurrentEntity->origin, dir );
|
||||
VectorRotate( dir, m_pCurrentEntity->axis, vec );
|
||||
}
|
||||
else VectorSubtract( r_refdef.vieworg, m_pCurrentEntity->origin, vec );
|
||||
else VectorSubtract( r_origin, m_pCurrentEntity->origin, vec );
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
|
@ -480,8 +480,8 @@ static void RB_CalcTextureCoords( stageBundle_t *bundle, uint unit )
|
|||
else
|
||||
{
|
||||
R_LightDir( m_pCurrentEntity->origin, dir );
|
||||
if(!Matrix4x4_CompareRotateOnly( m_pCurrentEntity->matrix, identitymatrix ))
|
||||
Matrix4x4_Rotate( m_pCurrentEntity->matrix, dir, lightVector );
|
||||
if( !AxisCompare( m_pCurrentEntity->axis, axisDefault ))
|
||||
VectorRotate( dir, m_pCurrentEntity->axis, lightVector );
|
||||
else VectorCopy( dir, lightVector );
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
|
@ -513,11 +513,12 @@ static void RB_CalcTextureCoords( stageBundle_t *bundle, uint unit )
|
|||
{
|
||||
R_LightDir( m_pCurrentEntity->origin, dir );
|
||||
|
||||
if(!Matrix4x4_CompareRotateOnly( m_pCurrentEntity->matrix, identitymatrix ))
|
||||
if( !AxisCompare( m_pCurrentEntity->axis, axisDefault ))
|
||||
{
|
||||
Matrix4x4_Rotate( m_pCurrentEntity->matrix, dir, lightVector );
|
||||
VectorSubtract(r_refdef.vieworg, m_pCurrentEntity->origin, dir);
|
||||
Matrix4x4_Rotate( m_pCurrentEntity->matrix, dir, eyeVector );
|
||||
VectorRotate( dir, m_pCurrentEntity->axis, lightVector );
|
||||
|
||||
VectorSubtract( r_origin, m_pCurrentEntity->origin, dir );
|
||||
VectorRotate( dir, m_pCurrentEntity->axis, eyeVector );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -648,18 +649,10 @@ static void RB_SetupVertexProgram( shaderStage_t *stage )
|
|||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 1, r_forward[0], r_forward[1], r_forward[2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 2, r_right[0], r_right[1], r_right[2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 3, r_up[0], r_up[1], r_up[2], 0 );
|
||||
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 4, m_pCurrentEntity->origin[0], m_pCurrentEntity->origin[1], m_pCurrentEntity->origin[2], 0 );
|
||||
#ifdef OPENGL_STYLE
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 5, m_pCurrentEntity->matrix[0][0], m_pCurrentEntity->matrix[1][0], m_pCurrentEntity->matrix[2][0], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 6, m_pCurrentEntity->matrix[0][1], m_pCurrentEntity->matrix[1][1], m_pCurrentEntity->matrix[2][1], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 7, m_pCurrentEntity->matrix[0][2], m_pCurrentEntity->matrix[1][2], m_pCurrentEntity->matrix[2][2], 0 );
|
||||
#else
|
||||
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 5, m_pCurrentEntity->matrix[0][0], m_pCurrentEntity->matrix[0][1], m_pCurrentEntity->matrix[0][2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 6, m_pCurrentEntity->matrix[1][0], m_pCurrentEntity->matrix[1][1], m_pCurrentEntity->matrix[1][2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 7, m_pCurrentEntity->matrix[2][0], m_pCurrentEntity->matrix[2][1], m_pCurrentEntity->matrix[2][2], 0 );
|
||||
#endif
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 5, m_pCurrentEntity->axis[0][0], m_pCurrentEntity->axis[0][1], m_pCurrentEntity->axis[0][2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 6, m_pCurrentEntity->axis[1][0], m_pCurrentEntity->axis[1][1], m_pCurrentEntity->axis[1][2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 7, m_pCurrentEntity->axis[2][0], m_pCurrentEntity->axis[2][1], m_pCurrentEntity->axis[2][2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_VERTEX_PROGRAM_ARB, 8, m_fShaderTime, 0, 0, 0 );
|
||||
}
|
||||
|
||||
|
@ -677,17 +670,10 @@ static void RB_SetupFragmentProgram( shaderStage_t *stage )
|
|||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 1, r_forward[0], r_forward[1], r_forward[2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 2, r_right[0], r_right[1], r_right[2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 3, r_up[0], r_up[1], r_up[2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 4, m_pCurrentEntity->origin[0], m_pCurrentEntity->origin[1], m_pCurrentEntity->origin[2], 0);
|
||||
|
||||
#ifdef OPENGL_STYLE
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 5, m_pCurrentEntity->matrix[0][0], m_pCurrentEntity->matrix[1][0], m_pCurrentEntity->matrix[2][0], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 6, m_pCurrentEntity->matrix[0][1], m_pCurrentEntity->matrix[1][1], m_pCurrentEntity->matrix[2][1], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 7, m_pCurrentEntity->matrix[0][2], m_pCurrentEntity->matrix[1][2], m_pCurrentEntity->matrix[2][2], 0 );
|
||||
#else
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 5, m_pCurrentEntity->matrix[0][0], m_pCurrentEntity->matrix[0][1], m_pCurrentEntity->matrix[0][2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 6, m_pCurrentEntity->matrix[1][0], m_pCurrentEntity->matrix[1][1], m_pCurrentEntity->matrix[1][2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 7, m_pCurrentEntity->matrix[2][0], m_pCurrentEntity->matrix[2][1], m_pCurrentEntity->matrix[2][2], 0 );
|
||||
#endif
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 4, m_pCurrentEntity->origin[0], m_pCurrentEntity->origin[1], m_pCurrentEntity->origin[2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 5, m_pCurrentEntity->axis[0][0], m_pCurrentEntity->axis[0][1], m_pCurrentEntity->axis[0][2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 6, m_pCurrentEntity->axis[1][0], m_pCurrentEntity->axis[1][1], m_pCurrentEntity->axis[1][2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 7, m_pCurrentEntity->axis[2][0], m_pCurrentEntity->axis[2][1], m_pCurrentEntity->axis[2][2], 0 );
|
||||
pglProgramLocalParameter4fARB( GL_FRAGMENT_PROGRAM_ARB, 8, m_fShaderTime, 0, 0, 0 );
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1008,7 @@ static void RB_DrawTris( void )
|
|||
{
|
||||
pglPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
|
||||
|
||||
pglColor4ub( 255, 255, 255, 255 );
|
||||
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
pglDisableClientState( GL_NORMAL_ARRAY );
|
||||
pglDisableClientState( GL_COLOR_ARRAY );
|
||||
|
@ -1062,7 +1048,7 @@ static void RB_DrawNormals( void )
|
|||
if( m_pRenderMesh->meshType == MESH_POLY )
|
||||
return;
|
||||
|
||||
pglColor4ub( 255, 255, 255, 255 );
|
||||
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
pglBegin( GL_LINES );
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
|
@ -1087,7 +1073,7 @@ static void RB_DrawTangentSpace( void )
|
|||
if( m_pRenderMesh->meshType != MESH_SURFACE && m_pRenderMesh->meshType != MESH_STUDIO )
|
||||
return;
|
||||
|
||||
pglColor4ub( 255, 0, 0, 255 );
|
||||
pglColor4f( 1.0f, 0.0f, 0.0f, 1.0f );
|
||||
|
||||
pglBegin( GL_LINES );
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
|
@ -1098,7 +1084,7 @@ static void RB_DrawTangentSpace( void )
|
|||
}
|
||||
pglEnd();
|
||||
|
||||
pglColor4ub( 0, 255, 0, 255 );
|
||||
pglColor4f( 0.0f, 1.0f, 0.0f, 1.0f );
|
||||
|
||||
pglBegin( GL_LINES );
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
|
@ -1109,7 +1095,7 @@ static void RB_DrawTangentSpace( void )
|
|||
}
|
||||
pglEnd();
|
||||
|
||||
pglColor4ub( 0, 0, 255, 255 );
|
||||
pglColor4f( 0.0f, 0.0f, 1.0f, 1.0f );
|
||||
|
||||
pglBegin( GL_LINES );
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
|
@ -1154,7 +1140,7 @@ static void RB_DrawModelBounds( void )
|
|||
else return;
|
||||
|
||||
// draw it
|
||||
pglColor4ub( 255, 255, 255, 255 );
|
||||
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
pglBegin( GL_LINES );
|
||||
for( i = 0; i < 2; i += 1 )
|
||||
|
|
|
@ -181,7 +181,7 @@ static bool R_RecursiveLightPoint( node_t *node, const vec3_t start, const vec3_
|
|||
|
||||
for( map = 0; map < surf->numStyles; map++ )
|
||||
{
|
||||
VectorScale(r_refdef.lightstyles[surf->styles[map]].rgb, r_modulate->value * (1.0/255), scale);
|
||||
VectorScale( r_refdef.lightstyles[surf->styles[map]].rgb, r_modulate->value, scale );
|
||||
|
||||
r_pointColor[0] += lm[0] * scale[0];
|
||||
r_pointColor[1] += lm[1] * scale[1];
|
||||
|
@ -233,7 +233,7 @@ void R_LightForPoint( const vec3_t point, vec3_t ambientLight )
|
|||
if( !dist || dist > dl->intensity )
|
||||
continue;
|
||||
|
||||
add = (dl->intensity - dist) * (1.0/255);
|
||||
add = (dl->intensity - dist);
|
||||
VectorMA( ambientLight, add, dl->color, ambientLight );
|
||||
}
|
||||
}
|
||||
|
@ -345,10 +345,10 @@ void R_LightingAmbient( void )
|
|||
{
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
colorArray[i][0] = 255;
|
||||
colorArray[i][1] = 255;
|
||||
colorArray[i][2] = 255;
|
||||
colorArray[i][3] = 255;
|
||||
colorArray[i][0] = 1.0f;
|
||||
colorArray[i][1] = 1.0f;
|
||||
colorArray[i][2] = 1.0f;
|
||||
colorArray[i][3] = 1.0f;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ void R_LightingAmbient( void )
|
|||
if( !dist || dist > dl->intensity + radius )
|
||||
continue;
|
||||
|
||||
add = (dl->intensity - dist) * (1.0/255);
|
||||
add = (dl->intensity - dist);
|
||||
VectorMA( ambientLight, add, dl->color, ambientLight );
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ void R_LightingAmbient( void )
|
|||
colorArray[i][0] = ambientLight[0];
|
||||
colorArray[i][1] = ambientLight[1];
|
||||
colorArray[i][2] = ambientLight[2];
|
||||
colorArray[i][3] = 255;
|
||||
colorArray[i][3] = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,10 +421,10 @@ void R_LightingDiffuse( void )
|
|||
{
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
{
|
||||
colorArray[i][0] = 255;
|
||||
colorArray[i][1] = 255;
|
||||
colorArray[i][2] = 255;
|
||||
colorArray[i][3] = 255;
|
||||
colorArray[i][0] = 1.0f;
|
||||
colorArray[i][1] = 1.0f;
|
||||
colorArray[i][2] = 1.0f;
|
||||
colorArray[i][3] = 1.0f;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ void R_LightingDiffuse( void )
|
|||
}
|
||||
|
||||
// Compute lighting at each vertex
|
||||
Matrix4x4_Rotate( m_pCurrentEntity->matrix, lightDir, dir );
|
||||
VectorRotate( lightDir, m_pCurrentEntity->axis, dir );
|
||||
VectorNormalizeFast( dir );
|
||||
|
||||
for( i = 0; i < numVertex; i++ )
|
||||
|
@ -481,7 +481,7 @@ void R_LightingDiffuse( void )
|
|||
if( !dist || dist > dl->intensity + radius )
|
||||
continue;
|
||||
|
||||
Matrix4x4_Rotate( m_pCurrentEntity->matrix, dir, lightDir );
|
||||
VectorRotate( dir, m_pCurrentEntity->axis, lightDir );
|
||||
intensity = dl->intensity * 8;
|
||||
|
||||
// compute lighting at each vertex
|
||||
|
@ -506,7 +506,7 @@ void R_LightingDiffuse( void )
|
|||
colorArray[i][0] = r_lightColors[i][0];
|
||||
colorArray[i][1] = r_lightColors[i][1];
|
||||
colorArray[i][2] = r_lightColors[i][2];
|
||||
colorArray[i][3] = 255;
|
||||
colorArray[i][3] = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ LIGHT SAMPLING
|
|||
=======================================================================
|
||||
*/
|
||||
|
||||
static float r_blockLights[128*128*3];
|
||||
static vec3_t r_blockLights[128*128];
|
||||
|
||||
|
||||
/*
|
||||
|
@ -557,10 +557,10 @@ static void R_AddDynamicLights( surface_t *surf )
|
|||
if(!(surf->dlightBits & (1<<l)))
|
||||
continue; // not lit by this light
|
||||
|
||||
if(!Matrix4x4_CompareRotateOnly( m_pCurrentEntity->matrix, identitymatrix ))
|
||||
if( !AxisCompare( m_pCurrentEntity->axis, axisDefault ))
|
||||
{
|
||||
VectorSubtract( dl->origin, m_pCurrentEntity->origin, tmp );
|
||||
Matrix4x4_Rotate( m_pCurrentEntity->matrix, tmp, origin );
|
||||
VectorRotate( tmp, m_pCurrentEntity->axis, origin );
|
||||
}
|
||||
else VectorSubtract( dl->origin, m_pCurrentEntity->origin, origin );
|
||||
|
||||
|
@ -582,7 +582,7 @@ static void R_AddDynamicLights( surface_t *surf )
|
|||
sl = DotProduct(impact, tex->vecs[0]) + tex->vecs[0][3] - surf->textureMins[0];
|
||||
tl = DotProduct(impact, tex->vecs[1]) + tex->vecs[1][3] - surf->textureMins[1];
|
||||
|
||||
bl = r_blockLights;
|
||||
bl = (float *)r_blockLights;
|
||||
|
||||
for( t = 0, tacc = 0; t < surf->lmHeight; t++, tacc += 16 )
|
||||
{
|
||||
|
@ -630,7 +630,7 @@ static void R_BuildLightmap( surface_t *surf, byte *dest, int stride )
|
|||
if( !lm )
|
||||
{
|
||||
// set to full bright if no light data
|
||||
for( i = 0, bl = r_blockLights; i < size; i++, bl += 3 )
|
||||
for( i = 0, bl = (float *)r_blockLights; i < size; i++, bl += 3 )
|
||||
{
|
||||
bl[0] = 255;
|
||||
bl[1] = 255;
|
||||
|
@ -642,7 +642,7 @@ static void R_BuildLightmap( surface_t *surf, byte *dest, int stride )
|
|||
// add all the lightmaps
|
||||
VectorScale( r_refdef.lightstyles[surf->styles[0]].rgb, r_modulate->value, scale );
|
||||
|
||||
for( i = 0, bl = r_blockLights; i < size; i++, bl += 3, lm += 3 )
|
||||
for( i = 0, bl = (float *)r_blockLights; i < size; i++, bl += 3, lm += 3 )
|
||||
{
|
||||
bl[0] = lm[0] * scale[0];
|
||||
bl[1] = lm[1] * scale[1];
|
||||
|
@ -654,7 +654,7 @@ static void R_BuildLightmap( surface_t *surf, byte *dest, int stride )
|
|||
for( map = 1; map < surf->numStyles; map++ )
|
||||
{
|
||||
VectorScale( r_refdef.lightstyles[surf->styles[map]].rgb, r_modulate->value, scale );
|
||||
for( i = 0, bl = r_blockLights; i < size; i++, bl += 3, lm += 3 )
|
||||
for( i = 0, bl = (float *)r_blockLights; i < size; i++, bl += 3, lm += 3 )
|
||||
{
|
||||
bl[0] += lm[0] * scale[0];
|
||||
bl[1] += lm[1] * scale[1];
|
||||
|
@ -670,7 +670,7 @@ static void R_BuildLightmap( surface_t *surf, byte *dest, int stride )
|
|||
|
||||
// put into texture format
|
||||
stride -= (surf->lmWidth<<2);
|
||||
bl = r_blockLights;
|
||||
bl = (float *)r_blockLights;
|
||||
|
||||
for( t = 0; t < surf->lmHeight; t++ )
|
||||
{
|
||||
|
@ -723,7 +723,7 @@ static void R_UploadLightmap( void )
|
|||
r_generic.type = PF_RGBA_GN; // generated
|
||||
r_generic.size = r_generic.width * r_generic.height * 4;
|
||||
r_generic.numMips = 1;
|
||||
r_generic.buffer = r_lmState.buffer;
|
||||
r_generic.buffer = (byte *)r_lmState.buffer;
|
||||
r_lightmapTextures[r_lmState.currentNum++] = R_LoadTexture( name, &r_generic, TF_CLAMP, 0 );
|
||||
|
||||
// reset
|
||||
|
@ -778,18 +778,20 @@ R_BeginBuildingLightmaps
|
|||
*/
|
||||
void R_BeginBuildingLightmaps( void )
|
||||
{
|
||||
static lightstyle_t lightstyles[MAX_LIGHTSTYLES];
|
||||
int i;
|
||||
|
||||
|
||||
// setup the base lightstyles so the lightmaps
|
||||
// won't have to be regenerated the first time they're seen
|
||||
for( i = 0; i < MAX_LIGHTSTYLES; i++ )
|
||||
{
|
||||
r_refdef.lightstyles[i].white = 3;
|
||||
r_refdef.lightstyles[i].rgb[0] = 1;
|
||||
r_refdef.lightstyles[i].rgb[1] = 1;
|
||||
r_refdef.lightstyles[i].rgb[2] = 1;
|
||||
lightstyles[i].white = 3;
|
||||
lightstyles[i].rgb[0] = 1;
|
||||
lightstyles[i].rgb[1] = 1;
|
||||
lightstyles[i].rgb[2] = 1;
|
||||
}
|
||||
|
||||
r_refdef.lightstyles = lightstyles;
|
||||
|
||||
r_lmState.currentNum = -1;
|
||||
memset( r_lmState.allocated, 0, sizeof( r_lmState.allocated ));
|
||||
memset( r_lmState.buffer, 255, sizeof( r_lmState.buffer ));
|
||||
|
|
|
@ -41,6 +41,7 @@ extern byte *r_temppool;
|
|||
#define TF_HEIGHTMAP 0x0020 // need heightmap
|
||||
#define TF_LUMA 0x0040 // need luminance
|
||||
#define TF_COMPRESS 0x0080 // compress image
|
||||
#define TF_STATIC 0x0100 // never freed by R_ImageFreeUnused()
|
||||
|
||||
// manager flags (don't try set this flags manually, engine will be reset it)
|
||||
#define TF_MIPMAPS 0x1000 // image contained miplevels (base or generated by engine)
|
||||
|
@ -480,7 +481,7 @@ typedef struct particle_s
|
|||
float radius;
|
||||
float length;
|
||||
float rotation;
|
||||
color32 modulate;
|
||||
vec4_t modulate;
|
||||
} particle_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -488,7 +489,7 @@ typedef struct
|
|||
vec3_t xyz;
|
||||
vec2_t st;
|
||||
vec2_t lightmap;
|
||||
color32 color;
|
||||
vec4_t color;
|
||||
} surfPolyVert_t;
|
||||
|
||||
typedef struct surfPoly_s
|
||||
|
@ -842,10 +843,10 @@ typedef struct ref_entity_s
|
|||
|
||||
// shader information
|
||||
shader_t *shader;
|
||||
color32 shaderRGBA; // used by rgbGen/alphaGen entity shaders
|
||||
vec4_t shaderRGBA; // used by rgbGen/alphaGen entity shaders
|
||||
float shaderTime; // subtracted from refdef time to control effect start times
|
||||
float radius; // bbox approximate radius
|
||||
matrix4x4 matrix; // entity transformation matrix
|
||||
vec3_t axis[3]; // Rotation vectors
|
||||
float rotation; // what the hell ???
|
||||
} ref_entity_t;
|
||||
|
||||
|
@ -934,8 +935,8 @@ typedef struct glstate_s
|
|||
|
||||
vec4_t draw_color; // current color
|
||||
uint activeTMU;
|
||||
int *texNum;
|
||||
int *texEnv;
|
||||
int texNum[MAX_TEXTURE_UNITS];
|
||||
int texEnv[MAX_TEXTURE_UNITS];
|
||||
|
||||
// render current state
|
||||
bool cullFace;
|
||||
|
@ -1125,11 +1126,11 @@ extern vec3_t r_up;
|
|||
|
||||
extern gl_matrix r_projectionMatrix;
|
||||
extern gl_matrix r_worldMatrix;
|
||||
extern matrix4x4 r_entityMatrix;
|
||||
extern gl_matrix r_entityMatrix;
|
||||
extern gl_matrix r_textureMatrix;
|
||||
|
||||
extern cplane_t r_frustum[4];
|
||||
|
||||
extern vec3_t axisDefault[3];
|
||||
extern float r_frameTime;
|
||||
|
||||
extern mesh_t r_solidMeshes[MAX_MESHES];
|
||||
|
@ -1198,6 +1199,15 @@ void R_DrawStretchRaw( int x, int y, int w, int h, int width, int height, const
|
|||
void R_DrawStretchPic( float x, float y, float w, float h, float sl, float tl, float sh, float th, const char *name );
|
||||
void R_GetPicSize( int *w, int *h, const char *pic );
|
||||
|
||||
// r_utils.c (test)
|
||||
void AxisClear( vec3_t axis[3] );
|
||||
void AnglesToAxis ( const vec3_t angles );
|
||||
void AxisCopy( const vec3_t in[3], vec3_t out[3] );
|
||||
void AnglesToAxisPrivate (const vec3_t angles, vec3_t axis[3]);
|
||||
bool AxisCompare( const vec3_t axis1[3], const vec3_t axis2[3] );
|
||||
void VectorRotate ( const vec3_t v, const vec3_t matrix[3], vec3_t out );
|
||||
void MatrixGL_MultiplyFast (const gl_matrix m1, const gl_matrix m2, gl_matrix out);
|
||||
|
||||
// cvars
|
||||
extern cvar_t *r_check_errors;
|
||||
extern cvar_t *r_himodels;
|
||||
|
|
|
@ -14,7 +14,7 @@ stdlib_api_t com;
|
|||
byte *r_temppool;
|
||||
gl_matrix r_projectionMatrix;
|
||||
gl_matrix r_worldMatrix;
|
||||
matrix4x4 r_entityMatrix;
|
||||
gl_matrix r_entityMatrix;
|
||||
gl_matrix r_textureMatrix;
|
||||
cplane_t r_frustum[4];
|
||||
float r_frameTime;
|
||||
|
@ -167,9 +167,28 @@ R_RotateForEntity
|
|||
*/
|
||||
void R_RotateForEntity( ref_entity_t *entity )
|
||||
{
|
||||
//FIXME
|
||||
//Matrix4x4_Concat( r_entityMatrix, r_worldMatrix, entity->matrix );
|
||||
//GL_LoadMatrix( r_entityMatrix );
|
||||
gl_matrix rotateMatrix;
|
||||
|
||||
rotateMatrix[ 0] = entity->axis[0][0];
|
||||
rotateMatrix[ 1] = entity->axis[0][1];
|
||||
rotateMatrix[ 2] = entity->axis[0][2];
|
||||
rotateMatrix[ 3] = 0.0;
|
||||
rotateMatrix[ 4] = entity->axis[1][0];
|
||||
rotateMatrix[ 5] = entity->axis[1][1];
|
||||
rotateMatrix[ 6] = entity->axis[1][2];
|
||||
rotateMatrix[ 7] = 0.0;
|
||||
rotateMatrix[ 8] = entity->axis[2][0];
|
||||
rotateMatrix[ 9] = entity->axis[2][1];
|
||||
rotateMatrix[10] = entity->axis[2][2];
|
||||
rotateMatrix[11] = 0.0;
|
||||
rotateMatrix[12] = entity->origin[0];
|
||||
rotateMatrix[13] = entity->origin[1];
|
||||
rotateMatrix[14] = entity->origin[2];
|
||||
rotateMatrix[15] = 1.0;
|
||||
|
||||
MatrixGL_MultiplyFast(r_worldMatrix, rotateMatrix, r_entityMatrix);
|
||||
|
||||
pglLoadMatrixf(r_entityMatrix);
|
||||
}
|
||||
|
||||
|
||||
|
@ -294,10 +313,7 @@ void R_DrawSprite( void )
|
|||
normalArray[numVertex][0] = axis[0][0];
|
||||
normalArray[numVertex][1] = axis[0][1];
|
||||
normalArray[numVertex][2] = axis[0][2];
|
||||
inColorArray[numVertex][0] = m_pCurrentEntity->shaderRGBA.r;
|
||||
inColorArray[numVertex][1] = m_pCurrentEntity->shaderRGBA.g;
|
||||
inColorArray[numVertex][2] = m_pCurrentEntity->shaderRGBA.b;
|
||||
inColorArray[numVertex][3] = m_pCurrentEntity->shaderRGBA.a;
|
||||
Vector4Copy(m_pCurrentEntity->shaderRGBA, inColorArray[numVertex] );
|
||||
numVertex++;
|
||||
}
|
||||
}
|
||||
|
@ -390,10 +406,7 @@ void R_DrawBeam( void )
|
|||
normalArray[numVertex][0] = axis[0][0];
|
||||
normalArray[numVertex][1] = axis[0][1];
|
||||
normalArray[numVertex][2] = axis[0][2];
|
||||
inColorArray[numVertex][0] = m_pCurrentEntity->shaderRGBA.r;
|
||||
inColorArray[numVertex][1] = m_pCurrentEntity->shaderRGBA.g;
|
||||
inColorArray[numVertex][2] = m_pCurrentEntity->shaderRGBA.b;
|
||||
inColorArray[numVertex][3] = m_pCurrentEntity->shaderRGBA.a;
|
||||
Vector4Copy(m_pCurrentEntity->shaderRGBA, inColorArray[numVertex] );
|
||||
numVertex++;
|
||||
}
|
||||
}
|
||||
|
@ -498,21 +511,21 @@ static void R_DrawNullModels( void )
|
|||
{
|
||||
entity = r_nullModels[i];
|
||||
|
||||
VectorMA( entity->origin, 15, entity->matrix[0], points[0] );
|
||||
VectorMA( entity->origin, -15, entity->matrix[1], points[1] );
|
||||
VectorMA( entity->origin, 15, entity->matrix[2], points[2] );
|
||||
VectorMA( entity->origin, 15, entity->axis[0], points[0] );
|
||||
VectorMA( entity->origin, -15, entity->axis[1], points[1] );
|
||||
VectorMA( entity->origin, 15, entity->axis[2], points[2] );
|
||||
|
||||
pglBegin( GL_LINES );
|
||||
|
||||
pglColor4ub( 255, 0, 0, 127 );
|
||||
pglColor4f( 1.0f, 0.0f, 0.0f, 0.5f );
|
||||
pglVertex3fv( entity->origin );
|
||||
pglVertex3fv( points[0] );
|
||||
|
||||
pglColor4ub( 0, 255, 0, 127 );
|
||||
pglColor4f( 0, 1.0f, 0, 0.5f );
|
||||
pglVertex3fv( entity->origin );
|
||||
pglVertex3fv( points[1] );
|
||||
|
||||
pglColor4ub( 0, 0, 255, 127 );
|
||||
pglColor4f( 0, 0, 1.0f, 0.5f );
|
||||
pglVertex3fv( entity->origin );
|
||||
pglVertex3fv( points[2] );
|
||||
|
||||
|
@ -625,10 +638,7 @@ void R_DrawParticle( void )
|
|||
normalArray[numVertex][0] = axis[0][0];
|
||||
normalArray[numVertex][1] = axis[0][1];
|
||||
normalArray[numVertex][2] = axis[0][2];
|
||||
inColorArray[numVertex][0] = particle->modulate.r;
|
||||
inColorArray[numVertex][1] = particle->modulate.g;
|
||||
inColorArray[numVertex][2] = particle->modulate.b;
|
||||
inColorArray[numVertex][3] = particle->modulate.a;
|
||||
Vector4Copy(particle->modulate, inColorArray[numVertex] );
|
||||
numVertex++;
|
||||
}
|
||||
}
|
||||
|
@ -803,36 +813,6 @@ void R_AddMeshToList( meshType_t meshType, void *mesh, shader_t *shader, ref_ent
|
|||
|
||||
// =====================================================================
|
||||
|
||||
/*
|
||||
=================
|
||||
AnglesToAxis
|
||||
=================
|
||||
*/
|
||||
void AnglesToAxis ( const vec3_t angles )
|
||||
{
|
||||
static float sp, sy, sr, cp, cy, cr;
|
||||
float angle;
|
||||
|
||||
angle = DEG2RAD(angles[PITCH]);
|
||||
sp = sin(angle);
|
||||
cp = cos(angle);
|
||||
angle = DEG2RAD(angles[YAW]);
|
||||
sy = sin(angle);
|
||||
cy = cos(angle);
|
||||
angle = DEG2RAD(angles[ROLL]);
|
||||
sr = sin(angle);
|
||||
cr = cos(angle);
|
||||
|
||||
r_forward[0] = cp*cy;
|
||||
r_forward[1] = cp*sy;
|
||||
r_forward[2] = -sp;
|
||||
r_right[0] = sr*sp*cy+cr*-sy;
|
||||
r_right[1] = sr*sp*sy+cr*cy;
|
||||
r_right[2] = sr*cp;
|
||||
r_up[0] = cr*sp*cy+-sr*-sy;
|
||||
r_up[1] = cr*sp*sy+-sr*cy;
|
||||
r_up[2] = cr*cp;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
|
@ -845,7 +825,6 @@ static void R_SetFrustum( void )
|
|||
|
||||
// build the transformation matrix for the given view angles
|
||||
VectorCopy( r_refdef.vieworg, r_origin );
|
||||
//AngleVectors( r_refdef.viewangles, r_forward, r_right, r_up );
|
||||
AnglesToAxis( r_refdef.viewangles );
|
||||
|
||||
RotatePointAroundVector( r_frustum[0].normal, r_up, r_forward, -(90 - r_refdef.fov_x / 2));
|
||||
|
@ -911,8 +890,6 @@ static void R_SetMatrices( void )
|
|||
yDiv = 1.0 / (yMax - yMin);
|
||||
zDiv = 1.0 / (zFar - zNear);
|
||||
|
||||
// FIXME: make support for OPENGL_STYLE matrices
|
||||
|
||||
r_projectionMatrix[ 0] = (2.0 * zNear) * xDiv;
|
||||
r_projectionMatrix[ 1] = 0.0;
|
||||
r_projectionMatrix[ 2] = 0.0;
|
||||
|
@ -1199,8 +1176,8 @@ static bool R_AddEntityToScene( refdef_t *fd, entity_state_t *s1, entity_state_t
|
|||
r_worldEntity = &fd->entities[fd->num_entities++];
|
||||
r_worldEntity->model = r_worldModel;
|
||||
r_worldEntity->ent_type = ED_NORMAL;
|
||||
MatrixLoadIdentity( r_worldEntity->matrix );
|
||||
r_worldEntity->shaderRGBA = MakeRGBA( 255, 255, 255, 255 );
|
||||
AxisClear( r_worldEntity->axis );
|
||||
Vector4Set( r_worldEntity->shaderRGBA, 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
refent = &fd->entities[fd->num_entities];
|
||||
}
|
||||
|
||||
|
@ -1251,6 +1228,8 @@ static bool R_AddEntityToScene( refdef_t *fd, entity_state_t *s1, entity_state_t
|
|||
refent->angles[i] = LerpAngle( s2->angles[i], s1->angles[i], lerpfrac );
|
||||
}
|
||||
|
||||
AnglesToAxisPrivate( refent->angles, refent->axis );
|
||||
|
||||
// copy controllers
|
||||
for( i = 0; i < MAXSTUDIOCONTROLLERS; i++ )
|
||||
{
|
||||
|
@ -1326,7 +1305,7 @@ bool R_AddParticleToScene( refdef_t *fd, const vec3_t origin, float alpha, int c
|
|||
p->radius = 5;
|
||||
p->length = alpha;
|
||||
p->rotation = 0;
|
||||
p->modulate = MakeRGBA( 255, 255, 255, 255 );
|
||||
Vector4Set( p->modulate, 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
fd->num_particles++;
|
||||
r_refdef = *fd;
|
||||
|
||||
|
|
|
@ -590,15 +590,15 @@ static void R_SubdividePolygon( surface_t *surf, int numVerts, float *verts )
|
|||
totalLM[1] += t;
|
||||
|
||||
// vertex color
|
||||
p->vertices[i+1].color.r = 255;
|
||||
p->vertices[i+1].color.g = 255;
|
||||
p->vertices[i+1].color.b = 255;
|
||||
p->vertices[i+1].color.a = 255;
|
||||
p->vertices[i+1].color[0] = 1.0f;
|
||||
p->vertices[i+1].color[1] = 1.0f;
|
||||
p->vertices[i+1].color[2] = 1.0f;
|
||||
p->vertices[i+1].color[3] = 1.0f;
|
||||
|
||||
if( texInfo->flags & SURF_TRANS33 )
|
||||
p->vertices[i+1].color.a *= 0.33;
|
||||
p->vertices[i+1].color[3] *= 0.33;
|
||||
else if( texInfo->flags & SURF_TRANS66 )
|
||||
p->vertices[i+1].color.a *= 0.66;
|
||||
p->vertices[i+1].color[3] *= 0.66;
|
||||
}
|
||||
|
||||
// vertex
|
||||
|
@ -613,15 +613,15 @@ static void R_SubdividePolygon( surface_t *surf, int numVerts, float *verts )
|
|||
p->vertices[0].lightmap[1] = totalLM[1] / numVerts;
|
||||
|
||||
// vertex color
|
||||
p->vertices[0].color.r = 255;
|
||||
p->vertices[0].color.g = 255;
|
||||
p->vertices[0].color.b = 255;
|
||||
p->vertices[0].color.a = 255;
|
||||
p->vertices[0].color[0] = 1.0f;
|
||||
p->vertices[0].color[1] = 1.0f;
|
||||
p->vertices[0].color[2] = 1.0f;
|
||||
p->vertices[0].color[3] = 1.0f;
|
||||
|
||||
if( texInfo->flags & SURF_TRANS33 )
|
||||
p->vertices[0].color.a *= 0.33;
|
||||
p->vertices[0].color[3] *= 0.33;
|
||||
else if( texInfo->flags & SURF_TRANS66 )
|
||||
p->vertices[0].color.b *= 0.66;
|
||||
p->vertices[0].color[3] *= 0.66;
|
||||
|
||||
// copy first vertex to last
|
||||
Mem_Copy( &p->vertices[i+1], &p->vertices[1], sizeof(surfPolyVert_t));
|
||||
|
@ -691,15 +691,15 @@ static void R_BuildPolygon( surface_t *surf, int numVerts, float *verts )
|
|||
p->vertices[i].lightmap[1] = t;
|
||||
|
||||
// vertex color
|
||||
p->vertices[i+1].color.r = 255;
|
||||
p->vertices[i+1].color.g = 255;
|
||||
p->vertices[i+1].color.b = 255;
|
||||
p->vertices[i+1].color.a = 255;
|
||||
p->vertices[i+1].color[0] = 1.0f;
|
||||
p->vertices[i+1].color[1] = 1.0f;
|
||||
p->vertices[i+1].color[2] = 1.0f;
|
||||
p->vertices[i+1].color[3] = 1.0f;
|
||||
|
||||
if( texInfo->flags & SURF_TRANS33 )
|
||||
p->vertices[i+1].color.a *= 0.33;
|
||||
p->vertices[i+1].color[3] *= 0.33;
|
||||
else if( texInfo->flags & SURF_TRANS66 )
|
||||
p->vertices[i+1].color.a *= 0.66;
|
||||
p->vertices[i+1].color[3] *= 0.66;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3084,7 +3084,7 @@ static shader_t *R_CreateDefaultShader( const char *name, shaderType_t shaderTyp
|
|||
shader->stages[1]->bundles[0]->texType = TEX_LIGHTMAP;
|
||||
shader->stages[1]->flags |= SHADERSTAGE_BLENDFUNC;
|
||||
shader->stages[1]->blendFunc.src = GL_DST_COLOR;
|
||||
shader->stages[1]->blendFunc.dst = GL_ZERO;
|
||||
shader->stages[1]->blendFunc.dst = GL_ONE; //FIXME: was GL_ZERO
|
||||
shader->stages[1]->numBundles++;
|
||||
shader->numStages++;
|
||||
}
|
||||
|
@ -3106,7 +3106,7 @@ static shader_t *R_CreateDefaultShader( const char *name, shaderType_t shaderTyp
|
|||
// FIXME: make case SHADER_FONT and func RegisterShaderFont
|
||||
if(com.stristr( shader->name, "fonts/" )) buffer = FS_LoadInternal( "default.dds", &bufsize );
|
||||
shader->stages[0]->bundles[0]->flags |= STAGEBUNDLE_MAP;
|
||||
shader->stages[0]->bundles[0]->textures[0] = R_FindTexture( shader->name, buffer, bufsize, TF_COMPRESS, 0 );
|
||||
shader->stages[0]->bundles[0]->textures[0] = R_FindTexture( shader->name, buffer, bufsize, TF_COMPRESS|TF_IMAGE2D, 0 );
|
||||
if( !shader->stages[0]->bundles[0]->textures[0] )
|
||||
{
|
||||
MsgDev( D_WARN, "couldn't find texture for shader '%s', using default...\n", shader->name );
|
||||
|
|
|
@ -343,7 +343,7 @@ static void R_DrawSkyBox( texture_t *textures[6], bool blended )
|
|||
pglDepthRange( 1, 1 );
|
||||
pglEnable( GL_TEXTURE_2D );
|
||||
|
||||
pglColor4ub( 255, 255, 255, 255 );
|
||||
pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
pglDisableClientState( GL_NORMAL_ARRAY );
|
||||
pglDisableClientState( GL_COLOR_ARRAY );
|
||||
|
||||
|
@ -412,11 +412,8 @@ void R_DrawSky( void )
|
|||
// compute and load matrix
|
||||
VectorNegate( r_forward, r_backward );
|
||||
VectorNegate( r_right, r_left );
|
||||
Matrix4x4_FromVectors( matrix, r_left, r_up, r_backward, vec3_origin );
|
||||
|
||||
// FIXME:
|
||||
//if( sky->rotate ) Matrix4x4_CreateRotate( matrix, r_refdef.time * sky->rotate, sky->axis[0], sky->axis[1], sky->axis[2]);
|
||||
|
||||
Matrix4x4_FromVectors( matrix, r_left, r_up, r_backward, r_origin );
|
||||
if( sky->rotate ) Matrix4x4_ConcatRotate( matrix, r_refdef.time * sky->rotate, sky->axis[0], sky->axis[1], sky->axis[2] );
|
||||
GL_LoadMatrix( matrix );
|
||||
|
||||
// build indices in tri-strip order
|
||||
|
@ -484,10 +481,10 @@ void R_DrawSky( void )
|
|||
normalArray[numVertex][2] = v->normal[2];
|
||||
inTexCoordArray[numVertex][0] = v->sphere[0];
|
||||
inTexCoordArray[numVertex][1] = v->sphere[1];
|
||||
inColorArray[numVertex][0] = 255;
|
||||
inColorArray[numVertex][1] = 255;
|
||||
inColorArray[numVertex][2] = 255;
|
||||
inColorArray[numVertex][3] = 255;
|
||||
inColorArray[numVertex][0] = 1.0f;
|
||||
inColorArray[numVertex][1] = 1.0f;
|
||||
inColorArray[numVertex][2] = 1.0f;
|
||||
inColorArray[numVertex][3] = 1.0f;
|
||||
numVertex++;
|
||||
}
|
||||
}
|
||||
|
@ -594,7 +591,9 @@ void R_SetupSky( const char *name, float rotate, const vec3_t axis )
|
|||
sky->shader = R_FindShader( name, SHADER_SKY, 0 );
|
||||
|
||||
sky->rotate = rotate;
|
||||
VectorCopy( axis, sky->axis );
|
||||
if(!VectorIsNull( axis ))
|
||||
VectorCopy( axis, sky->axis );
|
||||
else VectorSet( sky->axis, 0, 0, 1 );
|
||||
|
||||
// fill sky sides
|
||||
for( i = 0, skySide = sky->skySides; i < 6; i++, skySide++ )
|
||||
|
|
|
@ -60,10 +60,7 @@ void R_DrawSurface( void )
|
|||
inTexCoordArray[numVertex][1] = v->st[1];
|
||||
inTexCoordArray[numVertex][2] = v->lightmap[0];
|
||||
inTexCoordArray[numVertex][3] = v->lightmap[1];
|
||||
inColorArray[numVertex][0] = v->color.r;
|
||||
inColorArray[numVertex][1] = v->color.g;
|
||||
inColorArray[numVertex][2] = v->color.b;
|
||||
inColorArray[numVertex][3] = v->color.a;
|
||||
Vector4Copy(v->color, inColorArray[numVertex]);
|
||||
numVertex++;
|
||||
}
|
||||
}
|
||||
|
@ -140,8 +137,7 @@ static void R_AddSurfaceToList( surface_t *surf, ref_entity_t *entity )
|
|||
// check for lightmap modification
|
||||
if( r_dynamiclights->integer && (shader->flags & SHADER_HASLIGHTMAP))
|
||||
{
|
||||
if( surf->dlightFrame == r_frameCount )
|
||||
lmNum = 255;
|
||||
if( surf->dlightFrame == r_frameCount ) lmNum = 255;
|
||||
else
|
||||
{
|
||||
for( map = 0; map < surf->numStyles; map++ )
|
||||
|
@ -196,7 +192,7 @@ void R_AddBrushModelToList( ref_entity_t *entity )
|
|||
return;
|
||||
|
||||
// cull
|
||||
if( !Matrix4x4_CompareRotateOnly( entity->matrix, identitymatrix ))
|
||||
if( !AxisCompare( entity->axis, axisDefault ))
|
||||
{
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
|
@ -207,8 +203,8 @@ void R_AddBrushModelToList( ref_entity_t *entity )
|
|||
if( R_CullSphere( entity->origin, model->radius, 15 ))
|
||||
return;
|
||||
|
||||
VectorSubtract( r_refdef.vieworg, entity->origin, tmp );
|
||||
Matrix4x4_Rotate( entity->matrix, tmp, origin );
|
||||
VectorSubtract( r_origin, entity->origin, tmp );
|
||||
VectorRotate( tmp, entity->axis, origin );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -496,6 +496,10 @@ bool R_GetPixelFormat( rgbdata_t *pic, uint tex_flags, float bumpScale )
|
|||
|
||||
if( image_desc.MipCount < 1 ) image_desc.MipCount = 1;
|
||||
image_desc.pal = pic->palette;
|
||||
|
||||
// check for permanent images
|
||||
if( image_desc.format == PF_RGBA_GN ) image_desc.tflags |= TF_STATIC;
|
||||
if( tex_flags & TF_IMAGE2D ) image_desc.tflags |= TF_STATIC;
|
||||
}
|
||||
|
||||
// restore temp dimensions
|
||||
|
@ -624,7 +628,6 @@ void R_ShutdownTextures( void )
|
|||
static void R_CreateBuiltInTextures( void )
|
||||
{
|
||||
byte data2D[256*256*4];
|
||||
byte *data3D, *dataCM;
|
||||
rgbdata_t r_generic;
|
||||
vec3_t normal;
|
||||
int i, x, y;
|
||||
|
@ -681,7 +684,8 @@ static void R_CreateBuiltInTextures( void )
|
|||
|
||||
if( GL_Support( R_TEXTURECUBEMAP_EXT ))
|
||||
{
|
||||
data3D = dataCM = Mem_Alloc( r_imagepool, 128*128*4 * 6 );
|
||||
byte data3D[128*128*4*6]; // full cubemap size
|
||||
byte *dataCM = (byte *)data3D;
|
||||
|
||||
// normalize texture
|
||||
for( i = 0; i < 6; i++ )
|
||||
|
@ -727,13 +731,10 @@ static void R_CreateBuiltInTextures( void )
|
|||
|
||||
r_generic.width = 128;
|
||||
r_generic.height = 128;
|
||||
r_generic.size = r_generic.width * r_generic.height * 4;
|
||||
r_generic.size = (r_generic.width * r_generic.height * 4) * 6;
|
||||
r_generic.flags = IMAGE_CUBEMAP; // yes it's cubemap
|
||||
r_generic.buffer = (byte *)data3D;
|
||||
|
||||
//FIXME
|
||||
//r_normalizeTexture = R_LoadTexture( "*normalize", &r_generic, TF_CLAMP|TF_CUBEMAP, 0 );
|
||||
Mem_Free( data3D );
|
||||
r_normalizeTexture = R_LoadTexture( "*normalize", &r_generic, TF_CLAMP|TF_CUBEMAP, 0 );
|
||||
}
|
||||
|
||||
// screen rect texture (just reserve a slot)
|
||||
|
@ -1274,7 +1275,7 @@ bool qrsDecompressedTexImage2D( uint target, int level, int internalformat, uint
|
|||
int scaled_width, scaled_height;
|
||||
uint *scaled = (uint *)image_desc.scaled;
|
||||
byte *fout = image_desc.source;
|
||||
bool noalpha = true;
|
||||
bool has_alpha = false;
|
||||
|
||||
if (!data) return false;
|
||||
fin = (byte *)data;
|
||||
|
@ -1290,7 +1291,7 @@ bool qrsDecompressedTexImage2D( uint target, int level, int internalformat, uint
|
|||
for (i = 0; i < width * height; i++)
|
||||
{
|
||||
p = fin[i];
|
||||
if( p == 255 ) noalpha = false;
|
||||
if( p == 255 ) has_alpha = true;
|
||||
fout[(i<<2)+0] = image_desc.pal[p*3+0];
|
||||
fout[(i<<2)+1] = image_desc.pal[p*3+1];
|
||||
fout[(i<<2)+2] = image_desc.pal[p*3+2];
|
||||
|
@ -1309,7 +1310,7 @@ bool qrsDecompressedTexImage2D( uint target, int level, int internalformat, uint
|
|||
fout[(i<<2)+3] = 255;
|
||||
}
|
||||
}
|
||||
if( noalpha ) image_desc.flags &= ~IMAGE_HAS_ALPHA;
|
||||
if( !has_alpha ) image_desc.flags &= ~IMAGE_HAS_ALPHA;
|
||||
break;
|
||||
case PF_INDEXED_32:
|
||||
// sprite indexed frame with alphachannel
|
||||
|
@ -1343,8 +1344,8 @@ bool qrsDecompressedTexImage2D( uint target, int level, int internalformat, uint
|
|||
|
||||
R_RoundImageDimensions( &scaled_width, &scaled_height );
|
||||
if( image_desc.tflags & TF_COMPRESS )
|
||||
image_desc.glSamples = (noalpha) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB;
|
||||
else image_desc.glSamples = (noalpha) ? GL_RGB : GL_RGBA;
|
||||
image_desc.glSamples = (image_desc.flags & IMAGE_HAS_ALPHA) ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB;
|
||||
else image_desc.glSamples = (image_desc.flags & IMAGE_HAS_ALPHA) ? GL_RGBA : GL_RGB;
|
||||
R_ResampleTexture((uint *)fout, width, height, scaled, scaled_width, scaled_height);
|
||||
if( !level ) GL_GenerateMipmaps( scaled_width, scaled_height ); // generate mips if needed
|
||||
pglTexImage2D( target, level, image_desc.glSamples, scaled_width, scaled_height, border, image_desc.glMask, image_desc.glType, (byte *)scaled );
|
||||
|
@ -1364,13 +1365,13 @@ bool R_LoadImageRGBA( byte *data, GLuint target )
|
|||
int w = image_desc.width;
|
||||
int h = image_desc.height;
|
||||
int d = image_desc.numLayers; // ABGR_64 may using some layers
|
||||
|
||||
for( i = 0; i < image_desc.MipCount; i++, data += size )
|
||||
|
||||
for( i = 0; i < image_desc.MipCount; i++, data += size )
|
||||
{
|
||||
R_SetPixelFormat( w, h, d );
|
||||
size = image_desc.SizeOfFile;
|
||||
|
||||
if(!qrsDecompressedTexImage2D( target, i, image_desc.format, w, h, 0, size, data ))
|
||||
|
||||
if(!qrsDecompressedTexImage2D( target, i, image_desc.format, w, h, 0, size, data ))
|
||||
break; // there were errors
|
||||
w = (w+1)>>1, h = (h+1)>>1, d = (d+1)>>1; // calc size of next mip
|
||||
}
|
||||
|
@ -1668,7 +1669,6 @@ texture_t *R_LoadTexture( const char *name, rgbdata_t *pic, uint flags, float bu
|
|||
}
|
||||
|
||||
image = &r_textures[r_numTextures++];
|
||||
Mem_Alloc( r_imagepool, sizeof( texture_t ));
|
||||
if( com.strlen( name ) >= sizeof(image->name)) MsgDev( D_WARN, "R_LoadImage: \"%s\" is too long", name);
|
||||
|
||||
// nothing to load
|
||||
|
@ -1727,25 +1727,26 @@ texture_t *R_LoadTexture( const char *name, rgbdata_t *pic, uint flags, float bu
|
|||
image->width = width = pic->width;
|
||||
image->height = height = pic->height;
|
||||
image->bumpScale = bumpScale;
|
||||
image->flags = flags;
|
||||
buf = pic->buffer;
|
||||
buf = pic->buffer;
|
||||
|
||||
// fill image_desc
|
||||
R_GetPixelFormat( pic, flags, bumpScale );
|
||||
|
||||
pglGenTextures( 1, &image->texnum );
|
||||
image->target = image_desc.glTarget;
|
||||
image->flags = image_desc.tflags; // merged by R_GetPixelFormat
|
||||
image->type = image_desc.format;
|
||||
|
||||
Msg("Register %s image->texnum %d\n", name, image->texnum );
|
||||
|
||||
for(i = 0; i < numsides; i++, buf += offset )
|
||||
for( i = 0; i < numsides; i++, buf += offset )
|
||||
{
|
||||
GL_BindTexture( image );
|
||||
|
||||
|
||||
R_SetPixelFormat( image_desc.width, image_desc.height, image_desc.numLayers );
|
||||
offset = image_desc.SizeOfFile; // move pointer
|
||||
|
||||
MsgDev(D_LOAD, "%s [%s] \n", name, PFDesc[image_desc.format].name );
|
||||
if( numsides == 6 )
|
||||
MsgDev( D_LOAD, "%s[%i] [%s] \n", name, i, PFDesc[image_desc.format].name );
|
||||
else MsgDev( D_LOAD, "%s [%s] \n", name, PFDesc[image_desc.format].name );
|
||||
R_UploadTexture( buf, pic->type, target + i );
|
||||
}
|
||||
// check for errors
|
||||
|
@ -1770,15 +1771,12 @@ void R_ImageFreeUnused( void )
|
|||
texture_t *image;
|
||||
int i;
|
||||
|
||||
// FIXME check pics for type and never free it
|
||||
return;
|
||||
|
||||
for( i = 0, image = r_textures; i < r_numTextures; i++, image++ )
|
||||
{
|
||||
// used this sequence
|
||||
if( image->registration_sequence == registration_sequence ) continue;
|
||||
if( image->type == PF_RGBA_GN ) continue; // never free system textures
|
||||
if( !image->name[0] ) continue; // free texture slot
|
||||
if( image->flags & TF_STATIC || !image->name[0] ) // static or already freed
|
||||
continue;
|
||||
pglDeleteTextures( 1, &image->texnum );
|
||||
memset( image, 0, sizeof( *image ));
|
||||
}
|
||||
|
|
155
render/r_utils.c
155
render/r_utils.c
|
@ -6,6 +6,161 @@
|
|||
#include "r_local.h"
|
||||
#include "mathlib.h"
|
||||
|
||||
vec3_t axisDefault[3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
|
||||
|
||||
/*
|
||||
=================
|
||||
AxisCopy
|
||||
=================
|
||||
*/
|
||||
void AxisCopy( const vec3_t in[3], vec3_t out[3] )
|
||||
{
|
||||
out[0][0] = in[0][0];
|
||||
out[0][1] = in[0][1];
|
||||
out[0][2] = in[0][2];
|
||||
out[1][0] = in[1][0];
|
||||
out[1][1] = in[1][1];
|
||||
out[1][2] = in[1][2];
|
||||
out[2][0] = in[2][0];
|
||||
out[2][1] = in[2][1];
|
||||
out[2][2] = in[2][2];
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
AxisClear
|
||||
=================
|
||||
*/
|
||||
void AxisClear( vec3_t axis[3] )
|
||||
{
|
||||
axis[0][0] = 1;
|
||||
axis[0][1] = 0;
|
||||
axis[0][2] = 0;
|
||||
axis[1][0] = 0;
|
||||
axis[1][1] = 1;
|
||||
axis[1][2] = 0;
|
||||
axis[2][0] = 0;
|
||||
axis[2][1] = 0;
|
||||
axis[2][2] = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
AnglesToAxis
|
||||
=================
|
||||
*/
|
||||
void AnglesToAxis ( const vec3_t angles )
|
||||
{
|
||||
static float sp, sy, sr, cp, cy, cr;
|
||||
float angle;
|
||||
|
||||
angle = DEG2RAD(angles[PITCH]);
|
||||
sp = sin(angle);
|
||||
cp = cos(angle);
|
||||
angle = DEG2RAD(angles[YAW]);
|
||||
sy = sin(angle);
|
||||
cy = cos(angle);
|
||||
angle = DEG2RAD(angles[ROLL]);
|
||||
sr = sin(angle);
|
||||
cr = cos(angle);
|
||||
|
||||
r_forward[0] = cp*cy;
|
||||
r_forward[1] = cp*sy;
|
||||
r_forward[2] = -sp;
|
||||
r_right[0] = sr*sp*cy+cr*-sy;
|
||||
r_right[1] = sr*sp*sy+cr*cy;
|
||||
r_right[2] = sr*cp;
|
||||
r_up[0] = cr*sp*cy+-sr*-sy;
|
||||
r_up[1] = cr*sp*sy+-sr*cy;
|
||||
r_up[2] = cr*cp;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
AnglesToAxis
|
||||
=================
|
||||
*/
|
||||
void AnglesToAxisPrivate (const vec3_t angles, vec3_t axis[3])
|
||||
{
|
||||
|
||||
static float sp, sy, sr, cp, cy, cr;
|
||||
float angle;
|
||||
|
||||
angle = DEG2RAD(angles[PITCH]);
|
||||
sp = sin(angle);
|
||||
cp = cos(angle);
|
||||
angle = DEG2RAD(angles[YAW]);
|
||||
sy = sin(angle);
|
||||
cy = cos(angle);
|
||||
angle = DEG2RAD(angles[ROLL]);
|
||||
sr = sin(angle);
|
||||
cr = cos(angle);
|
||||
|
||||
axis[0][0] = cp*cy;
|
||||
axis[0][1] = cp*sy;
|
||||
axis[0][2] = -sp;
|
||||
axis[1][0] = sr*sp*cy+cr*-sy;
|
||||
axis[1][1] = sr*sp*sy+cr*cy;
|
||||
axis[1][2] = sr*cp;
|
||||
axis[2][0] = cr*sp*cy+-sr*-sy;
|
||||
axis[2][1] = cr*sp*sy+-sr*cy;
|
||||
axis[2][2] = cr*cp;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
AxisCompare
|
||||
=================
|
||||
*/
|
||||
bool AxisCompare( const vec3_t axis1[3], const vec3_t axis2[3] )
|
||||
{
|
||||
if (axis1[0][0] != axis2[0][0] || axis1[0][1] != axis2[0][1] || axis1[0][2] != axis2[0][2])
|
||||
return false;
|
||||
if (axis1[1][0] != axis2[1][0] || axis1[1][1] != axis2[1][1] || axis1[1][2] != axis2[1][2])
|
||||
return false;
|
||||
if (axis1[2][0] != axis2[2][0] || axis1[2][1] != axis2[2][1] || axis1[2][2] != axis2[2][2])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
VectorRotate
|
||||
=================
|
||||
*/
|
||||
void VectorRotate ( const vec3_t v, const vec3_t matrix[3], vec3_t out )
|
||||
{
|
||||
out[0] = v[0]*matrix[0][0] + v[1]*matrix[0][1] + v[2]*matrix[0][2];
|
||||
out[1] = v[0]*matrix[1][0] + v[1]*matrix[1][1] + v[2]*matrix[1][2];
|
||||
out[2] = v[0]*matrix[2][0] + v[1]*matrix[2][1] + v[2]*matrix[2][2];
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
MatrixGL_MultiplyFast
|
||||
=================
|
||||
*/
|
||||
void MatrixGL_MultiplyFast (const gl_matrix m1, const gl_matrix m2, gl_matrix out)
|
||||
{
|
||||
|
||||
out[ 0] = m1[ 0] * m2[ 0] + m1[ 4] * m2[ 1] + m1[ 8] * m2[ 2];
|
||||
out[ 1] = m1[ 1] * m2[ 0] + m1[ 5] * m2[ 1] + m1[ 9] * m2[ 2];
|
||||
out[ 2] = m1[ 2] * m2[ 0] + m1[ 6] * m2[ 1] + m1[10] * m2[ 2];
|
||||
out[ 3] = 0.0;
|
||||
out[ 4] = m1[ 0] * m2[ 4] + m1[ 4] * m2[ 5] + m1[ 8] * m2[ 6];
|
||||
out[ 5] = m1[ 1] * m2[ 4] + m1[ 5] * m2[ 5] + m1[ 9] * m2[ 6];
|
||||
out[ 6] = m1[ 2] * m2[ 4] + m1[ 6] * m2[ 5] + m1[10] * m2[ 6];
|
||||
out[ 7] = 0.0;
|
||||
out[ 8] = m1[ 0] * m2[ 8] + m1[ 4] * m2[ 9] + m1[ 8] * m2[10];
|
||||
out[ 9] = m1[ 1] * m2[ 8] + m1[ 5] * m2[ 9] + m1[ 9] * m2[10];
|
||||
out[10] = m1[ 2] * m2[ 8] + m1[ 6] * m2[ 9] + m1[10] * m2[10];
|
||||
out[11] = 0.0;
|
||||
out[12] = m1[ 0] * m2[12] + m1[ 4] * m2[13] + m1[ 8] * m2[14] + m1[12];
|
||||
out[13] = m1[ 1] * m2[12] + m1[ 5] * m2[13] + m1[ 9] * m2[14] + m1[13];
|
||||
out[14] = m1[ 2] * m2[12] + m1[ 6] * m2[13] + m1[10] * m2[14] + m1[14];
|
||||
out[15] = 1.0;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
RotatePointAroundVector
|
||||
|
|
Reference in New Issue