Source release of Wolfenstein 3D Classic Platinum for iOS, 2.1

This commit is contained in:
Travis Bradshaw
2012-01-31 17:08:50 -06:00
parent 16304944b4
commit d7fff51d7d
235 changed files with 64191 additions and 1418 deletions

View File

@@ -109,12 +109,17 @@ PUBLIC W32 FS_FileSeek( filehandle_t *fhandle, SW32 offset, W32 origin )
return 1;
}
/* Commenting this out to avoid a warning - note that this is probably not what was
intended!
// offset is negative
if( (fhandle->filesize + offset) < 0 )
{
return 1;
}
*/
// offset is negative
fhandle->ptrCurrent = fhandle->ptrEnd + offset;
break;
@@ -223,7 +228,6 @@ PUBLIC filehandle_t *FS_OpenFile( const char *filename, W32 FlagsAndAttributes )
// high performance file mapping path, avoiding stdio
fd = open( netpath, O_RDONLY );
if ( fd == -1 ) {
// return NULL;
//if it couldn't be found in that path then check again in the document directory
//gsh
//pathBase = FS_ForceGamedir();
@@ -231,7 +235,7 @@ PUBLIC filehandle_t *FS_OpenFile( const char *filename, W32 FlagsAndAttributes )
pathBase = iphoneDocDirectory;
my_snprintf( netpath, sizeof( netpath ), "%s/%s", pathBase, filename );
fd = open( netpath, O_RDONLY );
if ( fd == -1 ) { //okay, couldn't find it there either... return null
if ( fd == -1 ) {
return NULL;
}
}

View File

@@ -172,7 +172,16 @@ PRIVATE char **FS_ListFiles( char *findname, int *numfiles, unsigned musthave, u
*/
PUBLIC void FS_InitFilesystem( void )
{
char *p;
p = getenv("CWD");
sprintf( fs_gamedir, "%s/base", p );
#define BASE_DIRECTORY "/base"
int length = SysIPhoneGetPathToMainBundleLength();
// Make sure the path will fit.
int fullPathLength = length + strlen( BASE_DIRECTORY ) + 1;
assert( fullPathLength < MAX_OSPATH );
SysIPhoneGetPathToMainBundle( fs_gamedir, length + 1 );
strcpy( fs_gamedir + length, BASE_DIRECTORY );
}

View File

@@ -39,6 +39,8 @@
#ifndef __FILESYSTEM_H__
#define __FILESYSTEM_H__
#include "arch.h"
#define MAX_GAMEPATH 256 // max length of a game pathname
#define MAX_OSPATH 256 // max length of a filesystem pathname

View File

@@ -76,12 +76,16 @@ W16 numSoundDevices, numDefaultSoundDevice;
PRIVATE void Sound_Device_getDeviceList( void )
{
char deviceName[ 256 ];
ALboolean isExtensionPresent = AL_FALSE;
my_strlcpy( deviceName, s_device->string, sizeof( deviceName ) );
if( pfalcIsExtensionPresent( NULL, (ALubyte*)"ALC_ENUMERATION_EXT") == AL_TRUE )
isExtensionPresent = pfalcIsExtensionPresent( NULL, (ALubyte*)"ALC_ENUMERATION_EXT");
ALC_CheckErrors();
if( isExtensionPresent == AL_TRUE )
{
// try out enumeration extension
deviceList = (char *)pfalcGetString( NULL, ALC_DEVICE_SPECIFIER );
ALC_CheckErrors();
for( numSoundDevices = 0 ; numSoundDevices < 12 ; ++numSoundDevices )
{
sound_devices[ numSoundDevices ] = NULL;
@@ -200,12 +204,14 @@ failed:
if( Context )
{
pfalcDestroyContext( Context );
ALC_CheckErrors();
Context = NULL;
}
if( Device )
{
pfalcCloseDevice( Device );
ALC_CheckErrors();
Device = NULL;
}
@@ -230,7 +236,9 @@ PUBLIC void Sound_Device_Shutdown( void )
if( Context )
{
pfalcMakeContextCurrent( NULL );
ALC_CheckErrors();
pfalcDestroyContext( Context );
ALC_CheckErrors();
Context = NULL;
}
@@ -238,6 +246,7 @@ PUBLIC void Sound_Device_Shutdown( void )
if( Device )
{
pfalcCloseDevice( Device );
ALC_CheckErrors();
Device = NULL;
}

View File

@@ -93,20 +93,20 @@ PUBLIC void R_Draw_Character( int x, int y, int num, font_t *myfont )
R_Bind( myfont->texfont->texnum );
pfglBegin( GL_QUADS );
pfglBegin( GL_TRIANGLE_STRIP );
pfglTexCoord2f( fcol, frow );
pfglVertex2i( x, y );
pfglTexCoord2f( fcol, frow+myfont->hFrac );
pfglVertex2i( x, (y+sh*scale) );
pfglTexCoord2f( fcol+myfont->wFrac, frow );
pfglVertex2i( x+myfont->nMaxWidth*scale, y );
pfglTexCoord2f( fcol+myfont->wFrac, frow+myfont->hFrac );
pfglVertex2i( x+myfont->nMaxWidth*scale, (y+sh*scale) );
pfglTexCoord2f( fcol, frow+myfont->hFrac );
pfglVertex2i( x, (y+sh*scale) );
@@ -146,12 +146,12 @@ PUBLIC void R_Draw_StretchPic( int x, int y, int w, int h, const char *pic )
R_Bind( gl->texnum );
pfglBegin( GL_QUADS );
pfglBegin( GL_TRIANGLE_STRIP );
pfglTexCoord2f( 0.0f, 0.0f ); pfglVertex2i( x, y );
pfglTexCoord2f( 0.0f, 1.0f ); pfglVertex2i( x, y+h );
pfglTexCoord2f( 1.0f, 0.0f ); pfglVertex2i( x+w, y );
pfglTexCoord2f( 1.0f, 1.0f ); pfglVertex2i( x+w, y+h );
pfglTexCoord2f( 0.0f, 1.0f ); pfglVertex2i( x, y+h );
pfglEnd();
}
@@ -186,7 +186,7 @@ PUBLIC void R_Draw_Fill( int x, int y, int w, int h, colour3_t c )
c4[3] = 255;
R_Draw_Blend( x, y, w, h, c4 );
#else
if ( revLand->value ) {
if ( deviceOrientation == ORIENTATION_LANDSCAPE_RIGHT ) {
qglScissor( x, y, w, h );
} else {
qglScissor( x, 320-(y+h), w, h );
@@ -203,12 +203,12 @@ PUBLIC void R_Draw_Blend( int x, int y, int w, int h, colour4_t c )
pfglDisable( GL_TEXTURE_2D );
pfglColor4ubv( c );
pfglBegin( GL_QUADS );
pfglBegin( GL_TRIANGLE_STRIP );
pfglVertex2i( x, y );
pfglVertex2i( x, y+h );
pfglVertex2i( x+w, y );
pfglVertex2i( x+w, y+h );
pfglVertex2i( x, y+h );
pfglEnd();

View File

@@ -131,6 +131,7 @@ typedef struct
const char *version_string;
const char *extensions_string;
_boolean Version_1_2;
bool framebuffer_discard;
} glconfig_t;

View File

@@ -284,7 +284,6 @@ PUBLIC void R_Init()
int err;
int a, b;
Com_Printf( "\n------ Display Initialization ------\n" );
Com_Printf( "Initializing OpenGL Subsystem\n" );
@@ -294,9 +293,6 @@ PUBLIC void R_Init()
// set our "safe" modes
gl_state.prev_mode = 0;
viddef.width = 480;
viddef.height = 320;
// get various GL strings
gl_config.vendor_string = (char *)pfglGetString( GL_VENDOR );
Com_Printf( "GL_VENDOR: %s\n", gl_config.vendor_string );
@@ -316,7 +312,6 @@ PUBLIC void R_Init()
my_strlcpy( vendor_buffer, gl_config.vendor_string, sizeof( vendor_buffer ) );
(void)my_strlwr( vendor_buffer );
sscanf( gl_config.version_string, "%d.%d", &a, &b );
if( a >= 1 && b >= 2 )
{
@@ -326,6 +321,14 @@ PUBLIC void R_Init()
pfglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glMaxTexSize );
Com_Printf( "GL_MAX_TEXTURE_SIZE: %d\n", glMaxTexSize);
if ( strstr( gl_config.extensions_string, "GL_EXT_discard_framebuffer" ) != 0 ) {
gl_config.framebuffer_discard = true;
} else {
gl_config.framebuffer_discard = false;
}
InitImmediateModeGL();
GL_SetDefaultState();
TM_Init();
@@ -359,7 +362,7 @@ PUBLIC void PrintGLError( W32 err, const char *from )
return;
}
if( from != "" )
if( strlen(from) != 0 )
{
Com_Printf( "\n\n\nGL Error: %s\n", from );
}

View File

@@ -95,6 +95,7 @@ PRIVATE void Sound_AllocChannels( void )
for( i = 0, ch = s_channels ; i < MAX_CHANNELS ; ++i, ++ch )
{
pfalGenSources( 1, &ch->sourceName );
AL_CheckErrors();
if( pfalGetError() != AL_NO_ERROR )
{
@@ -123,6 +124,7 @@ PRIVATE int Sound_ChannelState( channel_t *ch )
int state;
pfalGetSourcei( ch->sourceName, AL_SOURCE_STATE, &state );
AL_CheckErrors();
return state;
}
@@ -133,9 +135,16 @@ PRIVATE void Sound_PlayChannel( channel_t *ch, sfx_t *sfx )
ch->sfx = sfx;
pfalSourcei( ch->sourceName, AL_BUFFER, sfx->bufferNum );
AL_CheckErrors();
pfalSourcei( ch->sourceName, AL_LOOPING, ch->loopSound );
AL_CheckErrors();
pfalSourcei( ch->sourceName, AL_SOURCE_RELATIVE, AL_FALSE );
AL_CheckErrors();
pfalSourcePlay( ch->sourceName );
AL_CheckErrors();
}
@@ -147,12 +156,15 @@ PRIVATE void Sound_StopChannel( channel_t *ch )
// Only deleting the entire source seems to work.
pfalSourceStop( ch->sourceName );
AL_CheckErrors();
// pfalSourceStopv( 1, &ch->sourceName );
// pfalSourcei( ch->sourceName, AL_BUFFER, 0 );
// pfalSourceRewind( ch->sourceName );
#if 1
pfalDeleteSources( 1, &ch->sourceName );
AL_CheckErrors();
pfalGenSources( 1, &ch->sourceName );
AL_CheckErrors();
#endif
}
@@ -165,14 +177,18 @@ PRIVATE void Sound_SpatializeChannel( channel_t *ch )
if( ch->entNum == 0 || ! ch->distanceMult )
{
pfalSourcefv( ch->sourceName, AL_POSITION, s_listener.position );
AL_CheckErrors();
pfalSourcefv( ch->sourceName, AL_VELOCITY, s_listener.velocity );
AL_CheckErrors();
}
else
{
if( ch->fixedPosition )
{
pfalSource3f( ch->sourceName, AL_POSITION, ch->position[1], ch->position[2], -ch->position[0] );
AL_CheckErrors();
pfalSource3f( ch->sourceName, AL_VELOCITY, 0, 0, 0 );
AL_CheckErrors();
}
/* else
{
@@ -195,17 +211,23 @@ PRIVATE void Sound_SpatializeChannel( channel_t *ch )
if( ch->distanceMult )
{
pfalSourcef( ch->sourceName, AL_REFERENCE_DISTANCE, s_minDistance->value * ch->distanceMult );
AL_CheckErrors();
}
else
{
pfalSourcef( ch->sourceName, AL_REFERENCE_DISTANCE, s_maxDistance->value );
AL_CheckErrors();
}
pfalSourcef( ch->sourceName, AL_MAX_DISTANCE, s_maxDistance->value );
AL_CheckErrors();
// Update volume and rolloff factor
pfalSourcef( ch->sourceName, AL_GAIN, s_sfxVolume->value * ch->volume );
AL_CheckErrors();
pfalSourcef( ch->sourceName, AL_ROLLOFF_FACTOR, s_rolloffFactor->value );
AL_CheckErrors();
}
@@ -572,15 +594,26 @@ PUBLIC void Sound_Update( const vec3_t position, const vec3_t velocity, const ve
vectorSet( &s_listener.orientation[3], up[1], -up[2], -up[0] );
pfalListenerfv( AL_POSITION, s_listener.position );
AL_CheckErrors();
pfalListenerfv( AL_VELOCITY, s_listener.velocity );
AL_CheckErrors();
pfalListenerfv( AL_ORIENTATION, s_listener.orientation );
AL_CheckErrors();
pfalListenerf( AL_GAIN, (s_activeApp) ? s_masterVolume->value : 0.0);
AL_CheckErrors();
// Set state
pfalDistanceModel( AL_INVERSE_DISTANCE_CLAMPED );
AL_CheckErrors();
pfalDopplerFactor( s_dopplerFactor->value );
AL_CheckErrors();
pfalDopplerVelocity( s_dopplerVelocity->value );
AL_CheckErrors();
// Stream background track
Sound_StreamBGTrack();
@@ -639,9 +672,26 @@ PUBLIC void Sound_Activate( _boolean active )
}
pfalListenerf( AL_GAIN, ( active ) ? s_masterVolume->value : 0.0 );
AL_CheckErrors();
}
void AL_CheckErrors() {
#if 0
#ifdef DEBUG
ALenum error = alGetError();
if ( error != AL_NO_ERROR ) {
printf( "OpenAL error (al)! %d\n", error);
}
#endif
#endif
}
void ALC_CheckErrors() {
//ALenum error = alcGetError();
//if ( error != AL_NO_ERROR ) {
// printf( "OpenAL error (alc)! %d\n", error);
//}
}
/////////////////////////////////////////////////////////////////////
//
@@ -690,14 +740,14 @@ PRIVATE void Sound_Register( void )
{
s_initSound = Cvar_Get( "s_initSound", "1", CVAR_INIT );
s_masterVolume = Cvar_Get( "s_masterVolume", "0.3", CVAR_ARCHIVE ); //gsh changed this from "1.0" to "0.3" for the volume hack... otherwise it's too loud
s_masterVolume = Cvar_Get( "s_masterVolume", "0.6", CVAR_ARCHIVE ); //gsh changed this from "1.0" to "0.3" for the volume hack... otherwise it's too loud
s_sfxVolume = Cvar_Get( "s_sfxVolume", "1.0", CVAR_ARCHIVE );
s_musicVolume = Cvar_Get( "s_musicVolume", "1.0", CVAR_ARCHIVE );
s_minDistance = Cvar_Get( "s_minDistance", "0.0", CVAR_ARCHIVE );
s_maxDistance = Cvar_Get( "s_maxDistance", "1.0", CVAR_ARCHIVE );
s_rolloffFactor = Cvar_Get( "s_rolloffFactor", "1.0", CVAR_ARCHIVE );
s_dopplerFactor = Cvar_Get( "s_dopplerFactor", "1.0", CVAR_ARCHIVE );
s_dopplerVelocity = Cvar_Get( "s_dopplerVelocity", "0.0", CVAR_ARCHIVE );
s_dopplerVelocity = Cvar_Get( "s_dopplerVelocity", "1.0", CVAR_ARCHIVE );
Cmd_AddCommand( "play", Sound_Play_f );
Cmd_AddCommand( "stopsound", Sound_StopSound_f );

View File

@@ -106,6 +106,8 @@ extern sfx_t *Sound_FindSound( const char *name );
extern _boolean Sound_Device_Setup( void );
extern void Sound_Device_Shutdown( void );
void AL_CheckErrors();
void ALC_CheckErrors();
#endif /* __SOUND_LOCAL_H__ */

View File

@@ -96,7 +96,10 @@ PRIVATE void Sound_UploadSound( W8 *data, int sample_size, int channels, sfx_t *
// Upload the sound
pfalGenBuffers( 1, &sfx->bufferNum );
AL_CheckErrors();
pfalBufferData( sfx->bufferNum, sfx->format, data, size, sfx->rate );
AL_CheckErrors();
}
else
{
@@ -121,7 +124,10 @@ PRIVATE void Sound_UploadSound( W8 *data, int sample_size, int channels, sfx_t *
// Upload the sound
pfalGenBuffers( 1, &sfx->bufferNum );
AL_CheckErrors();
pfalBufferData( sfx->bufferNum, sfx->format, d, size * 2, sfx->rate );
AL_CheckErrors();
free( d );
}
}
@@ -163,7 +169,7 @@ PUBLIC _boolean Sound_LoadSound( sfx_t *sfx )
if ( ! LoadOggInfo( name, &data, &info ) ) {
sfx->defaulted = true;
Com_Printf( "Could not find sound (%s)\n", name );
//Com_Printf( "Could not find sound (%s)\n", name );
return false;
}

View File

@@ -284,17 +284,23 @@ PUBLIC void Sound_StreamBGTrack( void )
// Unqueue and delete any processed buffers
pfalGetSourcei( s_streamingChannel->sourceName, AL_BUFFERS_PROCESSED, &processed );
AL_CheckErrors();
if( processed > 0 )
{
while (processed--)
{
pfalSourceUnqueueBuffers( s_streamingChannel->sourceName, 1, &buffer );
AL_CheckErrors();
//printf( "OpenAL unqueued %d, about to delete it!\n", buffer);
pfalDeleteBuffers( 1, &buffer );
AL_CheckErrors();
}
}
// Make sure we always have at least 4 buffers in the queue
pfalGetSourcei( s_streamingChannel->sourceName, AL_BUFFERS_QUEUED, &queued );
AL_CheckErrors();
while( queued < 4 )
{
size = 0;
@@ -340,20 +346,29 @@ PUBLIC void Sound_StreamBGTrack( void )
// Upload and queue the new buffer
pfalGenBuffers( 1, &buffer );
AL_CheckErrors();
pfalBufferData( buffer, bgTrack.format, data, size, bgTrack.rate );
AL_CheckErrors();
pfalSourceQueueBuffers( s_streamingChannel->sourceName, 1, &buffer );
AL_CheckErrors();
queued++;
}
// Update volume
pfalSourcef( s_streamingChannel->sourceName, AL_GAIN, s_musicVolume->value );
AL_CheckErrors();
// If not playing, then do so
pfalGetSourcei( s_streamingChannel->sourceName, AL_SOURCE_STATE, &state );
AL_CheckErrors();
if( state != AL_PLAYING )
{
pfalSourcePlay(s_streamingChannel->sourceName);
AL_CheckErrors();
}
}
@@ -390,17 +405,28 @@ PUBLIC void Sound_StartStreaming( void )
// hmmm...
pfalDeleteSources( 1, &s_streamingChannel->sourceName );
AL_CheckErrors();
pfalGenSources( 1, &s_streamingChannel->sourceName );
AL_CheckErrors();
// Set up the source
pfalSourcei( s_streamingChannel->sourceName, AL_BUFFER, 0 );
AL_CheckErrors();
pfalSourcei( s_streamingChannel->sourceName, AL_LOOPING, AL_FALSE );
AL_CheckErrors();
pfalSourcei( s_streamingChannel->sourceName, AL_SOURCE_RELATIVE, AL_TRUE );
AL_CheckErrors();
pfalSourcefv( s_streamingChannel->sourceName, AL_POSITION, vec3_origin );
AL_CheckErrors();
pfalSourcefv( s_streamingChannel->sourceName, AL_VELOCITY, vec3_origin );
AL_CheckErrors();
pfalSourcef( s_streamingChannel->sourceName, AL_REFERENCE_DISTANCE, 1.0 );
AL_CheckErrors();
pfalSourcef( s_streamingChannel->sourceName, AL_MAX_DISTANCE, 1.0 );
AL_CheckErrors();
pfalSourcef( s_streamingChannel->sourceName, AL_ROLLOFF_FACTOR, 0.0 );
AL_CheckErrors();
}
/*
@@ -433,22 +459,30 @@ PUBLIC void Sound_StopStreaming( void )
pfalSourceStop( s_streamingChannel->sourceName );
AL_CheckErrors();
pfalGetSourcei( s_streamingChannel->sourceName, AL_BUFFERS_PROCESSED, &processed );
AL_CheckErrors();
if( processed > 0 )
{
while( processed-- )
{
pfalSourceUnqueueBuffers( s_streamingChannel->sourceName, 1, &buffer );
AL_CheckErrors();
pfalDeleteBuffers( 1, &buffer );
AL_CheckErrors();
}
}
pfalSourcei( s_streamingChannel->sourceName, AL_BUFFER, 0 );
AL_CheckErrors();
// hmmm...
pfalDeleteSources( 1, &s_streamingChannel->sourceName );
AL_CheckErrors();
pfalGenSources( 1, &s_streamingChannel->sourceName );
AL_CheckErrors();
s_streamingChannel = NULL;
}

View File

@@ -349,6 +349,19 @@ PUBLIC texture_t *TM_LoadTexture( const char *name, W8 *data, int width, int hei
TM_ResampleTexture( data, tex->width, tex->height, scaled, scaled_width, scaled_height, tex->bytes, INTERPOLATION_NONE );
}
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, WrapToGL( tex->WrapS ) );
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, WrapToGL( tex->WrapT ) );
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilterToGL( tex->MipMap, tex->MinFilter ) );
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MagFilterToGL( tex->MagFilter ) );
#ifdef IPHONE
if ( type == TT_Wall ) {
pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2.0f );
} else {
pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f );
}
#endif
{
// upload base image
GLenum internalFormat[] = { GL_LUMINANCE, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
@@ -379,20 +392,6 @@ PUBLIC texture_t *TM_LoadTexture( const char *name, W8 *data, int width, int hei
if ( scaled != data ) {
Z_Free( scaled );
}
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, WrapToGL( tex->WrapS ) );
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, WrapToGL( tex->WrapT ) );
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilterToGL( tex->MipMap, tex->MinFilter ) );
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MagFilterToGL( tex->MagFilter ) );
#ifdef IPHONE
if ( type == TT_Wall ) {
pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2.0f );
} else {
pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0 );
}
#endif
return tex;
}
@@ -486,7 +485,8 @@ PUBLIC texture_t *TM_FindTexture( const char *name, texturetype_t type )
// load the texture from disk
//
data = NULL;
if( strcmp( name + len - 4, ".tga" ) ) {
const char* const extension = name + len - 4;
if( strcmp( extension, ".tga" ) && strcmp( extension, ".png" ) ) {
return r_notexture;
}
@@ -537,6 +537,23 @@ PUBLIC texture_t *TM_FindTexture( const char *name, texturetype_t type )
tx->maxS = (float)ph->srcWidth / ph->uploadWidth;
tx->maxT = (float)ph->srcHeight / ph->uploadHeight;
unsigned char *s = (unsigned char *)(ph+1);
if ( noMips ) {
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
} else {
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
}
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
if ( type == TT_Wall ) {
pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2.0f );
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
} else {
pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f );
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
}
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
while( 1 ) {
int size = (w*h*fi->bpp)/8;
if ( fi->bpp < 16 ) {
@@ -568,26 +585,27 @@ PUBLIC texture_t *TM_FindTexture( const char *name, texturetype_t type )
}
}
FS_CloseFile( fh );
if ( noMips ) {
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
} else {
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
}
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
if ( type == TT_Wall ) {
pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2.0f );
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
} else {
pfglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0 );
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
}
pfglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
return tx;
}
// load a normal TGA
LoadTGA( name, &data, &width, &height, &bytes );
// load a normal PNG or TGA. Prioritize PNGs, if not found, fall back to TGA.
size_t filenameLength = strlen( name );
char * pngName = MM_MALLOC( filenameLength );
strcpy( pngName, name );
strcpy( pngName + filenameLength - 3, "png" );
// Try to load a PNG version.
LoadPNG( pngName, &data, &width, &height, &bytes );
MM_FREE( pngName );
pngName = NULL;
// Try finding a TGA if the PNG load failed.
if ( ( data == NULL ) && strcmp( extension, ".tga" ) == 0 ) {
LoadTGA( name, &data, &width, &height, &bytes );
}
if ( data ) {
tex = TM_LoadTexture( name, data, width, height, type, bytes );
MM_FREE( data );

View File

@@ -39,6 +39,9 @@
#ifndef __TEXTURE_MANAGER_H__
#define __TEXTURE_MANAGER_H__
#include "arch.h"
#include "filesystem.h"
#define MAX_TEXTURES 1024

View File

@@ -133,7 +133,7 @@ PUBLIC char *FS_FindFirst( const char *path, W32 musthave, W32 canthave )
{
struct dirent *d;
char *p;
p;
(void)p;
if( fdir )
{

View File

@@ -42,6 +42,8 @@
#ifndef __VIDEO_H__
#define __VIDEO_H__
#include "arch.h"
typedef struct vrect_s
{
int x, y, width, height;