13 #include "../gldrv/gl_globals.h"
18 static set< AnimatedTexture* >
anis;
20 static inline unsigned int intmin(
unsigned int a,
unsigned int b )
25 static inline unsigned int intmax(
unsigned int a,
unsigned int b )
33 if (addrmodestr ==
"wrap")
36 else if (addrmodestr ==
"mirror")
39 else if (addrmodestr ==
"clamp")
42 else if (addrmodestr ==
"border")
64 active =
intmin( active, numframes-1 );
67 if (fraction < 0) fraction += 1.0f;
73 if (Decal && Decal[active] && Decal[nextactive]) {
77 }
else if (Decal && Decal[active]) {
83 if ( frames_maxtc.size() <
intmax( active, nextactive ) ) {
84 this->
maxtcoord = (1-fraction)*frames_maxtc[active]+fraction*frames_maxtc[nextactive];
85 this->
mintcoord = (1-fraction)*frames_mintc[active]+fraction*frames_mintc[nextactive];
87 }
else if ( active < frames_maxtc.size() ) {
108 if (Decal && Decal[
active%numframes])
120 multipass_interp_basecolor =
GFXColorf();
121 GFXColor color = multipass_interp_basecolor;
135 }
else if (!vidSource) {
137 if (Decal && *Decal) {
138 if (
active != activebound)
140 (*Decal)->MakeActive( stage );
182 GFXColor color = multipass_interp_basecolor;
214 for (set< AnimatedTexture* >::iterator iter =
anis.begin(); iter !=
anis.end(); iter++)
222 for (set< AnimatedTexture* >::iterator iter =
anis.begin(); iter !=
anis.end(); iter++) {
224 if (ani->options & optSoundTiming) {
232 double drift = newcurtime - ani->
lastcurtime - delta;
233 if (fabs(drift) > 1.0) {
236 }
else if (fabs(drift) > 0.2) {
237 double catchup = drift * ((delta > 0.5) ? 0.5 : delta);
263 using namespace VSFileSystem;
273 f.
Fscanf(
"%f %f", &width, &height );
277 Load( f, stage, imm, detailtex );
289 void AnimatedTexture::AniInit()
312 curtime = lastcurtime = lastrealtime = 0;
313 constframerate =
true;
325 Load( fp, stage, imm, detailtex );
350 retval->Decal =
new Texture*[nf];
351 for (
int i = 0;
i < nf;
i++)
352 retval->Decal[
i] = Decal[
i]->
Clone();
353 }
else if (vidSource) {
358 retval->
bound =
false;
364 anis.insert( retval );
392 for (i = 0; i < nf; i++)
404 img_sides = SIDE_SINGLE;
411 string::size_type ltrim = str.find_first_not_of(
" \t\r\n" );
412 string::size_type rtrim = str.find_last_not_of(
" \t\r\n" );
413 if (rtrim != string::npos) str.resize( rtrim+1 );
414 str.erase( 0, ltrim );
421 strcpy( _str, str.c_str() );
428 frames_maxtc.clear();
429 frames_mintc.clear();
433 LoadAni( f, stage, ismipmapped, detailtex );
439 wrapper_file_type = f.
GetType();
447 vidSource = new::VidFile();
498 fprintf( stderr,
"CreateVideoTexture could not find %s\n", fname.c_str() );
510 f.
ReadLine( options,
sizeof (options)-
sizeof (*options) );
511 options[
sizeof (options)/
sizeof (*options)-1] = 0;
560 if (vidMode) Decal[0] =
new Texture;
561 char temp[512] =
"white.bmp";
562 char file[512] =
"white.bmp";
563 char alp[512] =
"white.bmp";
566 for (; i < static_cast<int>(
numframes); i++)
567 if ( loadall || (i == midframe) ) {
570 while ( numgets <= 0 && !f.
Eof() ) {
580 numgets = sscanf( temp,
"%s %s %[^\r\n]", file, alp, opt );
581 if ( (numgets < 2) || (strcmp( alp,
"-" ) == 0) ) alp[0] =
'\0';
585 frames.push_back( StringPool::Reference(
string( temp ) ) );
586 frames_mintc.push_back(
Vector(
590 frames_maxtc.push_back(
Vector(
597 "" ), defaultAddressMode );
598 if (alp[0] !=
'\0') {
610 (detailtex ?
GFXTRUE : GFXFALSE),
621 (detailtex ?
GFXTRUE : GFXFALSE),
637 this->texstage =
stage;
638 this->detailTex = detailtex;
639 this->ismipmapped = ismipmapped;
642 wrapper_file_type = f.
GetType();
655 if ( !vidMode || (Decal == NULL) || (*Decal == NULL) )
return;
656 if ( (frame < 0) || (frame >= static_cast<int>(
numframes)) )
return;
657 if ( (activebound >= 0) && (activebound <
numframes) && (frames[frame] == frames[activebound]) )
return;
658 const char *temp = frames[frame].get().c_str();
659 char file[512] =
"white.bmp";
660 char alp[512] =
"white.bmp";
663 numgets = sscanf( temp,
"%s %s %[^\r\n]", file, alp, opt );
664 if ( (numgets < 2) || (strcmp( alp,
"-" ) == 0) ) alp[0] =
'\0';
682 if (alp[0] !=
'\0') {
683 (*Decal)->Load( file,
693 (detailTex ?
GFXTRUE : GFXFALSE),
696 }
else if (numgets == 1) {
706 loadSuccess = loadSuccess && (*Decal)->LoadSuccess();
707 if (loadSuccess) activebound = frame;
712 return loadSuccess !=
false;
741 options |= optSoundTiming;
744 options &= ~optSoundTiming;
750 options &= ~optSoundTiming;