[Opentnl-cvs] tnl/zap main.cpp,1.24,1.25 sfx.cpp,1.18,1.19
Brought to you by:
mark_frohnmayer,
s_alanet
From: Mark F. <mar...@us...> - 2004-05-10 22:34:50
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22383/zap Modified Files: main.cpp sfx.cpp Log Message: Added initial pass-through journaling code to TNL cleaned up SFX a bit. Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** main.cpp 7 May 2004 22:59:11 -0000 1.24 --- main.cpp 10 May 2004 22:34:24 -0000 1.25 *************** *** 29,32 **** --- 29,33 ---- #include "../tnl/tnlGhostConnection.h" #include "../tnl/tnlNetInterface.h" + #include "../tnl/tnlJournal.h" #include "glutInclude.h" *************** *** 58,69 **** const char *gLevelList = "level4.txt level2.txt level1.txt level2.txt level3.txt level2.txt"; void reshape(int nw, int nh) { ! UserInterface::windowWidth = nw; ! UserInterface::windowHeight = nh; } void motion(int x, int y) { if(UserInterface::current) UserInterface::current->onMouseDragged(x, y); --- 59,97 ---- const char *gLevelList = "level4.txt level2.txt level1.txt level2.txt level3.txt level2.txt"; + class ZapJournal : public Journal + { + public: + TNL_DECLARE_JOURNAL_ENTRYPOINT(reshape, (S32 newWidth, S32 newHeight)); + TNL_DECLARE_JOURNAL_ENTRYPOINT(motion, (S32 x, S32 y)); + TNL_DECLARE_JOURNAL_ENTRYPOINT(passivemotion, (S32 x, S32 y)); + TNL_DECLARE_JOURNAL_ENTRYPOINT(key, (U8 key, S32 x, S32 y)); + TNL_DECLARE_JOURNAL_ENTRYPOINT(keyup, (U8 key, S32 x, S32 y)); + TNL_DECLARE_JOURNAL_ENTRYPOINT(mouse, (S32 button, S32 state, S32 x, S32 y)); + TNL_DECLARE_JOURNAL_ENTRYPOINT(specialkey, (S32 key, S32 x, S32 y)); + TNL_DECLARE_JOURNAL_ENTRYPOINT(specialkeyup, (S32 key, S32 x, S32 y)); + TNL_DECLARE_JOURNAL_ENTRYPOINT(idle, ()); + TNL_DECLARE_JOURNAL_ENTRYPOINT(display, ()); + }; + + ZapJournal gZapJournal; + void reshape(int nw, int nh) { ! gZapJournal.reshape(nw, nh); ! } ! ! TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, reshape, (S32 newWidth, S32 newHeight)) ! { ! UserInterface::windowWidth = newWidth; ! UserInterface::windowHeight = newHeight; } void motion(int x, int y) { + gZapJournal.motion(x, y); + } + + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, motion, (S32 x, S32 y)) + { if(UserInterface::current) UserInterface::current->onMouseDragged(x, y); *************** *** 72,75 **** --- 100,108 ---- void passivemotion(int x, int y) { + gZapJournal.passivemotion(x, y); + } + + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, passivemotion, (S32 x, S32 y)) + { if(UserInterface::current) UserInterface::current->onMouseMoved(x, y); *************** *** 78,81 **** --- 111,119 ---- void key(unsigned char key, int x, int y) { + gZapJournal.key(key, x, y); + } + + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, key, (U8 key, S32 x, S32 y)) + { if(UserInterface::current) UserInterface::current->onKeyDown(key); *************** *** 84,87 **** --- 122,130 ---- void keyup(unsigned char key, int x, int y) { + gZapJournal.keyup(key, x, y); + } + + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, keyup, (U8 key, S32 x, S32 y)) + { if(UserInterface::current) UserInterface::current->onKeyUp(key); *************** *** 90,93 **** --- 133,141 ---- void mouse(int button, int state, int x, int y) { + gZapJournal.mouse(button, state, x, y); + } + + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, mouse, (S32 button, S32 state, S32 x, S32 y)) + { static int mouseState[2] = { 0, }; if(!UserInterface::current) *************** *** 124,127 **** --- 172,180 ---- void specialkey(int key, int x, int y) { + gZapJournal.specialkey(key, x, y); + } + + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, specialkey, (S32 key, S32 x, S32 y)) + { if(UserInterface::current) UserInterface::current->onSpecialKeyDown(key); *************** *** 130,133 **** --- 183,191 ---- void specialkeyup(int key, int x, int y) { + gZapJournal.specialkeyup(key, x, y); + } + + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, specialkeyup, (S32 key, S32 x, S32 y)) + { if(UserInterface::current) UserInterface::current->onSpecialKeyUp(key); *************** *** 136,139 **** --- 194,202 ---- void idle() { + gZapJournal.idle(); + } + + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, idle, ()) + { static S64 lastTimer = Platform::getHighPrecisionTimerValue(); static F64 unusedFraction = 0; *************** *** 172,175 **** --- 235,243 ---- void display(void) { + gZapJournal.display(); + } + + TNL_IMPLEMENT_JOURNAL_ENTRYPOINT(ZapJournal, display, ()) + { if(UserInterface::current) UserInterface::current->render(); Index: sfx.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/sfx.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** sfx.cpp 8 May 2004 22:59:58 -0000 1.18 --- sfx.cpp 10 May 2004 22:34:24 -0000 1.19 *************** *** 210,215 **** static ALuint gSources[NumSources]; - static bool gSourceActive[NumSources]; - static bool gQueuedBuffers[NumSources] = { false, }; Point SFXObject::mListenerPosition; Point SFXObject::mListenerVelocity; --- 210,213 ---- *************** *** 338,341 **** --- 336,342 ---- void SFXObject::queueBuffer(ByteBufferPtr p) { + if(!gSFXValid) + return; + mInitialBuffer = p; if(mSourceIndex != -1) *************** *** 389,399 **** mInitialBuffer->getBufferSize(), 8000); alSourceQueueBuffers(source, 1, &buffer); - gQueuedBuffers[mSourceIndex] = true; } else - { alSourcei(source, AL_BUFFER, gBuffers[mSFXIndex]); - gQueuedBuffers[mSourceIndex] = false; - } alSourcei(source, AL_LOOPING, mProfile->isLooping); --- 390,396 ---- *************** *** 409,412 **** --- 406,412 ---- void SFXObject::setGain(F32 gain) { + if(!gSFXValid) + return; + mGain = gain; if(mSourceIndex != -1) *************** *** 416,419 **** --- 416,422 ---- void SFXObject::setMovementParams(Point position, Point velocity) { + if(!gSFXValid) + return; + mPosition = position; mVelocity = velocity; *************** *** 424,427 **** --- 427,433 ---- void SFXObject::play() { + if(!gSFXValid) + return; + if(mSourceIndex != -1) return; *************** *** 438,441 **** --- 444,450 ---- void SFXObject::stop() { + if(!gSFXValid) + return; + // remove from the play list, if this sound is playing: if(mSourceIndex != -1) *************** *** 541,544 **** --- 550,554 ---- // ones need to be retired: + bool sourceActive[NumSources]; for(S32 i = 0; i < NumSources; i++) { *************** *** 546,550 **** unqueueBuffers(i); alGetSourcei(gSources[i], AL_SOURCE_STATE, &state); ! gSourceActive[i] = state != AL_STOPPED && state != AL_INITIAL; } for(S32 i = 0; i < gPlayList.size(); ) --- 556,560 ---- unqueueBuffers(i); alGetSourcei(gSources[i], AL_SOURCE_STATE, &state); ! sourceActive[i] = state != AL_STOPPED && state != AL_INITIAL; } for(S32 i = 0; i < gPlayList.size(); ) *************** *** 552,556 **** SFXHandle &s = gPlayList[i]; ! if(s->mSourceIndex != -1 && !gSourceActive[s->mSourceIndex]) { // this sound was playing; now it is stopped, --- 562,566 ---- SFXHandle &s = gPlayList[i]; ! if(s->mSourceIndex != -1 && !sourceActive[s->mSourceIndex]) { // this sound was playing; now it is stopped, *************** *** 593,597 **** if(s->mSourceIndex != -1) { ! gSourceActive[s->mSourceIndex] = false; s->mSourceIndex = -1; } --- 603,607 ---- if(s->mSourceIndex != -1) { ! sourceActive[s->mSourceIndex] = false; s->mSourceIndex = -1; } *************** *** 612,619 **** if(s->mSourceIndex == -1) { ! while(gSourceActive[firstFree]) firstFree++; s->mSourceIndex = firstFree; ! gSourceActive[firstFree] = true; s->playOnSource(); } --- 622,629 ---- if(s->mSourceIndex == -1) { ! while(sourceActive[firstFree]) firstFree++; s->mSourceIndex = firstFree; ! sourceActive[firstFree] = true; s->playOnSource(); } |