diff --git a/Sources/DecodeReport/DecodeReport.cpp b/Sources/DecodeReport/DecodeReport.cpp index 09e2569..2abf202 100644 --- a/Sources/DecodeReport/DecodeReport.cpp +++ b/Sources/DecodeReport/DecodeReport.cpp @@ -77,7 +77,7 @@ void SubMain( int argc, char *argv[]) } // initialize engine - SE_InitEngine(""); + SE_InitEngine(argv[0], ""); _fnmApplicationPath = CTString(""); @@ -103,7 +103,7 @@ void SubMain( int argc, char *argv[]) strmSrc.GetLine_t(strLine); // try to find address marker in it - const char *strAdr = strstr(strLine, "$adr:"); + char *strAdr = strstr(strLine, "$adr:"); // if there is no marker if (strAdr==NULL) { // just copy the line diff --git a/Sources/DedicatedServer/DedicatedServer.cpp b/Sources/DedicatedServer/DedicatedServer.cpp index c651abb..224c7a7 100644 --- a/Sources/DedicatedServer/DedicatedServer.cpp +++ b/Sources/DedicatedServer/DedicatedServer.cpp @@ -1,58 +1,64 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ +#ifdef PLATFORM_UNIX /* rcg10072001 */ +#include +#endif + #include "StdAfx.h" #include #define DECL_DLL -#if 0 /* rcg10042001 Doesn't seem to exist. */ -#include -#endif - // application state variables -extern BOOL _bRunning = TRUE; +BOOL _bRunning = TRUE; static BOOL _bForceRestart = FALSE; static BOOL _bForceNextMap = FALSE; -extern CTString _strSamVersion = "no version information"; -extern INDEX ded_iMaxFPS = 100; -extern CTString ded_strConfig = ""; -extern CTString ded_strLevel = ""; -extern INDEX ded_bRestartWhenEmpty = TRUE; -extern FLOAT ded_tmTimeout = -1; -extern CGame *_pGame = NULL; -extern CTString sam_strFirstLevel = "Levels\\KarnakDemo.wld"; -extern CTString sam_strIntroLevel = "Levels\\Intro.wld"; -extern CTString sam_strGameName = "serioussam"; +CTString _strSamVersion = "no version information"; +INDEX ded_iMaxFPS = 100; +CTString ded_strConfig = ""; +CTString ded_strLevel = ""; +INDEX ded_bRestartWhenEmpty = TRUE; +FLOAT ded_tmTimeout = -1; +CGame *_pGame = NULL; +CTString sam_strFirstLevel = "Levels\\KarnakDemo.wld"; +CTString sam_strIntroLevel = "Levels\\Intro.wld"; +CTString sam_strGameName = "serioussam"; -CTimerValue _tvLastLevelEnd(-1i64); +CTimerValue _tvLastLevelEnd((__int64) -1); void InitializeGame(void) { - try { - #ifndef NDEBUG - #define GAMEDLL _fnmApplicationExe.FileDir()+"Game"+_strModExt+"D.dll" + #ifdef STATICALLY_LINKED + #define fnmExpanded NULL + CPrintF(TRANS("Loading game library '%s'...\n"), "(statically linked)"); + #else + CTFileName fnmDLL; + #ifndef NDEBUG + fnmDLL = "Bin\\Debug\\Game"+_strModExt+"D.dll"; #else - #define GAMEDLL _fnmApplicationExe.FileDir()+"Game"+_strModExt+".dll" + fnmDLL = "Bin\\Game"+_strModExt+".dll"; #endif + + fnmDLL = CDynamicLoader::ConvertLibNameToPlatform(fnmDLL); CTFileName fnmExpanded; - ExpandFilePath(EFP_READ, CTString(GAMEDLL), fnmExpanded); - + ExpandFilePath(EFP_READ | EFP_NOZIPS,fnmDLL,fnmExpanded); CPrintF(TRANS("Loading game library '%s'...\n"), (const char *)fnmExpanded); - HMODULE hGame = LoadLibraryA(fnmExpanded); - if (hGame==NULL) { - ThrowF_t("%s", GetWindowsError(GetLastError())); - } - CGame* (*GAME_Create)(void) = (CGame* (*)(void))GetProcAddress(hGame, "GAME_Create"); - if (GAME_Create==NULL) { - ThrowF_t("%s", GetWindowsError(GetLastError())); - } - _pGame = GAME_Create(); + #endif - } catch (char *strError) { - FatalError("%s", strError); + CDynamicLoader *loader = CDynamicLoader::GetInstance(fnmExpanded); + CGame *(*GAME_Create)(void) = NULL; + + if (loader->GetError() == NULL) { + GAME_Create = (CGame* (*)(void)) loader->FindSymbol("GAME_Create"); + } + + if (GAME_Create == NULL) { + FatalError("%s", loader->GetError()); + } else { + _pGame = GAME_Create(); + // init game - this will load persistent symbols + _pGame->Initialize(CTString("Data\\DedicatedServer.gms")); } - // init game - this will load persistent symbols - _pGame->Initialize(CTString("Data\\DedicatedServer.gms")); } static void QuitGame(void) @@ -84,12 +90,16 @@ void LimitFrameRate(void) // limit maximum frame rate ded_iMaxFPS = ClampDn( ded_iMaxFPS, 1L); TIME tmWantedDelta = 1.0f / ded_iMaxFPS; - if( tmCurrentDeltaSleep( (DWORD) ((tmWantedDelta-tmCurrentDelta)*1000.0f) ); // remember new time tvLast = _pTimer->GetHighPrecisionTimer(); } + +/* rcg10072001 win32ism. */ +#ifdef PLATFORM_WIN32 // break/close handler BOOL WINAPI HandlerRoutine( DWORD dwCtrlType // control signal type @@ -104,13 +114,22 @@ BOOL WINAPI HandlerRoutine( } return TRUE; } +#endif + +#ifdef PLATFORM_UNIX +void unix_signal_catcher(int signum) +{ + _bRunning = FALSE; +} +#endif + #define REFRESHTIME (0.1f) static void LoadingHook_t(CProgressHookInfo *pphi) { // measure time since last call - static CTimerValue tvLast(0I64); + static CTimerValue tvLast((__int64) 0); CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); if (!_bRunning) { @@ -126,8 +145,13 @@ static void LoadingHook_t(CProgressHookInfo *pphi) // print status text CTString strRes; +#ifdef PLATFORM_WIN32 printf("\r "); - printf("\r%s : %3.0f%%\r", pphi->phi_strDescription, pphi->phi_fCompleted*100); + printf("\r%s : %3.0f%%\r", (const char *) pphi->phi_strDescription, pphi->phi_fCompleted*100); +#else + // !!! FIXME: This isn't right, either... + printf("%s : %3.0f%%\n", (const char *) pphi->phi_strDescription, pphi->phi_fCompleted*100); +#endif } // loading hook functions @@ -158,14 +182,21 @@ BOOL StartGame(CTString &strLevel) return _pGame->NewGame( _pGame->gam_strSessionName, strLevel, sp); } -void ExecScript(const CTString &str) +void ExecScript(const CTFileName &fnmScript) { - CPrintF("Executing: '%s'\n", str); + CPrintF("Executing: '%s'\n", (const char *) fnmScript); CTString strCmd; - strCmd.PrintF("include \"%s\"", str); + strCmd.PrintF("include \"%s\"", (const char *) fnmScript); _pShell->Execute(strCmd); } + +#ifdef PLATFORM_WIN32 + #define DelayBeforeExit() fgetc(stdin); +#else + #define DelayBeforeExit() +#endif + BOOL Init(int argc, char* argv[]) { _bDedicatedServer = TRUE; @@ -174,11 +205,14 @@ BOOL Init(int argc, char* argv[]) // NOTE: this cannot be translated - translations are not loaded yet printf("Usage: DedicatedServer []\n" "This starts a server reading configs from directory 'Scripts\\Dedicated\\\\'\n"); - getch(); + + DelayBeforeExit(); exit(0); } - SetConsoleTitleA(argv[1]); + #ifdef PLATFORM_WIN32 + SetConsoleTitle(argv[1]); + #endif ded_strConfig = CTString("Scripts\\Dedicated\\")+argv[1]+"\\"; @@ -190,7 +224,7 @@ BOOL Init(int argc, char* argv[]) _strLogFile = CTString("Dedicated_")+argv[1]; // initialize engine - SE_InitEngine(sam_strGameName); + SE_InitEngine(argv[0], sam_strGameName); // ParseCommandLine(strCmdLine); @@ -211,32 +245,40 @@ BOOL Init(int argc, char* argv[]) FinishTranslationTable(); } catch (char *strError) { - FatalError("%s %s", CTString(fnmTransTable), strError); + CTString str(fnmTransTable); + FatalError("%s %s", (const char *) str, strError); } // always disable all warnings when in serious sam _pShell->Execute( "con_bNoWarnings=1;"); // declare shell symbols - _pShell->DeclareSymbol("persistent user INDEX ded_iMaxFPS;", &ded_iMaxFPS); - _pShell->DeclareSymbol("user void Quit(void);", &QuitGame); - _pShell->DeclareSymbol("user CTString ded_strLevel;", &ded_strLevel); - _pShell->DeclareSymbol("user FLOAT ded_tmTimeout;", &ded_tmTimeout); - _pShell->DeclareSymbol("user INDEX ded_bRestartWhenEmpty;", &ded_bRestartWhenEmpty); - _pShell->DeclareSymbol("user void Restart(void);", &RestartGame); - _pShell->DeclareSymbol("user void NextMap(void);", &NextMap); - _pShell->DeclareSymbol("persistent user CTString sam_strIntroLevel;", &sam_strIntroLevel); - _pShell->DeclareSymbol("persistent user CTString sam_strGameName;", &sam_strGameName); - _pShell->DeclareSymbol("user CTString sam_strFirstLevel;", &sam_strFirstLevel); + _pShell->DeclareSymbol("persistent user INDEX ded_iMaxFPS;", (void *) &ded_iMaxFPS); + _pShell->DeclareSymbol("user void Quit(void);", (void *) &QuitGame); + _pShell->DeclareSymbol("user CTString ded_strLevel;", (void *) &ded_strLevel); + _pShell->DeclareSymbol("user FLOAT ded_tmTimeout;", (void *) &ded_tmTimeout); + _pShell->DeclareSymbol("user INDEX ded_bRestartWhenEmpty;", (void *) &ded_bRestartWhenEmpty); + _pShell->DeclareSymbol("user void Restart(void);", (void *) &RestartGame); + _pShell->DeclareSymbol("user void NextMap(void);", (void *) &NextMap); + _pShell->DeclareSymbol("persistent user CTString sam_strIntroLevel;", (void *) &sam_strIntroLevel); + _pShell->DeclareSymbol("persistent user CTString sam_strGameName;", (void *) &sam_strGameName); + _pShell->DeclareSymbol("user CTString sam_strFirstLevel;", (void *) &sam_strFirstLevel); // init game - this will load persistent symbols InitializeGame(); _pNetwork->md_strGameID = sam_strGameName; LoadStringVar(CTString("Data\\Var\\Sam_Version.var"), _strSamVersion); - CPrintF(TRANS("Serious Sam version: %s\n"), _strSamVersion); + CPrintF(TRANS("Serious Sam version: %s\n"), (const char *) _strSamVersion); - SetConsoleCtrlHandler(HandlerRoutine, TRUE); + #if (defined PLATFORM_WIN32) + SetConsoleCtrlHandler(HandlerRoutine, TRUE); + #elif (defined PLATFORM_UNIX) + signal(SIGINT, unix_signal_catcher); + signal(SIGHUP, unix_signal_catcher); + signal(SIGQUIT, unix_signal_catcher); + signal(SIGTERM, unix_signal_catcher); + #endif // if there is a mod if (_fnmMod!="") { @@ -269,8 +311,8 @@ void RoundBegin(void) { // repeat generate script names FOREVER { - strBegScript.PrintF("%s%d_begin.ini", ded_strConfig, iRound); - strEndScript.PrintF("%s%d_end.ini", ded_strConfig, iRound); + strBegScript.PrintF("%s%d_begin.ini", (const char *) ded_strConfig, iRound); + strEndScript.PrintF("%s%d_end.ini", (const char *) ded_strConfig, iRound); // if start script exists if (FileExists(strBegScript)) { // stop searching @@ -303,7 +345,7 @@ void RoundBegin(void) _bHadPlayers = 0; _bRestart = 0; DisableLoadingHook(); - _tvLastLevelEnd = CTimerValue(-1i64); + _tvLastLevelEnd = CTimerValue((__int64) -1); CPrintF(TRANS("\nALL OK: Dedicated server is now running!\n")); CPrintF(TRANS("Use Ctrl+C to shutdown the server.\n")); CPrintF(TRANS("DO NOT use the 'Close' button, it might leave the port hanging!\n\n")); @@ -317,7 +359,7 @@ void ForceNextMap(void) _bHadPlayers = 0; _bRestart = 0; DisableLoadingHook(); - _tvLastLevelEnd = CTimerValue(-1i64); + _tvLastLevelEnd = CTimerValue((__int64) -1); } void RoundEnd(void) @@ -331,6 +373,10 @@ void RoundEnd(void) // do the main game loop and render screen void DoGame(void) { + #ifdef SINGLE_THREADED + _pTimer->HandleTimerHandlers(); + #endif + // do the main game loop if( _pGame->gm_bGameOn) { _pGame->GameMainLoop(); diff --git a/Sources/DedicatedServer/StdAfx.h b/Sources/DedicatedServer/StdAfx.h index 6427857..0bec01e 100644 --- a/Sources/DedicatedServer/StdAfx.h +++ b/Sources/DedicatedServer/StdAfx.h @@ -5,7 +5,7 @@ #include #include -/* rcg10042001 protect against Visual C-isms. */ +// rcg10042001 protect against Visual C-isms. #ifdef _MSC_VER #define DECL_DLL _declspec(dllimport) #endif @@ -18,6 +18,8 @@ #include #include #include +#include // rcg10072001 needed enum definition. #include #undef DECL_DLL + diff --git a/Sources/Depend/Dependency.cpp b/Sources/Depend/Dependency.cpp index 17f4e94..7bdd8f3 100644 --- a/Sources/Depend/Dependency.cpp +++ b/Sources/Depend/Dependency.cpp @@ -427,18 +427,21 @@ void CDependencyList::ExtractTranslations_t( const CTFileName &fnTranslations) // for each byte in file for(INDEX iByte=0; iByte 254 || iStrLen<0) { continue; } @@ -449,7 +452,7 @@ void CDependencyList::ExtractTranslations_t( const CTFileName &fnTranslations) // add it AddStringForTranslation(str); // if text translatable string is here - } else if (*pul=='SRTT') { + } else if (ul=='SRTT') { // after describing long and one space we will find file name char *pchrStart = (char*)pub + 4 + 1; diff --git a/Sources/Depend/UtilityDepend.cpp b/Sources/Depend/UtilityDepend.cpp index 4d23cf8..7594757 100644 --- a/Sources/Depend/UtilityDepend.cpp +++ b/Sources/Depend/UtilityDepend.cpp @@ -45,7 +45,7 @@ void SubMain( int argc, char *argv[]) } // initialize engine - SE_InitEngine(""); + SE_InitEngine(argv[0], ""); // get application path from cmd line _fnmApplicationPath = CTString(ACHR_APP_DIR); // if not ending with backslash diff --git a/Sources/Ecc/Parser.y b/Sources/Ecc/Parser.y index aa676f9..b05f96a 100644 --- a/Sources/Ecc/Parser.y +++ b/Sources/Ecc/Parser.y @@ -3,6 +3,13 @@ #include "Ecc/StdH.h" #include "Ecc/Main.h" +// turn off over-helpful bit of bison... --ryan. +#ifdef __GNUC__ +#define __attribute__(x) +#endif + +#define YYINITDEPTH 1000 + static char *_strCurrentClass; static int _iCurrentClassID; static char *_strCurrentBase; @@ -125,7 +132,7 @@ void CreateInternalHandlerFunction(char *strFunctionName, char *strID) void DeclareFeatureProperties(void) { if (_bFeature_CanBePredictable) { - fprintf(_fTables, " CEntityProperty(CEntityProperty::EPT_ENTITYPTR, NULL, (0x%08x<<8)+%s, offsetof(%s, %s), %s, %s, %s, %s),\n", + fprintf(_fTables, " CEntityProperty(CEntityProperty::EPT_ENTITYPTR, NULL, (0x%08x<<8)+%s, _offsetof(%s, %s), %s, %s, %s, %s),\n", _iCurrentClassID, "255", _strCurrentClass, @@ -142,7 +149,7 @@ void DeclareFeatureProperties(void) } } -#undef YYERROR_VERBOSE +#define YYERROR_VERBOSE 1 %} @@ -584,7 +591,7 @@ empty_property_declaration_list property_declaration : property_id property_type property_identifier property_wed_name_opt property_default_opt property_flags_opt { - fprintf(_fTables, " CEntityProperty(%s, %s, (0x%08x<<8)+%s, offsetof(%s, %s), %s, %s, %s, %s),\n", + fprintf(_fTables, " CEntityProperty(%s, %s, (0x%08x<<8)+%s, _offsetof(%s, %s), %s, %s, %s, %s),\n", _strCurrentPropertyPropertyType, _strCurrentPropertyEnumType, _iCurrentClassID, diff --git a/Sources/Ecc/StdH.h b/Sources/Ecc/StdH.h index 4ecb9f0..a41ea48 100644 --- a/Sources/Ecc/StdH.h +++ b/Sources/Ecc/StdH.h @@ -4,10 +4,13 @@ #include #include #include -#include #include #include +#if !PLATFORM_MACOSX +#include +#endif + #ifdef PLATFORM_UNIX #include #include diff --git a/Sources/Engine/Base/Anim.cpp b/Sources/Engine/Base/Anim.cpp index 98c51f5..15ee92e 100644 --- a/Sources/Engine/Base/Anim.cpp +++ b/Sources/Engine/Base/Anim.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include @@ -17,7 +17,8 @@ /* * One animation of an animateable object */ -class COneAnim { +class COneAnim +{ public: COneAnim(); ~COneAnim(); @@ -61,20 +62,20 @@ CTmpListHead::~CTmpListHead() { FORDELETELIST(COneAnimNode, coan_Node, *this, it) delete &it.Current(); -}; +} // Remember ptr to animation and add this node at the end of given animation list COneAnimNode::COneAnimNode(COneAnim *AnimToInsert, CListHead *LH) { coan_OneAnim = AnimToInsert; LH->AddTail( coan_Node); -}; +} // Constructor sets invalid data COneAnim::COneAnim() { oa_FrameIndices = NULL; -}; +} // Free allocated frame indices array for this animation COneAnim::~COneAnim() @@ -82,7 +83,7 @@ COneAnim::~COneAnim() ASSERT(oa_FrameIndices != NULL); FreeMemory( oa_FrameIndices); oa_FrameIndices = NULL; -}; +} /* * Copy constructor. @@ -113,18 +114,18 @@ CFileNameNode::CFileNameNode(const char *NewFileName, CListHead *LH) ASSERT(strlen(NewFileName)>0); strcpy( cfnn_FileName, NewFileName); LH->AddTail( cfnn_Node); -}; +} CAnimData::CAnimData() { ad_Anims = NULL; ad_NumberOfAnims = 0; -}; +} CAnimData::~CAnimData() { Clear(); -}; +} void CAnimData::Clear() { @@ -135,7 +136,7 @@ void CAnimData::Clear() // clear serial object CSerial::Clear(); -}; +} // get amount of memory used by this object SLONG CAnimData::GetUsedMemory(void) @@ -157,19 +158,24 @@ BOOL CAnimData::IsAutoFreed(void) ///////////////////////////////////////////////////////////////////// // Reference counting functions -void CAnimData::AddReference(void) { +void CAnimData::AddReference(void) +{ if (this!=NULL) { MarkUsed(); } -}; -void CAnimData::RemReference(void) { +} + +void CAnimData::RemReference(void) +{ if (this!=NULL) { RemReference_internal(); } -}; -void CAnimData::RemReference_internal(void) { +} + +void CAnimData::RemReference_internal(void) +{ _pAnimStock->Release(this); -}; +} // creates given number of default animations (1 frame, given name and speed) void CAnimData::CreateAnimations( INDEX ctAnimations, CTString strName/*="None"*/, @@ -228,7 +234,7 @@ void CAnimData::DefaultAnimation() ad_Anims->oa_NumberOfFrames = 1; ad_Anims->oa_FrameIndices = (INDEX *) AllocMemory( sizeof(INDEX)); ad_Anims->oa_FrameIndices[0] = 0; -}; +} // Returns index of given frame name in global frame names list. If it is not found // new CFileNameObject is added into frames list @@ -243,7 +249,7 @@ INDEX FindFrameIndex( CListHead *pFrameFileList, const char *pFileName) } new CFileNameNode( pFileName, pFrameFileList); return( i); -}; +} CTString GetFrameFileName( CListHead *pFrameFileList, INDEX iMemberInList) { @@ -306,8 +312,11 @@ void CAnimData::LoadFromScript_t( CTStream *File, CListHead *pFrameFileList) // // if it is not yet there else if( EQUAL_SUB_STR( "DIRECTORY")) { - _strupr( ld_line); - sscanf( ld_line, "DIRECTORY %s", base_path); + // !!! FIXME : rcg10092001 You can't uppercase filenames! + //_strupr( ld_line); + sscanf( ld_line, "DIRECTORY %s", base_path); + + // !!! FIXME : rcg10092001 Use CFileSystem::GetDirSeparator(). if( base_path[ strlen( base_path) - 1] != '\\') strcat( base_path,"\\"); } @@ -430,7 +439,7 @@ void CAnimData::LoadFromScript_t( CTStream *File, CListHead *pFrameFileList) // FORDELETELIST( COneAnimNode, coan_Node, TempAnimationList, litDel) delete &litDel.Current(); -}; +} void CAnimData::Write_t( CTStream *ostrFile) // throw char * { @@ -448,7 +457,7 @@ void CAnimData::Write_t( CTStream *ostrFile) // throw char * ostrFile->Write_t( ad_Anims[i].oa_FrameIndices, ad_Anims[i].oa_NumberOfFrames * sizeof( INDEX)); } -}; +} // print #define lines for all animations into given file void CAnimData::ExportAnimationNames_t( CTStream *ostrFile, CTString strAnimationPrefix) // throw char * @@ -458,7 +467,7 @@ void CAnimData::ExportAnimationNames_t( CTStream *ostrFile, CTString strAnimatio for( INDEX iAnimation=0; iAnimationPutLine_t( chrLine); @@ -500,22 +509,37 @@ void CAnimData::AddAnimation(void) } // replaces requested animation's name with given one -void CAnimData::SetName( INDEX iAnimation, CTString strNewName){ +void CAnimData::SetName( INDEX iAnimation, CTString strNewName) +{ ASSERT(strlen(strNewName)ExpectID_t( CChunkID( "ADAT")); // Then we load and create number of animations - istrFile->Read_t( &ad_NumberOfAnims, sizeof( INDEX)); + (*istrFile)>>ad_NumberOfAnims; ad_Anims = new COneAnim[ ad_NumberOfAnims]; for( i=0; iRead_t( &ad_Anims[i].oa_Name, sizeof( NAME)); - istrFile->Read_t( &ad_Anims[i].oa_SecsPerFrame, sizeof( TIME)); - istrFile->Read_t( &ad_Anims[i].oa_NumberOfFrames, sizeof( INDEX)); + istrFile->Read_t(ad_Anims[i].oa_Name, sizeof (ad_Anims[i].oa_Name)); // char[32] + (*istrFile)>>ad_Anims[i].oa_SecsPerFrame; + (*istrFile)>>ad_Anims[i].oa_NumberOfFrames; ad_Anims[i].oa_FrameIndices = (INDEX *) AllocMemory( ad_Anims[i].oa_NumberOfFrames * sizeof( INDEX)); - istrFile->Read_t( ad_Anims[i].oa_FrameIndices, - ad_Anims[i].oa_NumberOfFrames * sizeof( INDEX)); + for (SLONG j = 0; j < ad_Anims[i].oa_NumberOfFrames; j++) + (*istrFile)>>ad_Anims[i].oa_FrameIndices[j]; } -}; +} /* * Default constructor. @@ -575,13 +599,13 @@ CAnimObject::CAnimObject(void) ao_iCurrentAnim = -1; ao_iLastAnim = -1; ao_ulFlags = AOF_PAUSED; -}; +} /* Destructor. */ CAnimObject::~CAnimObject(void) { ao_AnimData->RemReference(); -}; +} // copy from another object of same class ENGINE_API void CAnimObject::Copy(CAnimObject &aoOther) @@ -604,7 +628,7 @@ ENGINE_API void CAnimObject::Synchronize(CAnimObject &aoOther) } /* - * Get animation's lenght. + * Get animation's length. */ FLOAT CAnimObject::GetAnimLength(INDEX iAnim) const { @@ -616,7 +640,7 @@ FLOAT CAnimObject::GetAnimLength(INDEX iAnim) const ASSERT( (iAnim >= 0) && (iAnim < ao_AnimData->ad_NumberOfAnims) ); COneAnim *pCOA = &ao_AnimData->ad_Anims[iAnim]; return pCOA->oa_NumberOfFrames*pCOA->oa_SecsPerFrame; -}; +} FLOAT CAnimObject::GetCurrentAnimLength(void) const { @@ -659,7 +683,8 @@ void CAnimObject::PauseAnim(void) /* * Continues paused animation */ -void CAnimObject::ContinueAnim(void){ +void CAnimObject::ContinueAnim(void) +{ if( !(ao_ulFlags&AOF_PAUSED)) return; // calculate freezed frame index inside current animation (not in global list of frames!) COneAnim *pCOA = &ao_AnimData->ad_Anims[ao_iCurrentAnim]; @@ -677,7 +702,8 @@ void CAnimObject::ContinueAnim(void){ /* * Offsets the animation phase */ -void CAnimObject::OffsetPhase(TIME tm){ +void CAnimObject::OffsetPhase(TIME tm) +{ ao_tmAnimStart += tm; } @@ -685,19 +711,21 @@ void CAnimObject::OffsetPhase(TIME tm){ /* * Loop anims forward */ -void CAnimObject::NextAnim(){ +void CAnimObject::NextAnim() +{ ASSERT( ao_iCurrentAnim != -1); ASSERT( ao_AnimData != NULL); ao_iCurrentAnim = (ao_iCurrentAnim + 1) % ao_AnimData->ad_NumberOfAnims; ao_iLastAnim = ao_iCurrentAnim; ao_tmAnimStart = _pTimer->CurrentTick(); MarkChanged(); -}; +} /* * Loop anims backward */ -void CAnimObject::PrevAnim(){ +void CAnimObject::PrevAnim() +{ ASSERT( ao_iCurrentAnim != -1); ASSERT( ao_AnimData != NULL); ao_iCurrentAnim = (ao_AnimData->ad_NumberOfAnims + ao_iCurrentAnim - 1) % @@ -705,7 +733,7 @@ void CAnimObject::PrevAnim(){ ao_iLastAnim = ao_iCurrentAnim; ao_tmAnimStart = _pTimer->CurrentTick(); MarkChanged(); -}; +} /* * Selects frame for given time offset from animation start (0) @@ -730,31 +758,34 @@ void CAnimObject::LastFrame(void) /* * Loop frames forward */ -void CAnimObject::NextFrame(){ +void CAnimObject::NextFrame() +{ ASSERT( ao_iCurrentAnim != -1); ASSERT( ao_AnimData != NULL); ASSERT( ao_ulFlags&AOF_PAUSED); ao_tmAnimStart += ao_AnimData->ad_Anims[ ao_iCurrentAnim].oa_SecsPerFrame; MarkChanged(); -}; +} /* * Loop frames backward */ -void CAnimObject::PrevFrame(){ +void CAnimObject::PrevFrame() +{ ASSERT( ao_iCurrentAnim != -1); ASSERT( ao_AnimData != NULL); ASSERT( ao_ulFlags&AOF_PAUSED); ao_tmAnimStart -= ao_AnimData->ad_Anims[ ao_iCurrentAnim].oa_SecsPerFrame; MarkChanged(); -}; +} /* * Retrieves paused flag */ -BOOL CAnimObject::IsPaused(){ +BOOL CAnimObject::IsPaused() +{ return ao_ulFlags&AOF_PAUSED; -}; +} /* * Test if some updateable object is up to date with this anim object. @@ -773,7 +804,8 @@ BOOL CAnimObject::IsUpToDate(const CUpdateable &ud) const /* * Attach data to this object. */ -void CAnimObject::SetData(CAnimData *pAD) { +void CAnimObject::SetData(CAnimData *pAD) +{ // mark new data as referenced once more pAD->AddReference(); // mark old data as referenced once less @@ -809,7 +841,8 @@ void CAnimObject::SetData_t(const CTFileName &fnmAnim) // throw char * /* * Sets new animation (but doesn't starts it). */ -void CAnimObject::SetAnim(INDEX iNew) { +void CAnimObject::SetAnim(INDEX iNew) +{ if(ao_AnimData == NULL) return; // clamp animation if( iNew >= GetAnimsCt() ) @@ -826,18 +859,19 @@ void CAnimObject::SetAnim(INDEX iNew) { ao_iLastAnim=iNew; // mark that something has changed MarkChanged(); -}; +} /* * Start new animation. */ -void CAnimObject::StartAnim(INDEX iNew) { +void CAnimObject::StartAnim(INDEX iNew) +{ if(ao_AnimData == NULL) return; // set new animation SetAnim( iNew); // set pause off, looping on ao_ulFlags = AOF_LOOPING; -}; +} /* Start playing an animation. */ void CAnimObject::PlayAnim(INDEX iNew, ULONG ulFlags) @@ -887,7 +921,7 @@ void CAnimObject::PlayAnim(INDEX iNew, ULONG ulFlags) // mark that something has changed MarkChanged(); -}; +} /* Seamlessly continue playing another animation from same point. */ void CAnimObject::SwitchToAnim(INDEX iNew) @@ -906,13 +940,14 @@ void CAnimObject::SwitchToAnim(INDEX iNew) /* * Reset anim (restart) */ -void CAnimObject::ResetAnim() { +void CAnimObject::ResetAnim() +{ if(ao_AnimData == NULL) return; // remember starting time ao_tmAnimStart = _pTimer->CurrentTick(); // mark that something has changed MarkChanged(); -}; +} // Get info about some animation void CAnimObject::GetAnimInfo(INDEX iAnimNo, CAnimInfo &aiInfo) const @@ -989,14 +1024,13 @@ INDEX CAnimObject::GetAnimsCt(void) const if(ao_AnimData == NULL) return 1; ASSERT( ao_AnimData != NULL); return( ao_AnimData->ad_NumberOfAnims); -}; +} // get index of current animation INDEX CAnimObject::GetAnim(void) const { return( ao_iCurrentAnim); -}; - +} /* * Gets the number of current frame. @@ -1007,10 +1041,11 @@ INDEX CAnimObject::GetFrame(void) const } /* Gets number of frames in current anim. */ -INDEX CAnimObject::GetFramesInCurrentAnim(void) const { +INDEX CAnimObject::GetFramesInCurrentAnim(void) const +{ ASSERT( ao_AnimData != NULL); return ao_AnimData->ad_Anims[ao_iCurrentAnim].oa_NumberOfFrames; -}; +} /* * Get information for linear interpolation beetween frames. @@ -1070,23 +1105,23 @@ void CAnimObject::GetFrame( INDEX &iFrame0, INDEX &iFrame1, FLOAT &fRatio) const void CAnimObject::Write_t( CTStream *pstr) // throw char * { (*pstr).WriteID_t("ANOB"); - (*pstr).WriteRawChunk_t( &ao_tmAnimStart, sizeof( TIME)); - (*pstr).WriteRawChunk_t( &ao_iCurrentAnim, sizeof( INDEX)); - (*pstr).WriteRawChunk_t( &ao_iLastAnim, sizeof( INDEX)); - (*pstr).WriteRawChunk_t( &ao_ulFlags, sizeof( INDEX)); -}; + (*pstr)<>ao_tmAnimStart; + (*pstr)>>ao_iCurrentAnim; + (*pstr)>>ao_iLastAnim; + (*pstr)>>ao_ulFlags; } else { - (*pstr).ReadRawChunk_t( &ao_tmAnimStart, sizeof( TIME)); - (*pstr).ReadRawChunk_t( &ao_iCurrentAnim, sizeof( INDEX)); + (*pstr)>>ao_tmAnimStart; + (*pstr)>>ao_iCurrentAnim; ao_iLastAnim = ao_iCurrentAnim; ao_ulFlags = 0; } @@ -1101,4 +1136,5 @@ void CAnimObject::Read_t( CTStream *pstr) // throw char * { ao_iLastAnim = 0; } -}; +} + diff --git a/Sources/Engine/Base/Anim.h b/Sources/Engine/Base/Anim.h index 849048d..82abf03 100644 --- a/Sources/Engine/Base/Anim.h +++ b/Sources/Engine/Base/Anim.h @@ -12,7 +12,11 @@ #define NAME_SIZE 32 typedef char NAME[NAME_SIZE]; -#define PATH_MAX 260 + +#if (!defined PATH_MAX) + #define PATH_MAX 260 +#endif + typedef char FILE_NAME[PATH_MAX]; /* diff --git a/Sources/Engine/Base/CRC.cpp b/Sources/Engine/Base/CRC.cpp index 7ad1488..5ea37f5 100644 --- a/Sources/Engine/Base/CRC.cpp +++ b/Sources/Engine/Base/CRC.cpp @@ -1,6 +1,7 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" +#include "Engine/Base/CRC.h" // Note: this CRC calculation algorithm, although originating from MSDN examples, // is in fact identical to the Adler32 used in ZIP's CRC calculation. diff --git a/Sources/Engine/Base/CRC.h b/Sources/Engine/Base/CRC.h index b1e1ae0..92bd51f 100644 --- a/Sources/Engine/Base/CRC.h +++ b/Sources/Engine/Base/CRC.h @@ -17,7 +17,7 @@ inline void CRC_AddBYTE( ULONG &ulCRC, UBYTE ub) ulCRC = (ulCRC>>8)^crc_aulCRCTable[UBYTE(ulCRC)^ub]; }; -inline void CRC_AddWORD( ULONG &ulCRC, UBYTE uw) +inline void CRC_AddWORD( ULONG &ulCRC, UWORD uw) { CRC_AddBYTE(ulCRC, UBYTE(uw>> 8)); CRC_AddBYTE(ulCRC, UBYTE(uw>> 0)); diff --git a/Sources/Engine/Base/CRCTable.cpp b/Sources/Engine/Base/CRCTable.cpp index 460d451..e32ad74 100644 --- a/Sources/Engine/Base/CRCTable.cpp +++ b/Sources/Engine/Base/CRCTable.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Engine/StdH.h" #include #include @@ -48,7 +48,7 @@ extern BOOL FileMatchesList(CDynamicStackArray &afnm, const CTFileNa static CDynamicStackArray _aceEntries; static CNameTable_CCRCEntry _ntEntries; -extern BOOL CRCT_bGatherCRCs = FALSE; // set while gathering CRCs of all loaded files +BOOL CRCT_bGatherCRCs = FALSE; // set while gathering CRCs of all loaded files // init CRC table void CRCT_Init(void) @@ -169,13 +169,14 @@ ULONG CRCT_MakeCRCForFiles_t(CTStream &strmFiles) // throw char * // read the name CTString strName; strmFiles>>strName; + CTFileName fname = strName; // try to find it in table - CCRCEntry *pce = _ntEntries.Find(strName); + CCRCEntry *pce = _ntEntries.Find(fname); // if not there if (pce==NULL) { - CRCT_AddFile_t(strName); + CRCT_AddFile_t(fname); // add it now - pce = _ntEntries.Find(strName); + pce = _ntEntries.Find(fname); } // add the crc CRC_AddLONG(ulCRC, pce->ce_ulCRC); diff --git a/Sources/Engine/Base/CTString.cpp b/Sources/Engine/Base/CTString.cpp index d7c4a70..dbf30bc 100644 --- a/Sources/Engine/Base/CTString.cpp +++ b/Sources/Engine/Base/CTString.cpp @@ -1,12 +1,15 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include #include +#ifndef _MSC_VER +#include // for vsscanf() +#endif /* * Equality comparison. @@ -456,6 +459,7 @@ INDEX CTString::PrintF(const char *strFormat, ...) va_list arg; va_start(arg, strFormat); return VPrintF(strFormat, arg); + va_end(arg); } @@ -491,8 +495,8 @@ INDEX CTString::VPrintF(const char *strFormat, va_list arg) return iLen; } - - +// !!! FIXME: maybe don't do this, and just use the vsscanf() version. --ryan. +#ifdef _MSC_VER static void *psscanf = &sscanf; // Scan formatted from a string __declspec(naked) INDEX CTString::ScanF(const char *strFormat, ...) @@ -507,6 +511,20 @@ __declspec(naked) INDEX CTString::ScanF(const char *strFormat, ...) } } +#else + +INDEX CTString::ScanF(const char *strFormat, ...) +{ + INDEX retval; + va_list ap; + va_start(ap, strFormat); + retval = (INDEX) vsscanf((const char *) (*this), strFormat, ap); + va_end(ap); + return(retval); +} + +#endif + // split string in two strings at specified position (char AT splitting position goes to str2) void CTString::Split( INDEX iPos, CTString &str1, CTString &str2) @@ -541,10 +559,10 @@ void CTString::DeleteChar( INDEX iPos) if (ctChars==0) { return; } - if( iPos>ctChars) iPos=ctChars; + if( iPos>ctChars) iPos=ctChars - 1; else if( iPos<0) iPos=0; // copy part of string - memmove( &str_String[iPos], &str_String[iPos+1], ctChars-iPos+1); + memmove( &str_String[iPos], &str_String[iPos+1], ctChars-iPos); // shrink memory used by string over deleted char ShrinkMemory( (void**)&str_String, ctChars); } @@ -630,7 +648,7 @@ void CTString::LoadVar(const class CTFileName &fnmFile) str.Load_t(fnmFile); *this = str; } catch (char *strError) { - CPrintF(TRANS("Cannot load variable from '%s':\n%s\n"), (CTString&)fnmFile, strError); + CPrintF(TRANS("Cannot load variable from '%s':\n%s\n"), (const char *) (CTString&)fnmFile, strError); } } @@ -639,7 +657,7 @@ void CTString::SaveVar(const class CTFileName &fnmFile) try { Save_t(fnmFile); } catch (char *strError) { - CPrintF(TRANS("Cannot save variable to '%s':\n%s\n"), (CTString&)fnmFile, strError); + CPrintF(TRANS("Cannot save variable to '%s':\n%s\n"), (const char *) (CTString&)fnmFile, strError); } } diff --git a/Sources/Engine/Base/CTString.inl b/Sources/Engine/Base/CTString.inl index e6283b6..1a1ee4e 100644 --- a/Sources/Engine/Base/CTString.inl +++ b/Sources/Engine/Base/CTString.inl @@ -44,6 +44,7 @@ ENGINE_API CTString::CTString(INDEX iDummy, const char *strFormat, ...) va_list arg; va_start(arg, strFormat); VPrintF(strFormat, arg); + va_end(arg); } /* diff --git a/Sources/Engine/Base/Changeable.cpp b/Sources/Engine/Base/Changeable.cpp index ef48385..e19df9a 100644 --- a/Sources/Engine/Base/Changeable.cpp +++ b/Sources/Engine/Base/Changeable.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Base/Console.cpp b/Sources/Engine/Base/Console.cpp index 71f0b00..6403d53 100644 --- a/Sources/Engine/Base/Console.cpp +++ b/Sources/Engine/Base/Console.cpp @@ -1,9 +1,9 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include -#include +#include #include #include @@ -13,11 +13,11 @@ #include -extern CConsole *_pConsole = NULL; +CConsole *_pConsole = NULL; extern INDEX con_iLastLines; -extern BOOL con_bCapture = FALSE; -extern CTString con_strCapture = ""; +BOOL con_bCapture = FALSE; +CTString con_strCapture = ""; // Constructor. @@ -262,7 +262,7 @@ void CConsole::CloseLog(void) } // Print formated text to the main console. -extern void CPrintF(const char *strFormat, ...) +void CPrintF(const char *strFormat, ...) { if (_pConsole==NULL) { return; @@ -272,6 +272,7 @@ extern void CPrintF(const char *strFormat, ...) va_start(arg, strFormat); CTString strBuffer; strBuffer.VPrintF(strFormat, arg); + va_end(arg); // print it to the main console _pConsole->PutString(strBuffer); diff --git a/Sources/Engine/Base/Directory.cpp b/Sources/Engine/Base/Directory.cpp index dfe87d2..e764a89 100644 --- a/Sources/Engine/Base/Directory.cpp +++ b/Sources/Engine/Base/Directory.cpp @@ -1,11 +1,11 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include +#include #include -#include extern CDynamicStackArray _afnmBaseBrowseInc; extern CDynamicStackArray _afnmBaseBrowseExc; @@ -49,32 +49,33 @@ void FillDirList_internal(const CTFileName &fnmBasePath, continue; } + const char *dirsep = CFileSystem::GetDirSeparator(); + // start listing the directory - struct _finddata_t c_file; long hFile; - hFile = _findfirst( (const char *)(fnmBasePath+fnmDir+"*"), &c_file ); - + CDynamicArray *files; + files = _pFileSystem->FindFiles(fnmBasePath+fnmDir, "*"); + int max = files->Count(); + // for each file in the directory - for ( - BOOL bFileExists = hFile!=-1; - bFileExists; - bFileExists = _findnext( hFile, &c_file )==0) { + for (int i = 0; i < max; i++) { + const char *fname = (*files)[i]; // if dummy dir (this dir, parent dir, or any dir starting with '.') - if (c_file.name[0]=='.') { + if (_pFileSystem->IsDummyFile(fname)) { // skip it continue; } // get the file's filepath - CTFileName fnm = fnmDir+c_file.name; + CTFileName fnm = fnmDir + fname; // if it is a directory - if (c_file.attrib&_A_SUBDIR) { + if (_pFileSystem->IsDirectory(fnm)) { // if recursive reading if (bRecursive) { // add it to the list of directories to search CDirToRead *pdrNew = new CDirToRead; - pdrNew->dr_strDir = fnm+"\\"; + pdrNew->dr_strDir = fnm + dirsep; lhDirs.AddTail(pdrNew->dr_lnNode); } // if it matches the pattern @@ -83,13 +84,15 @@ void FillDirList_internal(const CTFileName &fnmBasePath, afnm.Push() = fnm; } } + + delete files; } } // make a list of all files in a directory ENGINE_API void MakeDirList( - CDynamicStackArray &afnmDir, const CTFileName &fnmDir, const CTString &strPattern, ULONG ulFlags) + CDynamicStackArray &afnmDir, const CTFileName &fnmDir, const CTFileName &fnmPattern, ULONG ulFlags) { afnmDir.PopAll(); BOOL bRecursive = ulFlags&DLI_RECURSIVE; @@ -99,17 +102,21 @@ ENGINE_API void MakeDirList( CDynamicStackArray afnm; if (_fnmMod!="") { - FillDirList_internal(_fnmApplicationPath, afnm, fnmDir, strPattern, bRecursive, + FillDirList_internal(_fnmUserDir, afnm, fnmDir, fnmPattern, bRecursive, + &_afnmBaseBrowseInc, &_afnmBaseBrowseExc); + FillDirList_internal(_fnmApplicationPath, afnm, fnmDir, fnmPattern, bRecursive, &_afnmBaseBrowseInc, &_afnmBaseBrowseExc); if (bSearchCD) { - FillDirList_internal(_fnmCDPath, afnm, fnmDir, strPattern, bRecursive, + FillDirList_internal(_fnmCDPath, afnm, fnmDir, fnmPattern, bRecursive, &_afnmBaseBrowseInc, &_afnmBaseBrowseExc); } - FillDirList_internal(_fnmApplicationPath+_fnmMod, afnm, fnmDir, strPattern, bRecursive, NULL, NULL); + FillDirList_internal(_fnmUserDir+_fnmMod, afnm, fnmDir, fnmPattern, bRecursive, NULL, NULL); + FillDirList_internal(_fnmApplicationPath+_fnmMod, afnm, fnmDir, fnmPattern, bRecursive, NULL, NULL); } else { - FillDirList_internal(_fnmApplicationPath, afnm, fnmDir, strPattern, bRecursive, NULL, NULL); + FillDirList_internal(_fnmUserDir, afnm, fnmDir, fnmPattern, bRecursive, NULL, NULL); + FillDirList_internal(_fnmApplicationPath, afnm, fnmDir, fnmPattern, bRecursive, NULL, NULL); if (bSearchCD) { - FillDirList_internal(_fnmCDPath, afnm, fnmDir, strPattern, bRecursive, NULL, NULL); + FillDirList_internal(_fnmCDPath, afnm, fnmDir, fnmPattern, bRecursive, NULL, NULL); } } @@ -131,7 +138,7 @@ ENGINE_API void MakeDirList( } // if doesn't match pattern - if (strPattern!="" && !fnm.Matches(strPattern)) { + if (fnmPattern!="" && !fnm.Matches(fnmPattern)) { // skip it continue; } diff --git a/Sources/Engine/Base/DynamicLoader.h b/Sources/Engine/Base/DynamicLoader.h new file mode 100644 index 0000000..3b67860 --- /dev/null +++ b/Sources/Engine/Base/DynamicLoader.h @@ -0,0 +1,42 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#ifndef SE_INCL_DYNAMICLOADER_H +#define SE_INCL_DYNAMICLOADER_H +#ifdef PRAGMA_ONCE + #pragma once +#endif + +/* + * This class handles DLL loading in a platform-abstracted manner. + */ +class ENGINE_API CDynamicLoader { +public: + // Construct a CDynamicLoader to handle symbol lookups in a shared lib. + // (libname) is a platform-independent filename. If you specify "game", + // then you get "Game.dll" on windows, and "libgame.so" on Linux. + // You should ALWAYS use lowercase, unless you know what you're doing. + static CDynamicLoader *GetInstance(const char *libname); + + // Convert a win32 DLL path to a platform-specific equivalent. + // ("Bin\\Entities.dll" becomes "Bin/libEntities.so" on Linux, etc.) + static CTFileName ConvertLibNameToPlatform(const char *libname); + + virtual ~CDynamicLoader(void) {} + + // Lookup (sym) and return a pointer to it. + // Returns NULL on error/symbol not found. + virtual void *FindSymbol(const char *sym) = 0; + + // return a human-readable error message. NULL if there's no error. + virtual const char *GetError(void) = 0; + +protected: + // use GetInstance(), instead. + CDynamicLoader() {} +}; + +#endif + +// end of DynamicLoader.h ... + + diff --git a/Sources/Engine/Base/ErrorReporting.cpp b/Sources/Engine/Base/ErrorReporting.cpp index 99db6de..40ab116 100644 --- a/Sources/Engine/Base/ErrorReporting.cpp +++ b/Sources/Engine/Base/ErrorReporting.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -34,18 +34,21 @@ void FatalError(const char *strFormat, ...) // (this is a low overhead and shouldn't allocate memory) CDS_ResetMode(); +#ifdef PLATFORM_WIN32 // hide fullscreen window if any if( _bFullScreen) { // must do minimize first - don't know why :( ShowWindow( _hwndMain, SW_MINIMIZE); ShowWindow( _hwndMain, SW_HIDE); } +#endif // format the message in buffer va_list arg; va_start(arg, strFormat); CTString strBuffer; strBuffer.VPrintF(strFormat, arg); + va_end(arg); if (_pConsole!=NULL) { // print the buffer to the console @@ -55,14 +58,20 @@ void FatalError(const char *strFormat, ...) _pConsole->CloseLog(); } +#ifdef PLATFORM_WIN32 // create message box with just OK button MessageBoxA(NULL, strBuffer, TRANS("Fatal Error"), MB_OK|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); - _bInFatalError = FALSE; - extern void EnableWindowsKeys(void); EnableWindowsKeys(); +#else + // !!! FIXME : Use SDL2's SDL_ShowSimpleMessageBox(). + // !!! FIXME : We should really SDL_Quit() here. + fprintf(stderr, "FATAL ERROR:\n \"%s\"\n\n", (const char *) strBuffer); +#endif + + _bInFatalError = FALSE; // exit program exit(EXIT_FAILURE); } @@ -77,13 +86,18 @@ void WarningMessage(const char *strFormat, ...) va_start(arg, strFormat); CTString strBuffer; strBuffer.VPrintF(strFormat, arg); + va_end(arg); // print it to console - CPrintF("%s\n", strBuffer); + CPrintF("%s\n", (const char *) strBuffer); // if warnings are enabled if( !con_bNoWarnings) { // create message box - MessageBoxA(NULL, strBuffer, TRANS("Warning"), MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_TASKMODAL); + #ifdef PLATFORM_WIN32 + MessageBoxA(NULL, (const char *) strBuffer, TRANS("Warning"), MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_TASKMODAL); + #else // !!! FIXME: SDL_ShowSimpleMessageBox() in SDL2. + fprintf(stderr, "WARNING: \"%s\"\n", (const char *) strBuffer); + #endif } } @@ -94,11 +108,17 @@ void InfoMessage(const char *strFormat, ...) va_start(arg, strFormat); CTString strBuffer; strBuffer.VPrintF(strFormat, arg); + va_end(arg); // print it to console - CPrintF("%s\n", strBuffer); + CPrintF("%s\n", (const char *) strBuffer); + // create message box - MessageBoxA(NULL, strBuffer, TRANS("Information"), MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND|MB_TASKMODAL); + #ifdef PLATFORM_WIN32 + MessageBoxA(NULL, (const char *) strBuffer, TRANS("Information"), MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND|MB_TASKMODAL); + #else // !!! FIXME: SDL_ShowSimpleMessageBox() in SDL2. + fprintf(stderr, "INFO: \"%s\"\n", (const char *) strBuffer); + #endif } /* Ask user for yes/no answer(stops program until user responds). */ @@ -109,11 +129,27 @@ BOOL YesNoMessage(const char *strFormat, ...) va_start(arg, strFormat); CTString strBuffer; strBuffer.VPrintF(strFormat, arg); + va_end(arg); // print it to console - CPrintF("%s\n", strBuffer); + CPrintF("%s\n", (const char *) strBuffer); + // create message box + #ifdef PLATFORM_WIN32 return MessageBoxA(NULL, strBuffer, TRANS("Question"), MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND|MB_TASKMODAL)==IDYES; + #else + // !!! FIXME: SDL_messagebox + fprintf(stderr, "QUESTION: \"%s\" [y/n] : ", (const char *) strBuffer); + while (true) + { + int ch = fgetc(stdin); + if (ch == 'y') + return 1; + else if (ch == 'n') + return 0; + } + return 0; + #endif } /* @@ -122,11 +158,18 @@ BOOL YesNoMessage(const char *strFormat, ...) void ThrowF_t(char *strFormat, ...) // throws char * { const SLONG slBufferSize = 256; - char strBuffer[slBufferSize+1]; + //char strBuffer[slBufferSize+1]; // Can't throw from the stack like this! + static char *strBuffer = NULL; + + // !!! FIXME: This could be dangerous if you call this in a catch handler... + delete[] strBuffer; + strBuffer = new char[slBufferSize+1]; + // format the message in buffer va_list arg; va_start(arg, strFormat); // variable arguments start after this argument _vsnprintf(strBuffer, slBufferSize, strFormat, arg); + va_end(arg); throw strBuffer; } @@ -161,7 +204,8 @@ void ThrowF_t(char *strFormat, ...) // throws char * */ extern const CTString GetWindowsError(DWORD dwWindowsErrorCode) { - // buffer to receive error description +#ifdef PLATFORM_WIN32 + // buffer to recieve error description LPVOID lpMsgBuf; // call function that will prepare text abount given windows error code FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, @@ -172,10 +216,23 @@ void ThrowF_t(char *strFormat, ...) // throws char * // Free the buffer. LocalFree( lpMsgBuf ); return strResultMessage; +#else + CTString retval = "This isn't Windows, so calling this function is probably a portability bug."; + return(retval); +#endif } // must be in separate function to disable stupid optimizer extern void Breakpoint(void) { +#if (defined USE_PORTABLE_C) + raise(SIGTRAP); // This may not work everywhere. Good luck. +#elif (defined __MSVC_INLINE__) __asm int 0x03; +#elif (defined __GNU_INLINE__) + __asm__ __volatile__ ("int $3\n\t"); +#else + #error Please define something for your platform. +#endif } + diff --git a/Sources/Engine/Base/FileName.cpp b/Sources/Engine/Base/FileName.cpp index 13cdef5..7004658 100644 --- a/Sources/Engine/Base/FileName.cpp +++ b/Sources/Engine/Base/FileName.cpp @@ -1,18 +1,105 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include +#include #include #include -template CDynamicArray; -template CDynamicStackArray; +template class CDynamicArray; +template class CDynamicStackArray; #include -template CStaticStackArray; +template class CStaticStackArray; + + +const char *CTFileName::convertFromWin32(const char *src) +{ +#if (defined PLATFORM_WIN32) + return(src); +#else + static const char *dirsep = NULL; + static size_t seplen = 0; + static char buf[MAX_PATH]; // This is NOT thread safe, fyi. + char *dest = buf; + + if (src == NULL) + { + buf[0] = '\0'; + return(buf); + } + + if (dirsep == NULL) + { + dirsep = CFileSystem::GetDirSeparator(); + seplen = strlen(dirsep); + } + + for (dest = buf; *src != '\0'; src++) + { + if (*src == '\\') + { + strcpy(dest, dirsep); + dest += seplen; + } + else + { + *(dest++) = *src; + } + } + + *dest = '\0'; + return(buf); +#endif +} + + +const char *CTFileName::convertToWin32(const char *src) +{ +#if (defined PLATFORM_WIN32) + return(src); +#else + static const char *dirsep = NULL; + static size_t seplen = 0; + static char buf[MAX_PATH]; // This is NOT thread safe, fyi. + char *dest = buf; + + if (src == NULL) + { + buf[0] = '\0'; + return(buf); + } + + if (dirsep == NULL) + { + dirsep = CFileSystem::GetDirSeparator(); + seplen = strlen(dirsep); + } + + for (dest = buf; *src != '\0'; src++) + { + if ((*src == *dirsep) && (strncmp(src, dirsep, seplen) == 0)) + { + *(dest++) = '\\'; + src += (seplen - 1); + } + else + { + *(dest++) = *src; + } + } + + *dest = '\0'; + return(buf); +#endif +} + + +#define USE_ABSTRACT_CTFILENAME 1 + /* * Get directory part of a filename. @@ -24,14 +111,32 @@ CTFileName CTFileName::FileDir() const // make a temporary copy of string CTFileName strPath(*this); // find last backlash in it - char *pPathBackSlash = strrchr( strPath.str_String, '\\'); + +#ifdef USE_ABSTRACT_CTFILENAME + const char *dirsep = CFileSystem::GetDirSeparator(); + char *pPathBackSlash = strstr( strPath.str_String, dirsep); // if there is no backslash if( pPathBackSlash == NULL) { // return emptystring as directory return( CTFileName("")); } + + for (char *p = pPathBackSlash; + (p = strstr(p + 1, dirsep)) != NULL; + pPathBackSlash = p) + { + // (*yawn*). + } + // set end of string after where the backslash was + pPathBackSlash[strlen(dirsep)] = 0; + +#else + + char *pPathBackSlash = strrchr( strPath.str_String, '\\'); pPathBackSlash[1] = 0; +#endif + // return a copy of temporary string return( CTFileName( strPath)); } @@ -51,23 +156,50 @@ CTFileName CTFileName::FileName() const // make a temporary copy of string CTFileName strPath(*this); + + // find last backlash in what's left +#ifdef USE_ABSTRACT_CTFILENAME + const char *dirsep = CFileSystem::GetDirSeparator(); + char *pBackSlash = strstr( strPath.str_String, dirsep); + // if there is no backslash + if( pBackSlash == NULL) { + // return it all as filename + pBackSlash = strPath.str_String; + } else { + for (char *p = pBackSlash; + (p = strstr(p + 1, dirsep)) != NULL; + pBackSlash = p) + { + // (*yawn*). + } + + pBackSlash += strlen(dirsep); + } + // find last dot in it - char *pDot = strrchr( strPath.str_String, '.'); + char *pDot = strrchr(pBackSlash, '.'); // if there is a dot if( pDot != NULL) { // set end of string there - pDot[0] = 0; + *pDot = '\0'; } - // find last backlash in what's left + // return a copy of temporary string, starting after the backslash + return( CTFileName( pBackSlash )); + +#else + char *pBackSlash = strrchr( strPath.str_String, '\\'); + // if there is no backslash if( pBackSlash == NULL) { // return it all as filename return( CTFileName(strPath)); } + // return a copy of temporary string, starting after the backslash return( CTFileName( pBackSlash+1)); +#endif } /* @@ -93,88 +225,22 @@ CTFileName CTFileName::NoExt() const return FileDir()+FileName(); } -static INDEX GetSlashPosition(const CHAR* pszString) -{ - for (INDEX iPos = 0; '\0' != *pszString; ++iPos, ++pszString) { - if (('\\' == *pszString) || ('/' == *pszString)) { - return iPos; - } - } - return -1; -} - /* - * Set path to the absolute path, taking \.. and /.. into account. + * Remove application path from a file name. */ -void CTFileName::SetAbsolutePath(void) +void CTFileName::RemoveApplicationPath_t(void) // throws char * { - // Collect path parts - CTString strRemaining(*this); - CStaticStackArray astrParts; - INDEX iSlashPos = GetSlashPosition(strRemaining); - if (0 > iSlashPos) { - return; // Invalid path - } - for (;;) { - CTString &strBeforeSlash = astrParts.Push(); - CTString strAfterSlash; - strRemaining.Split(iSlashPos, strBeforeSlash, strAfterSlash); - strAfterSlash.TrimLeft(strAfterSlash.Length() - 1); - strRemaining = strAfterSlash; - iSlashPos = GetSlashPosition(strRemaining); - if (0 > iSlashPos) { - astrParts.Push() = strRemaining; - break; - } - } - // Remove certain path parts - for (INDEX iPart = 0; iPart < astrParts.Count(); ++iPart) { - if (CTString("..") != astrParts[iPart]) { - continue; - } - if (0 == iPart) { - return; // Invalid path - } - // Remove ordered - CStaticStackArray astrShrinked; - astrShrinked.Push(astrParts.Count() - 2); - astrShrinked.PopAll(); - for (INDEX iCopiedPart = 0; iCopiedPart < astrParts.Count(); ++iCopiedPart) { - if ((iCopiedPart != iPart - 1) && (iCopiedPart != iPart)) { - astrShrinked.Push() = astrParts[iCopiedPart]; - } - } - astrParts.MoveArray(astrShrinked); - iPart -= 2; - } - // Set new content - strRemaining.Clear(); - for (INDEX iPart = 0; iPart < astrParts.Count(); ++iPart) { - strRemaining += astrParts[iPart]; - if (iPart < astrParts.Count() - 1) { -#ifdef PLATFORM_WIN32 - strRemaining += CTString("\\"); -#else - strRemaining += CTString("/"); -#endif - } - } - (*this) = strRemaining; -} - -/* - * Remove application path from a file name and returns TRUE if it's a relative path. - */ -BOOL CTFileName::RemoveApplicationPath_t(void) // throws char * -{ - CTFileName fnmApp = _fnmApplicationPath; - fnmApp.SetAbsolutePath(); // remove the path string from beginning of the string - BOOL bIsRelative = RemovePrefix(fnmApp); + BOOL bHadRightPath = RemovePrefix(_fnmApplicationPath); if (_fnmMod!="") { RemovePrefix(_fnmApplicationPath+_fnmMod); } - return bIsRelative; + // if it had wrong path + if (!bHadRightPath) { + // throw error + ThrowF_t(TRANS("File '%s' has got wrong path!\nAll files must reside in directory '%s'."), + str_String, (const char *) (CTString&)_fnmApplicationPath); + } } /* @@ -195,8 +261,16 @@ BOOL CTFileName::RemoveApplicationPath_t(void) // throws char * char strTag[] = "_FNM"; strTag[0] = 'D'; // must create tag at run-time! // skip dependency catcher header strmStream.ExpectID_t(strTag); // data filename + // read the string +#ifdef PLATFORM_WIN32 strmStream>>(CTString &)fnmFileName; +#else + CTString ctstr; + strmStream>>ctstr; + fnmFileName = CTString(CTFileName::convertFromWin32(ctstr)); // converts from win32 paths. +#endif + fnmFileName.fnm_pserPreloaded = NULL; } @@ -228,12 +302,24 @@ BOOL CTFileName::RemoveApplicationPath_t(void) // throws char * // write dependency catcher header strmStream.WriteID_t(strTag); // data filename // write the string +#ifdef PLATFORM_WIN32 strmStream<<(CTString &)fnmFileName; +#else + strmStream< + +// !!! FIXME: rcg10142001 This should really be using CTStrings... + +/* + * This class handles filesystem differences between platforms. + */ +class ENGINE_API CFileSystem { +public: + // Construct a system-dependent version of CFileSystem. + // (argv0) is argv[0] in your mainline. + // gamename is a simple token that identifies your game. + static CFileSystem *GetInstance(const char *argv0, const char *gamename); + + virtual ~CFileSystem(void) {} + + // Get the platform-specific directory separator. This could be + // "\\" on win32, "/" on unix, and ":" on MacOS Classic. + // Consider the returned pointer to be READ ONLY, as it points to a + // static, internal literal string on most platforms. + // Some platforms may define a dir separator that is MORE THAN ONE + // CHARACTER LONG. You have been warned. + static const char *GetDirSeparator(void); + + // Returns TRUE if (fname) is not a real file ("." and ".." on win32, etc.) + // THIS DOES NOT CHECK IF A SPECIFIC FILE EXISTS IN THE FILESYSTEM! + static BOOL IsDummyFile(const char *fname); + + // Returns TRUE if (fname) exists at all. May be a symlink, dir, file, etc. + static BOOL Exists(const char *fname); + + // Returns TRUE if (fname) is a directory. + static BOOL IsDirectory(const char *fname); + + // Get the path of the binary (.EXE file) being run. + // (buf) is where to store the info, and (bufSize) is the size, in bytes, + // of what's pointed to by (buf). The buffer is always promised to be + // null-terminated. + virtual void GetExecutablePath(char *buf, ULONG bufSize) = 0; + + // Get the user directory. This is the user's home directory on systems + // with that concept, and the base (buf) is where to store the info, and + // (bufSize) is the size, in bytes, of what's pointed to by (buf). The + // buffer is always promised to be null-terminated, and, if there's room, + // with have a trailing dir separator. It is likely that you will have + // write permission in the user directory tree, and will NOT have write + // permission in the base directory. You have been warned. + virtual void GetUserDirectory(char *buf, ULONG bufSize) = 0; + + // Get an array of CTStrings containing the names of files in (dir) that + // match (wildcard). + virtual CDynamicArray *FindFiles(const char *dir, + const char *wildcard) = 0; + +protected: + // use GetInstance(), instead. + CFileSystem() {} +}; + +ENGINE_API extern CFileSystem *_pFileSystem; + +#endif + +// end of FileSystem.h ... + + diff --git a/Sources/Engine/Base/IFeel.cpp b/Sources/Engine/Base/IFeel.cpp index a1e5fb7..c991e5c 100644 --- a/Sources/Engine/Base/IFeel.cpp +++ b/Sources/Engine/Base/IFeel.cpp @@ -1,14 +1,20 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include #include #include +#include + +// rcg12122001 Moved this over to the CDynamicLoader abstraction, even though +// this is somewhat win32-specific. Hey, you never know; maybe a Linux +// version will show up, so we might as well leave the IFeel interface +// in place... //Imm_GetProductName -HINSTANCE _hLib = NULL; +CDynamicLoader *_hLib = NULL; BOOL (*immCreateDevice)(HINSTANCE &hInstance, HWND &hWnd) = NULL; void (*immDeleteDevice)(void) = NULL; BOOL (*immProductName)(char *strProduct,int iMaxCount) = NULL; @@ -86,16 +92,16 @@ CTString IFeel_GetProjectFileName() if(strProduct == strDeviceName) return strProjectFile; } // device was not found, return default project file - CPrintF("No project file specified for device '%s'.\nUsing default project file\n",strProduct); + CPrintF("No project file specified for device '%s'.\nUsing default project file\n", (const char *) strProduct); return strDefaultProjectFile; } // inits imm ifeel device BOOL IFeel_InitDevice(HINSTANCE &hInstance, HWND &hWnd) { - _pShell->DeclareSymbol("void inp_IFeelGainChange(INDEX);", &ifeel_GainChange); - _pShell->DeclareSymbol("persistent user FLOAT inp_fIFeelGain post:inp_IFeelGainChange;", &ifeel_fGain); - _pShell->DeclareSymbol("const user INDEX sys_bIFeelEnabled;", &ifeel_bEnabled); + _pShell->DeclareSymbol("void inp_IFeelGainChange(INDEX);", (void *) &ifeel_GainChange); + _pShell->DeclareSymbol("persistent user FLOAT inp_fIFeelGain post:inp_IFeelGainChange;", (void *) &ifeel_fGain); + _pShell->DeclareSymbol("const user INDEX sys_bIFeelEnabled;", (void *) &ifeel_bEnabled); IFeel_ChangeGain(ifeel_fGain); // load iFeel lib @@ -103,24 +109,34 @@ BOOL IFeel_InitDevice(HINSTANCE &hInstance, HWND &hWnd) ExpandFilePath(EFP_READ | EFP_NOZIPS,(CTString)IFEEL_DLL_NAME,fnmExpanded); if(_hLib!=NULL) return FALSE; +#ifdef PLATFORM_WIN32 UINT iOldErrorMode = SetErrorMode( SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS); - _hLib = LoadLibraryA(fnmExpanded); +#endif + + _hLib = CDynamicLoader::GetInstance(fnmExpanded); + +#ifdef PLATFORM_WIN32 SetErrorMode(iOldErrorMode); - if(_hLib==NULL) +#endif + + const char *err = _hLib->GetError(); + if (err != NULL) { - CPrintF("Error loading ImmWraper.dll.\n\tIFeel disabled\n"); + CPrintF("Error loading ImmWraper.dll.\n\tIFeel disabled\nError: %s\n", err); + delete _hLib; + _hLib = NULL; return FALSE; } // take func pointers - immCreateDevice = (BOOL(*)(HINSTANCE &hInstance, HWND &hWnd)) GetProcAddress(_hLib,"Imm_CreateDevice"); - immDeleteDevice = (void(*)(void)) GetProcAddress(_hLib,"Imm_DeleteDevice"); - immProductName = (BOOL(*)(char *strProduct,int iMaxCount)) GetProcAddress(_hLib,"Imm_GetProductName"); - immLoadFile = (BOOL(*)(const char *fnFile))GetProcAddress(_hLib,"Imm_LoadFile"); - immUnloadFile = (void(*)(void))GetProcAddress(_hLib,"immUnloadFile"); - immPlayEffect = (void(*)(const char *pstrEffectName))GetProcAddress(_hLib,"Imm_PlayEffect"); - immStopEffect = (void(*)(const char *pstrEffectName))GetProcAddress(_hLib,"Imm_StopEffect"); - immChangeGain = (void(*)(const float fGain))GetProcAddress(_hLib,"Imm_ChangeGain"); + immCreateDevice = (BOOL(*)(HINSTANCE &hInstance, HWND &hWnd)) _hLib->FindSymbol("Imm_CreateDevice"); + immDeleteDevice = (void(*)(void)) _hLib->FindSymbol("Imm_DeleteDevice"); + immProductName = (BOOL(*)(char *strProduct,int iMaxCount)) _hLib->FindSymbol("Imm_GetProductName"); + immLoadFile = (BOOL(*)(const char *fnFile))_hLib->FindSymbol("Imm_LoadFile"); + immUnloadFile = (void(*)(void))_hLib->FindSymbol("immUnloadFile"); + immPlayEffect = (void(*)(const char *pstrEffectName))_hLib->FindSymbol("Imm_PlayEffect"); + immStopEffect = (void(*)(const char *pstrEffectName))_hLib->FindSymbol("Imm_StopEffect"); + immChangeGain = (void(*)(const float fGain))_hLib->FindSymbol("Imm_ChangeGain"); // create device if(immCreateDevice == NULL) @@ -151,7 +167,7 @@ void IFeel_DeleteDevice() immStopEffect = NULL; immChangeGain = NULL; - if(_hLib != NULL) FreeLibrary(_hLib); + if(_hLib != NULL) delete _hLib; _hLib = NULL; } // loads project file @@ -165,12 +181,12 @@ BOOL IFeel_LoadFile(CTFileName fnFile) BOOL hr = immLoadFile((const char*)fnmExpanded); if(hr) { - CPrintF("IFeel project file '%s' loaded\n", fnFile); + CPrintF("IFeel project file '%s' loaded\n", (const char *) fnFile); return TRUE; } else { - CPrintF("Error loading IFeel project file '%s'\n", fnFile); + CPrintF("Error loading IFeel project file '%s'\n", (const char *) fnFile); return FALSE; } } diff --git a/Sources/Engine/Base/Input.cpp b/Sources/Engine/Base/Input.cpp index 2e7597a..4454551 100644 --- a/Sources/Engine/Base/Input.cpp +++ b/Sources/Engine/Base/Input.cpp @@ -1,513 +1,29 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include #include #include -#include +#include #include #include #include -extern INDEX inp_iKeyboardReadingMethod; -extern FLOAT inp_fMouseSensitivity; -extern INDEX inp_bAllowMouseAcceleration; -extern INDEX inp_bMousePrecision; -extern FLOAT inp_fMousePrecisionFactor; -extern FLOAT inp_fMousePrecisionThreshold; -extern FLOAT inp_fMousePrecisionTimeout; -extern FLOAT inp_bInvertMouse; -extern INDEX inp_bFilterMouse; -extern INDEX inp_bAllowPrescan; +/* + * rcg10072001 + * The bulk of CInput's implementation is in the platform-specific subdirs. + * For example, if you want the win32 implementation, look in + * Engine\Base\win32\Win32Input.cpp ... + */ -extern INDEX inp_i2ndMousePort; -extern FLOAT inp_f2ndMouseSensitivity; -extern INDEX inp_b2ndMousePrecision; -extern FLOAT inp_f2ndMousePrecisionThreshold; -extern FLOAT inp_f2ndMousePrecisionTimeout; -extern FLOAT inp_f2ndMousePrecisionFactor; -extern INDEX inp_bFilter2ndMouse; -extern INDEX inp_bInvert2ndMouse; - -extern INDEX inp_iMButton4Dn = 0x20040; -extern INDEX inp_iMButton4Up = 0x20000; -extern INDEX inp_iMButton5Dn = 0x10020; -extern INDEX inp_iMButton5Up = 0x10000; -extern INDEX inp_bMsgDebugger = FALSE; -extern INDEX inp_bForceJoystickPolling = 0; -extern INDEX inp_ctJoysticksAllowed = 8; -extern INDEX inp_bAutoDisableJoysticks = 0; +INDEX inp_ctJoysticksAllowed = 8; static CTString inp_astrAxisTran[MAX_OVERALL_AXES];// translated names for axis -/* - -NOTE: Three different types of key codes are used here: - 1) kid - engine internal type - defined in KeyNames.h - 2) scancode - raw PC keyboard scancodes as returned in keydown/keyup messages - 3) virtkey - virtual key codes used by windows - -*/ - -// name that is not translated (international) -#define INTNAME(str) str, "" -// name that is translated -#define TRANAME(str) str, "ETRS" str - -// basic key conversion table -static struct KeyConversion { - INDEX kc_iKID; - INDEX kc_iVirtKey; - INDEX kc_iScanCode; - char *kc_strName; - char *kc_strNameTrans; -} _akcKeys[] = { - - // reserved for 'no-key-pressed' - { KID_NONE, -1, -1, TRANAME("None")}, - -// numbers row - { KID_1 , '1', 2, INTNAME("1")}, - { KID_2 , '2', 3, INTNAME("2")}, - { KID_3 , '3', 4, INTNAME("3")}, - { KID_4 , '4', 5, INTNAME("4")}, - { KID_5 , '5', 6, INTNAME("5")}, - { KID_6 , '6', 7, INTNAME("6")}, - { KID_7 , '7', 8, INTNAME("7")}, - { KID_8 , '8', 9, INTNAME("8")}, - { KID_9 , '9', 10, INTNAME("9")}, - { KID_0 , '0', 11, INTNAME("0")}, - { KID_MINUS , 189, 12, INTNAME("-")}, - { KID_EQUALS , 187, 13, INTNAME("=")}, - -// 1st alpha row - { KID_Q , 'Q', 16, INTNAME("Q")}, - { KID_W , 'W', 17, INTNAME("W")}, - { KID_E , 'E', 18, INTNAME("E")}, - { KID_R , 'R', 19, INTNAME("R")}, - { KID_T , 'T', 20, INTNAME("T")}, - { KID_Y , 'Y', 21, INTNAME("Y")}, - { KID_U , 'U', 22, INTNAME("U")}, - { KID_I , 'I', 23, INTNAME("I")}, - { KID_O , 'O', 24, INTNAME("O")}, - { KID_P , 'P', 25, INTNAME("P")}, - { KID_LBRACKET , 219, 26, INTNAME("[")}, - { KID_RBRACKET , 221, 27, INTNAME("]")}, - { KID_BACKSLASH , 220, 43, INTNAME("\\")}, - -// 2nd alpha row - { KID_A , 'A', 30, INTNAME("A")}, - { KID_S , 'S', 31, INTNAME("S")}, - { KID_D , 'D', 32, INTNAME("D")}, - { KID_F , 'F', 33, INTNAME("F")}, - { KID_G , 'G', 34, INTNAME("G")}, - { KID_H , 'H', 35, INTNAME("H")}, - { KID_J , 'J', 36, INTNAME("J")}, - { KID_K , 'K', 37, INTNAME("K")}, - { KID_L , 'L', 38, INTNAME("L")}, - { KID_SEMICOLON , 186, 39, INTNAME(";")}, - { KID_APOSTROPHE , 222, 40, INTNAME("'")}, -// 3rd alpha row - { KID_Z , 'Z', 44, INTNAME("Z")}, - { KID_X , 'X', 45, INTNAME("X")}, - { KID_C , 'C', 46, INTNAME("C")}, - { KID_V , 'V', 47, INTNAME("V")}, - { KID_B , 'B', 48, INTNAME("B")}, - { KID_N , 'N', 49, INTNAME("N")}, - { KID_M , 'M', 50, INTNAME("M")}, - { KID_COMMA , 190, 51, INTNAME(",")}, - { KID_PERIOD , 188, 52, INTNAME(".")}, - { KID_SLASH , 191, 53, INTNAME("/")}, - -// row with F-keys - { KID_F1 , VK_F1, 59, INTNAME("F1")}, - { KID_F2 , VK_F2, 60, INTNAME("F2")}, - { KID_F3 , VK_F3, 61, INTNAME("F3")}, - { KID_F4 , VK_F4, 62, INTNAME("F4")}, - { KID_F5 , VK_F5, 63, INTNAME("F5")}, - { KID_F6 , VK_F6, 64, INTNAME("F6")}, - { KID_F7 , VK_F7, 65, INTNAME("F7")}, - { KID_F8 , VK_F8, 66, INTNAME("F8")}, - { KID_F9 , VK_F9, 67, INTNAME("F9")}, - { KID_F10 , VK_F10, 68, INTNAME("F10")}, - { KID_F11 , VK_F11, 87, INTNAME("F11")}, - { KID_F12 , VK_F12, 88, INTNAME("F12")}, - -// extra keys - { KID_ESCAPE , VK_ESCAPE, 1, TRANAME("Escape")}, - { KID_TILDE , -1, 41, TRANAME("Tilde")}, - { KID_BACKSPACE , VK_BACK, 14, TRANAME("Backspace")}, - { KID_TAB , VK_TAB, 15, TRANAME("Tab")}, - { KID_CAPSLOCK , VK_CAPITAL, 58, TRANAME("Caps Lock")}, - { KID_ENTER , VK_RETURN, 28, TRANAME("Enter")}, - { KID_SPACE , VK_SPACE, 57, TRANAME("Space")}, - -// modifier keys - { KID_LSHIFT , VK_LSHIFT , 42, TRANAME("Left Shift")}, - { KID_RSHIFT , VK_RSHIFT , 54, TRANAME("Right Shift")}, - { KID_LCONTROL , VK_LCONTROL, 29, TRANAME("Left Control")}, - { KID_RCONTROL , VK_RCONTROL, 256+29, TRANAME("Right Control")}, - { KID_LALT , VK_LMENU , 56, TRANAME("Left Alt")}, - { KID_RALT , VK_RMENU , 256+56, TRANAME("Right Alt")}, - -// navigation keys - { KID_ARROWUP , VK_UP, 256+72, TRANAME("Arrow Up")}, - { KID_ARROWDOWN , VK_DOWN, 256+80, TRANAME("Arrow Down")}, - { KID_ARROWLEFT , VK_LEFT, 256+75, TRANAME("Arrow Left")}, - { KID_ARROWRIGHT , VK_RIGHT, 256+77, TRANAME("Arrow Right")}, - { KID_INSERT , VK_INSERT, 256+82, TRANAME("Insert")}, - { KID_DELETE , VK_DELETE, 256+83, TRANAME("Delete")}, - { KID_HOME , VK_HOME, 256+71, TRANAME("Home")}, - { KID_END , VK_END, 256+79, TRANAME("End")}, - { KID_PAGEUP , VK_PRIOR, 256+73, TRANAME("Page Up")}, - { KID_PAGEDOWN , VK_NEXT, 256+81, TRANAME("Page Down")}, - { KID_PRINTSCR , VK_SNAPSHOT, 256+55, TRANAME("Print Screen")}, - { KID_SCROLLLOCK , VK_SCROLL, 70, TRANAME("Scroll Lock")}, - { KID_PAUSE , VK_PAUSE, 69, TRANAME("Pause")}, - -// numpad numbers - { KID_NUM0 , VK_NUMPAD0, 82, INTNAME("Num 0")}, - { KID_NUM1 , VK_NUMPAD1, 79, INTNAME("Num 1")}, - { KID_NUM2 , VK_NUMPAD2, 80, INTNAME("Num 2")}, - { KID_NUM3 , VK_NUMPAD3, 81, INTNAME("Num 3")}, - { KID_NUM4 , VK_NUMPAD4, 75, INTNAME("Num 4")}, - { KID_NUM5 , VK_NUMPAD5, 76, INTNAME("Num 5")}, - { KID_NUM6 , VK_NUMPAD6, 77, INTNAME("Num 6")}, - { KID_NUM7 , VK_NUMPAD7, 71, INTNAME("Num 7")}, - { KID_NUM8 , VK_NUMPAD8, 72, INTNAME("Num 8")}, - { KID_NUM9 , VK_NUMPAD9, 73, INTNAME("Num 9")}, - { KID_NUMDECIMAL , VK_DECIMAL, 83, INTNAME("Num .")}, - -// numpad gray keys - { KID_NUMLOCK , VK_NUMLOCK, 256+69, INTNAME("Num Lock")}, - { KID_NUMSLASH , VK_DIVIDE, 256+53, INTNAME("Num /")}, - { KID_NUMMULTIPLY , VK_MULTIPLY, 55, INTNAME("Num *")}, - { KID_NUMMINUS , VK_SUBTRACT, 74, INTNAME("Num -")}, - { KID_NUMPLUS , VK_ADD, 78, INTNAME("Num +")}, - { KID_NUMENTER , VK_SEPARATOR, 256+28, TRANAME("Num Enter")}, - -// mouse buttons - { KID_MOUSE1 , VK_LBUTTON, -1, TRANAME("Mouse Button 1")}, - { KID_MOUSE2 , VK_RBUTTON, -1, TRANAME("Mouse Button 2")}, - { KID_MOUSE3 , VK_MBUTTON, -1, TRANAME("Mouse Button 3")}, - { KID_MOUSE4 , -1, -1, TRANAME("Mouse Button 4")}, - { KID_MOUSE5 , -1, -1, TRANAME("Mouse Button 5")}, - { KID_MOUSEWHEELUP , -1, -1, TRANAME("Mouse Wheel Up")}, - { KID_MOUSEWHEELDOWN , -1, -1, TRANAME("Mouse Wheel Down")}, - -// 2nd mouse buttons - { KID_2MOUSE1 , -1, -1, TRANAME("2nd Mouse Button 1")}, - { KID_2MOUSE2 , -1, -1, TRANAME("2nd Mouse Button 2")}, - { KID_2MOUSE3 , -1, -1, TRANAME("2nd Mouse Button 3")}, -}; - - -// autogenerated fast conversion tables -static INDEX _aiScanToKid[512]; -static INDEX _aiVirtToKid[256]; - -// make fast conversion tables from the general table -static void MakeConversionTables(void) -{ - // clear conversion tables - memset(_aiScanToKid, -1, sizeof(_aiScanToKid)); - memset(_aiVirtToKid, -1, sizeof(_aiVirtToKid)); - - // for each Key - for (INDEX iKey=0; iKey=0) { - _aiScanToKid[iScan] = iKID; - } - if (iVirt>=0) { - _aiVirtToKid[iVirt] = iKID; - } - } -} - -// variables for message interception -static HHOOK _hGetMsgHook = NULL; -static HHOOK _hSendMsgHook = NULL; -static int _iMouseZ = 0; -static BOOL _bWheelUp = FALSE; -static BOOL _bWheelDn = FALSE; - -CTCriticalSection csInput; - -// which keys are pressed, as recorded by message interception (by KIDs) -static UBYTE _abKeysPressed[256]; - -// set a key according to a keydown/keyup message -static void SetKeyFromMsg(MSG *pMsg, BOOL bDown) -{ - INDEX iKID = -1; - // if capturing scan codes - if (inp_iKeyboardReadingMethod==2) { - // get scan code - INDEX iScan = (pMsg->lParam>>16)&0x1FF; // (we use the extended bit too!) - // convert scan code to kid - iKID = _aiScanToKid[iScan]; - // if capturing virtual key codes - } else if (inp_iKeyboardReadingMethod==1) { - // get virtualkey - INDEX iVirt = (pMsg->wParam)&0xFF; - - if (iVirt == VK_SHIFT) { - iVirt = VK_LSHIFT; - } - if (iVirt == VK_CONTROL) { - iVirt = VK_LCONTROL; - } - if (iVirt == VK_MENU) { - iVirt = VK_LMENU; - } - // convert virtualkey to kid - iKID = _aiVirtToKid[iVirt]; - // if not capturing - } else { - // do nothing - return; - } - if (iKID>=0 && iKIDinp_strButtonNames[iKID], bDown); - _abKeysPressed[iKID] = bDown; - } -} - -static void CheckMessage(MSG *pMsg) -{ - if ( pMsg->message == WM_LBUTTONUP) { - _abKeysPressed[KID_MOUSE1] = FALSE; - } else if ( pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONDBLCLK) { - _abKeysPressed[KID_MOUSE1] = TRUE; - } else if ( pMsg->message == WM_RBUTTONUP) { - _abKeysPressed[KID_MOUSE2] = FALSE; - } else if ( pMsg->message == WM_RBUTTONDOWN || pMsg->message == WM_RBUTTONDBLCLK) { - _abKeysPressed[KID_MOUSE2] = TRUE; - } else if ( pMsg->message == WM_MBUTTONUP) { - _abKeysPressed[KID_MOUSE3] = FALSE; - } else if ( pMsg->message == WM_MBUTTONDOWN || pMsg->message == WM_MBUTTONDBLCLK) { - _abKeysPressed[KID_MOUSE3] = TRUE; - - } else if ( pMsg->message == inp_iMButton4Dn) { - _abKeysPressed[KID_MOUSE4] = TRUE; - } else if ( pMsg->message == inp_iMButton4Up) { - _abKeysPressed[KID_MOUSE4] = FALSE; - - } else if ( pMsg->message == inp_iMButton5Dn) { - _abKeysPressed[KID_MOUSE5] = TRUE; - } else if ( pMsg->message == inp_iMButton5Up) { - _abKeysPressed[KID_MOUSE5] = FALSE; - - } else if (pMsg->message==WM_KEYUP || pMsg->message==WM_SYSKEYUP) { - SetKeyFromMsg(pMsg, FALSE); - } else if (pMsg->message==WM_KEYDOWN || pMsg->message==WM_SYSKEYDOWN) { - SetKeyFromMsg(pMsg, TRUE); - } else if (inp_bMsgDebugger && pMsg->message >= 0x10000) { - CPrintF("%08x(%d)\n", pMsg->message, pMsg->message); - } -} - - -// procedure called when message is retreived -LRESULT CALLBACK GetMsgProc( - int nCode, // hook code - WPARAM wParam, // message identifier - LPARAM lParam) // mouse coordinates -{ - MSG *pMsg = (MSG*)lParam; - CheckMessage(pMsg); - - LRESULT retValue = 0; - retValue = CallNextHookEx( _hGetMsgHook, nCode, wParam, lParam ); - -#ifndef WM_MOUSEWHEEL - #define WM_MOUSEWHEEL 0x020A -#endif - - if (wParam == PM_NOREMOVE) { - return retValue; - } - - if ( pMsg->message == WM_MOUSEWHEEL) { - _iMouseZ += SWORD(UWORD(HIWORD(pMsg->wParam))); - } - - return retValue; -} - - -// procedure called when message is sent -LRESULT CALLBACK SendMsgProc( - int nCode, // hook code - WPARAM wParam, // message identifier - LPARAM lParam) // mouse coordinates -{ - MSG *pMsg = (MSG*)lParam; - CheckMessage(pMsg); - - LRESULT retValue = 0; - retValue = CallNextHookEx( _hSendMsgHook, nCode, wParam, lParam ); - - return retValue; -} - - - -// --------- 2ND MOUSE HANDLING - -#define MOUSECOMBUFFERSIZE 256L -static HANDLE _h2ndMouse = NONE; -static BOOL _bIgnoreMouse2 = TRUE; -static INDEX _i2ndMouseX, _i2ndMouseY, _i2ndMouseButtons; -static INDEX _iByteNum = 0; -static UBYTE _aubComBytes[4] = {0,0,0,0}; -static INDEX _iLastPort = -1; - - - -static void Poll2ndMouse(void) -{ - // reset (mouse reading is relative) - _i2ndMouseX = 0; - _i2ndMouseY = 0; - if( _h2ndMouse==NONE) return; - - // check - COMSTAT csComStat; - DWORD dwErrorFlags; - ClearCommError( _h2ndMouse, &dwErrorFlags, &csComStat); - DWORD dwLength = Min( MOUSECOMBUFFERSIZE, (INDEX)csComStat.cbInQue); - if( dwLength<=0) return; - - // readout - UBYTE aubMouseBuffer[MOUSECOMBUFFERSIZE]; - INDEX iRetries = 999; - while( iRetries>0 && !ReadFile( _h2ndMouse, aubMouseBuffer, dwLength, &dwLength, NULL)) iRetries--; - if( iRetries<=0) return; // what, didn't make it? - - // parse the mouse packets - for( INDEX i=0; i>4; - } - // axes ? - else if( _iByteNum==3) { - char iDX = ((_aubComBytes[0] & 3) <<6) + _aubComBytes[1]; - char iDY = ((_aubComBytes[0] & 12) <<4) + _aubComBytes[2]; - _i2ndMouseX += iDX; - _i2ndMouseY += iDY; - } - // 3rd button? - else if( _iByteNum==4) { - _i2ndMouseButtons &= ~4; - if( aubMouseBuffer[i]&32) _i2ndMouseButtons |= 4; - } - } - - // ignore pooling? - if( _bIgnoreMouse2) { - if( _i2ndMouseX!=0 || _i2ndMouseY!=0) _bIgnoreMouse2 = FALSE; - _i2ndMouseX = 0; - _i2ndMouseY = 0; - _i2ndMouseButtons = 0; - return; - } -} - - -static void Startup2ndMouse(INDEX iPort) -{ - // skip if disabled - ASSERT( iPort>=0 && iPort<=4); - if( iPort==0) return; - // determine port string - CTString str2ndMousePort( 0, "COM%d", iPort); - - // create COM handle if needed - if( _h2ndMouse==NONE) { - _h2ndMouse = CreateFileA( str2ndMousePort, GENERIC_READ|GENERIC_WRITE, 0, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if( _h2ndMouse==INVALID_HANDLE_VALUE) { - // failed! :( - INDEX iError = GetLastError(); -/* - if( iError==5) CPrintF( "Cannot open %s (access denied).\n" - "The port is probably already used by another device (mouse, modem...)\n", - str2ndMousePort); - else CPrintF( "Cannot open %s (error %d).\n", str2ndMousePort, iError); - */ - _h2ndMouse = NONE; - return; - } - } - // setup and purge buffers - SetupComm( _h2ndMouse, MOUSECOMBUFFERSIZE, MOUSECOMBUFFERSIZE); - PurgeComm( _h2ndMouse, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR); - - // setup port to 1200 7N1 - DCB dcb; - dcb.DCBlength = sizeof(DCB); - GetCommState( _h2ndMouse, &dcb); - dcb.BaudRate = CBR_1200; - dcb.ByteSize = 7; - dcb.Parity = NOPARITY; - dcb.StopBits = ONESTOPBIT; - dcb.fDtrControl = DTR_CONTROL_ENABLE; - dcb.fRtsControl = RTS_CONTROL_ENABLE; - dcb.fBinary = TRUE; - dcb.fParity = TRUE; - SetCommState( _h2ndMouse, &dcb); - - // reset - _iByteNum = 0; - _aubComBytes[0] = _aubComBytes[1] = _aubComBytes[2] = _aubComBytes[3] = 0; - _bIgnoreMouse2 = TRUE; // ignore mouse polling until 1 after non-0 readout - _iLastPort = iPort; - //CPrintF( "STARTUP M2!\n"); -} - - -static void Shutdown2ndMouse(void) -{ - // skip if already disabled - if( _h2ndMouse==NONE) return; - - // disable! - SetCommMask( _h2ndMouse, 0); - EscapeCommFunction( _h2ndMouse, CLRDTR); - EscapeCommFunction( _h2ndMouse, CLRRTS); - PurgeComm( _h2ndMouse, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR); - // close port if changed - if( _iLastPort != inp_i2ndMousePort) { - CloseHandle( _h2ndMouse); - _h2ndMouse = NONE; - } // over and out - _bIgnoreMouse2 = TRUE; -} - - - - // pointer to global input object CInput *_pInput = NULL; @@ -530,15 +46,7 @@ CInput::CInput(void) inp_caiAllAxisInfo[ iAxis].cai_bExisting = FALSE; } - MakeConversionTables(); -} - - -// destructor -CInput::~CInput() -{ - if( _h2ndMouse!=NONE) CloseHandle( _h2ndMouse); - _h2ndMouse = NONE; + PlatformInit(); } @@ -553,24 +61,12 @@ void CInput::SetJoyPolling(BOOL bPoll) void CInput::SetKeyNames( void) { // set name "None" for all keys, known keys will override this default name - {for( INDEX iKey=0; iKey= 0); - // save system mouse settings - SystemParametersInfo(SPI_GETMOUSE, 0, &inp_mscMouseSettings, 0); - // set new mouse speed - if (!inp_bAllowMouseAcceleration) { - MouseSpeedControl mscNewSetting = { 0, 0, 0}; - SystemParametersInfo(SPI_SETMOUSE, 0, &mscNewSetting, 0); - } - // set cursor position to screen center - SetCursorPos(inp_slScreenCenterX, inp_slScreenCenterY); - - _hGetMsgHook = SetWindowsHookEx(WH_GETMESSAGE, &GetMsgProc, NULL, GetCurrentThreadId()); - _hSendMsgHook = SetWindowsHookEx(WH_CALLWNDPROC, &SendMsgProc, NULL, GetCurrentThreadId()); - - // if required, try to enable 2nd mouse - Shutdown2ndMouse(); - inp_i2ndMousePort = Clamp( inp_i2ndMousePort, 0L, 4L); - Startup2ndMouse(inp_i2ndMousePort); - - // clear button's buffer - memset( _abKeysPressed, 0, sizeof( _abKeysPressed)); - - // This can be enabled to pre-read the state of currently pressed keys - // for snooping methods, since they only detect transitions. - // That has effect of detecting key presses for keys that were held down before - // enabling. - // the entire thing is disabled because it caused last menu key to re-apply in game. -#if 0 - // for each Key - {for (INDEX iKey=0; iKey=0) { - // transcribe if modifier - if (iVirt == VK_LSHIFT) { - iVirt = VK_SHIFT; - } - if (iVirt == VK_LCONTROL) { - iVirt = VK_CONTROL; - } - if (iVirt == VK_LMENU) { - iVirt = VK_MENU; - } - // is state is pressed - if (GetAsyncKeyState(iVirt)&0x8000) { - // mark it as pressed - _abKeysPressed[iKID] = 0xFF; - } - } - }} -#endif - - // remember current status - inp_bInputEnabled = TRUE; - inp_bPollJoysticks = FALSE; -} - - -/* - * Disable direct input - */ -void CInput::DisableInput( void) -{ - // skip if allready disabled - if( !inp_bInputEnabled) return; - - UnhookWindowsHookEx(_hGetMsgHook); - UnhookWindowsHookEx(_hSendMsgHook); - - // set mouse clip region to entire screen - ClipCursor(NULL); - // restore mouse pos - SetCursorPos( inp_ptOldMousePos.x, inp_ptOldMousePos.y); - - // show mouse on screen - while (ShowCursor(TRUE) < 0); - // set system mouse settings - SystemParametersInfo(SPI_SETMOUSE, 0, &inp_mscMouseSettings, 0); - - // eventually disable 2nd mouse - Shutdown2ndMouse(); - - // remember current status - inp_bInputEnabled = FALSE; - inp_bPollJoysticks = FALSE; -} - - -/* - * Scan states of all available input sources - */ -void CInput::GetInput(BOOL bPreScan) -{ -// CTSingleLock sl(&csInput, TRUE); - - if (!inp_bInputEnabled) { - return; - } - - if (bPreScan && !inp_bAllowPrescan) { - return; - } - - // if not pre-scanning - if (!bPreScan) { - // clear button's buffer - memset( inp_ubButtonsBuffer, 0, sizeof( inp_ubButtonsBuffer)); - - // for each Key - {for (INDEX iKey=0; iKey=0) { - // transcribe if modifier - if (iVirt == VK_LSHIFT) { - iVirt = VK_SHIFT; - } - if (iVirt == VK_LCONTROL) { - iVirt = VK_CONTROL; - } - if (iVirt == VK_LMENU) { - iVirt = VK_MENU; - } - // is state is pressed - if (GetAsyncKeyState(iVirt)&0x8000) { - // mark it as pressed - inp_ubButtonsBuffer[iKID] = 0xFF; - } - } - - // if snooping messages - } else { - // if snooped that key is pressed - if (_abKeysPressed[iKID]) { - // mark it as pressed - inp_ubButtonsBuffer[iKID] = 0xFF; - } - } - }} - } - - // read mouse position - POINT pntMouse; - if( GetCursorPos( &pntMouse)) - { - FLOAT fDX = FLOAT( SLONG(pntMouse.x) - inp_slScreenCenterX); - FLOAT fDY = FLOAT( SLONG(pntMouse.y) - inp_slScreenCenterY); - - FLOAT fSensitivity = inp_fMouseSensitivity; - if( inp_bAllowMouseAcceleration) fSensitivity *= 0.25f; - - FLOAT fD = Sqrt(fDX*fDX+fDY*fDY); - if (inp_bMousePrecision) { - static FLOAT _tmTime = 0.0f; - if( fDinp_fMousePrecisionTimeout) fSensitivity /= inp_fMousePrecisionFactor; - } - - static FLOAT fDXOld; - static FLOAT fDYOld; - static TIME tmOldDelta; - static CTimerValue tvBefore; - CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); - TIME tmNowDelta = (tvNow-tvBefore).GetSeconds(); - if (tmNowDelta<0.001f) { - tmNowDelta = 0.001f; - } - tvBefore = tvNow; - - FLOAT fDXSmooth = (fDXOld*tmOldDelta+fDX*tmNowDelta)/(tmOldDelta+tmNowDelta); - FLOAT fDYSmooth = (fDYOld*tmOldDelta+fDY*tmNowDelta)/(tmOldDelta+tmNowDelta); - fDXOld = fDX; - fDYOld = fDY; - tmOldDelta = tmNowDelta; - if (inp_bFilterMouse) { - fDX = fDXSmooth; - fDY = fDYSmooth; - } - - // get final mouse values - FLOAT fMouseRelX = +fDX*fSensitivity; - FLOAT fMouseRelY = -fDY*fSensitivity; - if (inp_bInvertMouse) { - fMouseRelY = -fMouseRelY; - } - FLOAT fMouseRelZ = _iMouseZ; - - // just interpret values as normal - inp_caiAllAxisInfo[1].cai_fReading = fMouseRelX; - inp_caiAllAxisInfo[2].cai_fReading = fMouseRelY; - inp_caiAllAxisInfo[3].cai_fReading = fMouseRelZ; - - // if not pre-scanning - if (!bPreScan) { - // detect wheel up/down movement - _bWheelDn = FALSE; - if (_iMouseZ>0) { - if (_bWheelUp) { - inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0x00; - } else { - inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0xFF; - _iMouseZ = ClampDn(_iMouseZ-120, 0); - } - } - _bWheelUp = inp_ubButtonsBuffer[KID_MOUSEWHEELUP]; - if (_iMouseZ<0) { - if (_bWheelDn) { - inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0x00; - } else { - inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0xFF; - _iMouseZ = ClampUp(_iMouseZ+120, 0); - } - } - _bWheelDn = inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN]; - } - } - inp_bLastPrescan = bPreScan; - - // set cursor position to screen center - if (pntMouse.x!=inp_slScreenCenterX || pntMouse.y!=inp_slScreenCenterY) { - SetCursorPos(inp_slScreenCenterX, inp_slScreenCenterY); - } - - // readout 2nd mouse if enabled - if( _h2ndMouse!=NONE) - { - Poll2ndMouse(); - //CPrintF( "m2X: %4d, m2Y: %4d, m2B: 0x%02X\n", _i2ndMouseX, _i2ndMouseY, _i2ndMouseButtons); - - // handle 2nd mouse buttons - if( _i2ndMouseButtons & 2) inp_ubButtonsBuffer[KID_2MOUSE1] = 0xFF; - if( _i2ndMouseButtons & 1) inp_ubButtonsBuffer[KID_2MOUSE2] = 0xFF; - if( _i2ndMouseButtons & 4) inp_ubButtonsBuffer[KID_2MOUSE3] = 0xFF; - - // handle 2nd mouse movement - FLOAT fDX = _i2ndMouseX; - FLOAT fDY = _i2ndMouseY; - FLOAT fSensitivity = inp_f2ndMouseSensitivity; - - FLOAT fD = Sqrt(fDX*fDX+fDY*fDY); - if( inp_b2ndMousePrecision) { - static FLOAT _tm2Time = 0.0f; - if( fDinp_f2ndMousePrecisionTimeout) fSensitivity /= inp_f2ndMousePrecisionFactor; - } - - static FLOAT f2DXOld; - static FLOAT f2DYOld; - static TIME tm2OldDelta; - static CTimerValue tv2Before; - CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); - TIME tmNowDelta = (tvNow-tv2Before).GetSeconds(); - if( tmNowDelta<0.001f) tmNowDelta = 0.001f; - tv2Before = tvNow; - - FLOAT fDXSmooth = (f2DXOld*tm2OldDelta+fDX*tmNowDelta) / (tm2OldDelta+tmNowDelta); - FLOAT fDYSmooth = (f2DYOld*tm2OldDelta+fDY*tmNowDelta) / (tm2OldDelta+tmNowDelta); - f2DXOld = fDX; - f2DYOld = fDY; - tm2OldDelta = tmNowDelta; - if( inp_bFilter2ndMouse) { - fDX = fDXSmooth; - fDY = fDYSmooth; - } - - // get final mouse values - FLOAT fMouseRelX = +fDX*fSensitivity; - FLOAT fMouseRelY = -fDY*fSensitivity; - if( inp_bInvert2ndMouse) fMouseRelY = -fMouseRelY; - - // just interpret values as normal - inp_caiAllAxisInfo[4].cai_fReading = fMouseRelX; - inp_caiAllAxisInfo[5].cai_fReading = fMouseRelY; - } - - - // if joystick polling is enabled - if (inp_bPollJoysticks || inp_bForceJoystickPolling) { - // scan all available joysticks - for( INDEX iJoy=0; iJoy diff --git a/Sources/Engine/Base/Memory.cpp b/Sources/Engine/Base/Memory.cpp index cbb0678..8dc4d7e 100644 --- a/Sources/Engine/Base/Memory.cpp +++ b/Sources/Engine/Base/Memory.cpp @@ -1,15 +1,22 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include + +/* rcg10282005 "new.h" is deprecated in newer C++ standards... --ryan. */ +#ifdef _MSC_VER #include +#else +#include +#endif -extern FLOAT _bCheckAllAllocations = FALSE; +FLOAT _bCheckAllAllocations = FALSE; +#ifdef PLATFORM_WIN32 /* * Declarations for setting up the 'new_handler'. */ @@ -31,14 +38,25 @@ _CRTIMP _PNH __cdecl _set_new_handler( _PNH );*/ // include user32 library (because of message box) #pragma comment (lib, "user32.lib") +#endif + // if not enough memory +#ifdef _MSC_VER int NewHandler(size_t size) { // terminate program FatalError(TRANS("Not enough memory (%d bytes needed)!"), size); return 0; } +#else +void NewHandler(void) +{ + // terminate program + FatalError(TRANS("Not enough memory!")); +} +#define _CrtCheckMemory() +#endif /* Static class used for initializing memory handlers. */ static class CMemHandlerInit { @@ -52,7 +70,9 @@ CMemHandlerInit::CMemHandlerInit(void) // set our not-enough-memory handler _set_new_handler(NewHandler); // make malloc use that handler + #ifdef _MSC_VER _set_new_mode(1); + #endif } #undef AllocMemory @@ -73,6 +93,7 @@ void *AllocMemory( SLONG memsize ) return pmem; } +#ifdef _MSC_VER #ifndef NDEBUG void *_debug_AllocMemory( SLONG memsize, int iType, const char *strFile, int iLine) { @@ -91,6 +112,7 @@ void *_debug_AllocMemory( SLONG memsize, int iType, const char *strFile, int iLi return pmem; } #endif +#endif void *AllocMemoryAligned( SLONG memsize, SLONG slAlignPow2) { diff --git a/Sources/Engine/Base/NullSynchronization.cpp b/Sources/Engine/Base/NullSynchronization.cpp new file mode 100644 index 0000000..5c68c04 --- /dev/null +++ b/Sources/Engine/Base/NullSynchronization.cpp @@ -0,0 +1,21 @@ +#include "Engine/StdH.h" +#include + +#if (!defined SINGLE_THREADED) +#error you probably want to define SINGLE_THREADED if you compile this. +#endif + +CTCriticalSection::CTCriticalSection(void) {} +CTCriticalSection::~CTCriticalSection(void) {} +INDEX CTCriticalSection::Lock(void) { return(1); } +INDEX CTCriticalSection::TryToLock(void) { return(1); } +INDEX CTCriticalSection::Unlock(void) { return(0); } +CTSingleLock::CTSingleLock(CTCriticalSection *pcs, BOOL bLock) : sl_cs(*pcs) {} +CTSingleLock::~CTSingleLock(void) {} +void CTSingleLock::Lock(void) {} +BOOL CTSingleLock::TryToLock(void) { return(TRUE); } +BOOL CTSingleLock::IsLocked(void) { return(TRUE); } +void CTSingleLock::Unlock(void) {} + +// end of NullSynchronization.cpp ... + diff --git a/Sources/Engine/Base/Parser.y b/Sources/Engine/Base/Parser.y index 1138ac4..f15ee68 100644 --- a/Sources/Engine/Base/Parser.y +++ b/Sources/Engine/Base/Parser.y @@ -1,5 +1,5 @@ %{ -#include "StdH.h" +#include #include #include @@ -11,6 +11,11 @@ %} %{ +// turn off over-helpful bit of bison... --ryan. +#ifdef __GNUC__ +#define __attribute__(x) +#endif + #define YYERROR_VERBOSE 1 // if error occurs in parsing void yyerror(char *str) @@ -95,7 +100,7 @@ void Declaration( if (!ShellTypeIsSame(ssNew.ss_istType, istType) || ((ssNew.ss_ulFlags&SSF_CONSTANT)!=(ulQualifiers&SSF_CONSTANT))) { // error - _pShell->ErrorF("Symbol '%s' is already declared diferrently", ssNew.ss_strName); + _pShell->ErrorF("Symbol '%s' is already declared diferrently", (const char *) ssNew.ss_strName); return; } @@ -112,7 +117,7 @@ void Declaration( NOTHING; // function values are not retained } else { // error - _pShell->ErrorF("'%s': old value couldn't be retained", ssNew.ss_strName); + _pShell->ErrorF("'%s': old value couldn't be retained", (const char *) ssNew.ss_strName); return; } } @@ -331,7 +336,7 @@ pre_func_opt ||_shell_ast[_shell_ast[$3->ss_istType].st_istBaseType].st_sttType!=STT_INDEX ||_shell_ast[$3->ss_istType].st_istFirstArgument!=_shell_ast[$3->ss_istType].st_istLastArgument ||_shell_ast[_shell_ast[$3->ss_istType].st_istFirstArgument].st_sttType!=STT_INDEX) { - _pShell->ErrorF("'%s' must return 'INDEX' and take 'INDEX' as input", $3->ss_strName); + _pShell->ErrorF("'%s' must return 'INDEX' and take 'INDEX' as input", (const char *) $3->ss_strName); } else { void *pv = $3->ss_pvValue; $$ = (INDEX(*)(INDEX))$3->ss_pvValue; @@ -347,7 +352,7 @@ post_func_opt ||_shell_ast[_shell_ast[$3->ss_istType].st_istBaseType].st_sttType!=STT_VOID ||_shell_ast[$3->ss_istType].st_istFirstArgument!=_shell_ast[$3->ss_istType].st_istLastArgument ||_shell_ast[_shell_ast[$3->ss_istType].st_istFirstArgument].st_sttType!=STT_INDEX) { - _pShell->ErrorF("'%s' must return 'void' and take 'INDEX' as input", $3->ss_strName); + _pShell->ErrorF("'%s' must return 'void' and take 'INDEX' as input", (const char *) $3->ss_strName); } else { $$ = (void(*)(INDEX))$3->ss_pvValue; } @@ -430,7 +435,7 @@ statement | lvalue '=' expression ';' { // if it is constant if ($1.lv_pssSymbol->ss_ulFlags&SSF_CONSTANT) { - _pShell->ErrorF("Symbol '%s' is a constant", $1.lv_pssSymbol->ss_strName); + _pShell->ErrorF("Symbol '%s' is a constant", (const char *) $1.lv_pssSymbol->ss_strName); // if it is not constant } else { // if it can be changed @@ -473,7 +478,7 @@ statement // if it is constant if (ssSymbol.ss_ulFlags&SSF_CONSTANT) { // error - _pShell->ErrorF("Symbol '%s' is a constant", ssSymbol.ss_strName); + _pShell->ErrorF("Symbol '%s' is a constant", (const char *) ssSymbol.ss_strName); } // get symbol type @@ -496,7 +501,7 @@ statement _pShell->ErrorF("Warning: assigning INDEX to FLOAT!"); *(FLOAT*)ssSymbol.ss_pvValue = $5.iIndex; } else { - _pShell->ErrorF("Symbol '%s' and its initializer have different types", ssSymbol.ss_strName); + _pShell->ErrorF("Symbol '%s' and its initializer have different types", (const char *) ssSymbol.ss_strName); } } | k_help identifier { @@ -566,7 +571,7 @@ lvalue $$.lv_pssSymbol = &ssSymbol; if (!ssSymbol.IsDeclared()) { // error - _pShell->ErrorF("Identifier '%s' is not declared", $1->ss_strName); + _pShell->ErrorF("Identifier '%s' is not declared", (const char *) $1->ss_strName); fDummy = -666; $$.lv_sttType = STT_VOID; $$.lv_pvAddress = &fDummy; @@ -578,7 +583,7 @@ lvalue // if the identifier is something else } else { // error - _pShell->ErrorF("'%s' doesn't have a value", $1->ss_strName); + _pShell->ErrorF("'%s' doesn't have a value", (const char *) $1->ss_strName); fDummy = -666.0f; $$.lv_sttType = STT_VOID; $$.lv_pvAddress = &fDummy; @@ -616,7 +621,7 @@ lvalue } } } else { - _pShell->ErrorF("'%s[]' doesn't have a value", $1->ss_strName); + _pShell->ErrorF("'%s[]' doesn't have a value", (const char *) $1->ss_strName); fDummy = -666.0f; $$.lv_pvAddress = &fDummy; } @@ -673,7 +678,7 @@ expression } else { $$.sttType = STT_FLOAT; $$.fFloat = -666.0f; - _pShell->ErrorF("'%s' is of wrong type", $1.lv_pssSymbol->ss_strName); + _pShell->ErrorF("'%s' is of wrong type", (const char *) $1.lv_pssSymbol->ss_strName); } } /* shift */ @@ -975,7 +980,7 @@ expression // if the identifier is not declared if (!$1->IsDeclared()) { // error - _pShell->ErrorF("Identifier '%s' is not declared", $1->ss_strName); + _pShell->ErrorF("Identifier '%s' is not declared", (const char *) $1->ss_strName); // if the identifier is declared } else { // get its type @@ -989,52 +994,76 @@ expression _shell_ast[_shell_ast[$3.istType].st_istBaseType].st_sttType = stResult.st_sttType; // if types are same if (ShellTypeIsSame($3.istType, $1->ss_istType)) { + bool callfunc = true; -#define PUSHPARAMS \ - memcpy(_alloca($3.ctBytes), _ubStack+_iStack-$3.ctBytes, $3.ctBytes); - - // if void - if (stResult.st_sttType==STT_VOID) { - // just call the function - $$.sttType = STT_VOID; - //PUSHPARAMS; - ((void (*)(void*))$1->ss_pvValue)(_ubStack+_iStack-$3.ctBytes); - // if index - } else if (stResult.st_sttType==STT_INDEX) { - // call the function and return result - $$.sttType = STT_INDEX; - PUSHPARAMS; - $$.iIndex = ((INDEX (*)(void))$1->ss_pvValue)(); - // if float - } else if (stResult.st_sttType==STT_FLOAT) { - // call the function and return result - $$.sttType = STT_FLOAT; - PUSHPARAMS; - $$.fFloat = ((FLOAT (*)(void))$1->ss_pvValue)(); - // if string - } else if (stResult.st_sttType==STT_STRING) { - // call the function and return result - $$.sttType = STT_STRING; - CTString &strNew = _shell_astrTempStrings.Push(); - PUSHPARAMS; - strNew = ((CTString (*)(void))$1->ss_pvValue)(); - $$.strString = (const char*)strNew; - } else { - ASSERT(FALSE); - $$.sttType = STT_FLOAT; - $$.fFloat = -666.0f; +// !!! FIXME: maybe just dump the win32 codepath here? This will break on Win64, and maybe break on different compilers/compiler versions, etc. +#ifdef PLATFORM_WIN32 + #define CALLPARAMS + #define FUNCSIG void + #define PUSHPARAMS memcpy(_alloca($3.ctBytes), _ubStack+_iStack-$3.ctBytes, $3.ctBytes); +#else + // This is possibly more portable, but no less scary than the alloca hack. + #define MAXSCRIPTFUNCARGS 5 + void *ARG[MAXSCRIPTFUNCARGS]; + if (($3.ctBytes > sizeof (ARG))) + { + _pShell->ErrorF("Function '%s' has too many arguments!", (const char *) $1->ss_strName); + callfunc = false; + } + else + { + memcpy(ARG, _ubStack+_iStack-$3.ctBytes, $3.ctBytes); + memset(((char *) ARG) + $3.ctBytes, '\0', sizeof (ARG) - $3.ctBytes); + } + #define PUSHPARAMS + #define FUNCSIG void*, void*, void*, void*, void* + #define CALLPARAMS ARG[0], ARG[1], ARG[2], ARG[3], ARG[4] +#endif + + if (callfunc) { + // if void + if (stResult.st_sttType==STT_VOID) { + // just call the function + $$.sttType = STT_VOID; + PUSHPARAMS; + ((void (*)(FUNCSIG))$1->ss_pvValue)(CALLPARAMS); + // if index + } else if (stResult.st_sttType==STT_INDEX) { + // call the function and return result + $$.sttType = STT_INDEX; + PUSHPARAMS; + $$.iIndex = ((INDEX (*)(FUNCSIG))$1->ss_pvValue)(CALLPARAMS); + // if float + } else if (stResult.st_sttType==STT_FLOAT) { + // call the function and return result + $$.sttType = STT_FLOAT; + PUSHPARAMS; + $$.fFloat = ((FLOAT (*)(FUNCSIG))$1->ss_pvValue)(CALLPARAMS); + // if string + } else if (stResult.st_sttType==STT_STRING) { + // call the function and return result + $$.sttType = STT_STRING; + CTString &strNew = _shell_astrTempStrings.Push(); + PUSHPARAMS; + strNew = ((CTString (*)(FUNCSIG))$1->ss_pvValue)(CALLPARAMS); + $$.strString = (const char*)strNew; + } else { + ASSERT(FALSE); + $$.sttType = STT_FLOAT; + $$.fFloat = -666.0f; + } } // if types are different } else { // error $$.sttType = STT_VOID; - _pShell->ErrorF("Wrong parameters for '%s'", $1->ss_strName); + _pShell->ErrorF("Wrong parameters for '%s'", (const char *) $1->ss_strName); } // if the identifier is something else } else { // error $$.sttType = STT_VOID; - _pShell->ErrorF("Can't call '%s'", $1->ss_strName); + _pShell->ErrorF("Can't call '%s'", (const char *) $1->ss_strName); } } diff --git a/Sources/Engine/Base/ParsingSymbols.h b/Sources/Engine/Base/ParsingSymbols.h index f9ec8a2..341248e 100644 --- a/Sources/Engine/Base/ParsingSymbols.h +++ b/Sources/Engine/Base/ParsingSymbols.h @@ -4,7 +4,14 @@ #include // needed for parser and scanner +#ifdef PLATFORM_WIN32 #define alloca _alloca +#endif + +// for static linking mojo... +#define yyparse yyparse_engine_base_parser +#define yyerror yyerror_engine_base_parser + extern void yyerror(char *s); extern int yyparse(void); diff --git a/Sources/Engine/Base/Priority.inl b/Sources/Engine/Base/Priority.inl index 7f90861..c75fe6f 100644 --- a/Sources/Engine/Base/Priority.inl +++ b/Sources/Engine/Base/Priority.inl @@ -1,5 +1,13 @@ + +#ifndef SE_INCL_PRIORITY_INL +#define SE_INCL_PRIORITY_INL +#ifdef PRAGMA_ONCE + #pragma once +#endif + class CSetPriority { public: +#ifdef PLATFORM_WIN32 DWORD sp_dwProcessOld; int sp_iThreadOld; HANDLE sp_hThread; @@ -21,4 +29,14 @@ public: BOOL bSuccessThread = SetThreadPriority(sp_hThread, sp_iThreadOld); ASSERT(bSuccessProcess && bSuccessThread); } + +#else + + CSetPriority(DWORD dwProcess, int iThread) { STUBBED(""); } + ~CSetPriority(void) { STUBBED(""); } + +#endif }; + +#endif /* include-once blocker. */ + diff --git a/Sources/Engine/Base/Profiling.cpp b/Sources/Engine/Base/Profiling.cpp index f2ef4ac..87dca66 100644 --- a/Sources/Engine/Base/Profiling.cpp +++ b/Sources/Engine/Base/Profiling.cpp @@ -1,16 +1,25 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include -template CStaticArray; -template CStaticArray; +template class CStaticArray; +template class CStaticArray; +#if (defined USE_PORTABLE_C) +#include +#endif static inline __int64 ReadTSC_profile(void) { +#if (defined USE_PORTABLE_C) + struct timeval tv; + gettimeofday(&tv, NULL); + return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_usec) / 1000) ); + +#elif (defined __MSVC_INLINE__) __int64 mmRet; __asm { rdtsc @@ -18,6 +27,22 @@ static inline __int64 ReadTSC_profile(void) mov dword ptr [mmRet+4],edx } return mmRet; + +#elif (defined __GNU_INLINE__) + __int64 mmRet; + __asm__ __volatile__ ( + "rdtsc \n\t" + "movl %%eax, 0(%%esi) \n\t" + "movl %%edx, 4(%%esi) \n\t" + : + : "S" (&mmRet) + : "memory", "eax", "edx" + ); + return(mmRet); + +#else + #error Please implement for your platform/compiler. +#endif } @@ -59,7 +84,15 @@ void CProfileForm::CalibrateProfilingTimers(void) #define REPEATCOUNT 10000 // measure how much it takes to start and stop timer - __int64 llMinStartStopTime(0x7fffffffffffffff); + +// rcg10102001 gcc needs the "ll" postfix for numbers this big. +#if (defined __GNUC__) + #define BIGBIGNUMBER 0x7fffffffffffffffll; +#else + #define BIGBIGNUMBER 0x7fffffffffffffff; +#endif + + __int64 llMinStartStopTime = BIGBIGNUMBER; {for (INDEX i=0; ipt_tvElapsed.Clear(); - itpt->pt_tvStarted.tv_llValue = -__int64(1); + itpt->pt_tvStarted.tv_llValue = (__int64) -1; itpt->pt_ctAveraging = 0; } } @@ -197,7 +231,7 @@ void CProfileForm::StopTimer_internal(INDEX iTimer) if (pf_ctRunningTimers==0) { pf_tvOverAllElapsed += tvNow-pf_tvOverAllStarted; } - IFDEBUG(pt.pt_tvStarted.tv_llValue = -__int64(1)); + IFDEBUG(pt.pt_tvStarted.tv_llValue = (__int64) -1); _tvCurrentProfilingEpsilon += _tvStopEpsilon; } @@ -259,7 +293,7 @@ void CProfileForm::Reset(void) FOREACHINSTATICARRAY(pf_aptTimers, CProfileTimer, itpt) { // clear the timer itpt->pt_tvElapsed.Clear(); - itpt->pt_tvStarted.tv_llValue = -__int64(1); + itpt->pt_tvStarted.tv_llValue = (__int64) -1; itpt->pt_ctAveraging = 0; } } @@ -271,7 +305,7 @@ void CProfileCounter::Report(char *&strBuffer, INDEX ctAveragingCount) ctAveragingCount = 1; } strBuffer += sprintf(strBuffer, "%-45s: %7d %7.2f\n", - pc_strName, pc_ctCount, (double)pc_ctCount/ctAveragingCount); + (const char *) pc_strName, pc_ctCount, (double)pc_ctCount/ctAveragingCount); } /* Print one timer in report. */ @@ -285,7 +319,7 @@ void CProfileTimer::Report(char *&strBuffer, if (pt_strAveragingName=="") { strBuffer += sprintf(strBuffer, "%-45s: %6.2f%% %6.2f%% %6.2f ms\n", - pt_strName, + (const char *) pt_strName, pt_tvElapsed.GetSeconds()/tvAppElapsed.GetSeconds()*100, pt_tvElapsed.GetSeconds()/tvModElapsed.GetSeconds()*100, pt_tvElapsed.GetSeconds()/ctAveragingCount*1000 @@ -296,12 +330,12 @@ void CProfileTimer::Report(char *&strBuffer, ctLocalAveraging = 1; } strBuffer += sprintf(strBuffer, "%-45s: %6.2f%% %6.2f%% %6.2f ms (%4.0fc/%s x%d)\n", - pt_strName, + (const char *) pt_strName, pt_tvElapsed.GetSeconds()/tvAppElapsed.GetSeconds()*100, pt_tvElapsed.GetSeconds()/tvModElapsed.GetSeconds()*100, pt_tvElapsed.GetSeconds()/ctAveragingCount*1000, pt_tvElapsed.GetSeconds()/ctLocalAveraging*_pTimer->tm_llCPUSpeedHZ, - pt_strAveragingName, + (const char *) pt_strAveragingName, pt_ctAveraging/ctAveragingCount ); } @@ -328,7 +362,9 @@ void CProfileForm::Report(CTString &strReport) CTimerValue tvModuleElapsed = pf_tvOverAllElapsed; // print the main header strBuffer += sprintf(strBuffer, "%s profile for last %d %s:\n", - pf_strTitle, GetAveragingCounter(), pf_strAveragingUnits); + (const char *) pf_strTitle, + GetAveragingCounter(), + (const char *) pf_strAveragingUnits); // print header for timers strBuffer += sprintf(strBuffer, diff --git a/Sources/Engine/Base/Profiling.h b/Sources/Engine/Base/Profiling.h index 4318d22..537f2a6 100644 --- a/Sources/Engine/Base/Profiling.h +++ b/Sources/Engine/Base/Profiling.h @@ -47,7 +47,7 @@ private: // this file just defines TIMER_PROFILING as 1 or 0 #include -#endif ENGINE_INTERNAL +#endif //ENGINE_INTERNAL /* * Class for gathering and reporting profiling information. @@ -153,6 +153,19 @@ public: /* Get percentage of module time in application time. */ double GetModulePercentage(void); +#else + + // !!! FIXME : rcg10102001 I needed to add these to compile + // !!! FIXME : Engine/Classes/MovableEntity.es. What am I doing wrong? + inline void IncrementCounter(INDEX iCounter, INDEX ctAdd=1) {} + inline void StartTimer(INDEX iTimer) {}; + inline void StopTimer(INDEX iTimer) {}; + inline void IncrementTimerAveragingCounter(INDEX iTimer, INDEX ctAdd=1) {}; + inline void SetCounterName_internal(INDEX iCounter, const CTString &strName) {}; + inline void SetTimerName_internal(INDEX iTimer, const CTString &strName, const CTString &strAveragingName) {}; + #define SETCOUNTERNAME(a,b) SetCounterName_internal(a,"") + #define SETTIMERNAME(a,b,c) SetTimerName_internal(a,"","") + #endif // ENGINE_INTERNAL /* Reset all profiling values. */ diff --git a/Sources/Engine/Base/ProfilingEnabled.h b/Sources/Engine/Base/ProfilingEnabled.h index 72ce493..49c35e6 100644 --- a/Sources/Engine/Base/ProfilingEnabled.h +++ b/Sources/Engine/Base/ProfilingEnabled.h @@ -1,3 +1,4 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ #define TIMER_PROFILING 0 + diff --git a/Sources/Engine/Base/ProgressHook.cpp b/Sources/Engine/Base/ProgressHook.cpp index 75b3f43..f754a9a 100644 --- a/Sources/Engine/Base/ProgressHook.cpp +++ b/Sources/Engine/Base/ProgressHook.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include #include #include #include diff --git a/Sources/Engine/Base/Protection.cpp b/Sources/Engine/Base/Protection.cpp index ffe5d20..20eab97 100644 --- a/Sources/Engine/Base/Protection.cpp +++ b/Sources/Engine/Base/Protection.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include +#include #pragma warning (disable: 4244) diff --git a/Sources/Engine/Base/Protection.h b/Sources/Engine/Base/Protection.h index 276baf2..4aa02f7 100644 --- a/Sources/Engine/Base/Protection.h +++ b/Sources/Engine/Base/Protection.h @@ -5,6 +5,7 @@ #ifdef PRAGMA_ONCE #pragma once #endif +#define COPY_PROTECTION 1 typedef struct { unsigned long P[16 + 2]; diff --git a/Sources/Engine/Base/Registry.cpp b/Sources/Engine/Base/Registry.cpp index 67536eb..a640555 100644 --- a/Sources/Engine/Base/Registry.cpp +++ b/Sources/Engine/Base/Registry.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include diff --git a/Sources/Engine/Base/Relations.cpp b/Sources/Engine/Base/Relations.cpp index 3de736b..328165f 100644 --- a/Sources/Engine/Base/Relations.cpp +++ b/Sources/Engine/Base/Relations.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Base/Relations.h b/Sources/Engine/Base/Relations.h index 47c861a..16bf77f 100644 --- a/Sources/Engine/Base/Relations.h +++ b/Sources/Engine/Base/Relations.h @@ -62,10 +62,10 @@ void ENGINE_API AddRelationPairHeadHead(CRelationSrc &rsSrc, CRelationDst &rdDst // get a domain member related to a codomain member through a link #define DST(plink, dstclass, dstmember) \ - ( (dstclass *) ( ((UBYTE *)(&(plink->GetDst()))) - offsetof(dstclass, dstmember) ) ) + ( (dstclass *) ( ((UBYTE *)(&(plink->GetDst()))) - _offsetof(dstclass, dstmember) ) ) // get a codomain member that a domain member is related to through a link #define SRC(plink, srcclass, srcmember) \ - ( (srcclass *) ( ((UBYTE *)(&(plink->GetSrc()))) - offsetof(srcclass, srcmember) ) ) + ( (srcclass *) ( ((UBYTE *)(&(plink->GetSrc()))) - _offsetof(srcclass, srcmember) ) ) // make 'for' construct for walking all codomain members related to a domain member #define FOREACHDSTOFSRC(srchead, dstclass, dstmember, pdst) \ diff --git a/Sources/Engine/Base/ReplaceFile.cpp b/Sources/Engine/Base/ReplaceFile.cpp index 97d6888..4882678 100644 --- a/Sources/Engine/Base/ReplaceFile.cpp +++ b/Sources/Engine/Base/ReplaceFile.cpp @@ -1,12 +1,11 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include #include -#include #include #include #include @@ -41,6 +40,7 @@ extern INDEX wed_bUseBaseForReplacement; static CTFileName CallFileRequester(char *achrTitle, char *achrSelectedFile, char *pFilter) { +#ifdef PLATFORM_WIN32 typedef CTFileName FileRequester_t( char *pchrTitle, char *pchrFilters, @@ -62,6 +62,13 @@ static CTFileName CallFileRequester(char *achrTitle, char *achrSelectedFile, cha } return pFileRequester( achrTitle, pFilter, "Replace file directory", achrSelectedFile); + +#else + + STUBBED("wtf?!"); + +#endif + } BOOL GetReplacingFile(CTFileName fnSourceFile, CTFileName &fnReplacingFile, @@ -105,7 +112,7 @@ BOOL GetReplacingFile(CTFileName fnSourceFile, CTFileName &fnReplacingFile, (void) strError; } CTString strTitle; - strTitle.PrintF(TRANS("For:\"%s\""), (CTString&)fnSourceFile); + strTitle.PrintF(TRANS("For:\"%s\""), (const char *) (CTString&)fnSourceFile); // call file requester for substituting file CTString strDefaultFile; strDefaultFile = fnSourceFile.FileName() + fnSourceFile.FileExt(); @@ -122,7 +129,7 @@ BOOL GetReplacingFile(CTFileName fnSourceFile, CTFileName &fnReplacingFile, strBase.Load_t( fnBaseName); } CTString strNewRemap; - strNewRemap.PrintF( "\"%s\" \"%s\"\n", (CTString&)fnSourceFile, (CTString&)fnReplacingFile); + strNewRemap.PrintF( "\"%s\" \"%s\"\n", (const char *) (CTString&)fnSourceFile, (const char *) (CTString&)fnReplacingFile); strBase += strNewRemap; strBase.Save_t( fnBaseName); } @@ -162,7 +169,7 @@ void SetTextureWithPossibleReplacing_t(CTextureObject &to, CTFileName &fnmTextur to.SetData_t(fnmTexture); } else { ThrowF_t( TRANS("Unable to load world because texture \"%s\" can't be found."), - (CTString&)fnmTexture); + (const char *) ((CTString&)fnmTexture)); } } } @@ -189,7 +196,7 @@ void ReadTextureObject_t(CTStream &strm, CTextureObject &to) // replacing texture was provided fnTexture = fnReplacingTexture; } else { - ThrowF_t( TRANS("Cannot find substitution for \"%s\""), (CTString&)fnTexture); + ThrowF_t( TRANS("Cannot find substitution for \"%s\""), (const char *) (CTString&)fnTexture); } } } @@ -238,7 +245,7 @@ void ReadModelObject_t(CTStream &strm, CModelObject &mo) // replacing model was provided fnModel = fnReplacingModel; } else { - ThrowF_t( TRANS("Cannot find substitution for \"%s\""), (CTString&)fnModel); + ThrowF_t( TRANS("Cannot find substitution for \"%s\""), (const char *) (CTString&)fnModel); } } } @@ -482,7 +489,7 @@ void WriteOffsetAndChildren(CTStream &strm, CModelInstance &mi) { strm.WriteID_t("MIOF"); // model instance offset // write model instance offset and parent bone - strm.Write_t(&mi.mi_qvOffset,sizeof(QVect)); + strm<>mi.mi_qvOffset; CTString strParenBoneID; strm>>strParenBoneID; mi.mi_iParentBoneID = ska_GetIDFromStringTable(strParenBoneID); @@ -789,7 +796,7 @@ void ReadOffsetAndChildren_t(CTStream &strm, CModelInstance &mi) INDEX ctcmi = 0; strm.ExpectID_t("MIOF"); // model instance offset // read model instance offset and parent bone - strm.Read_t(&mi.mi_qvOffset,sizeof(QVect)); + strm>>mi.mi_qvOffset; CTString strParenBoneID; strm>>strParenBoneID; mi.mi_iParentBoneID = ska_GetIDFromStringTable(strParenBoneID); @@ -873,7 +880,7 @@ void ReadAnimObject_t(CTStream &strm, CAnimObject &ao) // replacing anim was provided fnAnim = fnReplacingAnim; } else { - ThrowF_t( TRANS("Cannot find substitution for \"%s\""), (CTString&)fnAnim); + ThrowF_t( TRANS("Cannot find substitution for \"%s\""), (const char *) (CTString&)fnAnim); } } } diff --git a/Sources/Engine/Base/SDL/SDLEvents.cpp b/Sources/Engine/Base/SDL/SDLEvents.cpp new file mode 100644 index 0000000..512cfce --- /dev/null +++ b/Sources/Engine/Base/SDL/SDLEvents.cpp @@ -0,0 +1,174 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#include +#include + +#include +#include +#include "SDL.h" + +static Uint16 next_message_char = 0; + + +// This keeps the input subsystem in sync with everything else, by +// making sure all SDL events tunnel through one function. +extern int SE_SDL_InputEventPoll(SDL_Event *event); + + +BOOL PeekMessage(MSG *msg, void *hwnd, UINT wMsgFilterMin, + UINT wMsgFilterMax, UINT wRemoveMsg) +{ + assert(msg != NULL); + assert(wRemoveMsg == PM_REMOVE); + assert(wMsgFilterMin == 0); + assert(wMsgFilterMax == 0); + + if (next_message_char != 0) + { + msg->message = WM_CHAR; + msg->wParam = next_message_char; + msg->unicode = next_message_char; + next_message_char = 0; + return(TRUE); + } // if + + SDL_Event sdlevent; + if (!SE_SDL_InputEventPoll(&sdlevent)) + return(FALSE); + + assert(sdlevent.type != SDL_NOEVENT); + + msg->message = sdlevent.type; + + switch (sdlevent.type) + { + case SDL_MOUSEMOTION: + msg->lParam = ( + ((sdlevent.motion.y << 16) & 0xFFFF0000) | + ((sdlevent.motion.x ) & 0x0000FFFF) + ); + break; + + case SDL_KEYDOWN: + if (sdlevent.key.keysym.mod & KMOD_ALT) + msg->message = WM_SYSKEYDOWN; + // deliberate fall through... + case SDL_KEYUP: + msg->unicode = sdlevent.key.keysym.unicode; + msg->wParam = sdlevent.key.keysym.sym; + break; + + case SDL_MOUSEBUTTONDOWN: + if (sdlevent.button.button == 2) // right button... + { + msg->message = WM_RBUTTONDOWN; + } // if + + else if (sdlevent.button.button == 4) // wheel up + { + msg->message = WM_MOUSEWHEEL; + msg->wParam = 120 << 16; + } // else if + + else if (sdlevent.button.button == 5) // wheel down + { + msg->message = WM_MOUSEWHEEL; + msg->wParam = -120 << 16; + } // else if + break; + + case SDL_MOUSEBUTTONUP: + if (sdlevent.button.button == 2) // right button... + { + msg->message = WM_RBUTTONUP; + } // if + break; + } // switch + + return(TRUE); +} // PeekMessage + + +void TranslateMessage(MSG *msg) +{ + if (msg->message == WM_KEYDOWN) + { + if (msg->unicode != 0) + next_message_char = msg->unicode; + } // if +} // TranslateMessage + + +void DispatchMessage(MSG *msg) +{ + // do nothing. +} // DispatchMessage + + +SHORT GetKeyState(int vk) +{ + SHORT retval = 0; + + switch (vk) + { + case VK_LBUTTON: + if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_LMASK) + retval = 0x8000; + break; + + case VK_RBUTTON: + if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_RMASK) + retval = 0x8000; + break; + + case VK_MBUTTON: + if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_MMASK) + retval = 0x8000; + break; + + default: + if (SDL_GetKeyState(NULL)[vk]) + retval = 0x8000; + break; + } // switch + + return(retval); +} // GetKeyState + + +SHORT GetAsyncKeyState(int vk) +{ + return(GetKeyState(vk)); +} // GetAsyncKeyState + + +BOOL GetCursorPos(LPPOINT lpPoint) +{ + assert(lpPoint != NULL); + + int x, y; + SDL_GetMouseState(&x, &y); + lpPoint->x = x; + lpPoint->y = y; + return(TRUE); +} // GetCursorPos + + +BOOL ScreenToClient(void *hWnd, LPPOINT lpPoint) +{ + // do nothing. SDL returns points in client coordinates already. + return(1); // success. :) +} // ScreenToClient + + +int ShowCursor(BOOL yes) +{ + static int count = 0; + count += (yes) ? 1 : -1; + SDL_ShowCursor((count >= 0) ? SDL_ENABLE : SDL_DISABLE); + return(count); +} // ShowCursor + +// end of SDLEvents.cpp ... + + diff --git a/Sources/Engine/Base/SDL/SDLEvents.h b/Sources/Engine/Base/SDL/SDLEvents.h new file mode 100644 index 0000000..570e0e0 --- /dev/null +++ b/Sources/Engine/Base/SDL/SDLEvents.h @@ -0,0 +1,132 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#ifndef SE_INCL_SDLEVENTS_H +#define SE_INCL_SDLEVENTS_H + +#ifdef PRAGMA_ONCE +#pragma once +#endif + +#include +#include "SDL.h" + +#define IsIconic(x) (FALSE) + +typedef struct SSAM_SDL_MSG { + UINT message; + WPARAM wParam; + LPARAM lParam; + Uint16 unicode; +} MSG, *PMSG; + +#define PM_REMOVE 37337 // super l33t. :) + +#define WM_CHAR (SDL_USEREVENT + 0) +#define WM_NULL (SDL_USEREVENT + 1) +#define WM_SYSKEYDOWN (SDL_USEREVENT + 2) +#define WM_LBUTTONDOWN (SDL_MOUSEBUTTONDOWN) +#define WM_LBUTTONUP (SDL_MOUSEBUTTONUP) +#define WM_RBUTTONDOWN (SDL_USEREVENT + 3) +#define WM_RBUTTONUP (SDL_USEREVENT + 4) +#define WM_MOUSEWHEEL (SDL_USEREVENT + 5) + +#define WM_KEYDOWN (SDL_KEYDOWN) +#define WM_KEYUP (SDL_KEYUP) +#define WM_MOUSEMOVE (SDL_MOUSEMOTION) +#define WM_PAINT (SDL_VIDEOEXPOSE) +#define WM_QUIT (SDL_QUIT) + +#define WM_CLOSE (SDL_NOEVENT) +#define WM_COMMAND (SDL_NOEVENT) +#define WM_ERASEBKGND (SDL_NOEVENT) +#define WM_KILLFOCUS (SDL_NOEVENT) +#define WM_MOUSEFIRST (SDL_NOEVENT) +#define WM_MOUSELAST (SDL_NOEVENT) +#define WM_LBUTTONDBLCLK (SDL_NOEVENT) +#define WM_RBUTTONDBLCLK (SDL_NOEVENT) +#define WM_SYSCOMMAND (SDL_NOEVENT) +#define WM_SETFOCUS (SDL_NOEVENT) +#define WM_ACTIVATE (SDL_NOEVENT) +#define WM_ACTIVATEAPP (SDL_NOEVENT) +#define WM_CANCELMODE (SDL_NOEVENT) + +BOOL PeekMessage(MSG *msg, void *hwnd, UINT wMsgFilterMin, + UINT wMsgFilterMax, UINT wRemoveMsg); +void TranslateMessage(MSG *msg); +void DispatchMessage(MSG *msg); + +#define VK_ADD SDLK_KP_PLUS +#define VK_BACK SDLK_BACKSPACE +#define VK_CAPITAL SDLK_CAPSLOCK +#define VK_CONTROL SDLK_RCTRL +#define VK_DECIMAL SDLK_KP_PERIOD +#define VK_DELETE SDLK_DELETE +#define VK_DIVIDE SDLK_KP_DIVIDE +#define VK_DOWN SDLK_DOWN +#define VK_END SDLK_END +#define VK_ESCAPE SDLK_ESCAPE +#define VK_F1 SDLK_F1 +#define VK_F2 SDLK_F2 +#define VK_F3 SDLK_F3 +#define VK_F4 SDLK_F4 +#define VK_F5 SDLK_F5 +#define VK_F6 SDLK_F6 +#define VK_F7 SDLK_F7 +#define VK_F8 SDLK_F8 +#define VK_F9 SDLK_F9 +#define VK_F10 SDLK_F10 +#define VK_F11 SDLK_F11 +#define VK_F12 SDLK_F12 +#define VK_HOME SDLK_HOME +#define VK_INSERT SDLK_INSERT +#define VK_LCONTROL SDLK_LCTRL +#define VK_LEFT SDLK_LEFT +#define VK_LMENU SDLK_LALT +#define VK_LSHIFT SDLK_LSHIFT +#define VK_MENU SDLK_LALT +#define VK_MULTIPLY SDLK_KP_MULTIPLY +#define VK_NEXT SDLK_PAGEDOWN +#define VK_NUMLOCK SDLK_NUMLOCK +#define VK_NUMPAD0 SDLK_KP0 +#define VK_NUMPAD1 SDLK_KP1 +#define VK_NUMPAD2 SDLK_KP2 +#define VK_NUMPAD3 SDLK_KP3 +#define VK_NUMPAD4 SDLK_KP4 +#define VK_NUMPAD5 SDLK_KP5 +#define VK_NUMPAD6 SDLK_KP6 +#define VK_NUMPAD7 SDLK_KP7 +#define VK_NUMPAD8 SDLK_KP8 +#define VK_NUMPAD9 SDLK_KP9 +#define VK_PAUSE SDLK_PAUSE +#define VK_PRIOR SDLK_PAGEUP +#define VK_RCONTROL SDLK_RCTRL +#define VK_RETURN SDLK_RETURN +#define VK_RIGHT SDLK_RIGHT +#define VK_RMENU SDLK_RALT +#define VK_RSHIFT SDLK_RSHIFT +#define VK_SCROLL SDLK_SCROLLOCK +#define VK_SEPARATOR SDLK_KP_ENTER +#define VK_SHIFT SDLK_LSHIFT +#define VK_SNAPSHOT SDLK_PRINT +#define VK_SPACE SDLK_SPACE +#define VK_SUBTRACT SDLK_KP_MINUS +#define VK_TAB SDLK_TAB +#define VK_UP SDLK_UP + +// Pray these never get filled. +#define VK_LBUTTON 1 +#define VK_RBUTTON 2 +#define VK_MBUTTON 3 + +SHORT GetKeyState(int vk); +SHORT GetAsyncKeyState(int vk); +BOOL GetCursorPos(LPPOINT lpPoint); +BOOL ScreenToClient(void *hWnd, LPPOINT lpPoint); +int ShowCursor(BOOL yes); + +#define LOWORD(x) (x & 0x0000FFFF) +#define HIWORD(x) ((x >> 16) & 0x0000FFFF) + +#endif /* include-once blocker. */ + + diff --git a/Sources/Engine/Base/SDL/SDLInput.cpp b/Sources/Engine/Base/SDL/SDLInput.cpp new file mode 100644 index 0000000..c9b266d --- /dev/null +++ b/Sources/Engine/Base/SDL/SDLInput.cpp @@ -0,0 +1,1036 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +/* rcg10072001 Moved stuff into this file. */ + +#include "SDL.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern INDEX inp_iKeyboardReadingMethod; +extern FLOAT inp_fMouseSensitivity; +extern INDEX inp_bAllowMouseAcceleration; +extern INDEX inp_bMousePrecision; +extern FLOAT inp_fMousePrecisionFactor; +extern FLOAT inp_fMousePrecisionThreshold; +extern FLOAT inp_fMousePrecisionTimeout; +extern FLOAT inp_bInvertMouse; +extern INDEX inp_bFilterMouse; +extern INDEX inp_bAllowPrescan; + +extern INDEX inp_i2ndMousePort; +extern FLOAT inp_f2ndMouseSensitivity; +extern INDEX inp_b2ndMousePrecision; +extern FLOAT inp_f2ndMousePrecisionThreshold; +extern FLOAT inp_f2ndMousePrecisionTimeout; +extern FLOAT inp_f2ndMousePrecisionFactor; +extern INDEX inp_bFilter2ndMouse; +extern INDEX inp_bInvert2ndMouse; + +static BOOL inp_bSDLPermitCtrlG = TRUE; +static BOOL inp_bSDLGrabInput = TRUE; +static Sint16 mouse_relative_x = 0; +static Sint16 mouse_relative_y = 0; +static Sint16 mouse_previous_x = 0; +static Sint16 mouse_previous_y = 0; + +INDEX inp_iMButton4Dn = 0x20040; +INDEX inp_iMButton4Up = 0x20000; +INDEX inp_iMButton5Dn = 0x10020; +INDEX inp_iMButton5Up = 0x10000; +INDEX inp_bMsgDebugger = FALSE; +INDEX inp_bForceJoystickPolling = 0; +INDEX inp_bAutoDisableJoysticks = 0; + +extern INDEX inp_ctJoysticksAllowed; + +/* + +NOTE: Two different types of key codes are used here: + 1) kid - engine internal type - defined in KeyNames.h + 2) virtkey - virtual key codes used by SDL. + +*/ + +// name that is not translated (international) +#define INTNAME(str) str, "" +// name that is translated +#define TRANAME(str) str, "ETRS" str + +// basic key conversion table +static struct KeyConversion { + INDEX kc_iKID; + INDEX kc_iVirtKey; + char *kc_strName; + char *kc_strNameTrans; +} _akcKeys[] = { + + // reserved for 'no-key-pressed' + { KID_NONE, -1, TRANAME("None")}, + +// numbers row + { KID_1 , SDLK_1, INTNAME("1")}, + { KID_2 , SDLK_2, INTNAME("2")}, + { KID_3 , SDLK_3, INTNAME("3")}, + { KID_4 , SDLK_4, INTNAME("4")}, + { KID_5 , SDLK_5, INTNAME("5")}, + { KID_6 , SDLK_6, INTNAME("6")}, + { KID_7 , SDLK_7, INTNAME("7")}, + { KID_8 , SDLK_8, INTNAME("8")}, + { KID_9 , SDLK_9, INTNAME("9")}, + { KID_0 , SDLK_0, INTNAME("0")}, + { KID_MINUS , SDLK_MINUS, INTNAME("-")}, + { KID_EQUALS , SDLK_EQUALS, INTNAME("=")}, + +// 1st alpha row + { KID_Q , SDLK_q, INTNAME("Q")}, + { KID_W , SDLK_w, INTNAME("W")}, + { KID_E , SDLK_e, INTNAME("E")}, + { KID_R , SDLK_r, INTNAME("R")}, + { KID_T , SDLK_t, INTNAME("T")}, + { KID_Y , SDLK_y, INTNAME("Y")}, + { KID_U , SDLK_u, INTNAME("U")}, + { KID_I , SDLK_i, INTNAME("I")}, + { KID_O , SDLK_o, INTNAME("O")}, + { KID_P , SDLK_p, INTNAME("P")}, + { KID_LBRACKET , SDLK_RIGHTPAREN, INTNAME("[")}, + { KID_RBRACKET , SDLK_RIGHTPAREN, INTNAME("]")}, + { KID_BACKSLASH , SDLK_BACKSLASH, INTNAME("\\")}, + +// 2nd alpha row + { KID_A , SDLK_a, INTNAME("A")}, + { KID_S , SDLK_s, INTNAME("S")}, + { KID_D , SDLK_d, INTNAME("D")}, + { KID_F , SDLK_f, INTNAME("F")}, + { KID_G , SDLK_g, INTNAME("G")}, + { KID_H , SDLK_h, INTNAME("H")}, + { KID_J , SDLK_j, INTNAME("J")}, + { KID_K , SDLK_k, INTNAME("K")}, + { KID_L , SDLK_l, INTNAME("L")}, + { KID_SEMICOLON , SDLK_SEMICOLON, INTNAME(";")}, + { KID_APOSTROPHE , SDLK_QUOTE, INTNAME("'")}, + +// 3rd alpha row + { KID_Z , SDLK_z, INTNAME("Z")}, + { KID_X , SDLK_x, INTNAME("X")}, + { KID_C , SDLK_c, INTNAME("C")}, + { KID_V , SDLK_v, INTNAME("V")}, + { KID_B , SDLK_b, INTNAME("B")}, + { KID_N , SDLK_n, INTNAME("N")}, + { KID_M , SDLK_m, INTNAME("M")}, + { KID_COMMA , SDLK_COMMA, INTNAME(",")}, + { KID_PERIOD , SDLK_PERIOD, INTNAME(".")}, + { KID_SLASH , SDLK_SLASH, INTNAME("/")}, + +// row with F-keys + { KID_F1 , SDLK_F1, INTNAME("F1")}, + { KID_F2 , SDLK_F2, INTNAME("F2")}, + { KID_F3 , SDLK_F3, INTNAME("F3")}, + { KID_F4 , SDLK_F4, INTNAME("F4")}, + { KID_F5 , SDLK_F5, INTNAME("F5")}, + { KID_F6 , SDLK_F6, INTNAME("F6")}, + { KID_F7 , SDLK_F7, INTNAME("F7")}, + { KID_F8 , SDLK_F8, INTNAME("F8")}, + { KID_F9 , SDLK_F9, INTNAME("F9")}, + { KID_F10 , SDLK_F10, INTNAME("F10")}, + { KID_F11 , SDLK_F11, INTNAME("F11")}, + { KID_F12 , SDLK_F12, INTNAME("F12")}, + +// extra keys + { KID_ESCAPE , SDLK_ESCAPE, TRANAME("Escape")}, + { KID_TILDE , -1, TRANAME("Tilde")}, + { KID_BACKSPACE , SDLK_BACKSPACE, TRANAME("Backspace")}, + { KID_TAB , SDLK_TAB, TRANAME("Tab")}, + { KID_CAPSLOCK , SDLK_CAPSLOCK, TRANAME("Caps Lock")}, + { KID_ENTER , SDLK_RETURN, TRANAME("Enter")}, + { KID_SPACE , SDLK_SPACE, TRANAME("Space")}, + +// modifier keys + { KID_LSHIFT , SDLK_LSHIFT , TRANAME("Left Shift")}, + { KID_RSHIFT , SDLK_RSHIFT , TRANAME("Right Shift")}, + { KID_LCONTROL , SDLK_LCTRL, TRANAME("Left Control")}, + { KID_RCONTROL , SDLK_RCTRL, TRANAME("Right Control")}, + { KID_LALT , SDLK_LALT , TRANAME("Left Alt")}, + { KID_RALT , SDLK_RALT , TRANAME("Right Alt")}, + +// navigation keys + { KID_ARROWUP , SDLK_UP, TRANAME("Arrow Up")}, + { KID_ARROWDOWN , SDLK_DOWN, TRANAME("Arrow Down")}, + { KID_ARROWLEFT , SDLK_LEFT, TRANAME("Arrow Left")}, + { KID_ARROWRIGHT , SDLK_RIGHT, TRANAME("Arrow Right")}, + { KID_INSERT , SDLK_INSERT, TRANAME("Insert")}, + { KID_DELETE , SDLK_DELETE, TRANAME("Delete")}, + { KID_HOME , SDLK_HOME, TRANAME("Home")}, + { KID_END , SDLK_END, TRANAME("End")}, + { KID_PAGEUP , SDLK_PAGEUP, TRANAME("Page Up")}, + { KID_PAGEDOWN , SDLK_PAGEDOWN, TRANAME("Page Down")}, + { KID_PRINTSCR , SDLK_PRINT, TRANAME("Print Screen")}, + { KID_SCROLLLOCK , SDLK_SCROLLOCK, TRANAME("Scroll Lock")}, + { KID_PAUSE , SDLK_PAUSE, TRANAME("Pause")}, + +// numpad numbers + { KID_NUM0 , SDLK_KP0, INTNAME("Num 0")}, + { KID_NUM1 , SDLK_KP1, INTNAME("Num 1")}, + { KID_NUM2 , SDLK_KP2, INTNAME("Num 2")}, + { KID_NUM3 , SDLK_KP3, INTNAME("Num 3")}, + { KID_NUM4 , SDLK_KP4, INTNAME("Num 4")}, + { KID_NUM5 , SDLK_KP5, INTNAME("Num 5")}, + { KID_NUM6 , SDLK_KP6, INTNAME("Num 6")}, + { KID_NUM7 , SDLK_KP7, INTNAME("Num 7")}, + { KID_NUM8 , SDLK_KP8, INTNAME("Num 8")}, + { KID_NUM9 , SDLK_KP9, INTNAME("Num 9")}, + { KID_NUMDECIMAL , SDLK_KP_PERIOD, INTNAME("Num .")}, + +// numpad gray keys + { KID_NUMLOCK , SDLK_NUMLOCK, INTNAME("Num Lock")}, + { KID_NUMSLASH , SDLK_KP_DIVIDE, INTNAME("Num /")}, + { KID_NUMMULTIPLY , SDLK_KP_MULTIPLY, INTNAME("Num *")}, + { KID_NUMMINUS , SDLK_KP_MINUS, INTNAME("Num -")}, + { KID_NUMPLUS , SDLK_KP_PLUS, INTNAME("Num +")}, + { KID_NUMENTER , SDLK_KP_ENTER, TRANAME("Num Enter")}, + +// mouse buttons + { KID_MOUSE1 , -1, TRANAME("Mouse Button 1")}, + { KID_MOUSE2 , -1, TRANAME("Mouse Button 2")}, + { KID_MOUSE3 , -1, TRANAME("Mouse Button 3")}, + { KID_MOUSE4 , -1, TRANAME("Mouse Button 4")}, + { KID_MOUSE5 , -1, TRANAME("Mouse Button 5")}, + { KID_MOUSEWHEELUP , -1, TRANAME("Mouse Wheel Up")}, + { KID_MOUSEWHEELDOWN , -1, TRANAME("Mouse Wheel Down")}, + +// 2nd mouse buttons + { KID_2MOUSE1 , -1, TRANAME("2nd Mouse Button 1")}, + { KID_2MOUSE2 , -1, TRANAME("2nd Mouse Button 2")}, + { KID_2MOUSE3 , -1, TRANAME("2nd Mouse Button 3")}, + +}; + + +// autogenerated fast conversion tables +static INDEX _aiVirtToKid[SDLK_LAST]; + +// make fast conversion tables from the general table +static void MakeConversionTables(void) +{ + // clear conversion tables +// memset(_aiScanToKid, -1, sizeof(_aiScanToKid)); + memset(_aiVirtToKid, -1, sizeof(_aiVirtToKid)); + + // for each Key + for (INDEX iKey=0; iKey=0) { + _aiVirtToKid[iVirt] = iKID; + } + } +} + +// variables for message interception +//static HHOOK _hGetMsgHook = NULL; +//static HHOOK _hSendMsgHook = NULL; +static int _iMouseZ = 0; +static BOOL _bWheelUp = FALSE; +static BOOL _bWheelDn = FALSE; + +CTCriticalSection csInput; + +// which keys are pressed, as recorded by message interception (by KIDs) +static UBYTE _abKeysPressed[256]; + +// set a key according to a keydown/keyup message +static void SetKeyFromEvent(const SDL_Event *event, BOOL bDown) +{ + assert((event->type == SDL_KEYUP) || (event->type == SDL_KEYDOWN)); + + if ( (event->key.keysym.mod & KMOD_CTRL) && + (event->key.keysym.sym == SDLK_g) && + (event->type == SDL_KEYDOWN) && + (inp_bSDLPermitCtrlG) ) + { + if (inp_bSDLGrabInput) + { + //assert(SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON); + // turn off input grab. + SDL_ShowCursor(1); + SDL_WM_GrabInput(SDL_GRAB_OFF); + inp_bSDLGrabInput = FALSE; + mouse_previous_x = mouse_previous_y = 0; + } // if + else + { + //assert(SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF); + // turn on input grab. + SDL_ShowCursor(0); + SDL_WM_GrabInput(SDL_GRAB_ON); + inp_bSDLGrabInput = TRUE; + int x, y; + SDL_GetMouseState(&x, &y); + mouse_previous_x = x; + mouse_previous_y = y; + } // else + + mouse_relative_x = mouse_relative_y = 0; + return; + } // if + + INDEX iKID = -1; + SDLKey iVirt = event->key.keysym.sym; + + // convert virtualkey to kid + iKID = _aiVirtToKid[iVirt]; + + if (iKID>=0 && iKIDinp_strButtonNames[iKID], bDown); + _abKeysPressed[iKID] = bDown; + } +} + + +static void sdl_event_handler(const SDL_Event *event) +{ + switch (event->type) + { + case SDL_MOUSEMOTION: +#if 1 + mouse_relative_x += event->motion.xrel; + mouse_relative_y += event->motion.yrel; +#else + if (inp_bSDLGrabInput) + { + mouse_relative_x += event->motion.xrel; + mouse_relative_y += event->motion.yrel; + } // if + else + { + mouse_relative_x += (event->motion.x - mouse_previous_x); + mouse_relative_y += (event->motion.y - mouse_previous_y); + mouse_previous_x = event->motion.x; + mouse_previous_y = event->motion.y; + } // else +#endif + break; + + case SDL_MOUSEBUTTONDOWN: + switch (event->button.button) + { + case 1: + _abKeysPressed[KID_MOUSE1] = TRUE; + break; + case 2: + _abKeysPressed[KID_MOUSE2] = TRUE; + break; + case 3: + _abKeysPressed[KID_MOUSE3] = TRUE; + break; + + // !!! FIXME: mousewheel number should be set by a cvar. + case 4: + _abKeysPressed[KID_MOUSEWHEELUP] = TRUE; + break; + case 5: + _abKeysPressed[KID_MOUSEWHEELDOWN] = TRUE; + break; + } // switch + break; + + case SDL_MOUSEBUTTONUP: + switch (event->button.button) + { + case 1: + _abKeysPressed[KID_MOUSE1] = FALSE; + break; + case 2: + _abKeysPressed[KID_MOUSE2] = FALSE; + break; + case 3: + _abKeysPressed[KID_MOUSE3] = FALSE; + break; + + // !!! FIXME: mousewheel number should be set by a cvar. + // ignore mousewheel button-up events, since they are sent + // at the same time as the button-down, and cancel each other + // out in this system. + } // switch + break; + + case SDL_KEYDOWN: + SetKeyFromEvent(event, TRUE); + break; + + case SDL_KEYUP: + SetKeyFromEvent(event, FALSE); + break; + } // switch +} // sdl_event_handler + + +// This keeps the input subsystem in sync with everything else, by +// making sure all SDL events tunnel through one function. +// DO NOT DIRECTLY MESS WITH THE SDL EVENT QUEUE THROUGH ANY OTHER FUNCTION. +// Parameters/retval are same as SDL_PollEvent(). +int SE_SDL_InputEventPoll(SDL_Event *sdlevent) +{ + ASSERT(sdlevent != NULL); + int retval = SDL_PollEvent(sdlevent); + if (retval) + sdl_event_handler(sdlevent); + + return(retval); +} // SE_SDL_InputEventPoll + + +#if 0 // !!! FIXME: Can we support this? +// --------- 2ND MOUSE HANDLING + +#define MOUSECOMBUFFERSIZE 256L +static HANDLE _h2ndMouse = NONE; +static BOOL _bIgnoreMouse2 = TRUE; +static INDEX _i2ndMouseX, _i2ndMouseY, _i2ndMouseButtons; +static INDEX _iByteNum = 0; +static UBYTE _aubComBytes[4] = {0,0,0,0}; +static INDEX _iLastPort = -1; + + + +static void Poll2ndMouse(void) +{ + // reset (mouse reading is relative) + _i2ndMouseX = 0; + _i2ndMouseY = 0; + if( _h2ndMouse==NONE) return; + + // check + COMSTAT csComStat; + DWORD dwErrorFlags; + ClearCommError( _h2ndMouse, &dwErrorFlags, &csComStat); + DWORD dwLength = Min( MOUSECOMBUFFERSIZE, (INDEX)csComStat.cbInQue); + if( dwLength<=0) return; + + // readout + UBYTE aubMouseBuffer[MOUSECOMBUFFERSIZE]; + INDEX iRetries = 999; + while( iRetries>0 && !ReadFile( _h2ndMouse, aubMouseBuffer, dwLength, &dwLength, NULL)) iRetries--; + if( iRetries<=0) return; // what, didn't make it? + + // parse the mouse packets + for( INDEX i=0; i>4; + } + // axes ? + else if( _iByteNum==3) { + char iDX = ((_aubComBytes[0] & 3) <<6) + _aubComBytes[1]; + char iDY = ((_aubComBytes[0] & 12) <<4) + _aubComBytes[2]; + _i2ndMouseX += iDX; + _i2ndMouseY += iDY; + } + // 3rd button? + else if( _iByteNum==4) { + _i2ndMouseButtons &= ~4; + if( aubMouseBuffer[i]&32) _i2ndMouseButtons |= 4; + } + } + + // ignore pooling? + if( _bIgnoreMouse2) { + if( _i2ndMouseX!=0 || _i2ndMouseY!=0) _bIgnoreMouse2 = FALSE; + _i2ndMouseX = 0; + _i2ndMouseY = 0; + _i2ndMouseButtons = 0; + return; + } +} + + +static void Startup2ndMouse(INDEX iPort) +{ + // skip if disabled + ASSERT( iPort>=0 && iPort<=4); + if( iPort==0) return; + // determine port string + CTString str2ndMousePort( 0, "COM%d", iPort); + + // create COM handle if needed + if( _h2ndMouse==NONE) { + _h2ndMouse = CreateFile( str2ndMousePort, GENERIC_READ|GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if( _h2ndMouse==INVALID_HANDLE_VALUE) { + // failed! :( + INDEX iError = GetLastError(); + if( iError==5) CPrintF( "Cannot open %s (access denied).\n" + "The port is probably already used by another device (mouse, modem...)\n", + str2ndMousePort); + else CPrintF( "Cannot open %s (error %d).\n", str2ndMousePort, iError); + _h2ndMouse = NONE; + return; + } + } + // setup and purge buffers + SetupComm( _h2ndMouse, MOUSECOMBUFFERSIZE, MOUSECOMBUFFERSIZE); + PurgeComm( _h2ndMouse, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR); + + // setup port to 1200 7N1 + DCB dcb; + dcb.DCBlength = sizeof(DCB); + GetCommState( _h2ndMouse, &dcb); + dcb.BaudRate = CBR_1200; + dcb.ByteSize = 7; + dcb.Parity = NOPARITY; + dcb.StopBits = ONESTOPBIT; + dcb.fDtrControl = DTR_CONTROL_ENABLE; + dcb.fRtsControl = RTS_CONTROL_ENABLE; + dcb.fBinary = TRUE; + dcb.fParity = TRUE; + SetCommState( _h2ndMouse, &dcb); + + // reset + _iByteNum = 0; + _aubComBytes[0] = _aubComBytes[1] = _aubComBytes[2] = _aubComBytes[3] = 0; + _bIgnoreMouse2 = TRUE; // ignore mouse polling until 1 after non-0 readout + _iLastPort = iPort; + //CPrintF( "STARTUP M2!\n"); +} + + +static void Shutdown2ndMouse(void) +{ + // skip if already disabled + if( _h2ndMouse==NONE) return; + + // disable! + SetCommMask( _h2ndMouse, 0); + EscapeCommFunction( _h2ndMouse, CLRDTR); + EscapeCommFunction( _h2ndMouse, CLRRTS); + PurgeComm( _h2ndMouse, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR); + // close port if changed + if( _iLastPort != inp_i2ndMousePort) { + CloseHandle( _h2ndMouse); + _h2ndMouse = NONE; + } // over and out + _bIgnoreMouse2 = TRUE; +} +#endif + +static SDL_Joystick **sticks = NULL; +static int ctJoysticks = 0; + +BOOL CInput::PlatformInit(void) +{ +#if 0 + _h2ndMouse = NONE; +#endif + + assert(sticks == NULL); + assert(ctJoysticks == 0); + + _pShell->DeclareSymbol("persistent user INDEX inp_bSDLPermitCtrlG;", (void*)&inp_bSDLPermitCtrlG); + _pShell->DeclareSymbol("persistent user INDEX inp_bSDLGrabInput;", (void*)&inp_bSDLGrabInput); + MakeConversionTables(); + return(TRUE); +} + + +// destructor +CInput::~CInput() +{ + if (sticks != NULL) { + int max = ctJoysticks; + for (int i = 0; i < max; i++) { + if (sticks[i] != NULL) { + SDL_JoystickClose(sticks[i]); + } + } + delete[] sticks; + sticks = NULL; + } + + ctJoysticks = 0; + +#if 0 + if (_h2ndMouse != NONE) + CloseHandle(_h2ndMouse); + _h2ndMouse = NONE; +#endif +} + + +BOOL CInput::PlatformSetKeyNames(void) +{ + // for each Key + for (INDEX iKey=0; iKey 0) { + sticks = new SDL_Joystick *[retval]; + ctJoysticks = (int) retval; + memset(sticks, '\0', sizeof (SDL_Joystick *) * retval); + } + + return(retval); +} + + +// check if a joystick exists +BOOL CInput::CheckJoystick(INDEX iJoy) +{ + CPrintF(TRANS(" joy %d:"), iJoy + 1); + + assert(ctJoysticks > iJoy); + CPrintF(" '%s'\n", SDL_JoystickName(iJoy)); + + SDL_Joystick *stick = SDL_JoystickOpen(iJoy); + if (stick == NULL) { + CPrintF(" ...can't open joystick.\n reason: %s\n", SDL_GetError()); + return FALSE; + } + + assert(sticks != NULL); + assert(sticks[iJoy] == NULL); + sticks[iJoy] = stick; + + int ctAxes = SDL_JoystickNumAxes(stick); + CPrintF(TRANS(" %d axes\n"), ctAxes); + CPrintF(TRANS(" %d buttons\n"), SDL_JoystickNumButtons(stick)); + if (SDL_JoystickNumHats(stick) > 0) { + CPrintF(TRANS(" POV hat present\n")); + } + + // for each axis + for(INDEX iAxis=0; iAxisw / 2; + inp_slScreenCenterY = screen->h / 2; + + // remember mouse pos + int mousex, mousey; + SDL_GetMouseState(&mousex, &mousey); + inp_ptOldMousePos.x = mousex; + inp_ptOldMousePos.y = mousey; + + if (inp_bSDLGrabInput) + { + SDL_ShowCursor(0); + SDL_WM_GrabInput(SDL_GRAB_ON); + } // if + else + { + SDL_ShowCursor(1); + SDL_WM_GrabInput(SDL_GRAB_OFF); + } // else + + // save system mouse settings + memset(&inp_mscMouseSettings, '\0', sizeof (MouseSpeedControl)); + +#if 0 + // if required, try to enable 2nd mouse + Shutdown2ndMouse(); + inp_i2ndMousePort = Clamp( inp_i2ndMousePort, 0L, 4L); + Startup2ndMouse(inp_i2ndMousePort); +#endif + + // clear button's buffer + memset( _abKeysPressed, 0, sizeof( _abKeysPressed)); + + // remember current status + inp_bInputEnabled = TRUE; + inp_bPollJoysticks = FALSE; +} + + +/* + * Disable direct input + */ +void CInput::DisableInput( void) +{ + // skip if allready disabled + if( !inp_bInputEnabled) return; + + assert(SDL_GetVideoSurface() != NULL); + + SDL_JoystickEventState(SDL_DISABLE); + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + + // show mouse on screen + SDL_ShowCursor(1); + if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON) + SDL_WM_GrabInput(SDL_GRAB_OFF); + + SDL_WarpMouse(inp_ptOldMousePos.x, inp_ptOldMousePos.y); + + // eventually disable 2nd mouse +#if 0 + Shutdown2ndMouse(); +#endif + + // remember current status + inp_bInputEnabled = FALSE; + inp_bPollJoysticks = FALSE; +} + + +// blank any queued mousemove events...SDLInput.cpp needs this when +// returning from the menus/console to game or the viewport will jump... +void CInput::ClearRelativeMouseMotion(void) +{ + mouse_relative_x = mouse_relative_y = 0; +} + + +/* + * Scan states of all available input sources + */ +void CInput::GetInput(BOOL bPreScan) +{ +// CTSingleLock sl(&csInput, TRUE); + + if (!inp_bInputEnabled) { + return; + } + + if (bPreScan && !inp_bAllowPrescan) { + return; + } + + SDL_Event event; + while (SE_SDL_InputEventPoll(&event)) { /* do nothing... */ } + + // if not pre-scanning + if (!bPreScan) { + // clear button's buffer + memset( inp_ubButtonsBuffer, 0, sizeof( inp_ubButtonsBuffer)); + + // for each Key + for (INDEX iKey=0; iKeyinp_fMousePrecisionTimeout) fSensitivity /= inp_fMousePrecisionFactor; + } + + static FLOAT fDXOld; + static FLOAT fDYOld; + static TIME tmOldDelta; + static CTimerValue tvBefore; + CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); + TIME tmNowDelta = (tvNow-tvBefore).GetSeconds(); + if (tmNowDelta<0.001f) { + tmNowDelta = 0.001f; + } + tvBefore = tvNow; + + FLOAT fDXSmooth = (fDXOld*tmOldDelta+fDX*tmNowDelta)/(tmOldDelta+tmNowDelta); + FLOAT fDYSmooth = (fDYOld*tmOldDelta+fDY*tmNowDelta)/(tmOldDelta+tmNowDelta); + fDXOld = fDX; + fDYOld = fDY; + tmOldDelta = tmNowDelta; + if (inp_bFilterMouse) { + fDX = fDXSmooth; + fDY = fDYSmooth; + } + + // get final mouse values + FLOAT fMouseRelX = +fDX*fSensitivity; + FLOAT fMouseRelY = -fDY*fSensitivity; + if (inp_bInvertMouse) { + fMouseRelY = -fMouseRelY; + } + FLOAT fMouseRelZ = _iMouseZ; + + // just interpret values as normal + inp_caiAllAxisInfo[1].cai_fReading = fMouseRelX; + inp_caiAllAxisInfo[2].cai_fReading = fMouseRelY; + inp_caiAllAxisInfo[3].cai_fReading = fMouseRelZ; + } else { + inp_caiAllAxisInfo[1].cai_fReading = 0.0; + inp_caiAllAxisInfo[2].cai_fReading = 0.0; + inp_caiAllAxisInfo[3].cai_fReading = 0.0; + } + +/* + // if not pre-scanning + if (!bPreScan) { + // detect wheel up/down movement + _bWheelDn = FALSE; + if (_iMouseZ>0) { + if (_bWheelUp) { + inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0x00; + } else { + inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0xFF; + _iMouseZ = ClampDn(_iMouseZ-120, 0); + } + } + _bWheelUp = inp_ubButtonsBuffer[KID_MOUSEWHEELUP]; + if (_iMouseZ<0) { + if (_bWheelDn) { + inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0x00; + } else { + inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0xFF; + _iMouseZ = ClampUp(_iMouseZ+120, 0); + } + } + _bWheelDn = inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN]; + } +*/ + + inp_bLastPrescan = bPreScan; + +// !!! FIXME +#if 0 + // readout 2nd mouse if enabled + if( _h2ndMouse!=NONE) + { + Poll2ndMouse(); + //CPrintF( "m2X: %4d, m2Y: %4d, m2B: 0x%02X\n", _i2ndMouseX, _i2ndMouseY, _i2ndMouseButtons); + + // handle 2nd mouse buttons + if( _i2ndMouseButtons & 2) inp_ubButtonsBuffer[KID_2MOUSE1] = 0xFF; + if( _i2ndMouseButtons & 1) inp_ubButtonsBuffer[KID_2MOUSE2] = 0xFF; + if( _i2ndMouseButtons & 4) inp_ubButtonsBuffer[KID_2MOUSE3] = 0xFF; + + // handle 2nd mouse movement + FLOAT fDX = _i2ndMouseX; + FLOAT fDY = _i2ndMouseY; + FLOAT fSensitivity = inp_f2ndMouseSensitivity; + + FLOAT fD = Sqrt(fDX*fDX+fDY*fDY); + if( inp_b2ndMousePrecision) { + static FLOAT _tm2Time = 0.0f; + if( fDinp_f2ndMousePrecisionTimeout) fSensitivity /= inp_f2ndMousePrecisionFactor; + } + + static FLOAT f2DXOld; + static FLOAT f2DYOld; + static TIME tm2OldDelta; + static CTimerValue tv2Before; + CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); + TIME tmNowDelta = (tvNow-tv2Before).GetSeconds(); + if( tmNowDelta<0.001f) tmNowDelta = 0.001f; + tv2Before = tvNow; + + FLOAT fDXSmooth = (f2DXOld*tm2OldDelta+fDX*tmNowDelta) / (tm2OldDelta+tmNowDelta); + FLOAT fDYSmooth = (f2DYOld*tm2OldDelta+fDY*tmNowDelta) / (tm2OldDelta+tmNowDelta); + f2DXOld = fDX; + f2DYOld = fDY; + tm2OldDelta = tmNowDelta; + if( inp_bFilter2ndMouse) { + fDX = fDXSmooth; + fDY = fDYSmooth; + } + + // get final mouse values + FLOAT fMouseRelX = +fDX*fSensitivity; + FLOAT fMouseRelY = -fDY*fSensitivity; + if( inp_bInvert2ndMouse) fMouseRelY = -fMouseRelY; + + // just interpret values as normal + inp_caiAllAxisInfo[4].cai_fReading = fMouseRelX; + inp_caiAllAxisInfo[5].cai_fReading = fMouseRelY; + } +#endif + + // if joystick polling is enabled + if (inp_bPollJoysticks || inp_bForceJoystickPolling) { + // scan all available joysticks + for( INDEX iJoy=0; iJoy iJoy); + assert(sticks != NULL); + assert(sticks[iJoy] != NULL); + + SDL_Joystick *stick = sticks[iJoy]; + + // for each available axis + for( INDEX iAxis=0; iAxis + +// !!! FIXME: rcg10142001 Most of CTSingleLock is platform-independent. + +CTCriticalSection::CTCriticalSection(void) +{ + LockCounter = 0; + cs_pvObject = (void *) SDL_CreateMutex(); + ASSERT(cs_pvObject != NULL); +} + +CTCriticalSection::~CTCriticalSection(void) +{ + SDL_DestroyMutex((SDL_mutex *) cs_pvObject); +} + +INDEX CTCriticalSection::Lock(void) +{ + LockCounter++; + if (LockCounter == 1) + SDL_LockMutex((SDL_mutex *) cs_pvObject); + return(LockCounter); +} + +INDEX CTCriticalSection::TryToLock(void) +{ + if (LockCounter > 0) // !!! race condition. Ironic, eh? + return(0); + Lock(); + return(1); +} + +INDEX CTCriticalSection::Unlock(void) +{ + if (LockCounter > 0) + { + LockCounter--; + if (LockCounter == 0) + SDL_UnlockMutex((SDL_mutex *) cs_pvObject); + } + + return(LockCounter); +} + +CTSingleLock::CTSingleLock(CTCriticalSection *pcs, BOOL bLock) : sl_cs(*pcs) +{ + // initially not locked + sl_bLocked = FALSE; + sl_iLastLockedIndex = -2; + // critical section must have index assigned + //ASSERT(sl_cs.cs_iIndex>=1||sl_cs.cs_iIndex==-1); + // if should lock immediately + if (bLock) { + Lock(); + } +} +CTSingleLock::~CTSingleLock(void) +{ + // if locked + if (sl_bLocked) { + // unlock + Unlock(); + } +} +void CTSingleLock::Lock(void) +{ + // must not be locked + ASSERT(!sl_bLocked); + ASSERT(sl_iLastLockedIndex==-2); + + // if not locked + if (!sl_bLocked) { + // lock + INDEX ctLocks = sl_cs.Lock(); + // if this mutex was not locked already +// if (ctLocks==1) { +// // check that locking in given order +// if (sl_cs.cs_iIndex!=-1) { +// ASSERT(_iLastLockedMutex=1) { + sl_bLocked = TRUE; + + // if this mutex was not locked already +// if (ctLocks==1) { +// // check that locking in given order +// if (sl_cs.cs_iIndex!=-1) { +// ASSERT(_iLastLockedMutex + +ULONG ThreadLocalGetCurrentTID(void) +{ + return(SDL_ThreadID()); +} // ThreadLocalGetCurrentTID + +// end of SDLThreadLocalStorage.cpp ... + + diff --git a/Sources/Engine/Base/SDL/SDLTimer.cpp b/Sources/Engine/Base/SDL/SDLTimer.cpp new file mode 100644 index 0000000..86a80bb --- /dev/null +++ b/Sources/Engine/Base/SDL/SDLTimer.cpp @@ -0,0 +1,16 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +/* rcg10072001 Moved stuff into this file. */ + +#include "SDL.h" +#include +#include + +void CTimer::Sleep(DWORD milliseconds) +{ + SDL_Delay(milliseconds); +} + +// end of SDLTimer.cpp ... + + diff --git a/Sources/Engine/Base/Scanner.l b/Sources/Engine/Base/Scanner.l index fe991d3..5db324f 100644 --- a/Sources/Engine/Base/Scanner.l +++ b/Sources/Engine/Base/Scanner.l @@ -13,6 +13,10 @@ #define YY_DECL int yylex (YYSTYPE *lvalp) #define yylval (*lvalp) +#ifdef __cplusplus +extern "C" { int yywrap(void); } +#endif + int yywrap(void) { // no more bufers @@ -113,8 +117,8 @@ PARAMCONTENT ([^\ \n\";]|(\\\ )) if (strParam.FindSubstr(strParamNo)!=-1) { _pShell->ErrorF("Parameter substitution recursion detected!"); } else { - INDEX ctFound=0; - for(;; ctFound++) { + INDEX ctFound; + for(ctFound=0;; ctFound++) { if (!_strCmd.ReplaceSubstr(strParamNo, strParam)) { break; } diff --git a/Sources/Engine/Base/Serial.cpp b/Sources/Engine/Base/Serial.cpp index 378f7f7..ad59291 100644 --- a/Sources/Engine/Base/Serial.cpp +++ b/Sources/Engine/Base/Serial.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include @@ -81,7 +81,7 @@ void CSerial::Reload(void) // if there is some error while reloading //} catch (char *strError) { // quit the application with error explanation - //FatalError(TRANS("Cannot reload file '%s':\n%s"), (CTString&)fnmOldName, strError); + //FatalError(TRANS("Cannot reload file '%s':\n%s"), (const char *) (CTString&)fnmOldName, strError); //} // if still here (no exceptions raised) diff --git a/Sources/Engine/Base/Shell.cpp b/Sources/Engine/Base/Shell.cpp index b6c1ff3..7a01142 100644 --- a/Sources/Engine/Base/Shell.cpp +++ b/Sources/Engine/Base/Shell.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -14,17 +14,17 @@ #include #include -template CDynamicArray; +template class CDynamicArray; // shell type used for undeclared symbols -extern INDEX _shell_istUndeclared = -1; +INDEX _shell_istUndeclared = -1; // pointer to global shell object CShell *_pShell = NULL; void *_pvNextToDeclare=NULL; // != NULL if declaring external symbol defined in exe code // define console variable for number of last console lines -extern INDEX con_iLastLines = 5; +INDEX con_iLastLines = 5; extern void yy_switch_to_buffer(YY_BUFFER_STATE); @@ -99,10 +99,10 @@ CDynamicStackArray _shell_afExtFloats; static const char *strCommandLine = ""; -ENGINE_API extern FLOAT tmp_af[10] = { 0 }; -ENGINE_API extern INDEX tmp_ai[10] = { 0 }; -ENGINE_API extern INDEX tmp_fAdd = 0.0f; -ENGINE_API extern INDEX tmp_i = 0; +FLOAT tmp_af[10] = { 0 }; +INDEX tmp_ai[10] = { 0 }; +INDEX tmp_fAdd = 0; +INDEX tmp_i = 0; void CShellSymbol::Clear(void) { @@ -175,7 +175,7 @@ void MakeAccessViolation(void* pArgs) *p=1; } -extern int _a=123; +int _a=123; void MakeStackOverflow(void* pArgs) { INDEX bDont = NEXTARGUMENT(INDEX); @@ -196,6 +196,7 @@ void MakeFatalError(void* pArgs) extern void ReportGlobalMemoryStatus(void) { +#ifdef PLATFORM_WIN32 CPrintF(TRANS("Global memory status...\n")); MEMORYSTATUS ms; @@ -211,13 +212,15 @@ extern void ReportGlobalMemoryStatus(void) DWORD dwMax; GetProcessWorkingSetSize(GetCurrentProcess(), &dwMin, &dwMax); CPrintF(TRANS(" Process working set: %dMB-%dMB\n\n"), dwMin/(1024*1024), dwMax/(1024*1024)); +#endif } static void MemoryInfo(void) { ReportGlobalMemoryStatus(); - _HEAPINFO hinfo; +#ifdef PLATFORM_WIN32 + _HEAPINFO hinfo; int heapstatus; hinfo._pentry = NULL; SLONG slTotalUsed = 0; @@ -245,6 +248,7 @@ static void MemoryInfo(void) } CPrintF( "Total used: %d bytes (%.2f MB) in %d blocks\n", slTotalUsed, slTotalUsed/1024.0f/1024.0f, ctUsed); CPrintF( "Total free: %d bytes (%.2f MB) in %d blocks\n", slTotalFree, slTotalFree/1024.0f/1024.0f, ctFree); +#endif } // get help for a shell symbol @@ -293,14 +297,14 @@ extern void PrintShellSymbolHelp(const CTString &strSymbol) try { CTString strHelp = GetShellSymbolHelp_t(strSymbol); if (strHelp!="") { - CPrintF("%s\n", strHelp); + CPrintF("%s\n", (const char *) strHelp); } else { - CPrintF( TRANS("No help found for '%s'.\n"), strSymbol); + CPrintF( TRANS("No help found for '%s'.\n"), (const char *) strSymbol); } // if failed } catch(char *strError) { // just print the error - CPrintF( TRANS("Cannot print help for '%s': %s\n"), strSymbol, strError); + CPrintF( TRANS("Cannot print help for '%s': %s\n"), (const char *) strSymbol, strError); } } @@ -331,23 +335,23 @@ extern void ListSymbolsByPattern(CTString strPattern) // print its declaration to the console if (st.st_sttType == STT_FUNCTION) { - CPrintF("void %s(void)", ss.ss_strName); + CPrintF("void %s(void)", (const char *) ss.ss_strName); } else if (st.st_sttType == STT_STRING) { - CPrintF("CTString %s = \"%s\"", ss.ss_strName, *(CTString*)ss.ss_pvValue); + CPrintF("CTString %s = \"%s\"", (const char *) ss.ss_strName, (const char *) (*(CTString*)ss.ss_pvValue)); } else if (st.st_sttType == STT_FLOAT) { - CPrintF("FLOAT %s = %g", ss.ss_strName, *(FLOAT*)ss.ss_pvValue); + CPrintF("FLOAT %s = %g", (const char *) ss.ss_strName, *(FLOAT*)ss.ss_pvValue); } else if (st.st_sttType == STT_INDEX) { - CPrintF("INDEX %s = %d (0x%08x)", ss.ss_strName, *(INDEX*)ss.ss_pvValue, *(INDEX*)ss.ss_pvValue); + CPrintF("INDEX %s = %d (0x%08x)", (const char *) ss.ss_strName, *(INDEX*)ss.ss_pvValue, *(INDEX*)ss.ss_pvValue); } else if (st.st_sttType == STT_ARRAY) { // get base type ShellType &stBase = _shell_ast[st.st_istBaseType]; if (stBase.st_sttType == STT_FLOAT) { - CPrintF("FLOAT %s[%d]", ss.ss_strName, st.st_ctArraySize); + CPrintF("FLOAT %s[%d]", (const char *) ss.ss_strName, st.st_ctArraySize); } else if (stBase.st_sttType == STT_INDEX) { - CPrintF("INDEX %s[%d]", ss.ss_strName, st.st_ctArraySize); + CPrintF("INDEX %s[%d]", (const char *) ss.ss_strName, st.st_ctArraySize); } else if (stBase.st_sttType == STT_STRING) { - CPrintF("CTString %s[%d]", ss.ss_strName, st.st_ctArraySize); + CPrintF("CTString %s[%d]", (const char *) ss.ss_strName, st.st_ctArraySize); } else { ASSERT(FALSE); } @@ -421,7 +425,7 @@ void LoadCommands(void) { // list all command files CDynamicStackArray afnmCmds; - MakeDirList( afnmCmds, CTString("Scripts\\Commands\\"), "*.ini", DLI_RECURSIVE); + MakeDirList( afnmCmds, CTString("Scripts\\Commands\\"), CTString("*.ini"), DLI_RECURSIVE); // for each file for(INDEX i=0; iErrorF("Symbol '%s' is not suitable to be a command", ssNew.ss_strName); + _pShell->ErrorF("Symbol '%s' is not suitable to be a command", (const char *) ssNew.ss_strName); } } } @@ -527,32 +531,38 @@ void CShell::Initialize(void) DeclareSymbol("const INDEX YES;", (void*)&_bTRUE); DeclareSymbol("const INDEX NO;", (void*)&_bFALSE); - DeclareSymbol("user void LoadCommands(void);", &LoadCommands); - DeclareSymbol("user void ListSymbols(void);", &ListSymbols); - DeclareSymbol("user void MemoryInfo(void);", &MemoryInfo); - DeclareSymbol("user void MakeAccessViolation(INDEX);", &MakeAccessViolation); - DeclareSymbol("user void MakeStackOverflow(INDEX);", &MakeStackOverflow); - DeclareSymbol("user void MakeFatalError(INDEX);", &MakeFatalError); - DeclareSymbol("persistent user INDEX con_iLastLines;", &con_iLastLines); - DeclareSymbol("persistent user FLOAT tmp_af[10];", &tmp_af); - DeclareSymbol("persistent user INDEX tmp_ai[10];", &tmp_ai); - DeclareSymbol("persistent user INDEX tmp_i;", &tmp_i); - DeclareSymbol("persistent user FLOAT tmp_fAdd;", &tmp_fAdd); + DeclareSymbol("user void LoadCommands(void);", (void *)&LoadCommands); + DeclareSymbol("user void ListSymbols(void);", (void *)&ListSymbols); + DeclareSymbol("user void MemoryInfo(void);", (void *)&MemoryInfo); + DeclareSymbol("user void MakeAccessViolation(INDEX);", (void *)&MakeAccessViolation); + DeclareSymbol("user void MakeStackOverflow(INDEX);", (void *)&MakeStackOverflow); + DeclareSymbol("user void MakeFatalError(INDEX);", (void *)&MakeFatalError); + DeclareSymbol("persistent user INDEX con_iLastLines;", (void *)&con_iLastLines); + DeclareSymbol("persistent user FLOAT tmp_af[10];", (void *)&tmp_af); + DeclareSymbol("persistent user INDEX tmp_ai[10];", (void *)&tmp_ai); + DeclareSymbol("persistent user INDEX tmp_i;", (void *)&tmp_i); + DeclareSymbol("persistent user FLOAT tmp_fAdd;", (void *)&tmp_fAdd); - DeclareSymbol("user void Echo(CTString);", &Echo); - DeclareSymbol("user CTString UndecorateString(CTString);", &UndecorateString); - DeclareSymbol("user INDEX Matches(CTString, CTString);", &MatchStrings); - DeclareSymbol("user CTString LoadString(CTString);", &MyLoadString); - DeclareSymbol("user void SaveString(CTString, CTString);", &MySaveString); - DeclareSymbol("user CTString RemoveSubstring(CTString, CTString);", &RemoveSubstringCfunc); - DeclareSymbol("user CTString ToUpper(CTString);", &ToUpperCfunc); - DeclareSymbol("user CTString ToLower(CTString);", &ToLowerCfunc); + DeclareSymbol("user void Echo(CTString);", (void *)&Echo); + DeclareSymbol("user CTString UndecorateString(CTString);", (void *)&UndecorateString); + DeclareSymbol("user INDEX Matches(CTString, CTString);", (void *)&MatchStrings); + DeclareSymbol("user CTString LoadString(CTString);", (void *)&MyLoadString); + DeclareSymbol("user void SaveString(CTString, CTString);", (void *)&MySaveString); + DeclareSymbol("user CTString RemoveSubstring(CTString, CTString);", (void *)&RemoveSubstringCfunc); + DeclareSymbol("user CTString ToUpper(CTString);", (void *)&ToUpperCfunc); + DeclareSymbol("user CTString ToLower(CTString);", (void *)&ToLowerCfunc); } static BOOL _iParsing = 0; // Declare a symbol in the shell. +/* rcg10072001 Added second version of DeclareSymbol()... */ void CShell::DeclareSymbol(const CTString &strDeclaration, void *pvValue) +{ + DeclareSymbol((const char *) strDeclaration, pvValue); +} + +void CShell::DeclareSymbol(const char *strDeclaration, void *pvValue) { // synchronize access to shell CTSingleLock slShell(&sh_csShell, TRUE); @@ -578,7 +588,7 @@ void CShell::DeclareSymbol(const CTString &strDeclaration, void *pvValue) // don't use that value for parsing any more _pvNextToDeclare = NULL; -}; +} // Execute command(s). void CShell::Execute(const CTString &strCommands) @@ -813,6 +823,7 @@ void CShell::ErrorF(const char *strFormat, ...) va_start(arg, strFormat); CTString strBuffer; strBuffer.VPrintF(strFormat, arg); + va_end(arg); // print it to the main console CPrintF(strBuffer); @@ -843,7 +854,7 @@ void CShell::StorePersistentSymbols(const CTFileName &fnScript) continue; } - char *strUser = (ss.ss_ulFlags & SSF_USER)?"user ":""; + const char *strUser = (ss.ss_ulFlags & SSF_USER)?"user ":""; // get its type ShellType &st = _shell_ast[ss.ss_istType]; @@ -856,39 +867,39 @@ void CShell::StorePersistentSymbols(const CTFileName &fnScript) if (stBase.st_sttType==STT_FLOAT) { // dump all members as floats for(INDEX i=0; i #include diff --git a/Sources/Engine/Base/Shell_internal.h b/Sources/Engine/Base/Shell_internal.h index 7989de4..c5cc016 100644 --- a/Sources/Engine/Base/Shell_internal.h +++ b/Sources/Engine/Base/Shell_internal.h @@ -23,6 +23,17 @@ enum ShellTypeType { // data type structure struct ShellType { + ShellType() : + st_sttType(STT_ILLEGAL), + st_ctArraySize(0), + st_istBaseType(0), + st_istFirstArgument(0), + st_istLastArgument(0), + st_istNextInArguments(0), + st_istPrevInArguments(0) + { + } + enum ShellTypeType st_sttType; INDEX st_ctArraySize; // number of members if an array diff --git a/Sources/Engine/Base/StackDump.cpp b/Sources/Engine/Base/StackDump.cpp index 915fc92..5370626 100644 --- a/Sources/Engine/Base/StackDump.cpp +++ b/Sources/Engine/Base/StackDump.cpp @@ -1,11 +1,15 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include +#if (!defined PLATFORM_WIN32) +#error You probably should not try to compile this. +#endif + extern ULONG _ulEngineBuildMajor; extern ULONG _ulEngineBuildMinor; diff --git a/Sources/Engine/Base/Statistics.cpp b/Sources/Engine/Base/Statistics.cpp index 927897d..8e0ad84 100644 --- a/Sources/Engine/Base/Statistics.cpp +++ b/Sources/Engine/Base/Statistics.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -8,9 +8,9 @@ #include #include -template CStaticArray; -template CStaticArray; -template CStaticArray; +template class CStaticArray; +template class CStaticArray; +template class CStaticArray; // one globaly used stats report CStatForm _sfStats; diff --git a/Sources/Engine/Base/Stream.cpp b/Sources/Engine/Base/Stream.cpp index dd68da9..938dd24 100644 --- a/Sources/Engine/Base/Stream.cpp +++ b/Sources/Engine/Base/Stream.cpp @@ -1,14 +1,17 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" -#include -#include +#include +#include #include -#include -#include -#include +// !!! FIXME : rcg10162001 Need this anymore, since _findfirst() is abstracted? +#ifdef PLATFORM_WIN32 +#include +#endif + +#include #include #include @@ -19,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -28,22 +32,23 @@ // default size of page used for stream IO operations (4Kb) ULONG _ulPageSize = 0; -// maximum lenght of file that can be saved (default: 128Mb) +// maximum length of file that can be saved (default: 128Mb) ULONG _ulMaxLenghtOfSavingFile = (1UL<<20)*128; -extern INDEX fil_bPreferZips = FALSE; +INDEX fil_bPreferZips = FALSE; // set if current thread has currently enabled stream handling -static _declspec(thread) BOOL _bThreadCanHandleStreams = FALSE; +THREADLOCAL(BOOL, _bThreadCanHandleStreams, FALSE); // list of currently opened streams -static _declspec(thread) CListHead *_plhOpenedStreams = NULL; - ULONG _ulVirtuallyAllocatedSpace = 0; ULONG _ulVirtuallyAllocatedSpaceTotal = 0; +THREADLOCAL(CListHead *, _plhOpenedStreams, NULL); // global string with application path CTFileName _fnmApplicationPath; // global string with filename of the started application CTFileName _fnmApplicationExe; +// global string with user-specific writable directory. +CTFileName _fnmUserDir; // global string with current MOD path CTFileName _fnmMod; // global string with current name (the parameter that is passed on cmdline) @@ -104,10 +109,15 @@ static CTFileName _fnmApp; void InitStreams(void) { // obtain information about system +// !!! FIXME: Move this into an abstraction of some sort... +#ifdef PLATFORM_WIN32 SYSTEM_INFO siSystemInfo; GetSystemInfo( &siSystemInfo); // and remember page size _ulPageSize = siSystemInfo.dwPageSize*16; // cca. 64kB on WinNT/Win95 +#else + _ulPageSize = PAGESIZE; +#endif // keep a copy of path for setting purposes _fnmApp = _fnmApplicationPath; @@ -118,7 +128,9 @@ void InitStreams(void) LoadStringVar(CTString("DefaultMod.txt"), _fnmMod); } - CPrintF(TRANS("Current mod: %s\n"), _fnmMod==""?TRANS(""):(CTString&)_fnmMod); + CPrintF(TRANS("Current mod: %s\n"), + (_fnmMod=="") ? TRANS("") : + (const char *) (CTString&)_fnmMod); // if there is a mod active if (_fnmMod!="") { // load mod's include/exclude lists @@ -163,54 +175,49 @@ void InitStreams(void) } _findclose( hFile ); + CDynamicArray *files; + + files = _pFileSystem->FindFiles(_fnmApplicationPath, "*.gro"); + int max = files->Count(); + int i; + + // for each .gro file in the directory + for (i = 0; i < max; i++) { + // add it to active set + UNZIPAddArchive( _fnmApplicationPath+((*files)[i]) ); + } + delete files; + // if there is a mod active if (_fnmMod!="") { // for each group file in mod directory - struct _finddata_t c_file; - long hFile; - hFile = _findfirst(_fnmApplicationPath+_fnmMod+"*.gro", &c_file); - BOOL bOK = (hFile!=-1); - while(bOK) { - if (CTString(c_file.name).Matches("*.gro")) { - // add it to active set - UNZIPAddArchive(_fnmApplicationPath+_fnmMod+c_file.name); - } - bOK = _findnext(hFile, &c_file)==0; - } - _findclose( hFile ); + files = _pFileSystem->FindFiles(_fnmApplicationPath+_fnmMod, "*.gro"); + max = files->Count(); + for (i = 0; i < max; i++) { + UNZIPAddArchive( _fnmApplicationPath + _fnmMod + ((*files)[i]) ); + } + delete files; } // if there is a CD path if (_fnmCDPath!="") { // for each group file on the CD - struct _finddata_t c_file; - long hFile; - hFile = _findfirst(_fnmCDPath+"*.gro", &c_file); - BOOL bOK = (hFile!=-1); - while(bOK) { - if (CTString(c_file.name).Matches("*.gro")) { - // add it to active set - UNZIPAddArchive(_fnmCDPath+c_file.name); - } - bOK = _findnext(hFile, &c_file)==0; + files = _pFileSystem->FindFiles(_fnmCDPath, "*.gro"); + max = files->Count(); + for (i = 0; i < max; i++) { + UNZIPAddArchive( _fnmCDPath + ((*files)[i]) ); } - _findclose( hFile ); + delete files; // if there is a mod active if (_fnmMod!="") { // for each group file in mod directory - struct _finddata_t c_file; - long hFile; - hFile = _findfirst(_fnmCDPath+_fnmMod+"*.gro", &c_file); - BOOL bOK = (hFile!=-1); - while(bOK) { - if (CTString(c_file.name).Matches("*.gro")) { - // add it to active set - UNZIPAddArchive(_fnmCDPath+_fnmMod+c_file.name); - } - bOK = _findnext(hFile, &c_file)==0; + files = _pFileSystem->FindFiles(_fnmCDPath+_fnmMod, "*.gro"); + max = files->Count(); + for (i = 0; i < max; i++) { + UNZIPAddArchive( _fnmCDPath + _fnmMod + ((*files)[i]) ); } - _findclose( hFile ); + delete files; } } @@ -225,7 +232,8 @@ void InitStreams(void) } CPrintF("\n"); - LoadFileList(_afnmNoCRC, CTFILENAME("Data\\NoCRC.lst")); + const char *dirsep = CFileSystem::GetDirSeparator(); + LoadFileList(_afnmNoCRC, CTFILENAME("Data" + dirsep + "NoCRC.lst")); _pShell->SetINDEX(CTString("sys")+"_iCPU"+"Misc", 1); } @@ -268,6 +276,7 @@ void CTStream::DisableStreamHandling(void) _plhOpenedStreams = NULL; } +#ifdef PLATFORM_WIN32 int CTStream::ExceptionFilter(DWORD dwCode, _EXCEPTION_POINTERS *pExceptionInfoPtrs) { // If the exception is not a page fault, exit. @@ -312,6 +321,7 @@ void CTStream::ExceptionFatalError(void) { FatalError( GetWindowsError( GetLastError()) ); } +#endif /* * Throw an exception of formatted string. @@ -320,13 +330,20 @@ void CTStream::Throw_t(char *strFormat, ...) // throws char * { const SLONG slBufferSize = 256; char strFormatBuffer[slBufferSize]; - char strBuffer[slBufferSize]; + static char *strBuffer = NULL; + + // ...and yes, you are screwed if you call this in a catch block and + // try to access the previous text again. + delete[] strBuffer; + strBuffer = new char[slBufferSize]; + // add the stream description to the format string - _snprintf(strFormatBuffer, slBufferSize, "%s (%s)", strFormat, strm_strStreamDescription); + _snprintf(strFormatBuffer, slBufferSize, "%s (%s)", strFormat, (const char *) strm_strStreamDescription); // format the message in buffer va_list arg; va_start(arg, strFormat); // variable arguments start after this argument _vsnprintf(strBuffer, slBufferSize, strFormatBuffer, arg); + va_end(arg); throw strBuffer; } @@ -379,7 +396,7 @@ void CTStream::GetLine_t(char *strBuffer, SLONG slBufferSize, char cDelimiter /* INDEX iLetters = 0; // test if EOF reached if(AtEOF()) { - ThrowF_t(TRANS("EOF reached, file %s"), strm_strStreamDescription); + ThrowF_t(TRANS("EOF reached, file %s"), (const char *) strm_strStreamDescription); } // get line from istream FOREVER @@ -466,6 +483,7 @@ void CTStream::FPrintF_t(const char *strFormat, ...) // throw char * va_list arg; va_start(arg, strFormat); // variable arguments start after this argument _vsnprintf(strBuffer, slBufferSize, strFormat, arg); + va_end(arg); // print the buffer PutString_t(strBuffer); } @@ -504,11 +522,12 @@ void CTStream::ExpectID_t(const CChunkID &cidExpected) // throws char * void CTStream::ExpectKeyword_t(const CTString &strKeyword) // throw char * { // check that the keyword is present - for(INDEX iKeywordChar=0; iKeywordChar<(INDEX)strlen(strKeyword); iKeywordChar++) { + const INDEX total = (INDEX)strlen(strKeyword); + for(INDEX iKeywordChar=0; iKeywordChar>chKeywordChar; if (chKeywordChar!=strKeyword[iKeywordChar]) { - ThrowF_t(TRANS("Expected keyword %s not found"), strKeyword); + ThrowF_t(TRANS("Expected keyword %s not found"), (const char *) strKeyword); } } } @@ -821,7 +840,7 @@ void CTStream::DictionaryPreload_t(void) fnm.fnm_pserPreloaded = _pModelStock->Obtain_t(fnm); } } catch (char *strError) { - CPrintF( TRANS("Cannot preload %s: %s\n"), (CTString&)fnm, strError); + CPrintF( TRANS("Cannot preload %s: %s\n"), (const char *) (CTString&)fnm, strError); } } } @@ -883,9 +902,10 @@ void CTFileStream::Open_t(const CTFileName &fnFileName, CTStream::OpenMode om/*= if (!_bThreadCanHandleStreams) { // error ::ThrowF_t(TRANS("Cannot open file `%s', stream handling is not enabled for this thread"), - (CTString&)fnFileName); + (const char *) (CTString&)fnFileName); } + // check parameters ASSERT(strlen(fnFileName)>0); // check that the file is not open @@ -972,7 +992,7 @@ void CTFileStream::Create_t(const CTFileName &fnFileName, if(fstrm_pFile == NULL) { // throw exception - Throw_t(TRANS("Cannot create file `%s' (%s)"), (CTString&)fnmFullFileName, + Throw_t(TRANS("Cannot create file `%s' (%s)"), (const char *) (CTString&)fnmFullFileName, strerror(errno)); } // if file creation was successfull, set stream description to file name @@ -1367,7 +1387,7 @@ SLONG GetFileTimeStamp_t(const CTFileName &fnm) // try to open file for reading file_handle = _open( fnmExpanded, _O_RDONLY | _O_BINARY); if(file_handle==-1) { - ThrowF_t(TRANS("Cannot open file '%s' for reading"), CTString(fnm)); + ThrowF_t(TRANS("Cannot open file '%s' for reading"), (const char *) CTString(fnm)); return -1; } struct stat statFileStatus; @@ -1457,6 +1477,7 @@ static INDEX ExpandFilePath_read(ULONG ulType, const CTFileName &fnmFile, CTFile { // search for the file in zips INDEX iFileInZip = UNZIPGetFileIndex(fnmFile); + const BOOL userdir_not_basedir = (_fnmUserDir != _fnmApplicationPath); // if a mod is active if (_fnmMod!="") { @@ -1542,6 +1563,44 @@ static INDEX ExpandFilePath_read(ULONG ulType, const CTFileName &fnmFile, CTFile return EFP_NONE; } + +// rcg01042002 User dir and children may need to be created on the fly... +static void VerifyDirsExist(const char *_path) +{ + char *path = (char *) AllocMemory(strlen(_path) + 1); + strcpy(path, _path); + const char *dirsep = CFileSystem::GetDirSeparator(); + + // skip first dirsep. This assumes an absolute path and some other + // fundamentals of how a filepath is specified. + char *ptr = strstr(path, dirsep); + ASSERT(ptr != NULL); + if (ptr == NULL) + return; + + for (ptr = strstr(ptr+1, dirsep); ptr != NULL; ptr = strstr(ptr+1, dirsep)) { + char ch = *ptr; + *ptr = '\0'; // terminate the path. + if (!_pFileSystem->IsDirectory(path)) { + if (_pFileSystem->Exists(path)) { + CPrintF("Expected %s to be a directory, but it's a file!\n", path); + break; + } else { + CPrintF("Creating directory %s ...\n", path); + _mkdir(path); + if (!_pFileSystem->IsDirectory(path)) { + CPrintF("Creation of directory %s FAILED!\n", path); + break; + } + } + } + + *ptr = ch; // put path char back... + } + + FreeMemory(path); +} + // Expand a file's filename to full path INDEX ExpandFilePath(ULONG ulType, const CTFileName &fnmFile, CTFileName &fnmExpanded) { diff --git a/Sources/Engine/Base/Stream.h b/Sources/Engine/Base/Stream.h index 1f0a584..d517416 100644 --- a/Sources/Engine/Base/Stream.h +++ b/Sources/Engine/Base/Stream.h @@ -357,12 +357,14 @@ ENGINE_API INDEX ExpandFilePath(ULONG ulType, const CTFileName &fnmFile, CTFileN ENGINE_API void MakeDirList( CDynamicStackArray &adeDir, const CTFileName &fnmDir, // directory to list - const CTString &strPattern, // pattern for each file to match ("" matches all) + const CTFileName &fnmPattern, // pattern for each file to match ("" matches all) ULONG ulFlags // additional flags ); // global string with application path ENGINE_API extern CTFileName _fnmApplicationPath; +// global string with user-specific writable directory. +ENGINE_API extern CTFileName _fnmUserDir; // global string with current MOD path ENGINE_API extern CTFileName _fnmMod; // global string with current name (the parameter that is passed on cmdline) diff --git a/Sources/Engine/Base/Synchronization.h b/Sources/Engine/Base/Synchronization.h index 0a8f668..e09e0c8 100644 --- a/Sources/Engine/Base/Synchronization.h +++ b/Sources/Engine/Base/Synchronization.h @@ -7,9 +7,10 @@ #endif // intra-process mutex (only used by thread of same process) -// NOTE: mutex has no interface - it is locked using CTSingleLock class CTCriticalSection { public: + // !!! FIXME : rcg10142001 This would be better with a real subclass, + // !!! FIXME : and not void pointers. void *cs_pvObject; // object is internal to implementation INDEX cs_iIndex; // index of mutex used to prevent deadlock with assertions // use numbers from 1 and above for deadlock control, or -1 for no deadlock control @@ -18,6 +19,10 @@ public: INDEX Lock(void); INDEX TryToLock(void); INDEX Unlock(void); + +private: + ULONG LockCounter; + ULONG owner; }; // lock object for locking a mutex with automatic unlocking @@ -34,6 +39,6 @@ public: ENGINE_API void Unlock(void); }; - #endif /* include-once check. */ + diff --git a/Sources/Engine/Base/ThreadLocalStorage.h b/Sources/Engine/Base/ThreadLocalStorage.h new file mode 100644 index 0000000..c217df7 --- /dev/null +++ b/Sources/Engine/Base/ThreadLocalStorage.h @@ -0,0 +1,147 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#ifndef SE_INCL_THREADLOCALSTORAGE_H +#define SE_INCL_THREADLOCALSTORAGE_H +#ifdef PRAGMA_ONCE + #pragma once +#endif + +#ifdef SINGLE_THREADED +#define THREADLOCAL(type, name, defval) type name = defval +#define EXTERNTHREADLOCAL(type, name) extern type name +#elif (defined _MSC_VER) +#define THREADLOCAL(type, name, defval) type __declspec(thread) name = defval +#define EXTERNTHREADLOCAL(type, name) extern type __declspec(thread) name +#else +#define THREADLOCAL(type, name, defval) CThreadLocalStorage name(defval) +#define EXTERNTHREADLOCAL(type, name) extern CThreadLocalStorage name + +#include + +// !!! FIXME : There is a race condition if a thread is making space for +// !!! FIXME : itself at the same time another thread is touching this class. +// !!! FIXME : Generally, this won't be a problem, if you are careful about +// !!! FIXME : new threads accessing an instance of CThreadLocalStorage for +// !!! FIXME : the first time. I haven't added mutexes, since it would slow +// !!! FIXME : the template class down. If you need it, either do some +// !!! FIXME : external locking, or subclass CThreadLocalStorage to include +// !!! FIXME : a locking mechanism. + +// !!! FIXME: 15 years later: why didn't I just use a pthread_key? + +ULONG ThreadLocalGetCurrentTID(void); + +template +class CThreadLocalStorage +{ +protected: + + typedef struct + { + ULONG tid; + T data; + } LocalElements; + + size_t FindThreadIndex(void) + { + ULONG tid = ThreadLocalGetCurrentTID(); + for (size_t i = 0; i < array_size; i++) + { + if (elements[i].tid == tid) + return(i); + } // for + + LocalElements *_elements = new LocalElements[array_size + 1]; + for (size_t i = 0; i < array_size; i++) + { + _elements[i].data = elements[i].data; + _elements[i].tid = elements[i].tid; + } // for + + delete[] elements; + elements = _elements; + elements[array_size].data = defval; + elements[array_size].tid = tid; + return(array_size++); + } // FindThreadIndex + +private: + LocalElements *elements; + size_t array_size; + T defval; + +public: + CThreadLocalStorage(T _defval) + : elements(NULL), + array_size(0), + defval(_defval) + { + } // Constructor + + + ~CThreadLocalStorage(void) + { + delete[] elements; + } // Destructor + + T &operator =(T val) + { + elements[FindThreadIndex()].data = val; + return(val); + } // operator = + + T &operator->(void) + { + return(elements[FindThreadIndex()].data); + } // operator -> + + operator T &(void) + { + return(elements[FindThreadIndex()].data); + } // operator T & +}; + + +#if 0 +// a test program. +static CThreadLocalStorage tlocal(0); + +void *other_thread(void *arg) +{ + tlocal = 10; + + while (true) + { + printf("2nd thread: %d.\n", (int) tlocal); + sleep(1); + } + + return(NULL); +} + + +int main(int argc, char **argv) +{ + pthread_t thread; + + tlocal = 5; + + pthread_create(&thread, NULL, other_thread, NULL); + + while (true) + { + printf("main thread: %d.\n", (int) tlocal); + sleep(1); + } + + return(0); +} +#endif + +#endif // !defined SINGLE_THREADED + +#endif // include-once blocker. + + +// end of ThreadLocalStorage.h ... + diff --git a/Sources/Engine/Base/Timer.cpp b/Sources/Engine/Base/Timer.cpp index 7ebde07..a17c9f5 100644 --- a/Sources/Engine/Base/Timer.cpp +++ b/Sources/Engine/Base/Timer.cpp @@ -1,10 +1,11 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include +#include //rcg10242001 #include #include @@ -14,9 +15,23 @@ #include #include -// Read the Pentium TimeStampCounter +//#if ( (USE_PORTABLE_C) || (PLATFORM_UNIX) ) +//#define USE_GETTIMEOFDAY 1 +//#endif + +#if USE_GETTIMEOFDAY +#include +#endif + +// Read the Pentium TimeStampCounter (or something like that). static inline __int64 ReadTSC(void) { +#if USE_GETTIMEOFDAY + struct timeval tv; + gettimeofday(&tv, NULL); + return( (((__int64) tv.tv_sec) * 1000000) + ((__int64) tv.tv_usec) ); + +#elif (defined __MSVC_INLINE__) __int64 mmRet; __asm { rdtsc @@ -24,14 +39,32 @@ static inline __int64 ReadTSC(void) mov dword ptr [mmRet+4],edx } return mmRet; + +#elif (defined __GNU_INLINE__) + __int64 mmRet; + __asm__ __volatile__ ( + "rdtsc \n\t" + "movl %%eax, 0(%%esi) \n\t" + "movl %%edx, 4(%%esi) \n\t" + : + : "S" (&mmRet) + : "memory", "eax", "edx" + ); + return(mmRet); + +#else + #error Please implement for your platform/compiler. +#endif } // link with Win-MultiMedia +#ifdef _MSC_VER #pragma comment(lib, "winmm.lib") +#endif // current game time always valid for the currently active task -static _declspec(thread) TIME _CurrentTickTimer = 0.0f; +THREADLOCAL(TIME, _CurrentTickTimer, 0.0f); // CTimer implementation @@ -76,9 +109,30 @@ void CTimer_TimerFunc_internal(void) // streams and to group file before enabling that! // CTSTREAM_BEGIN { +#ifdef SINGLE_THREADED + + // rcg10272001 experimenting here... + static CTimerValue highResQuantum((double) _pTimer->TickQuantum); + + CTimerValue upkeep = _pTimer->GetHighPrecisionTimer() - _pTimer->tm_InitialTimerUpkeep; + TIME t = upkeep.GetSeconds(); + + if (t < _pTimer->TickQuantum) // not time to do an update, yet. + return; + + while (t >= _pTimer->TickQuantum) { + _pTimer->tm_InitialTimerUpkeep += highResQuantum; + _pTimer->tm_RealTimeTimer += _pTimer->TickQuantum; + t -= _pTimer->TickQuantum; + } + +#else + // increment the 'real time' timer _pTimer->tm_RealTimeTimer += _pTimer->TickQuantum; +#endif + // get the current time for real and in ticks CTimerValue tvTimeNow = _pTimer->GetHighPrecisionTimer(); TIME tmTickNow = _pTimer->tm_RealTimeTimer; @@ -104,6 +158,10 @@ void CTimer_TimerFunc_internal(void) // } CTSTREAM_END; } + +// !!! FIXME : rcg10192001 Abstract this! +#if (!defined SINGLE_THREADED) +#ifdef PLATFORM_WIN32 void __stdcall CTimer_TimerFunc(UINT uID, UINT uMsg, ULONG dwUser, ULONG dw1, ULONG dw2) { // access to the list of handlers must be locked @@ -111,7 +169,18 @@ void __stdcall CTimer_TimerFunc(UINT uID, UINT uMsg, ULONG dwUser, ULONG dw1, UL // handle all timers CTimer_TimerFunc_internal(); } - +#elif (defined PLATFORM_UNIX) +#include "SDL.h" +Uint32 CTimer_TimerFunc_SDL(Uint32 interval) +{ + // access to the list of handlers must be locked + CTSingleLock slHooks(&_pTimer->tm_csHooks, TRUE); + // handle all timers + CTimer_TimerFunc_internal(); + return(interval); +} +#endif +#endif #pragma inline_depth() @@ -121,6 +190,7 @@ static INDEX _aiTries[MAX_MEASURE_TRIES]; // Get processor speed in Hertz static __int64 GetCPUSpeedHz(void) { +#ifdef PLATFORM_WIN32 // get the frequency of the 'high' precision timer __int64 llTimerFrequency; BOOL bPerformanceCounterPresent = QueryPerformanceFrequency((LARGE_INTEGER*)&llTimerFrequency); @@ -138,8 +208,7 @@ static __int64 GetCPUSpeedHz(void) __int64 llSpeedMeasured; // try to measure 10 times - INDEX iSet=0; - for( ; iSet<10; iSet++) + for( INDEX iSet=0; iSet<10; iSet++) { // one time has several tries for( iTry=0; iTry3) FatalError(TRANS("Problem with initializing multimedia timer - please try again.")); } +#endif // !defined SINGLE_THREADED } /* @@ -267,19 +423,29 @@ CTimer::CTimer(BOOL bInterrupt /*=TRUE*/) */ CTimer::~CTimer(void) { + // !!! FIXME : abstract this. +#if (!defined SINGLE_THREADED) +#ifdef PLATFORM_WIN32 ASSERT(_pTimer == this); // destroy timer if (tm_bInterrupt) { - ASSERT(tm_TimerID!=NULL); + ASSERT(tm_TimerID); ULONG rval = timeKillEvent(tm_TimerID); ASSERT(rval == TIMERR_NOERROR); } // check that all handlers have been removed ASSERT(tm_lhHooks.IsEmpty()); +#else + SDL_SetTimer(0, NULL); +#endif + +#endif + // clear global pointer _pTimer = NULL; + } /* @@ -315,6 +481,13 @@ void CTimer::HandleTimerHandlers(void) CTimer_TimerFunc_internal(); } +/* + * Get current timer value of high precision timer. + */ +CTimerValue CTimer::GetHighPrecisionTimer(void) +{ + return ReadTSC(); +} /* * Set the real time tick value. @@ -377,7 +550,7 @@ void CTimer::DisableLerp(void) CTString TimeToString(FLOAT fTime) { CTString strTime; - int iSec = floor(fTime); + int iSec = (int) floor(fTime); int iMin = iSec/60; iSec = iSec%60; int iHou = iMin/60; diff --git a/Sources/Engine/Base/Timer.h b/Sources/Engine/Base/Timer.h index 396af8f..6b5a68e 100644 --- a/Sources/Engine/Base/Timer.h +++ b/Sources/Engine/Base/Timer.h @@ -23,7 +23,7 @@ public: inline CTimerValue(__int64 llValue) : tv_llValue(llValue) {}; public: /* Constructor. */ - inline CTimerValue(void) {}; + inline CTimerValue(void) : tv_llValue((__int64) -1) {} /* Constructor from seconds. */ inline CTimerValue(double dSeconds); /* Clear timer value (set it to zero). */ @@ -118,13 +118,20 @@ public: inline FLOAT GetLerpFactor2(void) const { return tm_fLerpFactor2; }; /* Get current timer value of high precision timer. */ - inline CTimerValue GetHighPrecisionTimer(void) { - __int64 mmRet; - _asm rdtsc - _asm mov dword ptr [mmRet+0],eax - _asm mov dword ptr [mmRet+4],edx - return mmRet; - }; + CTimerValue GetHighPrecisionTimer(void); + + /* + * rcg10072001 + * put current process to sleep for at least (milliseconds) milliseconds. + * Note that many platforms can't sleep less than 10 milliseconds, and + * most will not revive your thread at the exact moment you requested. + * So don't use this on life support machines. :) + */ + void Sleep(DWORD milliseconds); + +#ifdef SINGLE_THREADED + CTimerValue tm_InitialTimerUpkeep; // don't touch. +#endif }; // pointer to global timer object diff --git a/Sources/Engine/Base/Timer.inl b/Sources/Engine/Base/Timer.inl index eb17b9a..d9c28de 100644 --- a/Sources/Engine/Base/Timer.inl +++ b/Sources/Engine/Base/Timer.inl @@ -7,7 +7,7 @@ /* Constructor from seconds. */ inline CTimerValue::CTimerValue(double fSeconds) { - tv_llValue = __int64(fSeconds*_pTimer->tm_llPerformanceCounterFrequency); + tv_llValue = (__int64) (fSeconds*_pTimer->tm_llPerformanceCounterFrequency); } /* Clear timer value (set it to zero). */ inline void CTimerValue::Clear(void) diff --git a/Sources/Engine/Base/Translation.cpp b/Sources/Engine/Base/Translation.cpp index 1bbb88a..0fc1dec 100644 --- a/Sources/Engine/Base/Translation.cpp +++ b/Sources/Engine/Base/Translation.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Base/Types.h b/Sources/Engine/Base/Types.h index bdc196c..1c7254b 100644 --- a/Sources/Engine/Base/Types.h +++ b/Sources/Engine/Base/Types.h @@ -6,12 +6,16 @@ #pragma once #endif +#ifdef _MSC_VER +#define __MSVC_INLINE__ +#endif + #include #include typedef signed long int SLONG; typedef signed short int SWORD; -typedef signed char SBYTE; +typedef signed char SBYTE; typedef signed int SINT; typedef unsigned long int ULONG; @@ -20,27 +24,194 @@ typedef unsigned char UBYTE; typedef unsigned int UINT; -#ifdef PLATFORM_UNIX /* rcg10042001 */ - #define __forceinline inline +#if __POWERPC__ /* rcg03232004 */ + #define PLATFORM_BIGENDIAN 1 + #define PLATFORM_LITTLEENDIAN 0 +#else + #define PLATFORM_BIGENDIAN 0 + #define PLATFORM_LITTLEENDIAN 1 +#endif - #if (!defined MAX_PATH) - #define MAX_PATH 256 +// Mac symbols have an underscore prepended... +#if PLATFORM_MACOSX + #define ASMSYM(x) "_" #x +#else + #define ASMSYM(x) #x +#endif + +#ifdef PLATFORM_UNIX /* rcg10042001 */ + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include // for PAGESIZE... + #include + + // check for legacy defines... + #if (defined __ICC) + #if (!defined __INTEL_COMPILER) + #define __INTEL_COMPILER __ICC + #endif #endif - typedef long long __int64; + #if ((defined __GNUC__) && (!defined __GNU_INLINE__)) + #define __GNU_INLINE__ + #endif + + #if (defined __INTEL_COMPILER) + #if ((!defined __GNU_INLINE__) && (!defined __MSVC_INLINE__)) + #error Please define __GNU_INLINE__ or __MSVC_INLINE__ with Intel C++. + #endif + + #if ((defined __GNU_INLINE__) && (defined __MSVC_INLINE__)) + #error Define either __GNU_INLINE__ or __MSVC_INLINE__ with Intel C++. + #endif + #endif + + #ifndef PAGESIZE + #define PAGESIZE 4096 + #endif + + #define FAR + #define __forceinline inline + #define __stdcall + #define __cdecl + #define WINAPI + + #if (!defined MAX_PATH) + #if (defined MAXPATHLEN) + #define MAX_PATH MAXPATHLEN + #else + #define MAX_PATH 256 + #endif + #endif + + #define _O_BINARY 0 + #define _O_RDONLY O_RDONLY + #define _S_IWRITE S_IWRITE + #define _S_IREAD S_IREAD + + #if (!defined __INTEL_COMPILER) + #define _alloca alloca + #endif + + #define _CrtCheckMemory() 1 + #define _mkdir(x) mkdir(x, S_IRWXU) + #define _open open + #define _close close + #define _strupr strupr + #define stricmp strcasecmp + #define strcmpi strcasecmp + #define strnicmp strncasecmp + #define _vsnprintf vsnprintf + #define _snprintf snprintf + #define _set_new_handler std::set_new_handler + #define _finite finite + + inline void _RPT_do(const char *type, const char *fmt, ...) + { +#if 0 + #if (!defined NDEBUG) + va_list ap; + fprintf(stderr, "_RPT (%s): ", type); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fflush(stderr); + #endif +#endif + } // _RPT0 + + #define _CRT_WARN "_CRT_WARN" + #define _CRT_ERROR "_CRT_ERROR" + #define _CRT_ASSER "_CRT_ASSERT" + + #define _RPT0(type, fmt) _RPT_do(type, fmt) + #define _RPT1(type, fmt, a1) _RPT_do(type, fmt, a1) + #define _RPT2(type, fmt, a1, a2) _RPT_do(type, fmt, a1, a2) + #define _RPT3(type, fmt, a1, a2, a3) _RPT_do(type, fmt, a1, a2, a3) + #define _RPT4(type, fmt, a1, a2, a3, a4) _RPT_do(type, fmt, a1, a2, a3, a4) + + #define STUBBED(txt) fprintf(stderr, "STUB: %s in %s, line %d.\n", txt, __FILE__, __LINE__) + + // !!! FIXME : Should inline functions go somewhere else? + + inline void _strupr(char *str) + { + if (str != NULL) + { + for (char *ptr = str; *ptr; ptr++) + *ptr = toupper(*ptr); + } + } + + inline ULONG _rotl(ULONG ul, int bits) + { + #if (defined USE_PORTABLE_C) + // This is not fast at all, but it works. + for (int i = 0; i < bits; i++) + ul = ( (ul << 1) | ((ul & 0x80000000) >> 31) ); + return(ul); + + #elif (defined __GNU_INLINE__) + // This, on the other hand, is wicked fast. :) + __asm__ __volatile__ ( + "roll %%cl, %%eax \n\t" + : "=a" (ul) + : "a" (ul), "c" (bits) + : "cc" + ); + return(ul); + + #elif (defined __MSVC_INLINE__) + // MSVC version for Intel C++... + __asm + { + mov eax, dword ptr [ul] + mov ecx, dword ptr [bits] + rol eax, cl + mov dword ptr [ul], eax + } + return(ul); + + #else + #error need inline asm for your platform. + #endif + } + + typedef unsigned long long __uint64; + #if (!defined __INTEL_COMPILER) + typedef long long __int64; + #endif + + typedef UBYTE BYTE; + typedef unsigned short WORD; typedef unsigned long int DWORD; typedef signed long int LONG; + typedef void *LPVOID; + typedef char *LPSTR; + typedef signed long int WPARAM; + typedef signed long int LPARAM; + typedef signed short int SHORT; typedef void *HWND; /* !!! FIXME this sucks. */ typedef void *HINSTANCE; /* !!! FIXME this sucks. */ typedef void *HGLRC; /* !!! FIXME this sucks. */ + typedef void *HGLOBAL; /* !!! FIXME this sucks. */ typedef ULONG COLORREF; /* !!! FIXME this sucks. */ typedef struct { LONG x; LONG y; - } POINT; + } POINT, *LPPOINT; typedef struct { @@ -49,6 +220,20 @@ typedef unsigned int UINT; LONG right; LONG bottom; } RECT; + + #define WAVE_FORMAT_PCM 0x0001 + + typedef struct + { + SWORD wFormatTag; + WORD nChannels; + DWORD nSamplesPerSec; + WORD wBitsPerSample; + WORD nBlockAlign; + DWORD nAvgBytesPerSec; + WORD cbSize; + } WAVEFORMATEX; + #endif @@ -93,10 +278,18 @@ typedef long int INDEX; // for indexed values and quantities #define ANGLE_270 (270.0f) #define ANGLE_360 (360.0f) -// you need for this! + +// Stupid GCC bug. +#if (__GNUC__ >= 3) + #define _offsetof(cl, mbr) (((size_t)&(((cl *)0x0004)->mbr)) - 0x0004) +#else + // you need for this! + #define _offsetof(cl, mbr) offsetof(cl, mbr) +#endif + #define structptr(structure, member, ptr) \ ( (struct structure *) ( ((UBYTE *)(ptr)) - \ - offsetof(struct structure, member)) ) + _offsetof(struct structure, member)) ) // standard types @@ -396,6 +589,9 @@ typedef BSPCutter FLOATbspcutter3D; template inline void Clear(cType &t) { t.cType::Clear(); }; +template +inline void Clear(cType *t) { t->cType::Clear(); }; + // specific clearing functions for built-in types inline void Clear(signed long int sli) {}; inline void Clear(unsigned long int uli) {}; @@ -404,7 +600,101 @@ inline void Clear(float i) {}; inline void Clear(double i) {}; inline void Clear(void *pv) {}; -#define SYMBOLLOCATOR(symbol) +// These macros are not safe to use unless data is UNSIGNED! +#define BYTESWAP16_unsigned(x) ((((x)>>8)&0xff)+ (((x)<<8)&0xff00)) +#define BYTESWAP32_unsigned(x) (((x)>>24) + (((x)>>8)&0xff00) + (((x)<<8)&0xff0000) + ((x)<<24)) + +// rcg03242004 +#if PLATFORM_LITTLEENDIAN + #define BYTESWAP(x) +#else + + static inline void BYTESWAP(UWORD &val) + { + #if __POWERPC__ + __asm__ __volatile__ ( + "lhbrx %0,0,%1" + : "=r" (val) + : "r" (&val) + ); + #else + val = BYTESWAP16_unsigned(val); + #endif + } + + static inline void BYTESWAP(SWORD &val) + { + // !!! FIXME: reinterpret_cast ? + UWORD uval = *((UWORD *) &val); + BYTESWAP(uval); + val = *((SWORD *) &uval); + } + + static inline void BYTESWAP(ULONG &val) + { + #if __POWERPC__ + __asm__ __volatile__ ( + "lwbrx %0,0,%1" + : "=r" (val) + : "r" (&val) + ); + #else + val = BYTESWAP32_unsigned(val); + #endif + } + + static inline void BYTESWAP(SLONG &val) + { + // !!! FIXME: reinterpret_cast ? + ULONG uval = *((ULONG *) &val); + BYTESWAP(uval); + val = *((SLONG *) &uval); + } + + static inline void BYTESWAP(BOOL &val) + { + // !!! FIXME: reinterpret_cast ? + ULONG uval = *((ULONG *) &val); + BYTESWAP(uval); + val = *((BOOL *) &uval); + } + + static inline void BYTESWAP(FLOAT &val) + { + // !!! FIXME: reinterpret_cast ? + ULONG uval = *((ULONG *) &val); + BYTESWAP(uval); + val = *((FLOAT *) &uval); + } + + static inline void BYTESWAP(__uint64 &val) + { + ULONG l = (ULONG) (val & 0xFFFFFFFF); + ULONG h = (ULONG) ((val >> 32) & 0xFFFFFFFF); + BYTESWAP(l); + BYTESWAP(h); + val = ( (((__uint64) (l)) << 32) | + ((__uint64) (h)) ); + } + + static inline void BYTESWAP(__int64 &val) + { + // !!! FIXME: reinterpret_cast ? + __uint64 uval = *((__uint64 *) &val); + BYTESWAP(uval); + val = *((__int64 *) &uval); + } + + static inline void BYTESWAP(DOUBLE &val) + { + // !!! FIXME: reinterpret_cast ? + __uint64 uval = *((__uint64 *) &val); + BYTESWAP(uval); + val = *((DOUBLE *) &uval); + } + + +#endif #endif /* include-once check. */ diff --git a/Sources/Engine/Base/Unix/UnixDynamicLoader.cpp b/Sources/Engine/Base/Unix/UnixDynamicLoader.cpp new file mode 100644 index 0000000..de0f300 --- /dev/null +++ b/Sources/Engine/Base/Unix/UnixDynamicLoader.cpp @@ -0,0 +1,122 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +/* rcg10072001 Implemented. */ + +#include + +#include +#include + +class CUnixDynamicLoader : public CDynamicLoader +{ +public: + CUnixDynamicLoader(const char *libname); + virtual ~CUnixDynamicLoader(void); + virtual void *FindSymbol(const char *sym); + virtual const char *GetError(void); + +protected: + void DoOpen(const char *lib); + void SetError(void); + void *module; + CTString *err; +}; + + +CDynamicLoader *CDynamicLoader::GetInstance(const char *libname) +{ + return(new CUnixDynamicLoader(libname)); +} + + +void CUnixDynamicLoader::SetError(void) +{ + const char *errmsg = ::dlerror(); + delete err; + err = NULL; + + if (errmsg != NULL) + { + CPrintF("CUnixDynamicLoader error: %s\n", errmsg); + err = new CTString(errmsg); + } +} + + +const char *CUnixDynamicLoader::GetError(void) +{ + return((err) ? (const char *) (*err) : NULL); +} + + +void *CUnixDynamicLoader::FindSymbol(const char *sym) +{ + //printf("Looking for symbol %s\n", sym); + void *retval = NULL; + if (module != NULL) { + retval = ::dlsym(module, sym); + SetError(); + } + + return(retval); +} + + +void CUnixDynamicLoader::DoOpen(const char *lib) +{ + module = ::dlopen(lib, RTLD_LAZY | RTLD_GLOBAL); + SetError(); +} + + +CTFileName CDynamicLoader::ConvertLibNameToPlatform(const char *libname) +{ + #if PLATFORM_MACOSX + const char *DLLEXTSTR = ".dylib"; + #else + const char *DLLEXTSTR = ".so"; + #endif + CTFileName fnm = CTString(libname); + CTString libstr((strncmp("lib", fnm.FileName(), 3) == 0) ? "" : "lib"); + return(fnm.FileDir() + libstr + fnm.FileName() + DLLEXTSTR); +} + + +CUnixDynamicLoader::CUnixDynamicLoader(const char *libname) + : module(NULL), + err(NULL) +{ + if (libname == NULL) { + DoOpen(NULL); + } else { + CTFileName fnm = ConvertLibNameToPlatform(libname); + + // Always try to dlopen from inside the game dirs before trying + // system libraries... + if (fnm.FileDir() == "") { + char buf[MAX_PATH]; + _pFileSystem->GetExecutablePath(buf, sizeof (buf)); + CTFileName fnmDir = CTString(buf); + fnmDir = fnmDir.FileDir() + fnm; + DoOpen(fnmDir); + if (module != NULL) { + return; + } + } + + DoOpen(fnm); + } +} + + +CUnixDynamicLoader::~CUnixDynamicLoader(void) +{ + delete err; + if (module != NULL) + ::dlclose(module); +} + + +// end of UnixDynamicLoader.cpp ... + + diff --git a/Sources/Engine/Base/Unix/UnixFileSystem.cpp b/Sources/Engine/Base/Unix/UnixFileSystem.cpp new file mode 100644 index 0000000..871dc46 --- /dev/null +++ b/Sources/Engine/Base/Unix/UnixFileSystem.cpp @@ -0,0 +1,345 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +/* rcg10142001 Implemented. */ + + +// !!! FIXME: rcg10142001 This should really be using CTStrings... + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +ENGINE_API CFileSystem *_pFileSystem = NULL; + + +class CUnixFileSystem : public CFileSystem +{ +public: + CUnixFileSystem(const char *argv0, const char *gamename); + virtual ~CUnixFileSystem(void); + virtual void GetExecutablePath(char *buf, ULONG bufSize); + virtual void GetUserDirectory(char *buf, ULONG bufSize); + virtual CDynamicArray *FindFiles(const char *dir, + const char *wildcard); +protected: + char *exePath; + char *userDir; +}; + + +const char *CFileSystem::GetDirSeparator(void) +{ + return("/"); +} + + +BOOL CFileSystem::IsDummyFile(const char *fname) +{ + return( (strcmp(fname, ".") == 0) || (strcmp(fname, "..") == 0) ); +} + + +BOOL CFileSystem::Exists(const char *fname) +{ + struct stat s; + if (stat(fname, &s) == -1) + return(FALSE); + + return(TRUE); +} + + +BOOL CFileSystem::IsDirectory(const char *fname) +{ + struct stat s; + if (stat(fname, &s) == -1) + return(FALSE); + + return(S_ISDIR(s.st_mode) ? TRUE : FALSE); +} + + +CFileSystem *CFileSystem::GetInstance(const char *argv0, const char *gamename) +{ + return(new CUnixFileSystem(argv0, gamename)); +} + + +static char *copyEnvironmentVariable(const char *varname) +{ + const char *envr = getenv(varname); + char *retval = NULL; + + if (envr != NULL) + { + retval = new char[strlen(envr) + 1]; + strcpy(retval, envr); + } + + return(retval); +} + + +static char *getUserDirByUID(void) +{ + uid_t uid = getuid(); + struct passwd *pw; + char *retval = NULL; + + pw = getpwuid(uid); + if ((pw != NULL) && (pw->pw_dir != NULL)) + { + retval = new char[strlen(pw->pw_dir) + 1]; + strcpy(retval, pw->pw_dir); + } + + return(retval); +} + +// !!! FIXME: This could stand to use CTFileNames ... +static char *calcExePath(const char *_argv0) +{ + char *ptr; + char *retval = NULL; + char *argv0 = new char[strlen(_argv0) + 1]; + strcpy(argv0, _argv0); /* _argv0 may be read-only... */ + + ptr = strrchr(argv0, '/'); + if (ptr != NULL) // explicit path specified? We're done. + { + retval = new char[strlen(argv0) + 1]; + strcpy(retval, argv0); + } + + // If there isn't a path on argv0, then look through the $PATH for it... + else + { + char *envr; + char *start; + char *exe; + + envr = copyEnvironmentVariable("PATH"); + if (!envr) + { + delete[] argv0; + return(NULL); + } + + start = envr; + do + { + ptr = strchr(start, ':'); + if (ptr) + *ptr = '\0'; + + exe = new char[strlen(start) + strlen(argv0) + 2]; + strcpy(exe, start); + if (exe[strlen(exe) - 1] != '/') // make sure there's a dir sep... + strcat(exe, "/"); + + strcat(exe, argv0); // add on the binary name... + + if (access(exe, X_OK) != 0) // Not our binary? + delete[] exe; + + else // matching executable file found on path...this is it. + { + retval = new char[strlen(exe) + 1]; + strcpy(retval, exe); + delete[] exe; + break; + } + + start = ptr + 1; + } while (ptr != NULL); + + delete[] envr; + } + + delete[] argv0; + + if (retval != NULL) + { + char full[MAXPATHLEN]; + realpath(retval, full); + delete[] retval; + retval = new char[strlen(full) + 1]; + strcpy(retval, full); + } + + return(retval); +} + + +// !!! FIXME: cut and paste from Engine.cpp ! --ryan. +// reverses string +static void StrRev( char *str) { + char ctmp; + char *pch0 = str; + char *pch1 = str+strlen(str)-1; + while( pch1>pch0) { + ctmp = *pch0; + *pch0 = *pch1; + *pch1 = ctmp; + pch0++; + pch1--; + } +} + + +// FIXME: This is such a lame hack. --ryan. +static void calcModExt(char *full, const char *exePath, const char *gamename) +{ + strcat(full, gamename); + + // bah...duplication from Engine.cpp ... + char strDirPath[MAX_PATH] = ""; + char strTmpPath[MAX_PATH] = ""; + strncpy(strTmpPath, exePath, sizeof(strTmpPath)-1); + strDirPath[sizeof(strTmpPath)-1] = 0; + // remove name from application path + StrRev(strTmpPath); + // find last backslash + char *pstr = strchr( strTmpPath, '/'); + if( pstr==NULL) { + // not found - path is just "\" + strcpy( strTmpPath, "/"); + pstr = strTmpPath; + } + // remove 'debug' from app path if needed + if( strnicmp( pstr, "/gubed", 6)==0) pstr += 6; + if( *pstr == '/') pstr++; + char *pstrFin = strchr( pstr, '/'); + if( pstrFin==NULL) { + strcpy( pstr, "/"); + pstrFin = pstr; + } + // copy that to the path + StrRev(pstrFin); + strncpy( strDirPath, pstrFin, sizeof(strDirPath)-1); + strDirPath[sizeof(strDirPath)-1] = 0; + strcat(strDirPath, "/ModExt.txt"); + + if (access(strDirPath, F_OK) == 0) + { + FILE *in = fopen(strDirPath, "rb"); + int rc = fread(strTmpPath, 1, 30, in); + if (rc > 0) + { + strTmpPath[rc] = '\0'; + strcat(full, strTmpPath); + } + } + + strcat(full, "/"); +} + + +CUnixFileSystem::CUnixFileSystem(const char *argv0, const char *gamename) + : exePath(NULL), + userDir(NULL) +{ + exePath = calcExePath(argv0); + if (exePath == NULL) + { + exePath = new char[strlen(argv0) + 3]; + strcpy(exePath, "./"); // (*shrug*) + strcat(exePath, argv0); + } + + + userDir = copyEnvironmentVariable("HOME"); + if (userDir == NULL) + userDir = getUserDirByUID(); + + char full[MAXPATHLEN]; + realpath(userDir, full); + delete[] userDir; + + if (full[strlen(full) - 1] != '/') + strcat(full, "/"); + + // make sure it ends with a dir separator! + #if PLATFORM_MACOSX + strcat(full, "Library/"); + mkdir(full, S_IRWXU); // don't care if this fails. We'll catch it later. + strcat(full, "Application Support/"); + mkdir(full, S_IRWXU); // don't care if this fails. We'll catch it later. + strcat(full, "Serious Sam/"); + #else + strcat(full, ".serious/"); + #endif + + if (!Exists(full)) { + if (mkdir(full, S_IRWXU) == -1) { + FatalError("User dir creation failed! (%s)\n", strerror(errno)); + } + } + + calcModExt(full, exePath, gamename); + if (!Exists(full)) { + if (mkdir(full, S_IRWXU) == -1) { + FatalError("User dir creation failed! (%s)\n", strerror(errno)); + } + } + + userDir = new char[strlen(full) + 1]; + strcpy(userDir, full); +} + + +CUnixFileSystem::~CUnixFileSystem(void) +{ + delete[] exePath; + delete[] userDir; +} + + +void CUnixFileSystem::GetExecutablePath(char *buf, ULONG bufSize) +{ + buf[bufSize - 1] = '\0'; // just in case. + strncpy(buf, exePath, bufSize); +} + + +void CUnixFileSystem::GetUserDirectory(char *buf, ULONG bufSize) +{ + buf[bufSize - 1] = '\0'; // just in case. + strncpy(buf, userDir, bufSize); +} + + +CDynamicArray *CUnixFileSystem::FindFiles(const char *dir, + const char *wildcard) +{ + CDynamicArray *retval = new CDynamicArray; + DIR *d = opendir(dir); + + if (d != NULL) + { + struct dirent *dent; + while ((dent = readdir(d)) != NULL) + { + CTString str(dent->d_name); + if (str.Matches(wildcard)) + *retval->New() = str; + } + closedir(d); + } + + return(retval); +} + +// end of UnixFileSystem.cpp ... + + + diff --git a/Sources/Engine/Base/Unix/UnixSynchronization.cpp b/Sources/Engine/Base/Unix/UnixSynchronization.cpp new file mode 100644 index 0000000..07dc8f9 --- /dev/null +++ b/Sources/Engine/Base/Unix/UnixSynchronization.cpp @@ -0,0 +1,156 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#include +#include +#include + +#include "Engine/StdH.h" +#include + +CTCriticalSection::CTCriticalSection(void) +{ + cs_pvObject = (void *) new pthread_mutex_t; + pthread_mutex_init((pthread_mutex_t *) cs_pvObject, NULL); + LockCounter = 0; + owner = 0; +} + +CTCriticalSection::~CTCriticalSection(void) +{ + pthread_mutex_destroy((pthread_mutex_t *) cs_pvObject); + delete (pthread_mutex_t *) cs_pvObject; +} + +INDEX CTCriticalSection::Lock(void) +{ + if (owner == pthread_self()) + return(++LockCounter); + + pthread_mutex_lock((pthread_mutex_t *) cs_pvObject); + owner = pthread_self(); + return(++LockCounter); +} + +INDEX CTCriticalSection::TryToLock(void) +{ + if (owner == pthread_self()) + return(++LockCounter); + + if (pthread_mutex_trylock((pthread_mutex_t *) cs_pvObject) == EBUSY) + return(0); + + owner = pthread_self(); + return(++LockCounter); +} + +INDEX CTCriticalSection::Unlock(void) +{ + if (owner == pthread_self()) + { + if (LockCounter > 0) + { + if (--LockCounter == 0) + { + pthread_mutex_unlock((pthread_mutex_t *) cs_pvObject); + owner = 0; + } + } + } + + return(LockCounter); +} + +CTSingleLock::CTSingleLock(CTCriticalSection *pcs, BOOL bLock) : sl_cs(*pcs) +{ + // initially not locked + sl_bLocked = FALSE; + sl_iLastLockedIndex = -2; + // critical section must have index assigned + //ASSERT(sl_cs.cs_iIndex>=1||sl_cs.cs_iIndex==-1); + // if should lock immediately + if (bLock) { + Lock(); + } +} +CTSingleLock::~CTSingleLock(void) +{ + // if locked + if (sl_bLocked) { + // unlock + Unlock(); + } +} +void CTSingleLock::Lock(void) +{ + // must not be locked + ASSERT(!sl_bLocked); + ASSERT(sl_iLastLockedIndex==-2); + + // if not locked + if (!sl_bLocked) { + // lock + INDEX ctLocks = sl_cs.Lock(); + // if this mutex was not locked already +// if (ctLocks==1) { +// // check that locking in given order +// if (sl_cs.cs_iIndex!=-1) { +// ASSERT(_iLastLockedMutex=1) { + sl_bLocked = TRUE; + + // if this mutex was not locked already +// if (ctLocks==1) { +// // check that locking in given order +// if (sl_cs.cs_iIndex!=-1) { +// ASSERT(_iLastLockedMutex #include #include @@ -83,7 +83,7 @@ struct EndOfDir { SWORD eod_swEntriesInDir; SLONG eod_slSizeOfDir; SLONG eod_slDirOffsetInFile; - SWORD eod_swCommentLenght; + SWORD eod_swCommentLength; // follows: // zipfile comment (variable size) }; @@ -180,9 +180,11 @@ void CZipHandle::Clear(void) void CZipHandle::ThrowZLIBError_t(int ierr, const CTString &strDescription) { ThrowF_t(TRANS("(%s/%s) %s - ZLIB error: %s - %s"), - (const CTString&)*zh_zeEntry.ze_pfnmArchive, - (const CTString&)zh_zeEntry.ze_fnm, - strDescription, GetZlibError(ierr), zh_zstream.msg); + (const char *) (const CTString&)*zh_zeEntry.ze_pfnmArchive, + (const char *) (const CTString&)zh_zeEntry.ze_fnm, + (const char *) strDescription, + (const char *) GetZlibError(ierr), + (const char *) zh_zstream.msg); } // all files in all active zip archives @@ -203,13 +205,15 @@ void ConvertSlashes(char *p) } } +#define READ_ZIPFIELD(f, x) { fread(&x, sizeof(x), 1, f); BYTESWAP(x); } + // read directory of a zip archive and add all files in it to active set void ReadZIPDirectory_t(CTFileName *pfnmZip) { FILE *f = fopen(*pfnmZip, "rb"); if (f==NULL) { - ThrowF_t(TRANS("%s: Cannot open file (%s)"), (CTString&)*pfnmZip, strerror(errno)); + ThrowF_t(TRANS("%s: Cannot open file (%s)"), (const char *) (CTString&)*pfnmZip, strerror(errno)); } // start at the end of file, minus expected minimum overhead fseek(f, 0, SEEK_END); @@ -226,22 +230,30 @@ void ReadZIPDirectory_t(CTFileName *pfnmZip) for(; iPos>iMinPos; iPos--) { // read signature fseek(f, iPos, SEEK_SET); - int slSig; + SLONG slSig; fread(&slSig, sizeof(slSig), 1, f); + BYTESWAP(slSig); // if this is the sig if (slSig==SIGNATURE_EOD) { // read directory end - fread(&eod, sizeof(eod), 1, f); + READ_ZIPFIELD(f, eod.eod_swDiskNo); + READ_ZIPFIELD(f, eod.eod_swDirStartDiskNo); + READ_ZIPFIELD(f, eod.eod_swEntriesInDirOnThisDisk); + READ_ZIPFIELD(f, eod.eod_swEntriesInDir); + READ_ZIPFIELD(f, eod.eod_slSizeOfDir); + READ_ZIPFIELD(f, eod.eod_slDirOffsetInFile); + READ_ZIPFIELD(f, eod.eod_swCommentLength); + // if multi-volume zip if (eod.eod_swDiskNo!=0||eod.eod_swDirStartDiskNo!=0 ||eod.eod_swEntriesInDirOnThisDisk!=eod.eod_swEntriesInDir) { // fail - ThrowF_t(TRANS("%s: Multi-volume zips are not supported"), (CTString&)*pfnmZip); + ThrowF_t(TRANS("%s: Multi-volume zips are not supported"), (const char *) (CTString&)*pfnmZip); } // check against empty zips if (eod.eod_swEntriesInDir<=0) { // fail - ThrowF_t(TRANS("%s: Empty zip"), (CTString&)*pfnmZip); + ThrowF_t(TRANS("%s: Empty zip"), (const char *) (CTString&)*pfnmZip); } // all ok bEODFound = TRUE; @@ -251,7 +263,7 @@ void ReadZIPDirectory_t(CTFileName *pfnmZip) // if eod not found if (!bEODFound) { // fail - ThrowF_t(TRANS("%s: Cannot find 'end of central directory'"), (CTString&)*pfnmZip); + ThrowF_t(TRANS("%s: Cannot find 'end of central directory'"), (const char *) (CTString&)*pfnmZip); } // check if the zip is from a mod @@ -265,26 +277,44 @@ void ReadZIPDirectory_t(CTFileName *pfnmZip) // for each file for (INDEX iFile=0; iFileslMaxFileName) { - ThrowF_t(TRANS("%s: Too long filepath in zip"), (CTString&)*pfnmZip); + ThrowF_t(TRANS("%s: Too long filepath in zip"), (const char *) (CTString&)*pfnmZip); } if (fh.fh_swFileNameLen<=0) { - ThrowF_t(TRANS("%s: Invalid filepath length in zip"), (CTString&)*pfnmZip); + ThrowF_t(TRANS("%s: Invalid filepath length in zip"), (const char *) (CTString&)*pfnmZip); } fread(strBuffer, fh.fh_swFileNameLen, 1, f); @@ -299,7 +329,7 @@ void ReadZIPDirectory_t(CTFileName *pfnmZip) if (fh.fh_slUncompressedSize!=0 ||fh.fh_slCompressedSize!=0) { ThrowF_t(TRANS("%s/%s: Invalid directory"), - (CTString&)*pfnmZip, strBuffer); + (const char *) (CTString&)*pfnmZip, strBuffer); } // if the file is real file @@ -324,7 +354,8 @@ void ReadZIPDirectory_t(CTFileName *pfnmZip) ze.ze_bStored = FALSE; } else { ThrowF_t(TRANS("%s/%s: Only 'deflate' compression is supported"), - (CTString&)*ze.ze_pfnmArchive, ze.ze_fnm); + (const char *) (CTString&)*ze.ze_pfnmArchive, + (const char *) ze.ze_fnm); } } } @@ -332,11 +363,11 @@ void ReadZIPDirectory_t(CTFileName *pfnmZip) // if error reading if (ferror(f)) { // fail - ThrowF_t(TRANS("%s: Error reading central directory"), (CTString&)*pfnmZip); + ThrowF_t(TRANS("%s: Error reading central directory"), (const char *) (CTString&)*pfnmZip); } // report that file was read - CPrintF(TRANS(" %s: %d files\n"), (CTString&)*pfnmZip, ctFiles++); + CPrintF(TRANS(" %s: %d files\n"), (const char *) (CTString&)*pfnmZip, ctFiles++); } // add one zip archive to current active set @@ -449,7 +480,7 @@ void UNZIPReadDirectoriesReverse_t(void) // if there were errors if (strAllErrors!="") { // report them - ThrowF_t("%s", strAllErrors); + ThrowF_t("%s", (const char *) strAllErrors); } } @@ -537,13 +568,13 @@ INDEX UNZIPOpen_t(const CTFileName &fnm) // if not found if (pze==NULL) { // fail - ThrowF_t(TRANS("File not found: %s"), (const CTString&)fnm); + ThrowF_t(TRANS("File not found: %s"), (const char *) (const CTString&)fnm); } // for each existing handle BOOL bHandleFound = FALSE; - INDEX iHandle=1; - for (; iHandle<_azhHandles.Count(); iHandle++) { + INDEX iHandle; + for (iHandle=1; iHandle<_azhHandles.Count(); iHandle++) { // if unused if (!_azhHandles[iHandle].zh_bOpen) { // use that one @@ -570,23 +601,34 @@ INDEX UNZIPOpen_t(const CTFileName &fnm) // clear the handle zh.Clear(); // fail - ThrowF_t(TRANS("Cannot open '%s': %s"), (const CTString&)*pze->ze_pfnmArchive, + ThrowF_t(TRANS("Cannot open '%s': %s"), (const char *) (const CTString&)*pze->ze_pfnmArchive, strerror(errno)); } // seek to the local header of the entry fseek(zh.zh_fFile, zh.zh_zeEntry.ze_slDataOffset, SEEK_SET); // read the sig - int slSig; + SLONG slSig; fread(&slSig, sizeof(slSig), 1, zh.zh_fFile); + BYTESWAP(slSig); // if this is not the expected sig if (slSig!=SIGNATURE_LFH) { // fail ThrowF_t(TRANS("%s/%s: Wrong signature for 'local file header'"), - (CTString&)*zh.zh_zeEntry.ze_pfnmArchive, zh.zh_zeEntry.ze_fnm); + (const char *) (CTString&)*zh.zh_zeEntry.ze_pfnmArchive, (const char *) zh.zh_zeEntry.ze_fnm); } // read the header LocalFileHeader lfh; - fread(&lfh, sizeof(lfh), 1, zh.zh_fFile); + READ_ZIPFIELD(zh.zh_fFile, lfh.lfh_swVersionToExtract); + READ_ZIPFIELD(zh.zh_fFile, lfh.lfh_swGPBFlag); + READ_ZIPFIELD(zh.zh_fFile, lfh.lfh_swCompressionMethod); + READ_ZIPFIELD(zh.zh_fFile, lfh.lfh_swModFileTime); + READ_ZIPFIELD(zh.zh_fFile, lfh.lfh_swModFileDate); + READ_ZIPFIELD(zh.zh_fFile, lfh.lfh_slCRC32); + READ_ZIPFIELD(zh.zh_fFile, lfh.lfh_slCompressedSize); + READ_ZIPFIELD(zh.zh_fFile, lfh.lfh_slUncompressedSize); + READ_ZIPFIELD(zh.zh_fFile, lfh.lfh_swFileNameLen); + READ_ZIPFIELD(zh.zh_fFile, lfh.lfh_swExtraFieldLen); + // determine exact compressed data position zh.zh_zeEntry.ze_slDataOffset = ftell(zh.zh_fFile)+lfh.lfh_swFileNameLen+lfh.lfh_swExtraFieldLen; diff --git a/Sources/Engine/Base/Updateable.cpp b/Sources/Engine/Base/Updateable.cpp index 6795c89..6c4234f 100644 --- a/Sources/Engine/Base/Updateable.cpp +++ b/Sources/Engine/Base/Updateable.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Base/Win32/Win32DynamicLoader.cpp b/Sources/Engine/Base/Win32/Win32DynamicLoader.cpp new file mode 100644 index 0000000..a0af2fa --- /dev/null +++ b/Sources/Engine/Base/Win32/Win32DynamicLoader.cpp @@ -0,0 +1,89 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +/* rcg10072001 Implemented. */ + +#include +#include + +class CWin32DynamicLoader : public CDynamicLoader +{ +public: + CWin32DynamicLoader(const char *libname); + virtual ~CWin32DynamicLoader(void); + virtual void *FindSymbol(const char *sym); + virtual const char *GetError(void); + +protected: + void SetError(void); + HMODULE module; + CTString *err; +}; + + +CDynamicLoader *CDynamicLoader::GetInstance(const char *libname) +{ + return(new CWin32DynamicLoader(libname)); +} + + +void CWin32DynamicLoader::SetError(void) +{ + char *errmsg = ::GetWindowsError(::GetLastError()); + delete err; + err = NULL; + + if (errmsg != NULL) + err = new CTString(errmsg); +} + + +const char *CWin32DynamicLoader::GetError(void) +{ + return((err) ? (const char *) (*err) : NULL); +} + + +void *CWin32DynamicLoader::FindSymbol(const char *sym) +{ + void *retval = NULL; + if (module != NULL) { + retval = ::GetProcAddress(module, sym); + if (retval == NULL) + SetError(); + } + + return(retval); +} + + +CTFileName CDynamicLoader::ConvertLibNameToPlatform(const char *libname) +{ + return(CTFileName(CTString(libname))); +} + + +CWin32DynamicLoader::CWin32DynamicLoader(const char *libname) + : module(NULL), + err(NULL) +{ + CTFileName fnm(libname); + if (stricmp(fnm.FileExt(), ".dll") != 0) + fnm += ".dll"; + + module = ::LoadLibrary((const char *) fnm); + if (module == NULL) + SetError(); +} + + +CWin32DynamicLoader::~CWin32DynamicLoader(void) +{ + delete err; + if (module != NULL) + ::FreeLibrary(module); +} + + +// end of Win32DynamicLoader.cpp ... + + diff --git a/Sources/Engine/Base/Win32/Win32FileSystem.cpp b/Sources/Engine/Base/Win32/Win32FileSystem.cpp new file mode 100644 index 0000000..fe6f3cf --- /dev/null +++ b/Sources/Engine/Base/Win32/Win32FileSystem.cpp @@ -0,0 +1,121 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +/* rcg10072001 Implemented. */ + +// !!! FIXME: rcg10142001 This should really be using CTStrings... + +#include + +#include +#include + +ENGINE_API CFileSystem *_pFileSystem = NULL; + + +class CWin32FileSystem : public CFileSystem +{ +public: + CWin32FileSystem(const char *argv0, const char *gamename); + virtual ~CWin32FileSystem(void); + virtual void GetExecutablePath(char *buf, ULONG bufSize); + virtual void GetUserDirectory(char *buf, ULONG bufSize); + virtual CDynamicArray *FindFiles(const char *dir, + const char *wildcard); + +protected: + char *exePath; + char *userDir; +}; + + +const char *CFileSystem::GetDirSeparator(void) +{ + return("\\"); +} + + +BOOL CFileSystem::IsDummyFile(const char *fname) +{ + return( (strcmp(fname, ".") == 0) || (strcmp(fname, "..") == 0) ); +} + +BOOL CFileSystem::Exists(const char *fname) +{ + ASSERTALWAYS("Write me!"); +} + +BOOL CFileSystem::IsDirectory(const char *fname) +{ + ASSERTALWAYS("Write me!"); +} + +CFileSystem *CFileSystem::GetInstance(const char *argv0, const char *gamename) +{ + return(new CWin32FileSystem(argv0, gamename)); +} + + +CWin32FileSystem::CWin32FileSystem(const char *argv0, const char *gamename) + : exePath(NULL), + : userDir(NULL) +{ + char buf[MAX_PATH]; + memset(buf, '\0', sizeof (buf)); + GetModuleFileName(NULL, buf, sizeof (buf) - 1); + + exePath = new char[strlen(buf) + 1]; + strcpy(exePath, buf); + + userDir = new char[strlen(buf) + 1]; + strcpy(userDir, buf); + ASSERTALWAYS("We need to chop \\bin\\debug off the string if it's there.\n"); +} + + +CWin32FileSystem::~CWin32FileSystem(void) +{ + delete[] exePath; + delete[] userDir; +} + + +void CWin32FileSystem::GetExecutablePath(char *buf, ULONG bufSize) +{ + strncpy(buf, exePath, bufSize); + buf[bufSize - 1] = '\0'; // just in case. +} + + +void CWin32FileSystem::GetUserDirectory(char *buf, ULONG bufSize) +{ + strncpy(buf, userDir, bufSize); + buf[bufSize - 1] = '\0'; // just in case. +} + + +CDynamicArray CWin32FileSystem::FindFiles(const char *dir, + const char *wildcard) +{ + CDynamicArray *retval = new CDynamicArray; + + CTString str(dir); + if (dir[strlen(dir) - 1] != '\\') + str += "\\"; + + struct _finddata_t c_file; + long hFile = _findfirst( (const char *)(str+wildcard), &c_file ); + + for (BOOL bFileExists = hFile!=-1; + bFileExists; + bFileExists = _findnext( hFile, &c_file )==0) + { + *retval->New() = c_file.name; + } + + _findclose(hFile); + return(retval); +} + +// end of Win32FileSystem.cpp ... + + diff --git a/Sources/Engine/Base/Win32/Win32Input.cpp b/Sources/Engine/Base/Win32/Win32Input.cpp new file mode 100644 index 0000000..97be415 --- /dev/null +++ b/Sources/Engine/Base/Win32/Win32Input.cpp @@ -0,0 +1,986 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +/* rcg10072001 Moved stuff into this file. */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +extern INDEX inp_iKeyboardReadingMethod; +extern FLOAT inp_fMouseSensitivity; +extern INDEX inp_bAllowMouseAcceleration; +extern INDEX inp_bMousePrecision; +extern FLOAT inp_fMousePrecisionFactor; +extern FLOAT inp_fMousePrecisionThreshold; +extern FLOAT inp_fMousePrecisionTimeout; +extern FLOAT inp_bInvertMouse; +extern INDEX inp_bFilterMouse; +extern INDEX inp_bAllowPrescan; + +extern INDEX inp_i2ndMousePort; +extern FLOAT inp_f2ndMouseSensitivity; +extern INDEX inp_b2ndMousePrecision; +extern FLOAT inp_f2ndMousePrecisionThreshold; +extern FLOAT inp_f2ndMousePrecisionTimeout; +extern FLOAT inp_f2ndMousePrecisionFactor; +extern INDEX inp_bFilter2ndMouse; +extern INDEX inp_bInvert2ndMouse; + +extern INDEX inp_ctJoysticksAllowed; + +INDEX inp_iMButton4Dn = 0x20040; +INDEX inp_iMButton4Up = 0x20000; +INDEX inp_iMButton5Dn = 0x10020; +INDEX inp_iMButton5Up = 0x10000; +INDEX inp_bMsgDebugger = FALSE; +INDEX inp_bForceJoystickPolling = 0; +INDEX inp_bAutoDisableJoysticks = 0; + +/* + +NOTE: Three different types of key codes are used here: + 1) kid - engine internal type - defined in KeyNames.h + 2) scancode - raw PC keyboard scancodes as returned in keydown/keyup messages + 3) virtkey - virtual key codes used by windows + +*/ + +// name that is not translated (international) +#define INTNAME(str) str, "" +// name that is translated +#define TRANAME(str) str, "ETRS" str + +// basic key conversion table +static struct KeyConversion { + INDEX kc_iKID; + INDEX kc_iVirtKey; + INDEX kc_iScanCode; + char *kc_strName; + char *kc_strNameTrans; +} _akcKeys[] = { + + // reserved for 'no-key-pressed' + { KID_NONE, -1, -1, TRANAME("None")}, + +// numbers row + { KID_1 , '1', 2, INTNAME("1")}, + { KID_2 , '2', 3, INTNAME("2")}, + { KID_3 , '3', 4, INTNAME("3")}, + { KID_4 , '4', 5, INTNAME("4")}, + { KID_5 , '5', 6, INTNAME("5")}, + { KID_6 , '6', 7, INTNAME("6")}, + { KID_7 , '7', 8, INTNAME("7")}, + { KID_8 , '8', 9, INTNAME("8")}, + { KID_9 , '9', 10, INTNAME("9")}, + { KID_0 , '0', 11, INTNAME("0")}, + { KID_MINUS , 189, 12, INTNAME("-")}, + { KID_EQUALS , 187, 13, INTNAME("=")}, + +// 1st alpha row + { KID_Q , 'Q', 16, INTNAME("Q")}, + { KID_W , 'W', 17, INTNAME("W")}, + { KID_E , 'E', 18, INTNAME("E")}, + { KID_R , 'R', 19, INTNAME("R")}, + { KID_T , 'T', 20, INTNAME("T")}, + { KID_Y , 'Y', 21, INTNAME("Y")}, + { KID_U , 'U', 22, INTNAME("U")}, + { KID_I , 'I', 23, INTNAME("I")}, + { KID_O , 'O', 24, INTNAME("O")}, + { KID_P , 'P', 25, INTNAME("P")}, + { KID_LBRACKET , 219, 26, INTNAME("[")}, + { KID_RBRACKET , 221, 27, INTNAME("]")}, + { KID_BACKSLASH , 220, 43, INTNAME("\\")}, + +// 2nd alpha row + { KID_A , 'A', 30, INTNAME("A")}, + { KID_S , 'S', 31, INTNAME("S")}, + { KID_D , 'D', 32, INTNAME("D")}, + { KID_F , 'F', 33, INTNAME("F")}, + { KID_G , 'G', 34, INTNAME("G")}, + { KID_H , 'H', 35, INTNAME("H")}, + { KID_J , 'J', 36, INTNAME("J")}, + { KID_K , 'K', 37, INTNAME("K")}, + { KID_L , 'L', 38, INTNAME("L")}, + { KID_SEMICOLON , 186, 39, INTNAME(";")}, + { KID_APOSTROPHE , 222, 40, INTNAME("'")}, +// 3rd alpha row + { KID_Z , 'Z', 44, INTNAME("Z")}, + { KID_X , 'X', 45, INTNAME("X")}, + { KID_C , 'C', 46, INTNAME("C")}, + { KID_V , 'V', 47, INTNAME("V")}, + { KID_B , 'B', 48, INTNAME("B")}, + { KID_N , 'N', 49, INTNAME("N")}, + { KID_M , 'M', 50, INTNAME("M")}, + { KID_COMMA , 190, 51, INTNAME(",")}, + { KID_PERIOD , 188, 52, INTNAME(".")}, + { KID_SLASH , 191, 53, INTNAME("/")}, + +// row with F-keys + { KID_F1 , VK_F1, 59, INTNAME("F1")}, + { KID_F2 , VK_F2, 60, INTNAME("F2")}, + { KID_F3 , VK_F3, 61, INTNAME("F3")}, + { KID_F4 , VK_F4, 62, INTNAME("F4")}, + { KID_F5 , VK_F5, 63, INTNAME("F5")}, + { KID_F6 , VK_F6, 64, INTNAME("F6")}, + { KID_F7 , VK_F7, 65, INTNAME("F7")}, + { KID_F8 , VK_F8, 66, INTNAME("F8")}, + { KID_F9 , VK_F9, 67, INTNAME("F9")}, + { KID_F10 , VK_F10, 68, INTNAME("F10")}, + { KID_F11 , VK_F11, 87, INTNAME("F11")}, + { KID_F12 , VK_F12, 88, INTNAME("F12")}, + +// extra keys + { KID_ESCAPE , VK_ESCAPE, 1, TRANAME("Escape")}, + { KID_TILDE , -1, 41, TRANAME("Tilde")}, + { KID_BACKSPACE , VK_BACK, 14, TRANAME("Backspace")}, + { KID_TAB , VK_TAB, 15, TRANAME("Tab")}, + { KID_CAPSLOCK , VK_CAPITAL, 58, TRANAME("Caps Lock")}, + { KID_ENTER , VK_RETURN, 28, TRANAME("Enter")}, + { KID_SPACE , VK_SPACE, 57, TRANAME("Space")}, + +// modifier keys + { KID_LSHIFT , VK_LSHIFT , 42, TRANAME("Left Shift")}, + { KID_RSHIFT , VK_RSHIFT , 54, TRANAME("Right Shift")}, + { KID_LCONTROL , VK_LCONTROL, 29, TRANAME("Left Control")}, + { KID_RCONTROL , VK_RCONTROL, 256+29, TRANAME("Right Control")}, + { KID_LALT , VK_LMENU , 56, TRANAME("Left Alt")}, + { KID_RALT , VK_RMENU , 256+56, TRANAME("Right Alt")}, + +// navigation keys + { KID_ARROWUP , VK_UP, 256+72, TRANAME("Arrow Up")}, + { KID_ARROWDOWN , VK_DOWN, 256+80, TRANAME("Arrow Down")}, + { KID_ARROWLEFT , VK_LEFT, 256+75, TRANAME("Arrow Left")}, + { KID_ARROWRIGHT , VK_RIGHT, 256+77, TRANAME("Arrow Right")}, + { KID_INSERT , VK_INSERT, 256+82, TRANAME("Insert")}, + { KID_DELETE , VK_DELETE, 256+83, TRANAME("Delete")}, + { KID_HOME , VK_HOME, 256+71, TRANAME("Home")}, + { KID_END , VK_END, 256+79, TRANAME("End")}, + { KID_PAGEUP , VK_PRIOR, 256+73, TRANAME("Page Up")}, + { KID_PAGEDOWN , VK_NEXT, 256+81, TRANAME("Page Down")}, + { KID_PRINTSCR , VK_SNAPSHOT, 256+55, TRANAME("Print Screen")}, + { KID_SCROLLLOCK , VK_SCROLL, 70, TRANAME("Scroll Lock")}, + { KID_PAUSE , VK_PAUSE, 69, TRANAME("Pause")}, + +// numpad numbers + { KID_NUM0 , VK_NUMPAD0, 82, INTNAME("Num 0")}, + { KID_NUM1 , VK_NUMPAD1, 79, INTNAME("Num 1")}, + { KID_NUM2 , VK_NUMPAD2, 80, INTNAME("Num 2")}, + { KID_NUM3 , VK_NUMPAD3, 81, INTNAME("Num 3")}, + { KID_NUM4 , VK_NUMPAD4, 75, INTNAME("Num 4")}, + { KID_NUM5 , VK_NUMPAD5, 76, INTNAME("Num 5")}, + { KID_NUM6 , VK_NUMPAD6, 77, INTNAME("Num 6")}, + { KID_NUM7 , VK_NUMPAD7, 71, INTNAME("Num 7")}, + { KID_NUM8 , VK_NUMPAD8, 72, INTNAME("Num 8")}, + { KID_NUM9 , VK_NUMPAD9, 73, INTNAME("Num 9")}, + { KID_NUMDECIMAL , VK_DECIMAL, 83, INTNAME("Num .")}, + +// numpad gray keys + { KID_NUMLOCK , VK_NUMLOCK, 256+69, INTNAME("Num Lock")}, + { KID_NUMSLASH , VK_DIVIDE, 256+53, INTNAME("Num /")}, + { KID_NUMMULTIPLY , VK_MULTIPLY, 55, INTNAME("Num *")}, + { KID_NUMMINUS , VK_SUBTRACT, 74, INTNAME("Num -")}, + { KID_NUMPLUS , VK_ADD, 78, INTNAME("Num +")}, + { KID_NUMENTER , VK_SEPARATOR, 256+28, TRANAME("Num Enter")}, + +// mouse buttons + { KID_MOUSE1 , VK_LBUTTON, -1, TRANAME("Mouse Button 1")}, + { KID_MOUSE2 , VK_RBUTTON, -1, TRANAME("Mouse Button 2")}, + { KID_MOUSE3 , VK_MBUTTON, -1, TRANAME("Mouse Button 3")}, + { KID_MOUSE4 , -1, -1, TRANAME("Mouse Button 4")}, + { KID_MOUSE5 , -1, -1, TRANAME("Mouse Button 5")}, + { KID_MOUSEWHEELUP , -1, -1, TRANAME("Mouse Wheel Up")}, + { KID_MOUSEWHEELDOWN , -1, -1, TRANAME("Mouse Wheel Down")}, + +// 2nd mouse buttons + { KID_2MOUSE1 , -1, -1, TRANAME("2nd Mouse Button 1")}, + { KID_2MOUSE2 , -1, -1, TRANAME("2nd Mouse Button 2")}, + { KID_2MOUSE3 , -1, -1, TRANAME("2nd Mouse Button 3")}, +}; + + +// autogenerated fast conversion tables +static INDEX _aiScanToKid[512]; +static INDEX _aiVirtToKid[256]; + +// make fast conversion tables from the general table +static void MakeConversionTables(void) +{ + // clear conversion tables + memset(_aiScanToKid, -1, sizeof(_aiScanToKid)); + memset(_aiVirtToKid, -1, sizeof(_aiVirtToKid)); + + // for each Key + for (INDEX iKey=0; iKey=0) { + _aiScanToKid[iScan] = iKID; + } + if (iVirt>=0) { + _aiVirtToKid[iVirt] = iKID; + } + } +} + +// variables for message interception +static HHOOK _hGetMsgHook = NULL; +static HHOOK _hSendMsgHook = NULL; +static int _iMouseZ = 0; +static BOOL _bWheelUp = FALSE; +static BOOL _bWheelDn = FALSE; + +CTCriticalSection csInput; + +// which keys are pressed, as recorded by message interception (by KIDs) +static UBYTE _abKeysPressed[256]; + +// set a key according to a keydown/keyup message +static void SetKeyFromMsg(MSG *pMsg, BOOL bDown) +{ + INDEX iKID = -1; + // if capturing scan codes + if (inp_iKeyboardReadingMethod==2) { + // get scan code + INDEX iScan = (pMsg->lParam>>16)&0x1FF; // (we use the extended bit too!) + // convert scan code to kid + iKID = _aiScanToKid[iScan]; + // if capturing virtual key codes + } else if (inp_iKeyboardReadingMethod==1) { + // get virtualkey + INDEX iVirt = (pMsg->wParam)&0xFF; + + if (iVirt == VK_SHIFT) { + iVirt = VK_LSHIFT; + } + if (iVirt == VK_CONTROL) { + iVirt = VK_LCONTROL; + } + if (iVirt == VK_MENU) { + iVirt = VK_LMENU; + } + // convert virtualkey to kid + iKID = _aiVirtToKid[iVirt]; + // if not capturing + } else { + // do nothing + return; + } + if (iKID>=0 && iKIDinp_strButtonNames[iKID], bDown); + _abKeysPressed[iKID] = bDown; + } +} + +static void CheckMessage(MSG *pMsg) +{ + if ( pMsg->message == WM_LBUTTONUP) { + _abKeysPressed[KID_MOUSE1] = FALSE; + } else if ( pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONDBLCLK) { + _abKeysPressed[KID_MOUSE1] = TRUE; + } else if ( pMsg->message == WM_RBUTTONUP) { + _abKeysPressed[KID_MOUSE2] = FALSE; + } else if ( pMsg->message == WM_RBUTTONDOWN || pMsg->message == WM_RBUTTONDBLCLK) { + _abKeysPressed[KID_MOUSE2] = TRUE; + } else if ( pMsg->message == WM_MBUTTONUP) { + _abKeysPressed[KID_MOUSE3] = FALSE; + } else if ( pMsg->message == WM_MBUTTONDOWN || pMsg->message == WM_MBUTTONDBLCLK) { + _abKeysPressed[KID_MOUSE3] = TRUE; + + } else if ( pMsg->message == inp_iMButton4Dn) { + _abKeysPressed[KID_MOUSE4] = TRUE; + } else if ( pMsg->message == inp_iMButton4Up) { + _abKeysPressed[KID_MOUSE4] = FALSE; + + } else if ( pMsg->message == inp_iMButton5Dn) { + _abKeysPressed[KID_MOUSE5] = TRUE; + } else if ( pMsg->message == inp_iMButton5Up) { + _abKeysPressed[KID_MOUSE5] = FALSE; + + } else if (pMsg->message==WM_KEYUP || pMsg->message==WM_SYSKEYUP) { + SetKeyFromMsg(pMsg, FALSE); + } else if (pMsg->message==WM_KEYDOWN || pMsg->message==WM_SYSKEYDOWN) { + SetKeyFromMsg(pMsg, TRUE); + } else if (inp_bMsgDebugger && pMsg->message >= 0x10000) { + CPrintF("%08x(%d)\n", pMsg->message, pMsg->message); + } +} + + +// procedure called when message is retreived +LRESULT CALLBACK GetMsgProc( + int nCode, // hook code + WPARAM wParam, // message identifier + LPARAM lParam) // mouse coordinates +{ + MSG *pMsg = (MSG*)lParam; + CheckMessage(pMsg); + + LRESULT retValue = 0; + retValue = CallNextHookEx( _hGetMsgHook, nCode, wParam, lParam ); + +#ifndef WM_MOUSEWHEEL + #define WM_MOUSEWHEEL 0x020A +#endif + + if (wParam == PM_NOREMOVE) { + return retValue; + } + + if ( pMsg->message == WM_MOUSEWHEEL) { + _iMouseZ += SWORD(UWORD(HIWORD(pMsg->wParam))); + } + + return retValue; +} + + +// procedure called when message is sent +LRESULT CALLBACK SendMsgProc( + int nCode, // hook code + WPARAM wParam, // message identifier + LPARAM lParam) // mouse coordinates +{ + MSG *pMsg = (MSG*)lParam; + CheckMessage(pMsg); + + LRESULT retValue = 0; + retValue = CallNextHookEx( _hSendMsgHook, nCode, wParam, lParam ); + + return retValue; +} + + + +// --------- 2ND MOUSE HANDLING + +#define MOUSECOMBUFFERSIZE 256L +static HANDLE _h2ndMouse = NONE; +static BOOL _bIgnoreMouse2 = TRUE; +static INDEX _i2ndMouseX, _i2ndMouseY, _i2ndMouseButtons; +static INDEX _iByteNum = 0; +static UBYTE _aubComBytes[4] = {0,0,0,0}; +static INDEX _iLastPort = -1; + + + +static void Poll2ndMouse(void) +{ + // reset (mouse reading is relative) + _i2ndMouseX = 0; + _i2ndMouseY = 0; + if( _h2ndMouse==NONE) return; + + // check + COMSTAT csComStat; + DWORD dwErrorFlags; + ClearCommError( _h2ndMouse, &dwErrorFlags, &csComStat); + DWORD dwLength = Min( MOUSECOMBUFFERSIZE, (INDEX)csComStat.cbInQue); + if( dwLength<=0) return; + + // readout + UBYTE aubMouseBuffer[MOUSECOMBUFFERSIZE]; + INDEX iRetries = 999; + while( iRetries>0 && !ReadFile( _h2ndMouse, aubMouseBuffer, dwLength, &dwLength, NULL)) iRetries--; + if( iRetries<=0) return; // what, didn't make it? + + // parse the mouse packets + for( INDEX i=0; i>4; + } + // axes ? + else if( _iByteNum==3) { + char iDX = ((_aubComBytes[0] & 3) <<6) + _aubComBytes[1]; + char iDY = ((_aubComBytes[0] & 12) <<4) + _aubComBytes[2]; + _i2ndMouseX += iDX; + _i2ndMouseY += iDY; + } + // 3rd button? + else if( _iByteNum==4) { + _i2ndMouseButtons &= ~4; + if( aubMouseBuffer[i]&32) _i2ndMouseButtons |= 4; + } + } + + // ignore pooling? + if( _bIgnoreMouse2) { + if( _i2ndMouseX!=0 || _i2ndMouseY!=0) _bIgnoreMouse2 = FALSE; + _i2ndMouseX = 0; + _i2ndMouseY = 0; + _i2ndMouseButtons = 0; + return; + } +} + + +static void Startup2ndMouse(INDEX iPort) +{ + // skip if disabled + ASSERT( iPort>=0 && iPort<=4); + if( iPort==0) return; + // determine port string + CTString str2ndMousePort( 0, "COM%d", iPort); + + // create COM handle if needed + if( _h2ndMouse==NONE) { + _h2ndMouse = CreateFileA( str2ndMousePort, GENERIC_READ|GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if( _h2ndMouse==INVALID_HANDLE_VALUE) { + // failed! :( + INDEX iError = GetLastError(); +/* + if( iError==5) CPrintF( "Cannot open %s (access denied).\n" + "The port is probably already used by another device (mouse, modem...)\n", + str2ndMousePort); + else CPrintF( "Cannot open %s (error %d).\n", str2ndMousePort, iError); + */ + _h2ndMouse = NONE; + return; + } + } + // setup and purge buffers + SetupComm( _h2ndMouse, MOUSECOMBUFFERSIZE, MOUSECOMBUFFERSIZE); + PurgeComm( _h2ndMouse, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR); + + // setup port to 1200 7N1 + DCB dcb; + dcb.DCBlength = sizeof(DCB); + GetCommState( _h2ndMouse, &dcb); + dcb.BaudRate = CBR_1200; + dcb.ByteSize = 7; + dcb.Parity = NOPARITY; + dcb.StopBits = ONESTOPBIT; + dcb.fDtrControl = DTR_CONTROL_ENABLE; + dcb.fRtsControl = RTS_CONTROL_ENABLE; + dcb.fBinary = TRUE; + dcb.fParity = TRUE; + SetCommState( _h2ndMouse, &dcb); + + // reset + _iByteNum = 0; + _aubComBytes[0] = _aubComBytes[1] = _aubComBytes[2] = _aubComBytes[3] = 0; + _bIgnoreMouse2 = TRUE; // ignore mouse polling until 1 after non-0 readout + _iLastPort = iPort; + //CPrintF( "STARTUP M2!\n"); +} + + +static void Shutdown2ndMouse(void) +{ + // skip if already disabled + if( _h2ndMouse==NONE) return; + + // disable! + SetCommMask( _h2ndMouse, 0); + EscapeCommFunction( _h2ndMouse, CLRDTR); + EscapeCommFunction( _h2ndMouse, CLRRTS); + PurgeComm( _h2ndMouse, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR); + // close port if changed + if( _iLastPort != inp_i2ndMousePort) { + CloseHandle( _h2ndMouse); + _h2ndMouse = NONE; + } // over and out + _bIgnoreMouse2 = TRUE; +} + + +BOOL CInput::PlatformInit(void) +{ + _h2ndMouse = NONE; + MakeConversionTables(); + return TRUE; +} + + +// destructor +CInput::~CInput() +{ + if( _h2ndMouse!=NONE) CloseHandle( _h2ndMouse); + _h2ndMouse = NONE; +} + + +BOOL CInput::PlatformSetKeyNames(void) +{ + // for each Key + for (INDEX iKey=0; iKey= 0); + // save system mouse settings + SystemParametersInfo(SPI_GETMOUSE, 0, &inp_mscMouseSettings, 0); + // set new mouse speed + if (!inp_bAllowMouseAcceleration) { + MouseSpeedControl mscNewSetting = { 0, 0, 0}; + SystemParametersInfo(SPI_SETMOUSE, 0, &mscNewSetting, 0); + } + // set cursor position to screen center + SetCursorPos(inp_slScreenCenterX, inp_slScreenCenterY); + + _hGetMsgHook = SetWindowsHookEx(WH_GETMESSAGE, &GetMsgProc, NULL, GetCurrentThreadId()); + _hSendMsgHook = SetWindowsHookEx(WH_CALLWNDPROC, &SendMsgProc, NULL, GetCurrentThreadId()); + + // if required, try to enable 2nd mouse + Shutdown2ndMouse(); + inp_i2ndMousePort = Clamp( inp_i2ndMousePort, 0L, 4L); + Startup2ndMouse(inp_i2ndMousePort); + + // clear button's buffer + memset( _abKeysPressed, 0, sizeof( _abKeysPressed)); + + // This can be enabled to pre-read the state of currently pressed keys + // for snooping methods, since they only detect transitions. + // That has effect of detecting key presses for keys that were held down before + // enabling. + // the entire thing is disabled because it caused last menu key to re-apply in game. +#if 0 + // for each Key + {for (INDEX iKey=0; iKey=0) { + // transcribe if modifier + if (iVirt == VK_LSHIFT) { + iVirt = VK_SHIFT; + } + if (iVirt == VK_LCONTROL) { + iVirt = VK_CONTROL; + } + if (iVirt == VK_LMENU) { + iVirt = VK_MENU; + } + // is state is pressed + if (GetAsyncKeyState(iVirt)&0x8000) { + // mark it as pressed + _abKeysPressed[iKID] = 0xFF; + } + } + }} +#endif + + // remember current status + inp_bInputEnabled = TRUE; + inp_bPollJoysticks = FALSE; +} + + +/* + * Disable direct input + */ +void CInput::DisableInput( void) +{ + // skip if allready disabled + if( !inp_bInputEnabled) return; + + UnhookWindowsHookEx(_hGetMsgHook); + UnhookWindowsHookEx(_hSendMsgHook); + + // set mouse clip region to entire screen + ClipCursor(NULL); + // restore mouse pos + SetCursorPos( inp_ptOldMousePos.x, inp_ptOldMousePos.y); + + // show mouse on screen + while (ShowCursor(TRUE) < 0); + // set system mouse settings + SystemParametersInfo(SPI_SETMOUSE, 0, &inp_mscMouseSettings, 0); + + // eventually disable 2nd mouse + Shutdown2ndMouse(); + + // remember current status + inp_bInputEnabled = FALSE; + inp_bPollJoysticks = FALSE; +} + + +// blank any queued mousemove events...SDLInput.cpp needs this when +// returning from the menus/console to game or the viewport will jump... --ryan. +void CInput::ClearRelativeMouseMotion(void) +{ + // no-op on win32. --ryan. +} + + +/* + * Scan states of all available input sources + */ +void CInput::GetInput(BOOL bPreScan) +{ +// CTSingleLock sl(&csInput, TRUE); + + if (!inp_bInputEnabled) { + return; + } + + if (bPreScan && !inp_bAllowPrescan) { + return; + } + + // if not pre-scanning + if (!bPreScan) { + // clear button's buffer + memset( inp_ubButtonsBuffer, 0, sizeof( inp_ubButtonsBuffer)); + + // for each Key + {for (INDEX iKey=0; iKey=0) { + // transcribe if modifier + if (iVirt == VK_LSHIFT) { + iVirt = VK_SHIFT; + } + if (iVirt == VK_LCONTROL) { + iVirt = VK_CONTROL; + } + if (iVirt == VK_LMENU) { + iVirt = VK_MENU; + } + // is state is pressed + if (GetAsyncKeyState(iVirt)&0x8000) { + // mark it as pressed + inp_ubButtonsBuffer[iKID] = 0xFF; + } + } + + // if snooping messages + } else { + // if snooped that key is pressed + if (_abKeysPressed[iKID]) { + // mark it as pressed + inp_ubButtonsBuffer[iKID] = 0xFF; + } + } + }} + } + + // read mouse position + POINT pntMouse; + if( GetCursorPos( &pntMouse)) + { + FLOAT fDX = FLOAT( SLONG(pntMouse.x) - inp_slScreenCenterX); + FLOAT fDY = FLOAT( SLONG(pntMouse.y) - inp_slScreenCenterY); + + FLOAT fSensitivity = inp_fMouseSensitivity; + if( inp_bAllowMouseAcceleration) fSensitivity *= 0.25f; + + FLOAT fD = Sqrt(fDX*fDX+fDY*fDY); + if (inp_bMousePrecision) { + static FLOAT _tmTime = 0.0f; + if( fDinp_fMousePrecisionTimeout) fSensitivity /= inp_fMousePrecisionFactor; + } + + static FLOAT fDXOld; + static FLOAT fDYOld; + static TIME tmOldDelta; + static CTimerValue tvBefore; + CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); + TIME tmNowDelta = (tvNow-tvBefore).GetSeconds(); + if (tmNowDelta<0.001f) { + tmNowDelta = 0.001f; + } + tvBefore = tvNow; + + FLOAT fDXSmooth = (fDXOld*tmOldDelta+fDX*tmNowDelta)/(tmOldDelta+tmNowDelta); + FLOAT fDYSmooth = (fDYOld*tmOldDelta+fDY*tmNowDelta)/(tmOldDelta+tmNowDelta); + fDXOld = fDX; + fDYOld = fDY; + tmOldDelta = tmNowDelta; + if (inp_bFilterMouse) { + fDX = fDXSmooth; + fDY = fDYSmooth; + } + + // get final mouse values + FLOAT fMouseRelX = +fDX*fSensitivity; + FLOAT fMouseRelY = -fDY*fSensitivity; + if (inp_bInvertMouse) { + fMouseRelY = -fMouseRelY; + } + FLOAT fMouseRelZ = _iMouseZ; + + // just interpret values as normal + inp_caiAllAxisInfo[1].cai_fReading = fMouseRelX; + inp_caiAllAxisInfo[2].cai_fReading = fMouseRelY; + inp_caiAllAxisInfo[3].cai_fReading = fMouseRelZ; + + // if not pre-scanning + if (!bPreScan) { + // detect wheel up/down movement + _bWheelDn = FALSE; + if (_iMouseZ>0) { + if (_bWheelUp) { + inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0x00; + } else { + inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0xFF; + _iMouseZ = ClampDn(_iMouseZ-120, 0); + } + } + _bWheelUp = inp_ubButtonsBuffer[KID_MOUSEWHEELUP]; + if (_iMouseZ<0) { + if (_bWheelDn) { + inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0x00; + } else { + inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0xFF; + _iMouseZ = ClampUp(_iMouseZ+120, 0); + } + } + _bWheelDn = inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN]; + } + } + inp_bLastPrescan = bPreScan; + + // set cursor position to screen center + if (pntMouse.x!=inp_slScreenCenterX || pntMouse.y!=inp_slScreenCenterY) { + SetCursorPos(inp_slScreenCenterX, inp_slScreenCenterY); + } + + // readout 2nd mouse if enabled + if( _h2ndMouse!=NONE) + { + Poll2ndMouse(); + //CPrintF( "m2X: %4d, m2Y: %4d, m2B: 0x%02X\n", _i2ndMouseX, _i2ndMouseY, _i2ndMouseButtons); + + // handle 2nd mouse buttons + if( _i2ndMouseButtons & 2) inp_ubButtonsBuffer[KID_2MOUSE1] = 0xFF; + if( _i2ndMouseButtons & 1) inp_ubButtonsBuffer[KID_2MOUSE2] = 0xFF; + if( _i2ndMouseButtons & 4) inp_ubButtonsBuffer[KID_2MOUSE3] = 0xFF; + + // handle 2nd mouse movement + FLOAT fDX = _i2ndMouseX; + FLOAT fDY = _i2ndMouseY; + FLOAT fSensitivity = inp_f2ndMouseSensitivity; + + FLOAT fD = Sqrt(fDX*fDX+fDY*fDY); + if( inp_b2ndMousePrecision) { + static FLOAT _tm2Time = 0.0f; + if( fDinp_f2ndMousePrecisionTimeout) fSensitivity /= inp_f2ndMousePrecisionFactor; + } + + static FLOAT f2DXOld; + static FLOAT f2DYOld; + static TIME tm2OldDelta; + static CTimerValue tv2Before; + CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); + TIME tmNowDelta = (tvNow-tv2Before).GetSeconds(); + if( tmNowDelta<0.001f) tmNowDelta = 0.001f; + tv2Before = tvNow; + + FLOAT fDXSmooth = (f2DXOld*tm2OldDelta+fDX*tmNowDelta) / (tm2OldDelta+tmNowDelta); + FLOAT fDYSmooth = (f2DYOld*tm2OldDelta+fDY*tmNowDelta) / (tm2OldDelta+tmNowDelta); + f2DXOld = fDX; + f2DYOld = fDY; + tm2OldDelta = tmNowDelta; + if( inp_bFilter2ndMouse) { + fDX = fDXSmooth; + fDY = fDYSmooth; + } + + // get final mouse values + FLOAT fMouseRelX = +fDX*fSensitivity; + FLOAT fMouseRelY = -fDY*fSensitivity; + if( inp_bInvert2ndMouse) fMouseRelY = -fMouseRelY; + + // just interpret values as normal + inp_caiAllAxisInfo[4].cai_fReading = fMouseRelX; + inp_caiAllAxisInfo[5].cai_fReading = fMouseRelY; + } + + + // if joystick polling is enabled + if (inp_bPollJoysticks || inp_bForceJoystickPolling) { + // scan all available joysticks + for( INDEX iJoy=0; iJoy @@ -303,3 +303,4 @@ void CTSingleLock::Unlock(void) } sl_bLocked = FALSE; } + diff --git a/Sources/Engine/Base/Win32/Win32Timer.cpp b/Sources/Engine/Base/Win32/Win32Timer.cpp new file mode 100644 index 0000000..8eb701e --- /dev/null +++ b/Sources/Engine/Base/Win32/Win32Timer.cpp @@ -0,0 +1,15 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +/* rcg10072001 Moved stuff into this file. */ + +#include +#include + +void CTimer::Sleep(DWORD milliseconds) +{ + ::Sleep(milliseconds); +} + +// end of Win32Timer.cpp ... + + diff --git a/Sources/Engine/Brushes/Brush.cpp b/Sources/Engine/Brushes/Brush.cpp index 7c60c31..74661d2 100644 --- a/Sources/Engine/Brushes/Brush.cpp +++ b/Sources/Engine/Brushes/Brush.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Brushes/Brush.h b/Sources/Engine/Brushes/Brush.h index 252e658..c6660c1 100644 --- a/Sources/Engine/Brushes/Brush.h +++ b/Sources/Engine/Brushes/Brush.h @@ -254,16 +254,30 @@ public: CMappingDefinition bpt_mdMapping; // mapping of texture on polygon union { - struct { - UBYTE bpt_ubScroll; // texture scroll - UBYTE bpt_ubBlend; // type of texture blending used - UBYTE bpt_ubFlags; // additional flags - UBYTE bpt_ubDummy; // unused (alignment) - COLOR bpt_colColor; // defines constant color and alpha of polygon - } s; + struct { + UBYTE bpt_ubScroll; // texture scroll + UBYTE bpt_ubBlend; // type of texture blending used + UBYTE bpt_ubFlags; // additional flags + UBYTE bpt_ubDummy; // unused (alignment) + COLOR bpt_colColor; // defines constant color and alpha of polygon + } s; UBYTE bpt_auProperties[8]; }; + // ATTENTION! If you add/edit/remove any data member, PLEASE update the + // operator = method, below! --ryan. + CBrushPolygonTexture& operator =(const CBrushPolygonTexture &src) + { + if (this != &src) + { + bpt_toTexture = src.bpt_toTexture; + bpt_mdMapping = src.bpt_mdMapping; + memcpy(&bpt_auProperties, &src.bpt_auProperties, sizeof (bpt_auProperties)); + } + return *this; + } + + CBrushPolygonTexture(void) { s.bpt_ubScroll = 0; @@ -347,8 +361,29 @@ struct CBrushPolygonProperties { UWORD bpp_uwPretenderDistance; // distance for pretender switching [m] /* Default constructor. */ CBrushPolygonProperties(void) { memset(this, 0, sizeof(*this)); }; + friend __forceinline CTStream &operator>>(CTStream &strm, CBrushPolygonProperties &cbpp) + { + strm>>cbpp.bpp_ubSurfaceType; + strm>>cbpp.bpp_ubIlluminationType; + strm>>cbpp.bpp_ubShadowBlend; + strm>>cbpp.bpp_ubMirrorType; + strm>>cbpp.bpp_ubGradientType; + strm>>cbpp.bpp_sbShadowClusterSize; + strm>>cbpp.bpp_uwPretenderDistance; + return strm; + } + friend __forceinline CTStream &operator<<(CTStream &strm, const CBrushPolygonProperties &cbpp) + { + strm< CBrushPolygonSelection; // selection of brush polygons used for CSG diff --git a/Sources/Engine/Brushes/BrushArchive.cpp b/Sources/Engine/Brushes/BrushArchive.cpp index b7cabc3..ba1e642 100644 --- a/Sources/Engine/Brushes/BrushArchive.cpp +++ b/Sources/Engine/Brushes/BrushArchive.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -17,10 +17,15 @@ #include #include +// !!! FIXME: This confuses GCC, since CDynamicArray is a #included +// !!! FIXME: source file, and it ends up compiling the template more than +// !!! FIXME: once. :( --ryan. +#ifdef _MSC_VER template CDynamicArray; +#endif -extern BOOL _bPortalSectorLinksPreLoaded = FALSE; -extern BOOL _bEntitySectorLinksPreLoaded = FALSE; +BOOL _bPortalSectorLinksPreLoaded = FALSE; +BOOL _bEntitySectorLinksPreLoaded = FALSE; /* * Calculate bounding boxes in all brushes. diff --git a/Sources/Engine/Brushes/BrushExport.cpp b/Sources/Engine/Brushes/BrushExport.cpp index 1c0139f..e8354f3 100644 --- a/Sources/Engine/Brushes/BrushExport.cpp +++ b/Sources/Engine/Brushes/BrushExport.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Brushes/BrushIO.cpp b/Sources/Engine/Brushes/BrushIO.cpp index a77bdd9..f2d0f5c 100644 --- a/Sources/Engine/Brushes/BrushIO.cpp +++ b/Sources/Engine/Brushes/BrushIO.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -223,7 +223,7 @@ void CBrushPolygonTexture::Read_t( CTStream &strm) // throw char * if (bpt_toTexture.GetData()!=NULL) { bpt_toTexture.GetData()->AddToCRCTable(); } - strm.Read_t(&bpt_mdMapping, sizeof(bpt_mdMapping)); + strm>>bpt_mdMapping; strm>>s.bpt_ubScroll; strm>>s.bpt_ubBlend; strm>>s.bpt_ubFlags; @@ -402,7 +402,7 @@ void CBrushSector::Read_t( CTStream *pistrm) // throw char * // for each vertex {FOREACHINSTATICARRAY(bsc_abvxVertices, CBrushVertex, itbvx) { // read precise vertex coordinates - pistrm->Read_t(&itbvx->bvx_vdPreciseRelative, sizeof(DOUBLE3D)); + (*pistrm)>>itbvx->bvx_vdPreciseRelative; // remember sector pointer itbvx->bvx_pbscSector = this; }} @@ -417,7 +417,7 @@ void CBrushSector::Read_t( CTStream *pistrm) // throw char * // for each plane {FOREACHINSTATICARRAY(bsc_abplPlanes, CBrushPlane, itbpl) { // read precise plane coordinates - pistrm->Read_t(&itbpl->bpl_pldPreciseRelative, sizeof(DOUBLEplane3D)); + (*pistrm)>>itbpl->bpl_pldPreciseRelative; }} (*pistrm).ExpectID_t("EDGs"); // 'edges' @@ -478,7 +478,7 @@ void CBrushSector::Read_t( CTStream *pistrm) // throw char * bpo.bpo_abptTextures[2].Read_t(*pistrm); // read other polygon properties - (*pistrm).Read_t(&bpo.bpo_bppProperties, sizeof(bpo.bpo_bppProperties)); + (*pistrm)>>bpo.bpo_bppProperties; } else { // read textures @@ -495,7 +495,7 @@ void CBrushSector::Read_t( CTStream *pistrm) // throw char * // read texture mapping bpo.bpo_mdShadow.ReadOld_t(*pistrm); // read other polygon properties - (*pistrm).Read_t(&bpo.bpo_bppProperties, sizeof(bpo.bpo_bppProperties)); + (*pistrm)>>bpo.bpo_bppProperties; // adjust polygon and texture properties bpo.bpo_abptTextures[0].bpt_mdMapping = bpo.bpo_mdShadow; @@ -579,7 +579,9 @@ void CBrushSector::Read_t( CTStream *pistrm) // throw char * bpo.bpo_aiTriangleElements.New(ctElements); // read all element indices if (ctElements>0) { - (*pistrm).Read_t(&bpo.bpo_aiTriangleElements[0], ctElements*sizeof(INDEX)); + for (INDEX i = 0; i < ctElements; i++) { + (*pistrm)>>bpo.bpo_aiTriangleElements[i]; + } } } diff --git a/Sources/Engine/Brushes/BrushImport.cpp b/Sources/Engine/Brushes/BrushImport.cpp index 897dd6f..d09a13e 100644 --- a/Sources/Engine/Brushes/BrushImport.cpp +++ b/Sources/Engine/Brushes/BrushImport.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Brushes/BrushMip.cpp b/Sources/Engine/Brushes/BrushMip.cpp index d20ea14..a8b482b 100644 --- a/Sources/Engine/Brushes/BrushMip.cpp +++ b/Sources/Engine/Brushes/BrushMip.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -16,7 +16,7 @@ #include #include -template CDynamicArray; +template class CDynamicArray; // tolerance value for csg selection #define CSG_RANGE_EPSILON (0.25f) diff --git a/Sources/Engine/Brushes/BrushPolygon.cpp b/Sources/Engine/Brushes/BrushPolygon.cpp index c1975a9..3ef38dd 100644 --- a/Sources/Engine/Brushes/BrushPolygon.cpp +++ b/Sources/Engine/Brushes/BrushPolygon.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -13,9 +13,9 @@ #include #include -template CStaticArray; -template CStaticArray; -template CStaticArray; +template class CStaticArray; +template class CStaticArray; +template class CStaticArray; // set new absolute position for the vertex void CBrushVertex::SetAbsolutePosition(const DOUBLE3D &vAbsolute) diff --git a/Sources/Engine/Brushes/BrushSector.cpp b/Sources/Engine/Brushes/BrushSector.cpp index a01d261..df91259 100644 --- a/Sources/Engine/Brushes/BrushSector.cpp +++ b/Sources/Engine/Brushes/BrushSector.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Brushes/BrushShadows.cpp b/Sources/Engine/Brushes/BrushShadows.cpp index 5cb9e98..e2b6c64 100644 --- a/Sources/Engine/Brushes/BrushShadows.cpp +++ b/Sources/Engine/Brushes/BrushShadows.cpp @@ -1,7 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" - +#include #include #include #include diff --git a/Sources/Engine/Brushes/BrushTriangularize.cpp b/Sources/Engine/Brushes/BrushTriangularize.cpp index 1f74d78..f946549 100644 --- a/Sources/Engine/Brushes/BrushTriangularize.cpp +++ b/Sources/Engine/Brushes/BrushTriangularize.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -578,6 +578,7 @@ void CTriangularizer::DPrintF(char *strFormat, ...) va_list arg; va_start(arg, strFormat); vsprintf(strBuffer, strFormat, arg); + va_end(arg); // if the debug output file is not open if (!_bDebugOutputOpen) { @@ -717,7 +718,7 @@ void CTriangularizer::FindBestTriangle(void) #if 0 // if no acceptable triangles have been found - if (tr_fQualityBestbsc_abvxVertices, diff --git a/Sources/Engine/Classes/BaseEvents.es b/Sources/Engine/Classes/BaseEvents.es index 930b46c..8126680 100644 --- a/Sources/Engine/Classes/BaseEvents.es +++ b/Sources/Engine/Classes/BaseEvents.es @@ -2,7 +2,7 @@ 5 %{ -#include "StdH.h" +#include #define DECL_DLL ENGINE_API #include #include diff --git a/Sources/Engine/Classes/MovableBrushEntity.es b/Sources/Engine/Classes/MovableBrushEntity.es index 366b9bc..f761c7c 100644 --- a/Sources/Engine/Classes/MovableBrushEntity.es +++ b/Sources/Engine/Classes/MovableBrushEntity.es @@ -6,7 +6,7 @@ 3 %{ -#include "StdH.h" +#include #include %} diff --git a/Sources/Engine/Classes/MovableEntity.es b/Sources/Engine/Classes/MovableEntity.es index 8166394..a9a3cb9 100644 --- a/Sources/Engine/Classes/MovableEntity.es +++ b/Sources/Engine/Classes/MovableEntity.es @@ -5,7 +5,7 @@ */ 1 %{ -#include "StdH.h" +#include #include #include #include @@ -36,7 +36,7 @@ %{ #define ANYEXCEPTION ... -template CStaticStackArray; +template class CStaticStackArray; #define MAXCOLLISIONRETRIES 4*4 extern FLOAT phy_fCollisionCacheAhead; @@ -1107,12 +1107,12 @@ functions: BOOL IsStandingOnPolygon(CBrushPolygon *pbpo) { - _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StartTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); // if cannot optimize for standing on handle if (en_pciCollisionInfo==NULL ||!(en_pciCollisionInfo->ci_ulFlags&CIF_CANSTANDONHANDLE)) { // not standing on polygon - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return FALSE; } @@ -1133,7 +1133,7 @@ functions: // if handle is not on the plane if (plPolygon.PointDistance(vHandle)>0.01f) { // not standing on polygon - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return FALSE; } @@ -1157,12 +1157,12 @@ functions: // if the point is inside polygon if (isIntersector.IsIntersecting()) { // entity is standing on polygon - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return TRUE; // if the point is outside polygon } else { // entity is not standing on polygon - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return FALSE; } } @@ -1170,13 +1170,13 @@ functions: // check whether a polygon is below given point, but not too far away BOOL IsPolygonBelowPoint(CBrushPolygon *pbpo, const FLOAT3D &vPoint, FLOAT fMaxDist) { - _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StartTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); // if passable or not allowed as ground if ((pbpo->bpo_ulFlags&BPOF_PASSABLE) ||!AllowForGroundPolygon(pbpo)) { // it cannot be below - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return FALSE; } @@ -1188,7 +1188,7 @@ functions: // if polygon is vertical or upside down if (fCos>-0.01f) { // it cannot be below - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return FALSE; } @@ -1197,7 +1197,7 @@ functions: if (fCos>=-stReference.st_fClimbSlopeCos&&fCos<0 ||stReference.st_ulFlags&STF_SLIDEDOWNSLOPE) { // it cannot be below - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return FALSE; } @@ -1206,7 +1206,7 @@ functions: // if the point is behind the plane if (fD<-0.01f) { // it cannot be below - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return FALSE; } @@ -1215,7 +1215,7 @@ functions: // if too far away if (fDistance > fMaxDist) { // it cannot be below - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return FALSE; } // project point to the polygon along gravity vector @@ -1241,12 +1241,12 @@ functions: // if the point is inside polygon if (isIntersector.IsIntersecting()) { // it is below - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return TRUE; // if the point is outside polygon } else { // it is not below - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON); return FALSE; } } @@ -1399,9 +1399,9 @@ out:; // set current placement from next position void SetPlacementFromNextPosition(void) { - _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_SETPLACEMENTFROMNEXTPOSITION); + _pfPhysicsProfile.StartTimer((INDEX) CPhysicsProfile::PTI_SETPLACEMENTFROMNEXTPOSITION); - _pfPhysicsProfile.IncrementTimerAveragingCounter(CPhysicsProfile::PTI_SETPLACEMENTFROMNEXTPOSITION); + _pfPhysicsProfile.IncrementTimerAveragingCounter((INDEX) CPhysicsProfile::PTI_SETPLACEMENTFROMNEXTPOSITION); CPlacement3D plNew; plNew.pl_PositionVector = en_vNextPosition; DecomposeRotationMatrixNoSnap(plNew.pl_OrientationAngle, en_mNextRotation); @@ -1421,14 +1421,14 @@ out:; } */ - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_SETPLACEMENTFROMNEXTPOSITION); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_SETPLACEMENTFROMNEXTPOSITION); } BOOL TryToGoUpstairs(const FLOAT3D &vTranslationAbsolute, const CSurfaceType &stHit, BOOL bHitStairsOrg) { - _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_TRYTOGOUPSTAIRS); - _pfPhysicsProfile.IncrementTimerAveragingCounter(CPhysicsProfile::PTI_TRYTOGOUPSTAIRS); + _pfPhysicsProfile.StartTimer((INDEX) CPhysicsProfile::PTI_TRYTOGOUPSTAIRS); + _pfPhysicsProfile.IncrementTimerAveragingCounter((INDEX) CPhysicsProfile::PTI_TRYTOGOUPSTAIRS); // use only horizontal components of the movement FLOAT3D vTranslationHorizontal; @@ -1439,7 +1439,7 @@ out:; if(vTranslationHorizontal.Length()<0.001f) { //CPrintF("no value\n"); // don't do it - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOGOUPSTAIRS); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOGOUPSTAIRS); return FALSE; } FLOAT3D vTranslationHorizontalOrg = vTranslationHorizontal; @@ -1557,7 +1557,7 @@ out:; en_vNextPosition = plOriginal.pl_PositionVector; SetPlacementFromNextPosition(); // move is unsuccessful - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOGOUPSTAIRS); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOGOUPSTAIRS); //CPrintF("FAILED\n"); return FALSE; } @@ -1572,7 +1572,7 @@ out:; en_vAppliedTranslation += vTranslationHorizontalOrg; } // move is successful - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOGOUPSTAIRS); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOGOUPSTAIRS); //CPrintF("done\n"); return TRUE; } @@ -1592,9 +1592,9 @@ out:; // fail the move return FALSE; } - _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); - _pfPhysicsProfile.IncrementTimerAveragingCounter(CPhysicsProfile::PTI_TRYTOTRANSLATE); - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_TRYTOMOVE); + _pfPhysicsProfile.StartTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.IncrementTimerAveragingCounter((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_TRYTOMOVE); // create new placement with movement if (bTranslate) { @@ -1637,7 +1637,7 @@ out:; // clip the movement to the entity's world if (!bTranslate && bIgnoreRotation) { cmMove.cm_fMovementFraction = 2.0f; - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_TRYTOMOVE_FAST); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_TRYTOMOVE_FAST); } else { en_pwoWorld->ClipMove(cmMove); } @@ -1665,14 +1665,14 @@ out:; en_mAppliedRotation = en_mMoveRotation*en_mAppliedRotation; } // move is successful - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_TRYTOMOVE_PASS); - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_TRYTOMOVE_PASS); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); //CPrintF(" successful\n"); return TRUE; // if the move is clipped } else { - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_TRYTOMOVE_CLIP); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_TRYTOMOVE_CLIP); /* STREAMDUMP START if(GetRenderType()==RT_MODEL) @@ -1694,7 +1694,7 @@ out:; // if must not retry if (_ctTryToMoveCheckCounter<=0) { // fail - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); return FALSE; } @@ -1781,20 +1781,20 @@ out:; // make sure it is added to the movers list penBlocking->AddToMoversDuringMoving(); // push the blocking entity - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); BOOL bUnblocked = penBlocking->TryToMove(penPusher, bTranslate, bRotate); - _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StartTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); // if it has removed itself if (bUnblocked) { // retry the movement ClearNextPosition(); - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); return TryToMove(penPusher, bTranslate, bRotate); } else { // move is unsuccessful SendBlockEvent(cmMove); ClearNextPosition(); - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); return FALSE; } // if entity slides if blocked @@ -1849,7 +1849,7 @@ out:; if (cmMove.cm_pbpoHit!=NULL) { CSurfaceType &stHit = en_pwoWorld->wo_astSurfaceTypes[ cmMove.cm_pbpoHit->bpo_bppProperties.bpp_ubSurfaceType]; - // if it is not beeing pushed, and it can climb stairs + // if it is not being pushed, and it can climb stairs if (penPusher==NULL &&(en_ulPhysicsFlags&EPF_ONBLOCK_MASK)==EPF_ONBLOCK_CLIMBORSLIDE) { // NOTE: originally, the polygon's plane was considered here. @@ -1874,7 +1874,7 @@ out:; // if can go upstairs && TryToGoUpstairs(en_vMoveTranslation, stHit, bHitStairs)) { // movement is ok - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); return FALSE; } } @@ -1895,19 +1895,19 @@ out:; // if initial movement has some substantial value if(en_vMoveTranslation.Length()>0.001f && cmMove.cm_fMovementFraction>0.002f) { // go to where it is clipped (little bit before) - vSliding += en_vMoveTranslation*(cmMove.cm_fMovementFraction*0.985f); + vSliding += en_vMoveTranslation*(cmMove.cm_fMovementFraction*0.98f); } // ignore extremely small sliding if (vSliding.ManhattanNorm()<0.001f) { - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); return FALSE; } // recurse en_vMoveTranslation = vSliding; ClearNextPosition(); - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); TryToMove(penPusher, bTranslate, bRotate); // if bouncer if (bBounce) { @@ -1931,7 +1931,7 @@ out:; if (en_aDesiredRotationRelative.Length()<10) { en_aDesiredRotationRelative = ANGLE3D(0,0,0); } - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); // move is not successful return FALSE; } @@ -1939,13 +1939,13 @@ out:; en_vMoveTranslation = cmMove.cm_vClippedLine*-1.2f; // recurse ClearNextPosition(); - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); TryToMove(penPusher, TRUE, bRotate); // move is not entirely successful return FALSE; } // not translating and not rotating? - move is unsuccessful - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); return FALSE; // if entity has some other behaviour when blocked @@ -1953,7 +1953,7 @@ out:; // move is unsuccessful (EPF_ONBLOCK_STOP is assumed) SendBlockEvent(cmMove); ClearNextPosition(); - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_TRYTOTRANSLATE); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_TRYTOTRANSLATE); return FALSE; } } @@ -2019,8 +2019,8 @@ out:; ExportEntityPlacementAndSpeed( *(CMovableEntity *)this, "Pre moving (start of function)"); STREAMDUMP END */ - _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_PREMOVING); - _pfPhysicsProfile.IncrementTimerAveragingCounter(CPhysicsProfile::PTI_PREMOVING); + _pfPhysicsProfile.StartTimer((INDEX) CPhysicsProfile::PTI_PREMOVING); + _pfPhysicsProfile.IncrementTimerAveragingCounter((INDEX) CPhysicsProfile::PTI_PREMOVING); // remember old placement for lerping en_plLastPlacement = en_plPlacement; @@ -2260,7 +2260,7 @@ out:; // if gravity can cause the entity to fall if (!bGravityAlongPolygon) { - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_GRAVITY_NONTRIVIAL); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_GRAVITY_NONTRIVIAL); // add gravity acceleration FLOAT fGV=en_fGravityV*fTickQuantum*fSpeedModifier; @@ -2268,7 +2268,7 @@ out:; AddGAcceleration(vTranslationAbsolute, en_vGravityDir, fGA, fGV); // if entity can only slide down its stand-on polygon } else { - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_GRAVITY_TRIVIAL); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_GRAVITY_TRIVIAL); // disassemble gravity to parts parallel and normal to plane FLOAT3D vPolygonDir = -en_vReferencePlane; @@ -2419,7 +2419,7 @@ out:; // clear applied movement to be updated during movement en_vAppliedTranslation = FLOAT3D(0.0f, 0.0f, 0.0f); en_mAppliedRotation.Diagonal(1.0f); - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_PREMOVING); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_PREMOVING); // STREAMDUMP ExportEntityPlacementAndSpeed( *(CMovableEntity *)this, "Pre moving (end of function)"); } @@ -2845,16 +2845,16 @@ out:; } // STREAMDUMP ExportEntityPlacementAndSpeed(*(CMovableEntity *)this, "Do moving (start of function)"); - _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_DOMOVING); - _pfPhysicsProfile.IncrementTimerAveragingCounter(CPhysicsProfile::PTI_DOMOVING); + _pfPhysicsProfile.StartTimer((INDEX) CPhysicsProfile::PTI_DOMOVING); + _pfPhysicsProfile.IncrementTimerAveragingCounter((INDEX) CPhysicsProfile::PTI_DOMOVING); - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_DOMOVING); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING); FLOAT fTickQuantum=_pTimer->TickQuantum; // used for normalizing from SI units to game ticks // if rotation and translation are synchronized if (en_ulPhysicsFlags&EPF_RT_SYNCHRONIZED) { - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_DOMOVING_SYNC); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING_SYNC); // move both in translation and rotation en_vMoveTranslation = en_vIntendedTranslation-en_vAppliedTranslation; @@ -2870,11 +2870,11 @@ out:; // if rotation and translation are asynchronious } else { ASSERT((en_ulPhysicsFlags&EPF_ONBLOCK_MASK)!=EPF_ONBLOCK_PUSH); - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_DOMOVING_ASYNC); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING_ASYNC); // if there is no reference if (en_penReference == NULL) { - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_DOMOVING_ASYNC_SYNCTRY); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING_ASYNC_SYNCTRY); // try to do simple move both in translation and rotation en_vMoveTranslation = en_vIntendedTranslation-en_vAppliedTranslation; @@ -2885,14 +2885,14 @@ out:; // if it passes if (bMoveSuccessfull) { // finish - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_DOMOVING_ASYNC_SYNCPASS); - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_DOMOVING); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING_ASYNC_SYNCPASS); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_DOMOVING); // STREAMDUMP ExportEntityPlacementAndSpeed(*(CMovableEntity *)this, "Do moving (return: if it passes)"); return; } } - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_DOMOVING_ASYNC_TRANSLATE); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING_ASYNC_TRANSLATE); // translate en_vMoveTranslation = en_vIntendedTranslation-en_vAppliedTranslation; InitTryToMove(); @@ -2904,13 +2904,13 @@ out:; en_mMoveRotation(1,1)!=1 || en_mMoveRotation(1,2)!=0 || en_mMoveRotation(1,3)!=0 || en_mMoveRotation(2,1)!=0 || en_mMoveRotation(2,2)!=1 || en_mMoveRotation(2,3)!=0 || en_mMoveRotation(3,1)!=0 || en_mMoveRotation(3,2)!=0 || en_mMoveRotation(3,3)!=1) { - _pfPhysicsProfile.IncrementCounter(CPhysicsProfile::PCI_DOMOVING_ASYNC_ROTATE); + _pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING_ASYNC_ROTATE); InitTryToMove(); TryToMove(NULL, FALSE, TRUE); } } - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_DOMOVING); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_DOMOVING); // STREAMDUMP ExportEntityPlacementAndSpeed(*(CMovableEntity *)this, "Do moving (end of function)"); } @@ -2930,8 +2930,8 @@ out:; // STREAMDUMP ExportEntityPlacementAndSpeed(*(CMovableEntity *)this, "Post moving (start of function)"); - _pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_POSTMOVING); - _pfPhysicsProfile.IncrementTimerAveragingCounter(CPhysicsProfile::PTI_POSTMOVING); + _pfPhysicsProfile.StartTimer((INDEX) CPhysicsProfile::PTI_POSTMOVING); + _pfPhysicsProfile.IncrementTimerAveragingCounter((INDEX) CPhysicsProfile::PTI_POSTMOVING); // remember valid reference if valid if (en_penReference!=NULL) { @@ -3074,7 +3074,7 @@ out:; } //CPrintF("\n%f", _pTimer->CurrentTick()); - _pfPhysicsProfile.StopTimer(CPhysicsProfile::PTI_POSTMOVING); + _pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_POSTMOVING); // STREAMDUMP ExportEntityPlacementAndSpeed(*(CMovableEntity *)this, "Post moving (end of function)"); } diff --git a/Sources/Engine/Classes/MovableModelEntity.es b/Sources/Engine/Classes/MovableModelEntity.es index 584287e..70a33e8 100644 --- a/Sources/Engine/Classes/MovableModelEntity.es +++ b/Sources/Engine/Classes/MovableModelEntity.es @@ -6,7 +6,7 @@ 2 %{ -#include "StdH.h" +#include #include #include #include diff --git a/Sources/Engine/Classes/PlayerEntity.es b/Sources/Engine/Classes/PlayerEntity.es index 49ed97a..882dd5e 100644 --- a/Sources/Engine/Classes/PlayerEntity.es +++ b/Sources/Engine/Classes/PlayerEntity.es @@ -5,7 +5,7 @@ */ 4 %{ -#include "StdH.h" +#include #include #include #include @@ -40,7 +40,9 @@ functions: if (IsPredictor()) { penMe = GetPredicted(); } - for (INDEX iPlayer=0; iPlayer #include #include +#include #include #include #include #include #include -#include +#include #include #include #include @@ -31,6 +32,10 @@ #include #include +#if (defined PLATFORM_MACOSX) +#include +#endif + // this version string can be referenced from outside the engine ENGINE_API CTString _strEngineBuild = ""; ENGINE_API ULONG _ulEngineBuildMajor = _SE_BUILD_MAJOR; @@ -40,12 +45,13 @@ ENGINE_API BOOL _bDedicatedServer = FALSE; ENGINE_API BOOL _bWorldEditorApp = FALSE; ENGINE_API CTString _strLogFile = ""; -// global handle for application window -extern HWND _hwndMain = NULL; -extern BOOL _bFullScreen = FALSE; +// global handle for application windows +// !!! FIXME rcg10072001 this needs to be abstracted. +static HWND _hwndMain = NULL; +static BOOL _bFullScreen = FALSE; + +CTCriticalSection zip_csLock; // critical section for access to zlib functions -// critical section for access to zlib functions -CTCriticalSection zip_csLock; // to keep system gamma table static UWORD auwSystemGamma[256*3]; @@ -83,8 +89,10 @@ static CTString sys_strModName = ""; static CTString sys_strModExt = ""; // enables paranoia checks for allocation array -extern BOOL _bAllocationArrayParanoiaCheck = FALSE; +BOOL _bAllocationArrayParanoiaCheck = FALSE; +// rcg10072001 +#ifdef PLATFORM_WIN32 BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) @@ -103,14 +111,19 @@ BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReser static void DetectCPU(void) { +#if (defined USE_PORTABLE_C) // rcg10072001 + CPrintF(TRANS(" (No CPU detection in this binary.)\n")); + +#else char strVendor[12+1]; strVendor[12] = 0; ULONG ulTFMS; ULONG ulFeatures; + #if (defined __MSVC_INLINE__) // test MMX presence and update flag __asm { - mov eax,0 ;// request for basic id + xor eax,eax ;// request for basic id cpuid mov dword ptr [strVendor+0], ebx mov dword ptr [strVendor+4], edx @@ -121,6 +134,43 @@ static void DetectCPU(void) mov dword ptr [ulFeatures], edx } + #elif (defined __GNU_INLINE__) + // test MMX presence and update flag + __asm__ __volatile__ ( + "pushl %%ebx \n\t" + "xorl %%eax,%%eax \n\t" // request for basic id + "cpuid \n\t" + "movl %%ebx, (%%esi) \n\t" + "movl %%edx, 4(%%esi) \n\t" + "movl %%ecx, 8(%%esi) \n\t" + "popl %%ebx \n\t" + : // no specific outputs. + : "S" (strVendor) + : "eax", "ecx", "edx", "memory" + ); + + // need to break this into a separate asm block, since I'm clobbering + // too many registers. There's something to be said for letting MSVC + // figure out where on the stack your locals are resting, but yeah, + // I know, that's x86-specific anyhow... + // !!! FIXME: can probably do this right with modern GCC. + + __asm__ __volatile__ ( + "pushl %%ebx \n\t" + "movl $1, %%eax \n\t" // request for TFMS feature flags + "cpuid \n\t" + "mov %%eax, (%%esi) \n\t" // remember type, family, model and stepping + "mov %%edx, (%%edi) \n\t" + "popl %%ebx \n\t" + : // no specific outputs. + : "S" (&ulTFMS), "D" (&ulFeatures) + : "eax", "ecx", "edx", "memory" + ); + + #else + #error Please implement for your platform or define USE_PORTABLE_C. + #endif + INDEX iType = (ulTFMS>>12)&0x3; INDEX iFamily = (ulTFMS>> 8)&0xF; INDEX iModel = (ulTFMS>> 4)&0xF; @@ -137,8 +187,8 @@ static void DetectCPU(void) CTString strYes = TRANS("Yes"); CTString strNo = TRANS("No"); - CPrintF(TRANS(" MMX : %s\n"), bMMX ?strYes:strNo); - CPrintF(TRANS(" CMOV: %s\n"), bCMOV?strYes:strNo); + CPrintF(TRANS(" MMX : %s\n"), (const char *) (bMMX ?strYes:strNo)); + CPrintF(TRANS(" CMOV: %s\n"), (const char *) (bCMOV?strYes:strNo)); CPrintF(TRANS(" Clock: %.0fMHz\n"), _pTimer->tm_llCPUSpeedHZ/1E6); sys_strCPUVendor = strVendor; @@ -151,15 +201,27 @@ static void DetectCPU(void) sys_iCPUMHz = INDEX(_pTimer->tm_llCPUSpeedHZ/1E6); if( !bMMX) FatalError( TRANS("MMX support required but not present!")); + +#endif // defined USE_PORTABLE_C } static void DetectCPUWrapper(void) { +#ifdef _MSC_VER // rcg10072001 __try { DetectCPU(); } __except(EXCEPTION_EXECUTE_HANDLER) { CPrintF( TRANS("Cannot detect CPU: exception raised.\n")); } +#else + // We just have to punt and try this. The exception we're catching here + // is really a matter of whether the CPUID instruction is missing (on a + // pre Pentium system, which can't run this game anyhow) which will raise + // SIGILL on Unix platforms, or the CPU doesn't have MMX, in which case + // FatalError will end the process. USE_PORTABLE_C users will not have + // any exception at all. Have I rationalized this enough, yet? :) --ryan. + DetectCPU(); +#endif } // reverses string @@ -181,41 +243,80 @@ static char strDirPath[MAX_PATH] = ""; static void AnalyzeApplicationPath(void) { - strcpy(strDirPath, "D:\\"); - strcpy(strExePath, "D:\\TestExe.xbe"); + // rcg10072001 rewritten with abstraction layer. + const char *_dirsep = CFileSystem::GetDirSeparator(); + size_t seplen = strlen(_dirsep); + char *dirsep = new char[seplen + 1]; + strcpy(dirsep, _dirsep); + StrRev(dirsep); + char strTmpPath[MAX_PATH] = ""; - // get full path to the exe - GetModuleFileNameA( NULL, strExePath, sizeof(strExePath)-1); - // copy that to the path + + _pFileSystem->GetExecutablePath(strExePath, sizeof (strExePath)-1); strncpy(strTmpPath, strExePath, sizeof(strTmpPath)-1); strDirPath[sizeof(strTmpPath)-1] = 0; // remove name from application path StrRev(strTmpPath); // find last backslash - char *pstr = strchr( strTmpPath, '\\'); + char *pstr = strstr( strTmpPath, dirsep); if( pstr==NULL) { // not found - path is just "\" - strcpy( strTmpPath, "\\"); + strcpy( strTmpPath, dirsep); pstr = strTmpPath; } // remove 'debug' from app path if needed - if( strnicmp( pstr, "\\gubed", 6)==0) pstr += 6; - if( pstr[0] = '\\') pstr++; - char *pstrFin = strchr( pstr, '\\'); + if( strnicmp( pstr, (CTString(dirsep)+"gubed"), 5+seplen)==0) pstr += (5 + seplen); + if( strncmp(pstr, dirsep, seplen) == 0) pstr += seplen; + char *pstrFin = strstr( pstr, dirsep); if( pstrFin==NULL) { - strcpy( pstr, "\\"); + strcpy( pstr, dirsep); pstrFin = pstr; } // copy that to the path StrRev(pstrFin); strncpy( strDirPath, pstrFin, sizeof(strDirPath)-1); strDirPath[sizeof(strDirPath)-1] = 0; + delete[] dirsep; } +// rcg03242003 +static void SanityCheckTypes(void) +{ + ASSERT(sizeof (SBYTE) == 1); + ASSERT(sizeof (UBYTE) == 1); + ASSERT(sizeof (UWORD) == 2); + ASSERT(sizeof (SWORD) == 2); + ASSERT(sizeof (ULONG) == 4); + ASSERT(sizeof (SLONG) == 4); + ASSERT(sizeof (INDEX) == 4); + ASSERT(sizeof (BOOL) == 4); + + ULONG val = 0x02000001; + UBYTE num = *((UBYTE *) &val); + #if PLATFORM_BIGENDIAN + #if PLATFORM_LITTLEENDIAN + #error uh...what? + #endif + ASSERT(num == 0x02); + #endif + #if PLATFORM_LITTLEENDIAN + #if PLATFORM_BIGENDIAN + #error uh...what? + #endif + ASSERT(num == 0x01); + #endif +} // startup engine -ENGINE_API void SE_InitEngine(CTString strGameID) +ENGINE_API void SE_InitEngine(const char *argv0, CTString strGameID) { + SanityCheckTypes(); + + const char *gamename = "UnknownGame"; + if (strGameID != "") + gamename = (const char *) strGameID; + _pFileSystem = CFileSystem::GetInstance(argv0, gamename); // rcg10082001 + #pragma message(">> Remove this from SE_InitEngine : _bWorldEditorApp") if(strGameID=="SeriousEditor") { _bWorldEditorApp = TRUE; @@ -224,6 +325,12 @@ ENGINE_API void SE_InitEngine(CTString strGameID) AnalyzeApplicationPath(); _fnmApplicationPath = CTString(strDirPath); _fnmApplicationExe = CTString(strExePath); + + // rcg01012002 calculate user dir. + char buf[MAX_PATH]; + _pFileSystem->GetUserDirectory(buf, sizeof (buf)); + _fnmUserDir = CTString(buf); + try { _fnmApplicationExe.RemoveApplicationPath_t(); } catch (char *strError) { @@ -234,8 +341,10 @@ ENGINE_API void SE_InitEngine(CTString strGameID) _pConsole = new CConsole; if (_strLogFile=="") { _strLogFile = CTFileName(CTString(strExePath)).FileName(); + // chop off end of Unix executable filename... --ryan. + _strLogFile.ReplaceSubstr(CTString("-bin"), CTString("")); } - _pConsole->Initialize(_fnmApplicationPath+_strLogFile+".log", 90, 512); + _pConsole->Initialize(_fnmUserDir+_strLogFile+".log", 90, 512); _pAnimStock = new CStock_CAnimData; _pTextureStock = new CStock_CTextureData; @@ -247,6 +356,11 @@ ENGINE_API void SE_InitEngine(CTString strGameID) _pAnimSetStock = new CStock_CAnimSet; _pShaderStock = new CStock_CShader; + // rcg11232001 I moved this here so I can register platform-specific cvars. + // init main shell + _pShell = new CShell; + _pShell->Initialize(); + _pTimer = new CTimer; _pGfx = new CGfxLibrary; _pSound = new CSoundLibrary; @@ -259,20 +373,23 @@ ENGINE_API void SE_InitEngine(CTString strGameID) // print basic engine info CPrintF(TRANS("--- Serious Engine Startup ---\n")); - CPrintF(" %s\n\n", _strEngineBuild); + CPrintF(" %s\n\n", (const char *) _strEngineBuild); // print info on the started application CPrintF(TRANS("Executable: %s\n"), strExePath); - CPrintF(TRANS("Assumed engine directory: %s\n"), _fnmApplicationPath); + CPrintF(TRANS("Assumed engine directory: %s\n"), (const char *) _fnmApplicationPath); CPrintF("\n"); // report os info CPrintF(TRANS("Examining underlying OS...\n")); - OSVERSIONINFOA osv; + +// !!! FIXME: Abstract this somehow. +#if (defined PLATFORM_WIN32) + OSVERSIONINFO osv; memset(&osv, 0, sizeof(osv)); osv.dwOSVersionInfoSize = sizeof(osv); - if (GetVersionExA(&osv)) { + if (GetVersionEx(&osv)) { switch (osv.dwPlatformId) { case VER_PLATFORM_WIN32s: sys_strOS = "Win32s"; break; case VER_PLATFORM_WIN32_WINDOWS: sys_strOS = "Win9x"; break; @@ -292,11 +409,37 @@ ENGINE_API void SE_InitEngine(CTString strGameID) } else { CPrintF(TRANS("Error getting OS info: %s\n"), GetWindowsError(GetLastError()) ); } + +#elif (defined PLATFORM_MACOSX) + long osver = 0x0000; + OSErr err = Gestalt(gestaltSystemVersion, &osver); + if (err != noErr) + osver = 0x0000; + + sys_iOSMajor = ((osver & 0x0F00) >> 8) + (((osver & 0xF000) >> 12) * 10); + sys_iOSMinor = ((osver & 0x00F0) >> 4); + sys_iOSBuild = ((osver & 0x000F) >> 0); + sys_strOS = "Mac OS X"; + sys_strOSMisc = "Mac OS"; + CPrintF(TRANS(" Type: %s\n"), (const char*)sys_strOS); + CPrintF(TRANS(" Version: %d.%d.%d\n"), + (int)sys_iOSMajor, (int)sys_iOSMinor, (int)sys_iOSBuild); + +#elif (defined PLATFORM_UNIX) // !!! FIXME: rcg10082001 what to do with this? + sys_iOSMajor = 1; + sys_iOSMinor = 0; + sys_iOSBuild = 0; + sys_strOS = "Unix"; + sys_strOSMisc = "Unix"; + CPrintF(TRANS(" Type: %s\n"), (const char*)sys_strOS); + +#else + #error Do something with this for your platform. +#endif + CPrintF("\n"); - // init main shell - _pShell = new CShell; - _pShell->Initialize(); + // (rcg11232001 this is where _pShell was originally created.) // report CPU CPrintF(TRANS("Detecting CPU...\n")); @@ -307,6 +450,7 @@ ENGINE_API void SE_InitEngine(CTString strGameID) extern void ReportGlobalMemoryStatus(void); ReportGlobalMemoryStatus(); +#if (defined PLATFORM_WIN32) // !!! FIXME: Abstract this somehow. MEMORYSTATUS ms; GlobalMemoryStatus(&ms); @@ -314,10 +458,21 @@ ENGINE_API void SE_InitEngine(CTString strGameID) sys_iRAMPhys = ms.dwTotalPhys /MB; sys_iRAMSwap = ms.dwTotalPageFile/MB; +#elif (defined PLATFORM_UNIX) + sys_iRAMPhys = 1; // !!! FIXME: This is bad. Bad. BAD. + sys_iRAMSwap = 1; + +#else + #error Do something with this for your platform. +#endif + // initialize zip semaphore zip_csLock.cs_iIndex = -1; // not checked for locking order +// rcg10082001 Honestly, all of this is meaningless in a multitasking OS. +// That includes Windows, too. +#if (defined PLATFORM_WIN32) // !!! FIXME: Abstract this somehow. // get info on the first disk in system DWORD dwSerial; DWORD dwFreeClusters; @@ -330,48 +485,57 @@ ENGINE_API void SE_InitEngine(CTString strGameID) GetVolumeInformationA(strDrive, NULL, 0, &dwSerial, NULL, NULL, NULL, 0); GetDiskFreeSpaceA(strDrive, &dwSectors, &dwBytes, &dwFreeClusters, &dwClusters); - sys_iHDDSize = __int64(dwSectors)*dwBytes*dwClusters/MB; - sys_iHDDFree = __int64(dwSectors)*dwBytes*dwFreeClusters/MB; + sys_iHDDSize = ((__int64)dwSectors)*dwBytes*dwClusters/MB; + sys_iHDDFree = ((__int64)dwSectors)*dwBytes*dwFreeClusters/MB; sys_iHDDMisc = dwSerial; + +#elif (defined PLATFORM_UNIX) // !!! FIXME: Uhh...? + sys_iHDDSize = 1; + sys_iHDDFree = 1; + sys_iHDDMisc = 0xDEADBEEF; + +#else + #error Do something with this for your platform. +#endif // add console variables extern INDEX con_bNoWarnings; extern INDEX wld_bFastObjectOptimization; extern INDEX fil_bPreferZips; extern FLOAT mth_fCSGEpsilon; - _pShell->DeclareSymbol("user INDEX con_bNoWarnings;", &con_bNoWarnings); - _pShell->DeclareSymbol("user INDEX wld_bFastObjectOptimization;", &wld_bFastObjectOptimization); - _pShell->DeclareSymbol("user FLOAT mth_fCSGEpsilon;", &mth_fCSGEpsilon); - _pShell->DeclareSymbol("persistent user INDEX fil_bPreferZips;", &fil_bPreferZips); + _pShell->DeclareSymbol("user INDEX con_bNoWarnings;", (void *) &con_bNoWarnings); + _pShell->DeclareSymbol("user INDEX wld_bFastObjectOptimization;", (void *) &wld_bFastObjectOptimization); + _pShell->DeclareSymbol("user FLOAT mth_fCSGEpsilon;", (void *) &mth_fCSGEpsilon); + _pShell->DeclareSymbol("persistent user INDEX fil_bPreferZips;", (void *) &fil_bPreferZips); // OS info - _pShell->DeclareSymbol("user const CTString sys_strOS ;", &sys_strOS); - _pShell->DeclareSymbol("user const INDEX sys_iOSMajor ;", &sys_iOSMajor); - _pShell->DeclareSymbol("user const INDEX sys_iOSMinor ;", &sys_iOSMinor); - _pShell->DeclareSymbol("user const INDEX sys_iOSBuild ;", &sys_iOSBuild); - _pShell->DeclareSymbol("user const CTString sys_strOSMisc;", &sys_strOSMisc); + _pShell->DeclareSymbol("user const CTString sys_strOS ;", (void *) &sys_strOS); + _pShell->DeclareSymbol("user const INDEX sys_iOSMajor ;", (void *) &sys_iOSMajor); + _pShell->DeclareSymbol("user const INDEX sys_iOSMinor ;", (void *) &sys_iOSMinor); + _pShell->DeclareSymbol("user const INDEX sys_iOSBuild ;", (void *) &sys_iOSBuild); + _pShell->DeclareSymbol("user const CTString sys_strOSMisc;", (void *) &sys_strOSMisc); // CPU info - _pShell->DeclareSymbol("user const CTString sys_strCPUVendor;", &sys_strCPUVendor); - _pShell->DeclareSymbol("user const INDEX sys_iCPUType ;", &sys_iCPUType ); - _pShell->DeclareSymbol("user const INDEX sys_iCPUFamily ;", &sys_iCPUFamily ); - _pShell->DeclareSymbol("user const INDEX sys_iCPUModel ;", &sys_iCPUModel ); - _pShell->DeclareSymbol("user const INDEX sys_iCPUStepping ;", &sys_iCPUStepping); - _pShell->DeclareSymbol("user const INDEX sys_bCPUHasMMX ;", &sys_bCPUHasMMX ); - _pShell->DeclareSymbol("user const INDEX sys_bCPUHasCMOV ;", &sys_bCPUHasCMOV ); - _pShell->DeclareSymbol("user const INDEX sys_iCPUMHz ;", &sys_iCPUMHz ); - _pShell->DeclareSymbol(" const INDEX sys_iCPUMisc ;", &sys_iCPUMisc ); + _pShell->DeclareSymbol("user const CTString sys_strCPUVendor;", (void *) &sys_strCPUVendor); + _pShell->DeclareSymbol("user const INDEX sys_iCPUType ;", (void *) &sys_iCPUType ); + _pShell->DeclareSymbol("user const INDEX sys_iCPUFamily ;", (void *) &sys_iCPUFamily ); + _pShell->DeclareSymbol("user const INDEX sys_iCPUModel ;", (void *) &sys_iCPUModel ); + _pShell->DeclareSymbol("user const INDEX sys_iCPUStepping ;", (void *) &sys_iCPUStepping); + _pShell->DeclareSymbol("user const INDEX sys_bCPUHasMMX ;", (void *) &sys_bCPUHasMMX ); + _pShell->DeclareSymbol("user const INDEX sys_bCPUHasCMOV ;", (void *) &sys_bCPUHasCMOV ); + _pShell->DeclareSymbol("user const INDEX sys_iCPUMHz ;", (void *) &sys_iCPUMHz ); + _pShell->DeclareSymbol(" const INDEX sys_iCPUMisc ;", (void *) &sys_iCPUMisc ); // RAM info - _pShell->DeclareSymbol("user const INDEX sys_iRAMPhys;", &sys_iRAMPhys); - _pShell->DeclareSymbol("user const INDEX sys_iRAMSwap;", &sys_iRAMSwap); - _pShell->DeclareSymbol("user const INDEX sys_iHDDSize;", &sys_iHDDSize); - _pShell->DeclareSymbol("user const INDEX sys_iHDDFree;", &sys_iHDDFree); - _pShell->DeclareSymbol(" const INDEX sys_iHDDMisc;", &sys_iHDDMisc); + _pShell->DeclareSymbol("user const INDEX sys_iRAMPhys;", (void *) &sys_iRAMPhys); + _pShell->DeclareSymbol("user const INDEX sys_iRAMSwap;", (void *) &sys_iRAMSwap); + _pShell->DeclareSymbol("user const INDEX sys_iHDDSize;", (void *) &sys_iHDDSize); + _pShell->DeclareSymbol("user const INDEX sys_iHDDFree;", (void *) &sys_iHDDFree); + _pShell->DeclareSymbol(" const INDEX sys_iHDDMisc;", (void *) &sys_iHDDMisc); // MOD info - _pShell->DeclareSymbol("user const CTString sys_strModName;", &sys_strModName); - _pShell->DeclareSymbol("user const CTString sys_strModExt;", &sys_strModExt); + _pShell->DeclareSymbol("user const CTString sys_strModName;", (void *) &sys_strModName); + _pShell->DeclareSymbol("user const CTString sys_strModExt;", (void *) &sys_strModExt); // Stock clearing extern void FreeUnusedStock(void); - _pShell->DeclareSymbol("user void FreeUnusedStock(void);", &FreeUnusedStock); + _pShell->DeclareSymbol("user void FreeUnusedStock(void);", (void *) &FreeUnusedStock); // Timer tick quantum _pShell->DeclareSymbol("user const FLOAT fTickQuantum;", (FLOAT*)&_pTimer->TickQuantum); @@ -434,6 +598,8 @@ ENGINE_API void SE_InitEngine(CTString strGameID) _pfdDisplayFont = NULL; _pfdConsoleFont = NULL; +// !!! FIXME: Move this into GfxLibrary... +#ifdef PLATFORM_WIN32 // readout system gamma table HDC hdc = GetDC(NULL); BOOL bOK = GetDeviceGammaRamp( hdc, &auwSystemGamma[0]); @@ -443,7 +609,13 @@ ENGINE_API void SE_InitEngine(CTString strGameID) CPrintF( TRANS("\nWARNING: Gamma, brightness and contrast are not adjustable!\n\n")); } // done ReleaseDC( NULL, hdc); - +#else + // !!! FIXME : rcg01072002 This CAN be done with SDL, actually. Move this somewhere. + CPrintF( TRANS("\nWARNING: Gamma, brightness and contrast are not adjustable!\n\n")); +#endif + +// !!! FIXME : rcg12072001 Move this somewhere else. +#ifdef PLATFORM_WIN32 // init IFeel HWND hwnd = NULL;//GetDesktopWindow(); HINSTANCE hInstance = GetModuleHandle(NULL); @@ -463,12 +635,15 @@ ENGINE_API void SE_InitEngine(CTString strGameID) } CPrintF("\n"); } +#endif } // shutdown entire engine ENGINE_API void SE_EndEngine(void) { +// !!! FIXME: Move this into GfxLibrary... +#ifdef PLATFORM_WIN32 // restore system gamma table (if needed) if( _pGfx->gl_ulFlags&GLF_ADJUSTABLEGAMMA) { HDC hdc = GetDC(NULL); @@ -476,6 +651,7 @@ ENGINE_API void SE_EndEngine(void) //ASSERT(bOK); ReleaseDC( NULL, hdc); } +#endif // free stocks delete _pEntityClassStock; _pEntityClassStock = NULL; @@ -499,6 +675,7 @@ ENGINE_API void SE_EndEngine(void) delete _pTimer; _pTimer = NULL; delete _pShell; _pShell = NULL; delete _pConsole; _pConsole = NULL; + delete _pFileSystem; _pFileSystem = NULL; extern void EndStreams(void); EndStreams(); @@ -562,6 +739,7 @@ ENGINE_API void SE_UpdateWindowHandle( HWND hwndMain) static BOOL TouchBlock(UBYTE *pubMemoryBlock, INDEX ctBlockSize) { +#if (defined __MSC_VER) // cannot pretouch block that are smaller than 64KB :( ctBlockSize -= 16*0x1000; if( ctBlockSize<4) return FALSE; @@ -589,14 +767,25 @@ touchLoop: __except(EXCEPTION_EXECUTE_HANDLER) { return FALSE; } + +#else + + // !!! FIXME: How necessary is this on a system with a good memory manager? + // !!! More importantly, will this help if the system is paging to disk + // !!! like mad anyhow? Leaving this as a no-op for most systems seems safe + // !!! to me. --ryan. + +#endif + return TRUE; } // pretouch all memory commited by process -extern BOOL _bNeedPretouch = FALSE; +BOOL _bNeedPretouch = FALSE; ENGINE_API extern void SE_PretouchIfNeeded(void) { +#if (defined PLATFORM_WIN32) // only if pretouching is needed? extern INDEX gam_bPretouch; if( !_bNeedPretouch || !gam_bPretouch) return; @@ -668,6 +857,14 @@ nextRegion: // some blocks failed? if( ctFails>1) CPrintF( TRANS("(%d blocks were skipped)\n"), ctFails); //_pShell->Execute("StockDump();"); + +#else + + // See dissertation in TouchBlock(). --ryan. + + _bNeedPretouch = FALSE; + +#endif } diff --git a/Sources/Engine/Engine.h b/Sources/Engine/Engine.h index a9cac2e..6f00c70 100644 --- a/Sources/Engine/Engine.h +++ b/Sources/Engine/Engine.h @@ -1,7 +1,10 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -// set this to 1 to enable checks whether somethig is deleted while iterating some array/container -#define CHECKARRAYLOCKING 0 +#ifndef SE_INCL_ENGINE_H +#define SE_INCL_ENGINE_H +#ifdef PRAGMA_ONCE + #pragma once +#endif #ifdef _WIN32 #ifndef PLATFORM_WIN32 @@ -9,8 +12,10 @@ #endif #endif +// set this to 1 to enable checks whether somethig is deleted while iterating some array/container +#define CHECKARRAYLOCKING 0 + #include -#include #include #include #include @@ -20,6 +25,10 @@ #include // for qsort #include // for FPU control +#if !PLATFORM_MACOSX +#include +#endif + /* rcg10042001 !!! FIXME: Move these somewhere. */ #if (defined PLATFORM_WIN32) #include @@ -53,6 +62,10 @@ #include #include +#include // rcg10082001 +#include // rcg10082001 +#include // rcg10242001 + #include #include #include @@ -152,24 +165,31 @@ #include #include - // some global stuff -ENGINE_API void SE_InitEngine( CTString strGameID); + +// rcg10072001 (argv0) is, literally, argv[0] from your mainline. We need this +// on some platforms to determine where the program is running from in the +// filesystem. +ENGINE_API void SE_InitEngine(const char *argv0, CTString strGameID); ENGINE_API void SE_EndEngine(void); ENGINE_API void SE_LoadDefaultFonts(void); ENGINE_API void SE_UpdateWindowHandle( HWND hwndWindowed); ENGINE_API void SE_PretouchIfNeeded(void); -extern ENGINE_API CTString _strEngineBuild; // not valid before InitEngine()! -extern ENGINE_API ULONG _ulEngineBuildMajor; -extern ENGINE_API ULONG _ulEngineBuildMinor; +ENGINE_API extern CTString _strEngineBuild; // not valid before InitEngine()! +ENGINE_API extern ULONG _ulEngineBuildMajor; +ENGINE_API extern ULONG _ulEngineBuildMinor; -extern ENGINE_API BOOL _bDedicatedServer; -extern ENGINE_API BOOL _bWorldEditorApp; // is this world edtior app -extern ENGINE_API CTString _strLogFile; +ENGINE_API extern BOOL _bDedicatedServer; +ENGINE_API extern BOOL _bWorldEditorApp; // is this world editor app +ENGINE_API extern CTString _strLogFile; // temporary vars for adjustments ENGINE_API extern FLOAT tmp_af[10]; ENGINE_API extern INDEX tmp_ai[10]; ENGINE_API extern INDEX tmp_i; ENGINE_API extern INDEX tmp_fAdd; + +#endif /* include-once blocker. */ + + diff --git a/Sources/Engine/Entities/Entity.cpp b/Sources/Engine/Entities/Entity.cpp index ce8e4f1..e6a731b 100644 --- a/Sources/Engine/Entities/Entity.cpp +++ b/Sources/Engine/Entities/Entity.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -875,7 +875,7 @@ void CEntity::Teleport(const CPlacement3D &plNew, BOOL bTelefrag /*=TRUE*/) CEntity *ppenObstacleDummy; if (pmme->CheckForCollisionNow(pmme->en_iCollisionBox, &ppenObstacleDummy)) { CPrintF("Entity '%s' was teleported inside a wall at (%g,%g,%g)!\n", - GetName(), + (const char *) GetName(), en_plPlacement.pl_PositionVector(1), en_plPlacement.pl_PositionVector(2), en_plPlacement.pl_PositionVector(3)); @@ -998,7 +998,7 @@ void CEntity::FallDownToFloor( void) extern CEntity *_penLightUpdating; -extern BOOL _bDontDiscardLinks = FALSE; +BOOL _bDontDiscardLinks = FALSE; // internal repositioning function void CEntity::SetPlacement_internal(const CPlacement3D &plNew, const FLOATmatrix3D &mRotation, @@ -1432,8 +1432,8 @@ void CEntity::FindShadingInfo(void) INDEX iMipLevel = bsm.sm_iFirstMipLevel; FLOAT fpixU = FLOAT(vmexShadow(1)+bsm.sm_mexOffsetX)*(1.0f/(1<si_pixShadowU = floor(fpixU); - en_psiShadingInfo->si_pixShadowV = floor(fpixV); + en_psiShadingInfo->si_pixShadowU = (PIX) floor(fpixU); + en_psiShadingInfo->si_pixShadowV = (PIX) floor(fpixV); en_psiShadingInfo->si_fUDRatio = fpixU-en_psiShadingInfo->si_pixShadowU; en_psiShadingInfo->si_fLRRatio = fpixV-en_psiShadingInfo->si_pixShadowV; @@ -1444,8 +1444,8 @@ void CEntity::FindShadingInfo(void) en_psiShadingInfo->si_vNearPoint = _vNearPoint; FLOAT2D vTc = CalculateShadingTexCoords(_ptrTerrainNear,_vNearPoint); - en_psiShadingInfo->si_pixShadowU = floor(vTc(1)); - en_psiShadingInfo->si_pixShadowV = floor(vTc(2)); + en_psiShadingInfo->si_pixShadowU = (PIX) floor(vTc(1)); + en_psiShadingInfo->si_pixShadowV = (PIX) floor(vTc(2)); en_psiShadingInfo->si_fLRRatio = vTc(1) - en_psiShadingInfo->si_pixShadowU; en_psiShadingInfo->si_fUDRatio = vTc(2) - en_psiShadingInfo->si_pixShadowV; @@ -2356,7 +2356,7 @@ void CEntity::SetModel(const CTFileName &fnmModel) // if failed } catch(char *strErrorDefault) { FatalError(TRANS("Cannot load default model '%s':\n%s"), - (CTString&)fnmDefault, strErrorDefault); + (const char *) (CTString&)fnmDefault, strErrorDefault); } } UpdateSpatialRange(); @@ -2419,7 +2419,7 @@ BOOL CEntity::SetSkaModel(const CTString &fnmModel) // if failed } catch(char *strErrorDefault) { FatalError(TRANS("Cannot load default model '%s':\n%s"), - (CTString&)fnmDefault, strErrorDefault); + (const char *) (CTString&)fnmDefault, strErrorDefault); } // set colision info for default model SetSkaColisionInfo(); @@ -2476,7 +2476,7 @@ void CEntity::SetModelMainTexture(const CTFileName &fnmTexture) // if failed } catch(char *strErrorDefault) { FatalError(TRANS("Cannot load default texture '%s':\n%s"), - (CTString&)fnmDefault, strErrorDefault); + (const char *) (CTString&)fnmDefault, strErrorDefault); } } } @@ -2943,7 +2943,7 @@ void CEntity::PlaySound(CSoundObject &so, const CTFileName &fnmSound, SLONG slPl // if failed } catch(char *strErrorDefault) { FatalError(TRANS("Cannot load default sound '%s':\n%s"), - (CTString&)fnmDefault, strErrorDefault); + (const char *) (CTString&)fnmDefault, strErrorDefault); } } } @@ -3271,7 +3271,7 @@ void CEntity::Read_t( CTStream *istr) // throw char * >>en_ulCollisionFlags >>en_ulSpawnFlags >>en_ulFlags; - (*istr).Read_t(&en_mRotation, sizeof(en_mRotation)); + (*istr)>>en_mRotation; } else if (istr->PeekID_t()==CChunkID("ENT3")) { // entity v3 istr->ExpectID_t("ENT3"); (*istr)>>(ULONG &)en_RenderType @@ -3279,7 +3279,7 @@ void CEntity::Read_t( CTStream *istr) // throw char * >>en_ulCollisionFlags >>en_ulSpawnFlags >>en_ulFlags; - (*istr).Read_t(&en_mRotation, sizeof(en_mRotation)); + (*istr)>>en_mRotation; } else if (istr->PeekID_t()==CChunkID("ENT2")) { // entity v2 istr->ExpectID_t("ENT2"); (*istr)>>(ULONG &)en_RenderType @@ -3482,7 +3482,7 @@ void CEntity::DumpSync_t(CTStream &strm, INDEX iExtensiveSyncCheck) // throw ch strm.FPrintF_t("*** DELETED ***\n"); } strm.FPrintF_t("class: '%s'\n", GetClass()->ec_pdecDLLClass->dec_strName); - strm.FPrintF_t("name: '%s'\n", GetName()); + strm.FPrintF_t("name: '%s'\n", (const char *) GetName()); if (iExtensiveSyncCheck>0) { strm.FPrintF_t("en_ulFlags: 0x%08X\n", en_ulFlags&~ (ENF_SELECTED|ENF_INRENDERING|ENF_VALIDSHADINGINFO|ENF_FOUNDINGRIDSEARCH|ENF_WILLBEPREDICTED|ENF_PREDICTABLE)); @@ -3784,7 +3784,7 @@ void CRationalEntity::Write_t( CTStream *ostr) // throw char * void CRationalEntity::SetTimerAt(TIME timeAbsolute) { // must never set think back in time, except for special 'never' time - ASSERTMSG(timeAbsolute>_pTimer->CurrentTick() || + ASSERTMSG(timeAbsolute>=_pTimer->CurrentTick() || timeAbsolute==THINKTIME_NEVER, "Do not SetThink() back in time!"); // set the timer en_timeTimer = timeAbsolute; @@ -3881,7 +3881,7 @@ void CRationalEntity::Return(SLONG slThisState, const CEntityEvent &eeReturn) // print stack to debug output const char *CRationalEntity::PrintStackDebug(void) { - _RPT2(_CRT_WARN, "-- stack of '%s'@%gs\n", GetName(), _pTimer->CurrentTick()); + _RPT2(_CRT_WARN, "-- stack of '%s'@%gs\n", (const char *) GetName(), _pTimer->CurrentTick()); INDEX ctStates = en_stslStateStack.Count(); for(INDEX iState=ctStates-1; iState>=0; iState--) { diff --git a/Sources/Engine/Entities/EntityClass.cpp b/Sources/Engine/Entities/EntityClass.cpp index 121a95c..1f0f801 100644 --- a/Sources/Engine/Entities/EntityClass.cpp +++ b/Sources/Engine/Entities/EntityClass.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -208,52 +208,6 @@ void CEntityClass::ReleaseComponents(void) // overrides from CSerial ///////////////////////////////////////////////////// -/* - * Load a Dynamic Link Library. - */ -HINSTANCE LoadDLL_t(const char *strFileName) // throw char * -{ - HINSTANCE hiDLL = ::LoadLibraryA(strFileName); - - // if the DLL can not be loaded - if (hiDLL==NULL) { - // get the error code - DWORD dwMessageId = GetLastError(); - // format the windows error message - LPVOID lpMsgBuf; - DWORD dwSuccess = FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - dwMessageId, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language - (LPTSTR) &lpMsgBuf, - 0, - NULL - ); - CTString strWinError; - // if formatting succeeds - if (dwSuccess!=0) { - // copy the result - strWinError = ((char *)lpMsgBuf); - // free the windows message buffer - LocalFree( lpMsgBuf ); - } else { - // set our message about the failure - CTString strError; - strError.PrintF( - TRANS("Cannot format error message!\n" - "Original error code: %d,\n" - "Formatting error code: %d.\n"), - dwMessageId, GetLastError()); - strWinError = strError; - } - - // report error - ThrowF_t(TRANS("Cannot load DLL file '%s':\n%s"), strFileName, strWinError); - } - return hiDLL; -} - /* * Read from stream. */ @@ -265,31 +219,53 @@ void CEntityClass::Read_t( CTStream *istr) // throw char * CTString strClassName; strClassName.ReadFromText_t(*istr, "Class: "); - // create name of dll - #ifndef NDEBUG - fnmDLL = _fnmApplicationExe.FileDir()+fnmDLL.FileName()+_strModExt+"D"+fnmDLL.FileExt(); + const char *dllName = NULL; + + // load the DLL + #ifdef STATICALLY_LINKED + ec_hiClassDLL = CDynamicLoader::GetInstance(NULL); + dllName = "(statically linked)"; #else - fnmDLL = _fnmApplicationExe.FileDir()+fnmDLL.FileName()+_strModExt+fnmDLL.FileExt(); + // create name of dll + #ifndef NDEBUG + fnmDLL = fnmDLL.FileDir()+"Debug\\"+fnmDLL.FileName()+_strModExt+"D"+fnmDLL.FileExt(); + #else + fnmDLL = fnmDLL.FileDir()+fnmDLL.FileName()+_strModExt+fnmDLL.FileExt(); + #endif + fnmDLL = CDynamicLoader::ConvertLibNameToPlatform(fnmDLL); + CTFileName fnmExpanded; + ExpandFilePath(EFP_READ, fnmDLL, fnmExpanded); + dllName = fnmExpanded; + ec_hiClassDLL = CDynamicLoader::GetInstance(fnmExpanded); #endif + if (ec_hiClassDLL->GetError() != NULL) + { + CTString err(ec_hiClassDLL->GetError()); + delete ec_hiClassDLL; + ec_hiClassDLL = NULL; + ThrowF_t(TRANS("Cannot load DLL file '%s':\n%s"), + (const char *) dllName, (const char *) err); + } + + // load the DLL CTFileName fnmExpanded; ExpandFilePath(EFP_READ, fnmDLL, fnmExpanded); - ec_hiClassDLL = LoadDLL_t(fnmExpanded); ec_fnmClassDLL = fnmDLL; // get the pointer to the DLL class structure - ec_pdecDLLClass = (CDLLEntityClass *) GetProcAddress(ec_hiClassDLL, strClassName+"_DLLClass"); + ec_pdecDLLClass = (CDLLEntityClass *) ec_hiClassDLL->FindSymbol(strClassName+"_DLLClass"); + // if class structure is not found if (ec_pdecDLLClass == NULL) { // free the library - BOOL bSuccess = FreeLibrary(ec_hiClassDLL); - ASSERT(bSuccess); + delete ec_hiClassDLL; ec_hiClassDLL = NULL; ec_fnmClassDLL.Clear(); // report error - ThrowF_t(TRANS("Class '%s' not found in entity class package file '%s'"), strClassName, fnmDLL); + ThrowF_t(TRANS("Class '%s' not found in entity class package file '%s'"), (const char *) strClassName, dllName); } // obtain all components needed by the DLL @@ -356,7 +332,7 @@ CEntity::pEventHandler CEntityClass::HandlerForStateAndEvent(SLONG slState, SLON /* Get pointer to component from its identifier. */ class CEntityComponent *CEntityClass::ComponentForTypeAndID( - EntityComponentType ectType, SLONG slID) { + enum EntityComponentType ectType, SLONG slID) { return ec_pdecDLLClass->ComponentForTypeAndID(ectType, slID); } /* Get pointer to component from the component. */ diff --git a/Sources/Engine/Entities/EntityClass.h b/Sources/Engine/Entities/EntityClass.h index 5084d3a..7f0f705 100644 --- a/Sources/Engine/Entities/EntityClass.h +++ b/Sources/Engine/Entities/EntityClass.h @@ -8,7 +8,8 @@ #include #include -#include /* rcg10042001 */ +#include // rcg10042001 +#include // rcg10112001 /* * General structure of an entity class. @@ -21,7 +22,7 @@ public: void ReleaseComponents(void); public: CTFileName ec_fnmClassDLL; // filename of the DLL with the class - HINSTANCE ec_hiClassDLL; // handle to the DLL with the class + CDynamicLoader *ec_hiClassDLL; class CDLLEntityClass *ec_pdecDLLClass; // pointer to DLL class in the DLL /* Default constructor. */ @@ -50,9 +51,10 @@ public: /* Get event handler for given state and event code. */ CEntity::pEventHandler HandlerForStateAndEvent(SLONG slState, SLONG slEvent); /* Get pointer to component from its type and identifier. */ - class CEntityComponent *ComponentForTypeAndID(enum EntityComponentType ectType, SLONG slID); + class CEntityComponent *ComponentForTypeAndID( + enum EntityComponentType ectType, SLONG slID); /* Get pointer to component from the component. */ - class CEntityComponent *ComponentForPointer(void *pv); + inline class CEntityComponent *ComponentForPointer(void *pv); // overrides from CSerial /* Read from stream. */ diff --git a/Sources/Engine/Entities/EntityCollision.cpp b/Sources/Engine/Entities/EntityCollision.cpp index b9a1e2b..59c6bcb 100644 --- a/Sources/Engine/Entities/EntityCollision.cpp +++ b/Sources/Engine/Entities/EntityCollision.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Entities/EntityCopying.cpp b/Sources/Engine/Entities/EntityCopying.cpp index b9e6a22..01e3a4a 100644 --- a/Sources/Engine/Entities/EntityCopying.cpp +++ b/Sources/Engine/Entities/EntityCopying.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -36,7 +36,7 @@ public: static CStaticArray _aprRemaps; static BOOL _bRemapPointersToNULLs = TRUE; -extern BOOL _bReinitEntitiesWhileCopying = TRUE; +BOOL _bReinitEntitiesWhileCopying = TRUE; static BOOL _bMirrorAndStretch = FALSE; static FLOAT _fStretch = 1.0f; static enum WorldMirrorType _wmtMirror = WMT_NONE; diff --git a/Sources/Engine/Entities/EntityProperties.cpp b/Sources/Engine/Entities/EntityProperties.cpp index 21510a8..7e52f19 100644 --- a/Sources/Engine/Entities/EntityProperties.cpp +++ b/Sources/Engine/Entities/EntityProperties.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -183,21 +183,21 @@ void CEntity::ReadProperties_t(CTStream &istrm) // throw char * case CEntityProperty::EPT_FLOATAABBOX3D: { // skip FLOATAABBOX3D FLOATaabbox3D boxDummy; - istrm.Read_t(&boxDummy, sizeof(FLOATaabbox3D)); + istrm>>boxDummy; } break; // if it is FLOATMATRIX3D case CEntityProperty::EPT_FLOATMATRIX3D: { // skip FLOATMATRIX3D FLOATmatrix3D boxDummy; - istrm.Read_t(&boxDummy, sizeof(FLOATmatrix3D)); + istrm>>boxDummy; } break; // if it is EPT_FLOATQUAT3D case CEntityProperty::EPT_FLOATQUAT3D: { // skip EPT_FLOATQUAT3D FLOATquat3D qDummy; - istrm.Read_t(&qDummy, sizeof(FLOATquat3D)); + istrm>>qDummy; } break; // if it is FLOAT3D @@ -218,7 +218,7 @@ void CEntity::ReadProperties_t(CTStream &istrm) // throw char * case CEntityProperty::EPT_FLOATplane3D: { // skip FLOATplane3D FLOATplane3D plDummy; - istrm.Read_t(&plDummy, sizeof(plDummy)); + istrm>>plDummy; } break; // if it is MODELOBJECT @@ -331,32 +331,32 @@ void CEntity::ReadProperties_t(CTStream &istrm) // throw char * // if it is FLOATAABBOX3D case CEntityProperty::EPT_FLOATAABBOX3D: // read FLOATAABBOX3D - istrm.Read_t(&PROPERTY(pepProperty->ep_slOffset, FLOATaabbox3D), sizeof(FLOATaabbox3D)); + istrm>>(PROPERTY(pepProperty->ep_slOffset, FLOATaabbox3D)); break; // if it is FLOATMATRIX3D case CEntityProperty::EPT_FLOATMATRIX3D: // read FLOATMATRIX3D - istrm.Read_t(&PROPERTY(pepProperty->ep_slOffset, FLOATmatrix3D), sizeof(FLOATmatrix3D)); + istrm>>(PROPERTY(pepProperty->ep_slOffset, FLOATmatrix3D)); break; // if it is FLOATQUAT3D case CEntityProperty::EPT_FLOATQUAT3D: // read FLOATQUAT3D - istrm.Read_t(&PROPERTY(pepProperty->ep_slOffset, FLOATquat3D), sizeof(FLOATquat3D)); + istrm>>(PROPERTY(pepProperty->ep_slOffset, FLOATquat3D)); break; // if it is FLOAT3D case CEntityProperty::EPT_FLOAT3D: // read FLOAT3D - istrm.Read_t(&PROPERTY(pepProperty->ep_slOffset, FLOAT3D), sizeof(FLOAT3D)); + istrm>>(PROPERTY(pepProperty->ep_slOffset, FLOAT3D)); break; // if it is ANGLE3D case CEntityProperty::EPT_ANGLE3D: // read ANGLE3D - istrm.Read_t(&PROPERTY(pepProperty->ep_slOffset, ANGLE3D), sizeof(ANGLE3D)); + istrm>>(PROPERTY(pepProperty->ep_slOffset, ANGLE3D)); break; // if it is FLOATplane3D case CEntityProperty::EPT_FLOATplane3D: // read FLOATplane3D - istrm.Read_t(&PROPERTY(pepProperty->ep_slOffset, FLOATplane3D), sizeof(FLOATplane3D)); + istrm>>(PROPERTY(pepProperty->ep_slOffset, FLOATplane3D)); break; // if it is MODELOBJECT case CEntityProperty::EPT_MODELOBJECT: @@ -385,7 +385,7 @@ void CEntity::ReadProperties_t(CTStream &istrm) // throw char * // if it is CPlacement3D case CEntityProperty::EPT_PLACEMENT3D: // read CPlacement3D - istrm.Read_t(&PROPERTY(pepProperty->ep_slOffset, CPlacement3D), sizeof(CPlacement3D)); + istrm>>(PROPERTY(pepProperty->ep_slOffset, CPlacement3D)); break; default: ASSERTALWAYS("Unknown property type"); @@ -475,32 +475,32 @@ void CEntity::WriteProperties_t(CTStream &ostrm) // throw char * // if it is FLOATAABBOX3D case CEntityProperty::EPT_FLOATAABBOX3D: // write FLOATAABBOX3D - ostrm.Write_t(&PROPERTY(epProperty.ep_slOffset, FLOATaabbox3D), sizeof(FLOATaabbox3D)); + ostrm<ec_slID, ec_fnmComponent); + CPrintF(TRANS("Not precached: (0x%08X)'%s'\n"), this->ec_slID, (const char *) ec_fnmComponent); } - //CPrintF(TRANS("Precaching NOW: (0x%08X)'%s'\n"), this->ec_slID, ec_fnmComponent); + //CPrintF(TRANS("Precaching NOW: (0x%08X)'%s'\n"), this->ec_slID, (const char *) ec_fnmComponent); // add to CRC AddToCRCTable(); @@ -660,7 +660,7 @@ void CEntityComponent::Release(void) // if something else default: // error - ThrowF_t(TRANS("Component '%s'(%d) is of unknown type!"), (CTString&)ec_fnmComponent, ec_slID); + ThrowF_t(TRANS("Component '%s'(%d) is of unknown type!"), (const char *) (CTString&)ec_fnmComponent, ec_slID); } // released diff --git a/Sources/Engine/Entities/EntityProperties.h b/Sources/Engine/Entities/EntityProperties.h index 53b1472..9c64c41 100644 --- a/Sources/Engine/Entities/EntityProperties.h +++ b/Sources/Engine/Entities/EntityProperties.h @@ -24,7 +24,15 @@ public: // convert value of an enum to its name ENGINE_API const char *NameForValue(INDEX iValue); }; -#define EP_ENUMBEG(typename) extern _declspec (dllexport) CEntityPropertyEnumValue typename##_values[] = { + +/* rcg10072001 */ +#ifdef _MSC_VER + #define ENUMEXTERN extern _declspec (dllexport) +#else + #define ENUMEXTERN +#endif + +#define EP_ENUMBEG(typename) ENUMEXTERN CEntityPropertyEnumValue typename##_values[] = { #define EP_ENUMVALUE(value, name) {value, name} #define EP_ENUMEND(typename) }; CEntityPropertyEnumType typename##_enum = { \ typename##_values, sizeof(typename##_values)/sizeof(CEntityPropertyEnumValue ) } @@ -245,8 +253,7 @@ public: &classname##_OnWorldTick, \ &classname##_OnWorldRender, \ &classname##_OnWorldEnd \ - };\ - SYMBOLLOCATOR(classname##_DLLClass) + } #define ENTITY_CLASSDEFINITION_BASE(classname, id) \ extern "C" DECLSPEC_DLLEXPORT CDLLEntityClass classname##_DLLClass; \ diff --git a/Sources/Engine/Entities/FieldBSPTesting.cpp b/Sources/Engine/Entities/FieldBSPTesting.cpp index f1787bd..77a4fa0 100644 --- a/Sources/Engine/Entities/FieldBSPTesting.cpp +++ b/Sources/Engine/Entities/FieldBSPTesting.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Entities/LastPositions.cpp b/Sources/Engine/Entities/LastPositions.cpp index 84788a4..ce4d881 100644 --- a/Sources/Engine/Entities/LastPositions.cpp +++ b/Sources/Engine/Entities/LastPositions.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Entities/NearestPolygon.cpp b/Sources/Engine/Entities/NearestPolygon.cpp index c61ea37..b0597a2 100644 --- a/Sources/Engine/Entities/NearestPolygon.cpp +++ b/Sources/Engine/Entities/NearestPolygon.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Entities/PlayerCharacter.cpp b/Sources/Engine/Entities/PlayerCharacter.cpp index da824e3..2c0863d 100644 --- a/Sources/Engine/Entities/PlayerCharacter.cpp +++ b/Sources/Engine/Entities/PlayerCharacter.cpp @@ -1,17 +1,22 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include #include +#ifdef PLATFORM_WIN32 typedef HRESULT __stdcall CoCreateGuid_t(UBYTE *pguid); +#else +#include +#endif // get a GUID from system static void GetGUID(UBYTE aub[16]) { +#ifdef PLATFORM_WIN32 HINSTANCE hOle32Lib = NULL; CoCreateGuid_t *pCoCreateGuid = NULL; @@ -42,6 +47,14 @@ static void GetGUID(UBYTE aub[16]) } catch(char *strError) { FatalError(TRANS("Cannot make GUID for a player:\n%s"), strError); } + +#else + + // !!! FIXME : rcg10112001 Is this sufficient for these purposes? + for (int i = 0; i < sizeof (aub) / sizeof (aub[0]); i++) + aub[i] = (UBYTE) (255.0 * rand() / (RAND_MAX + 1.0)); + +#endif } /* diff --git a/Sources/Engine/Graphics/Adapter.cpp b/Sources/Engine/Graphics/Adapter.cpp index 268a37a..d634d98 100644 --- a/Sources/Engine/Graphics/Adapter.cpp +++ b/Sources/Engine/Graphics/Adapter.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -8,6 +8,11 @@ #include +// !!! FIXME : rcg11052001 move this somewhere. +#ifdef PLATFORM_UNIX +#include "SDL.h" +#endif + extern BOOL _bDedicatedServer; #ifdef SE1_D3D extern const D3DDEVTYPE d3dDevType; @@ -55,7 +60,8 @@ static CResolution _areResolutions[] = // THIS NUMBER MUST NOT BE OVER 25! (otherwise change it in adapter.h) static const INDEX MAX_RESOLUTIONS = sizeof(_areResolutions)/sizeof(_areResolutions[0]); - +// !!! FIXME : rcg11052001 abstract this... +#ifdef PLATFORM_WIN32 // initialize CDS support (enumerate modes at startup) void CGfxLibrary::InitAPIs(void) @@ -206,9 +212,102 @@ void CGfxLibrary::InitAPIs(void) D3DRELEASE( gl_pD3D, TRUE); if( gl_hiDriver!=NONE) FreeLibrary(gl_hiDriver); gl_hiDriver = NONE; -#endif // SE1_D3D } +#else + +/* +static SDL_Rect sdl_stdmode512x384 = { 0, 0, 512, 384 }; +static SDL_Rect sdl_stdmode640x480 = { 0, 0, 640, 480 }; +static SDL_Rect sdl_stdmode800x600 = { 0, 0, 800, 600 }; +static SDL_Rect sdl_stdmode1024x768 = { 0, 0, 1024, 768 }; + +static SDL_Rect *stdmodes[] = +{ + &sdl_stdmode512x384, + &sdl_stdmode640x480, + &sdl_stdmode800x600, + &sdl_stdmode1024x768, + NULL +}; +*/ + +static void sdl_addmodes(CDisplayAdapter *pda, Uint32 flags) +{ + Uint8 bpp = SDL_GetVideoInfo()->vfmt->BitsPerPixel; + DisplayDepth bits; + + if (bpp < 16) + return; + + switch (bpp) + { + case 16: + bits = DD_16BIT; + break; + case 32: + bits = DD_32BIT; + break; + case 24: + bits = DD_24BIT; + break; + default: + ASSERT(false); + } + + SDL_Rect **modes = SDL_ListModes(NULL, flags); + if ((modes == NULL) || (modes == (SDL_Rect **) -1)) + return; + + CDisplayMode *adm = &pda->da_admDisplayModes[0]; + size_t x = pda->da_ctDisplayModes; + size_t maxmodes = sizeof (pda->da_admDisplayModes) / sizeof (pda->da_admDisplayModes[0]); + for (int i = 0; ((modes[i] != NULL) && (x < maxmodes)); i++, x++) + { + adm[x].dm_pixSizeI = modes[i]->w; + adm[x].dm_pixSizeJ = modes[i]->h; + adm[x].dm_ddDepth = bits; + pda->da_ctDisplayModes++; + } +} + + +// initialize CDS support (enumerate modes at startup) +void CGfxLibrary::InitAPIs(void) +{ + // no need for gfx when dedicated server is on + if( _bDedicatedServer) return; + + // fill OpenGL adapter info + CDisplayAdapter *pda; + INDEX iResolution; + + gl_gaAPI[GAT_OGL].ga_ctAdapters = 1; + gl_gaAPI[GAT_OGL].ga_iCurrentAdapter = 0; + pda = &gl_gaAPI[GAT_OGL].ga_adaAdapter[0]; + pda->da_ulFlags = 0; + pda->da_strVendor = TRANS( "unknown"); + pda->da_strRenderer = TRANS( "Default ICD"); + pda->da_strVersion = "1.1+"; + + // detect modes for OpenGL ICD + pda->da_ctDisplayModes = 0; + pda->da_iCurrentDisplayMode = -1; + + if (SDL_Init(SDL_INIT_VIDEO) == -1) + { + CPrintF(TRANS("SDL_Init failed! Reason: %s\n"), SDL_GetError()); + return; + } + + sdl_addmodes(pda, SDL_OPENGL | SDL_FULLSCREEN); + sdl_addmodes(pda, SDL_OPENGL); +} + +#endif + + + // get list of all modes avaliable through CDS -- do not modify/free the returned list CListHead &CDS_GetModes(void) { @@ -222,6 +321,8 @@ BOOL CDS_SetMode( PIX pixSizeI, PIX pixSizeJ, enum DisplayDepth dd) // no need for gfx when dedicated server is on if( _bDedicatedServer) return FALSE; +// !!! FIXME : rcg11052001 better abstraction! +#ifdef PLATFORM_WIN32 // prepare general mode parameters DEVMODE devmode; memset(&devmode, 0, sizeof(devmode)); @@ -283,6 +384,7 @@ BOOL CDS_SetMode( PIX pixSizeI, PIX pixSizeJ, enum DisplayDepth dd) } // report CPrintF(TRANS(" CDS: mode set to %dx%dx%d\n"), pixSizeI, pixSizeJ, devmode.dmBitsPerPel); +#endif return TRUE; } @@ -293,7 +395,10 @@ void CDS_ResetMode(void) // no need for gfx when dedicated server is on if( _bDedicatedServer) return; +#ifdef PLATFORM_WIN32 LONG lRes = ChangeDisplaySettings( NULL, 0); ASSERT(lRes==DISP_CHANGE_SUCCESSFUL); CPrintF(TRANS(" CDS: mode reset to original desktop settings\n")); +#endif } + diff --git a/Sources/Engine/Graphics/Adapter.h b/Sources/Engine/Graphics/Adapter.h index 364db82..05fc92f 100644 --- a/Sources/Engine/Graphics/Adapter.h +++ b/Sources/Engine/Graphics/Adapter.h @@ -46,6 +46,7 @@ BOOL CDS_SetMode( PIX pixSizeI, PIX pixSizeJ, enum DisplayDepth dd); // reset windows to mode chosen by user within windows diplay properties void CDS_ResetMode(void); +ULONG DetermineDesktopWidth(void); #endif /* include-once check. */ diff --git a/Sources/Engine/Graphics/Benchmark.cpp b/Sources/Engine/Graphics/Benchmark.cpp index 40afa2f..9891d3a 100644 --- a/Sources/Engine/Graphics/Benchmark.cpp +++ b/Sources/Engine/Graphics/Benchmark.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -61,9 +61,8 @@ static DOUBLE FillRatePass(INDEX ct) { if( !_pdp->Lock()) { ASSERT(FALSE); - return 0; + return 0.0; } - StartTimer(); _pdp->Fill(C_GRAY|255); @@ -192,11 +191,12 @@ static void InitTris(void) _avtx[ivx].x = FLOAT(iC) / _ctC*4 -2.0f; _avtx[ivx].y = -FLOAT(iR) / _ctR*4 +2.0f; _avtx[ivx].z = -1.0f; - _atex[ivx].s = (iC+iR) % 2; - _atex[ivx].t = (iR) % 2; - _acol[ivx].abgr = 0xFFFFFFFF; + _atex[ivx].st.s = (iC+iR) % 2; + _atex[ivx].st.t = (iR) % 2; + _acol[ivx].ul.abgr = 0xFFFFFFFF; } } + INDEX ctTri = (_ctR-1)*(_ctC-1)*2; _aiElements.Push(ctTri*3); for( iR=0; iR<_ctR-1; iR++) { @@ -226,7 +226,7 @@ static DOUBLE TrisTroughputPass(INDEX ct) { if( !_pdp->Lock()) { ASSERT(FALSE); - return 0; + return 0.0; } StartTimer(); @@ -315,10 +315,12 @@ static DOUBLE _dX; static DOUBLE _dD; static void RunTest(DOUBLE (*pTest)(void), INDEX ct) { +#ifdef PLATFORM_WIN32 CSetPriority sp(REALTIME_PRIORITY_CLASS, THREAD_PRIORITY_TIME_CRITICAL); +#endif - DOUBLE dSum = 0; - DOUBLE dSum2 = 0; + DOUBLE dSum = 0.0; + DOUBLE dSum2 = 0.0; for(INDEX i=0; i<(ct+5); i++) { DOUBLE d = pTest(); // must ignore 1st couple of passes due to API queue @@ -345,7 +347,7 @@ void CGfxLibrary::Benchmark(CViewPort *pvp, CDrawPort *pdp) else if( _pGfx->gl_eCurrentAPI==GAT_D3D) strAPI = "Direct3D"; #endif // SE1_D3D CPrintF("=====================================\n"); - CPrintF("%s performance testing ...\n", strAPI); + CPrintF("%s performance testing ...\n", (const char *) strAPI); InitTexture(); InitTris(); @@ -388,36 +390,36 @@ void CGfxLibrary::Benchmark(CViewPort *pvp, CDrawPort *pdp) _bMultiTexture = 0; _bBlend = 0; _bDepth = 0; _bTexture = 0; RunTest(FillRate, 10); - CPrintF("%-38s %6.02f +- %5.02f Mpix/s\n", FillRateString(), _dX/1000/1000, _dD/1000/1000); + CPrintF("%-38s %6.02f +- %5.02f Mpix/s\n", (const char *) FillRateString(), _dX/1000/1000, _dD/1000/1000); _bBlend = 0; _bDepth = 0; _bTexture = 1; RunTest(FillRate, 10); - CPrintF("%-38s %6.02f +- %5.02f Mpix/s\n", FillRateString(), _dX/1000/1000, _dD/1000/1000); + CPrintF("%-38s %6.02f +- %5.02f Mpix/s\n", (const char *) FillRateString(), _dX/1000/1000, _dD/1000/1000); _bBlend = 0; _bDepth = 1; _bTexture = 1; RunTest(FillRate, 10); - CPrintF("%-38s %6.02f +- %5.02f Mpix/s\n", FillRateString(), _dX/1000/1000, _dD/1000/1000); + CPrintF("%-38s %6.02f +- %5.02f Mpix/s\n", (const char *) FillRateString(), _dX/1000/1000, _dD/1000/1000); _bBlend = 1; _bDepth = 1; _bTexture = 1; RunTest(FillRate, 10); - CPrintF("%-38s %6.02f +- %5.02f Mpix/s\n", FillRateString(), _dX/1000/1000, _dD/1000/1000); + CPrintF("%-38s %6.02f +- %5.02f Mpix/s\n", (const char *) FillRateString(), _dX/1000/1000, _dD/1000/1000); if( _pGfx->gl_ctTextureUnits>1) { _bMultiTexture = 1; RunTest(FillRate, 10); - CPrintF("%-38s %6.02f +- %5.02f Mpix/s\n", FillRateString(), _dX/1000/1000, _dD/1000/1000); + CPrintF("%-38s %6.02f +- %5.02f Mpix/s\n", (const char *) FillRateString(), _dX/1000/1000, _dD/1000/1000); } CPrintF("\n--- Geometry speed (%dpix tris)\n", (_pixSizeI/_ctR)*(_pixSizeI/_ctC)/2); _bMultiTexture = 0; _bBlend = 0; _bDepth = 1; _bTexture = 1; RunTest(TrisTroughput, 10); - CPrintF("%-34s %6.02f +- %5.02f Mtri/s\n", FillRateString(), _dX/1000/1000, _dD/1000/1000); + CPrintF("%-34s %6.02f +- %5.02f Mtri/s\n", (const char *) FillRateString(), _dX/1000/1000, _dD/1000/1000); _bBlend = 1; _bDepth = 1; _bTexture = 1; RunTest(TrisTroughput, 10); - CPrintF("%-34s %6.02f +- %5.02f Mtri/s\n", FillRateString(), _dX/1000/1000, _dD/1000/1000); + CPrintF("%-34s %6.02f +- %5.02f Mtri/s\n", (const char *) FillRateString(), _dX/1000/1000, _dD/1000/1000); if( _pGfx->gl_ctTextureUnits>1) { _bMultiTexture = 1; RunTest(TrisTroughput, 10); - CPrintF("%-34s %6.02f +- %5.02f Mtri/s\n", FillRateString(), _dX/1000/1000, _dD/1000/1000); + CPrintF("%-34s %6.02f +- %5.02f Mtri/s\n", (const char *) FillRateString(), _dX/1000/1000, _dD/1000/1000); } EndTris(); diff --git a/Sources/Engine/Graphics/Color.cpp b/Sources/Engine/Graphics/Color.cpp index 6a7f466..e5b32d1 100644 --- a/Sources/Engine/Graphics/Color.cpp +++ b/Sources/Engine/Graphics/Color.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -32,7 +32,7 @@ COLOR HSVToColor( UBYTE const ubH, UBYTE const ubS, UBYTE const ubV) case 3: return RGBToColor(slP,slQ,ubV); case 4: return RGBToColor(slT,slP,ubV); case 5: return RGBToColor(ubV,slP,slQ); - default: ASSERTALWAYS("WHAT???"); return C_BLACK; + default: ASSERTALWAYS("WHAT\?\?\?"); return C_BLACK; } } else return RGBToColor(ubV,ubV,ubV); } @@ -233,6 +233,31 @@ COLOR MulColors( COLOR col1, COLOR col2) if( col1==0xFFFFFFFF) return col2; if( col2==0xFFFFFFFF) return col1; if( col1==0 || col2==0) return 0; + +#if (defined USE_PORTABLE_C) + // !!! FIXME: This...is not fast. + union + { + COLOR col; + UBYTE bytes[4]; + } conv1; + + union + { + COLOR col; + UBYTE bytes[4]; + } conv2; + + conv1.col = col1; + conv2.col = col2; + conv1.bytes[0] = (UBYTE) ((((DWORD) conv1.bytes[0]) * ((DWORD) conv2.bytes[0])) / 255); + conv1.bytes[1] = (UBYTE) ((((DWORD) conv1.bytes[1]) * ((DWORD) conv2.bytes[1])) / 255); + conv1.bytes[2] = (UBYTE) ((((DWORD) conv1.bytes[2]) * ((DWORD) conv2.bytes[2])) / 255); + conv1.bytes[3] = (UBYTE) ((((DWORD) conv1.bytes[3]) * ((DWORD) conv2.bytes[3])) / 255); + + return(conv1.col); + +#elif (defined __MSVC_INLINE__) COLOR colRet; __asm { xor ebx,ebx @@ -308,6 +333,95 @@ COLOR MulColors( COLOR col1, COLOR col2) mov D [colRet],ebx } return colRet; + +#elif (defined __GNU_INLINE__) + COLOR colRet; + __asm__ __volatile__ ( + "pushl %%ebx \n\t" + "xorl %%ebx, %%ebx \n\t" + + // red + "movl %%esi, %%eax \n\t" + "andl $0xFF000000, %%eax \n\t" + "shrl $24, %%eax \n\t" + "movl %%eax, %%ecx \n\t" + "shll $8, %%ecx \n\t" + "orl %%ecx, %%eax \n\t" + "movl %%edi, %%edx \n\t" + "andl $0xFF000000, %%edx \n\t" + "shrl $24, %%edx \n\t" + "movl %%edx, %%ecx \n\t" + "shll $8, %%ecx \n\t" + "orl %%ecx, %%edx \n\t" + "imull %%edx, %%eax \n\t" + "shrl $24, %%eax \n\t" + "shll $24, %%eax \n\t" + "orl %%eax, %%ebx \n\t" + + // green + "movl %%esi, %%eax \n\t" + "andl $0x00FF0000, %%eax \n\t" + "shrl $16, %%eax \n\t" + "movl %%eax, %%ecx \n\t" + "shll $8,%%ecx \n\t" + "orl %%ecx, %%eax \n\t" + "movl %%edi, %%edx \n\t" + "andl $0x00FF0000, %%edx \n\t" + "shrl $16, %%edx \n\t" + "movl %%edx, %%ecx \n\t" + "shll $8, %%ecx \n\t" + "orl %%ecx, %%edx \n\t" + "imull %%edx, %%eax \n\t" + "shrl $24, %%eax \n\t" + "shll $16, %%eax \n\t" + "orl %%eax, %%ebx \n\t" + + // blue + "movl %%esi, %%eax \n\t" + "andl $0x0000FF00, %%eax \n\t" + "shrl $8, %%eax \n\t" + "movl %%eax, %%ecx \n\t" + "shll $8, %%ecx \n\t" + "orl %%ecx, %%eax \n\t" + "movl %%edi, %%edx \n\t" + "andl $0x0000FF00, %%edx \n\t" + "shrl $8, %%edx \n\t" + "movl %%edx, %%ecx \n\t" + "shll $8, %%ecx \n\t" + "orl %%ecx, %%edx \n\t" + "imull %%edx, %%eax \n\t" + "shrl $24, %%eax \n\t" + "shll $8, %%eax \n\t" + "orl %%eax, %%ebx \n\t" + + // alpha + "movl %%esi, %%eax \n\t" + "andl $0x000000FF, %%eax \n\t" + "shrl $0, %%eax \n\t" // !!! FIXME: Lose this line. + "movl %%eax, %%ecx \n\t" + "shll $8, %%ecx \n\t" + "orl %%ecx, %%eax \n\t" + "movl %%edi, %%edx \n\t" + "andl $0x000000FF, %%edx \n\t" + "shrl $0, %%edx \n\t" // !!! FIXME: Lose this line. + "movl %%edx, %%ecx \n\t" + "shll $8, %%ecx \n\t" + "orl %%ecx, %%edx \n\t" + "imull %%edx, %%eax \n\t" + "shrl $24, %%eax \n\t" + "shll $0, %%eax \n\t" // !!! FIXME: Lose this line. + "orl %%eax, %%ebx \n\t" + "movl %%ebx, %%ecx \n\t" + "popl %%ebx \n\t" + : "=c" (colRet) + : "S" (col1), "D" (col2) + : "eax", "edx", "cc", "memory" + ); + + return colRet; +#else + #error please fill in inline assembly for your platform. +#endif } @@ -318,6 +432,12 @@ COLOR AddColors( COLOR col1, COLOR col2) if( col2==0) return col1; if( col1==0xFFFFFFFF || col2==0xFFFFFFFF) return 0xFFFFFFFF; COLOR colRet; + +#if (defined USE_PORTABLE_C) + STUBBED("AddColors"); + colRet = 0; + +#elif (defined __MSVC_INLINE__) __asm { xor ebx,ebx mov esi,255 @@ -380,6 +500,88 @@ COLOR AddColors( COLOR col1, COLOR col2) // done mov D [colRet],ebx } + +#elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "pushl %%ebx \n\t" + "pushl %%edi \n\t" + "pushl %%esi \n\t" + "xorl %%ebx, %%ebx \n\t" + "mov $255, %%esi \n\t" + + // red + "movl (%%esp), %%eax \n\t" + "andl $0xFF000000, %%eax \n\t" + "shrl $24, %%eax \n\t" + "movl 4(%%esp), %%edx \n\t" + "andl $0xFF000000, %%edx \n\t" + "shrl $24, %%edx \n\t" + "addl %%edx, %%eax \n\t" + "cmpl %%eax, %%esi \n\t" // clamp + "sbbl %%ecx, %%ecx \n\t" + "orl %%ecx, %%eax \n\t" + "shll $24, %%eax \n\t" + "andl $0xFF000000, %%eax \n\t" + "orl %%eax, %%ebx \n\t" + + // green + "movl (%%esp), %%eax \n\t" + "andl $0x00FF0000, %%eax \n\t" + "shrl $16, %%eax \n\t" + "movl 4(%%esp), %%edx \n\t" + "andl $0x00FF0000, %%edx \n\t" + "shrl $16, %%edx \n\t" + "addl %%edx, %%eax \n\t" + "cmpl %%eax, %%esi \n\t" // clamp + "sbbl %%ecx, %%ecx \n\t" + "orl %%ecx, %%eax \n\t" + "shll $16, %%eax \n\t" + "andl $0x00FF0000, %%eax \n\t" + "orl %%eax, %%ebx \n\t" + + // blue + "movl (%%esp), %%eax \n\t" + "andl $0x0000FF00, %%eax \n\t" + "shrl $8, %%eax \n\t" + "movl 4(%%esp), %%edx \n\t" + "andl $0x0000FF00, %%edx \n\t" + "shrl $8, %%edx \n\t" + "addl %%edx, %%eax \n\t" + "cmpl %%eax, %%esi \n\t" // clamp + "sbbl %%ecx, %%ecx \n\t" + "orl %%ecx, %%eax \n\t" + "shll $8, %%eax \n\t" + "andl $0x0000FF00, %%eax \n\t" + "orl %%eax, %%ebx \n\t" + + // alpha + "movl (%%esp), %%eax \n\t" + "andl $0x000000FF, %%eax \n\t" + "shrl $0, %%eax \n\t" + "movl 4(%%esp), %%edx \n\t" + "andl $0x000000FF, %%edx \n\t" + "shrl $0, %%edx \n\t" + "addl %%edx, %%eax \n\t" + "cmpl %%eax, %%esi \n\t" // clamp + "sbbl %%ecx, %%ecx \n\t" + "orl %%ecx, %%eax \n\t" + "shll $0, %%eax \n\t" + "andl $0x000000FF, %%eax \n\t" + "orl %%eax, %%ebx \n\t" + "movl %%ebx, %%ecx \n\t" + + // done. + "addl $8, %%esp \n\t" + "popl %%ebx \n\t" + : "=c" (colRet) + : "S" (col1), "D" (col2) + : "eax", "edx", "cc", "memory" + ); + +#else + #error please fill in inline assembly for your platform. +#endif + return colRet; } @@ -388,6 +590,11 @@ COLOR AddColors( COLOR col1, COLOR col2) // multiple conversion from OpenGL color to DirectX color extern void abgr2argb( ULONG *pulSrc, ULONG *pulDst, INDEX ct) { +#if (defined USE_PORTABLE_C) + //#error write me. + STUBBED("abgr2argb"); + +#elif (defined __MSVC_INLINE__) __asm { mov esi,dword ptr [pulSrc] mov edi,dword ptr [pulDst] @@ -439,4 +646,12 @@ colSkip2: mov dword ptr [edi],eax colSkip1: } + +#elif (defined __GNU_INLINE__) + STUBBED("convert to inline asm."); + +#else + #error please fill in inline assembly for your platform. +#endif } + diff --git a/Sources/Engine/Graphics/Color.h b/Sources/Engine/Graphics/Color.h index 9dc94b4..502b584 100644 --- a/Sources/Engine/Graphics/Color.h +++ b/Sources/Engine/Graphics/Color.h @@ -92,6 +92,8 @@ #define C_vlPINK 0xF68C8C00UL // CT RGBA masks and shifts +// Beware that changing these breaks the GNU C version of some +// inline assembly. --ryan. #define CT_RMASK 0xFF000000UL #define CT_GMASK 0x00FF0000UL #define CT_BMASK 0x0000FF00UL @@ -190,12 +192,18 @@ __forceinline ULONG ByteSwap( ULONG ul) { /* rcg10052001 Platform-wrappers. */ #if (defined USE_PORTABLE_C) - return( ((ul << 24) ) | - ((ul << 8) & 0x00FF0000) | - ((ul >> 8) & 0x0000FF00) | - ((ul >> 24) ) ); + ul = ( ((ul << 24) ) | + ((ul << 8) & 0x00FF0000) | + ((ul >> 8) & 0x0000FF00) | + ((ul >> 24) ) ); -#elif (defined _MSC_VER) + #if (defined PLATFORM_BIGENDIAN) + BYTESWAP(ul); // !!! FIXME: May not be right! + #endif + + return(ul); + +#elif (defined __MSVC_INLINE__) ULONG ulRet; __asm { mov eax,dword ptr [ul] @@ -203,7 +211,8 @@ __forceinline ULONG ByteSwap( ULONG ul) mov dword ptr [ulRet],eax } return ulRet; -#elif (defined __GNUC__) + +#elif (defined __GNU_INLINE__) __asm__ __volatile__ ( "bswapl %%eax \n\t" : "=a" (ul) @@ -216,45 +225,66 @@ __forceinline ULONG ByteSwap( ULONG ul) #endif } -__forceinline ULONG rgba2argb( COLOR col) +__forceinline ULONG rgba2argb( ULONG ul) { #if (defined USE_PORTABLE_C) - return( (col << 24) | (col >> 8) ); + return( (ul << 24) | (ul >> 8) ); -#elif (defined _MSC_VER) +#elif (defined __MSVC_INLINE__) ULONG ulRet; __asm { - mov eax,dword ptr [col] + mov eax,dword ptr [ul] ror eax,8 mov dword ptr [ulRet],eax } return ulRet; +#elif (defined __GNU_INLINE__) + ULONG ulRet; + __asm__ __volatile__ ( + "rorl $8, %%eax \n\t" + : "=a" (ulRet) + : "a" (ul) + : "cc" + ); + return ulRet; + #else #error please define for your platform. #endif } -__forceinline ULONG abgr2argb( ULONG ul) +__forceinline ULONG abgr2argb( COLOR col) { #if (defined USE_PORTABLE_C) // this could be simplified, this is just a safe conversion from asm code - ul = ( ((ul << 24) ) | - ((ul << 8) & 0x00FF0000) | - ((ul >> 8) & 0x0000FF00) | - ((ul >> 24) ) ); - return( (ul << 24) | (ul >> 8) ); + col = ( ((col << 24) ) | + ((col << 8) & 0x00FF0000) | + ((col >> 8) & 0x0000FF00) | + ((col >> 24) ) ); + return( (col << 24) | (col >> 8) ); -#elif (defined _MSC_VER) +#elif (defined __MSVC_INLINE__) ULONG ulRet; __asm { - mov eax,dword ptr [ul] + mov eax,dword ptr [col] bswap eax ror eax,8 mov dword ptr [ulRet],eax } return ulRet; +#elif (defined __GNU_INLINE__) + ULONG ulRet; + __asm__ __volatile__ ( + "bswapl %%eax \n\t" + "rorl $8, %%eax \n\t" + : "=a" (ulRet) + : "a" (col) + : "cc" + ); + return ulRet; + #else #error please define for your platform. #endif @@ -268,7 +298,10 @@ extern void abgr2argb( ULONG *pulSrc, ULONG *pulDst, INDEX ct); // fast memory copy of ULONGs inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs) { -#if (defined _MSC_VER) +#if ((defined USE_PORTABLE_C) || (PLATFORM_MACOSX)) + memcpy( pulDst, pulSrc, ctLongs*4); + +#elif (defined __MSVC_INLINE__) __asm { cld mov esi,dword ptr [pulSrc] @@ -276,8 +309,23 @@ inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs) mov ecx,dword ptr [ctLongs] rep movsd } + +#elif (defined __GNU_INLINE__) + // I haven't benchmarked it, but in many cases, memcpy() becomes an + // inline (asm?) macro on GNU platforms, so this might not be a + // speed gain at all over the USE_PORTABLE_C version. + // You Have Been Warned. --ryan. + __asm__ __volatile__ ( + "cld \n\t" + "rep \n\t" + "movsd \n\t" + : // no outputs. + : "S" (pulSrc), "D" (pulDst), "c" (ctLongs) + : "cc", "memory" + ); + #else - memcpy( pulDst, pulSrc, ctLongs*4); +# error Please fill this in for your platform. #endif } @@ -285,7 +333,11 @@ inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs) // fast memory set of ULONGs inline void StoreLongs( ULONG ulVal, ULONG *pulDst, INDEX ctLongs) { -#if (defined _MSC_VER) +#if (defined USE_PORTABLE_C) + for( INDEX i=0; i #include #include #include -#include +#include #include #include @@ -42,11 +41,7 @@ static void UpdateDepthPointsVisibility( const CDrawPort *pdp, const INDEX iMirr DepthInfo *pdi, const INDEX ctCount) { const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT(GfxValidApi(eAPI)); ASSERT( pdp!=NULL && ctCount>0); const CRaster *pra = pdp->dp_Raster; @@ -276,9 +271,10 @@ extern void CheckDelayedDepthPoints( const CDrawPort *pdp, INDEX iMirrorLevel/*= // ignore stalls if( tmDelta>1.0f) return; - // check and upadete visibility of what has left + // check and update visibility of what has left ASSERT( ctPoints == _adiDelayed.Count()); if( ctPoints>0) UpdateDepthPointsVisibility( pdp, iMirrorLevel, &_adiDelayed[0], ctPoints); + // mark checking _iCheckIteration++; } diff --git a/Sources/Engine/Graphics/DisplayMode.cpp b/Sources/Engine/Graphics/DisplayMode.cpp index f453ae2..510bb5b 100644 --- a/Sources/Engine/Graphics/DisplayMode.cpp +++ b/Sources/Engine/Graphics/DisplayMode.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Graphics/DrawPort.cpp b/Sources/Engine/Graphics/DrawPort.cpp index 3ec4e57..bc42b02 100644 --- a/Sources/Engine/Graphics/DrawPort.cpp +++ b/Sources/Engine/Graphics/DrawPort.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include @@ -425,11 +425,7 @@ void CDrawPort::DrawPoint( PIX pixI, PIX pixJ, COLOR col, PIX pixRadius/*=1*/) c { // check API and radius const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); -#else // SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); ASSERT( pixRadius>=0); if( pixRadius==0) return; // do nothing if radius is 0 @@ -479,11 +475,7 @@ void CDrawPort::DrawPoint3D( FLOAT3D v, COLOR col, FLOAT fRadius/*=1.0f*/) const { // check API and radius const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); ASSERT( fRadius>=0); if( fRadius==0) return; // do nothing if radius is 0 @@ -528,11 +520,7 @@ void CDrawPort::DrawLine( PIX pixI0, PIX pixJ0, PIX pixI1, PIX pixJ1, COLOR col, { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // setup rendering mode gfxDisableDepthTest(); @@ -597,11 +585,7 @@ void CDrawPort::DrawLine3D( FLOAT3D v0, FLOAT3D v1, COLOR col) const { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // setup rendering mode gfxDisableTexture(); @@ -643,11 +627,7 @@ void CDrawPort::DrawBorder( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COL { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // setup rendering mode gfxDisableDepthTest(); @@ -733,11 +713,7 @@ void CDrawPort::Fill( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, COLOR col // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // OpenGL if( eAPI==GAT_OGL) @@ -784,11 +760,7 @@ void CDrawPort::Fill( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // setup rendering mode gfxDisableDepthTest(); @@ -854,11 +826,7 @@ void CDrawPort::Fill( COLOR col) const // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // OpenGL if( eAPI==GAT_OGL) @@ -869,28 +837,25 @@ void CDrawPort::Fill( COLOR col) const pglClearColor( ubR/255.0f, ubG/255.0f, ubB/255.0f, 1.0f); pglClear( GL_COLOR_BUFFER_BIT); } - // Direct3D -#ifdef SE1_D3D + +#ifdef PLATFORM_WIN32 // Direct3D else if( eAPI==GAT_D3D) { const ULONG d3dColor = rgba2argb(col); HRESULT hr = _pGfx->gl_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, d3dColor,0,0); D3D_CHECKERROR(hr); } -#endif SE1_D3D +#endif + } -// fill a part of Z-Buffer with a given value +// fill an part of Z-Buffer with a given value void CDrawPort::FillZBuffer( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight, FLOAT zval) const { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // clip and eventually reject const BOOL bInside = ClipToDrawPort( this, pixI, pixJ, pixWidth, pixHeight); @@ -927,11 +892,7 @@ void CDrawPort::FillZBuffer( FLOAT zval) const { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); gfxEnableDepthWrite(); // OpenGL @@ -958,11 +919,7 @@ void CDrawPort::GrabScreen( class CImageInfo &iiGrabbedImage, INDEX iGrabZBuffer { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); extern INDEX ogl_bGrabDepthBuffer; const BOOL bGrabDepth = eAPI==GAT_OGL && ((iGrabZBuffer==1 && ogl_bGrabDepthBuffer) || iGrabZBuffer==2); @@ -1060,11 +1017,7 @@ BOOL CDrawPort::IsPointVisible( PIX pixI, PIX pixJ, FLOAT fOoK, INDEX iID, INDEX // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // use delayed mechanism for checking extern BOOL CheckDepthPoint( const CDrawPort *pdp, PIX pixI, PIX pixJ, FLOAT fOoK, INDEX iID, INDEX iMirrorLevel=0); @@ -1077,11 +1030,7 @@ void CDrawPort::RenderLensFlare( CTextureObject *pto, FLOAT fI, FLOAT fJ, { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // setup rendering mode gfxEnableDepthTest(); @@ -1116,10 +1065,10 @@ void CDrawPort::RenderLensFlare( CTextureObject *pto, FLOAT fI, FLOAT fJ, pvtx[1].x = fI- fRICosA-fRJSinA; pvtx[1].y = fJ- fRISinA-fRJCosA; pvtx[1].z = 0.01f; pvtx[2].x = fI+ fRICosA-fRJSinA; pvtx[2].y = fJ+ fRISinA-fRJCosA; pvtx[2].z = 0.01f; pvtx[3].x = fI+ fRICosA+fRJSinA; pvtx[3].y = fJ+ fRISinA+fRJCosA; pvtx[3].z = 0.01f; - ptex[0].s = 0; ptex[0].t = 0; - ptex[1].s = 0; ptex[1].t = 1; - ptex[2].s = 1; ptex[2].t = 1; - ptex[3].s = 1; ptex[3].t = 0; + ptex[0].st.s = 0; ptex[0].st.t = 0; + ptex[1].st.s = 0; ptex[1].st.t = 1; + ptex[2].st.s = 1; ptex[2].st.t = 1; + ptex[3].st.s = 1; ptex[3].st.t = 0; pcol[0] = glcol; pcol[1] = glcol; pcol[2] = glcol; @@ -1208,11 +1157,7 @@ void CDrawPort::PutText( const CTString &strText, PIX pixX0, PIX pixY0, const CO { // check API and adjust position for D3D by half pixel const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // skip drawing if text falls above or below draw port if( pixY0>dp_Height || pixX0>dp_Width) return; @@ -1298,7 +1243,7 @@ void CDrawPort::PutText( const CTString &strText, PIX pixX0, PIX pixY0, const CO acTmp[6] = '\0'; // terminate string col = strtoul( acTmp, &pcDummy, 16) <<8; col = AdjustColor( col, _slTexHueShift, _slTexSaturation); - glcol.Set( col|glcol.a); // do color change but keep original alpha + glcol.Set( col|glcol.ub.a); // do color change but keep original alpha continue; // alpha change? case 'a': @@ -1364,8 +1309,8 @@ void CDrawPort::PutText( const CTString &strText, PIX pixX0, PIX pixY0, const CO } // adjust alpha for flashing - if( iFlash>0) glcol.a = ulAlpha*(sin(iFlash*tmFrame)*0.5f+0.5f); - else glcol.a = ulAlpha; + if( iFlash>0) glcol.ub.a = (UBYTE) (ulAlpha*(sin(iFlash*tmFrame)*0.5f+0.5f)); + else glcol.ub.a = ulAlpha; // prepare coordinates for screen and texture const FLOAT fX0 = pixXA; const FLOAT fX1 = fX0 +pixScaledWidth; @@ -1376,10 +1321,10 @@ void CDrawPort::PutText( const CTString &strText, PIX pixX0, PIX pixY0, const CO pvtx[1].x = fX0; pvtx[1].y = fY1; pvtx[1].z = 0; pvtx[2].x = fX1; pvtx[2].y = fY1; pvtx[2].z = 0; pvtx[3].x = fX1; pvtx[3].y = fY0; pvtx[3].z = 0; - ptex[0].s = fU0; ptex[0].t = fV0; - ptex[1].s = fU0; ptex[1].t = fV1; - ptex[2].s = fU1; ptex[2].t = fV1; - ptex[3].s = fU1; ptex[3].t = fV0; + ptex[0].st.s = fU0; ptex[0].st.t = fV0; + ptex[1].st.s = fU0; ptex[1].st.t = fV1; + ptex[2].st.s = fU1; ptex[2].st.t = fV1; + ptex[3].st.s = fU1; ptex[3].st.t = fV0; pcol[0] = glcol; pcol[1] = glcol; pcol[2] = glcol; @@ -1402,10 +1347,10 @@ void CDrawPort::PutText( const CTString &strText, PIX pixX0, PIX pixY0, const CO pvtx[1].x = pvtx[1-4].x +fAdjustX; pvtx[1].y = fY1; pvtx[1].z = 0; pvtx[2].x = pvtx[2-4].x +fAdjustX; pvtx[2].y = fY1; pvtx[2].z = 0; pvtx[3].x = pvtx[3-4].x +fAdjustX; pvtx[3].y = fY0; pvtx[3].z = 0; - ptex[0].s = fU0; ptex[0].t = fV0; - ptex[1].s = fU0; ptex[1].t = fV1; - ptex[2].s = fU1; ptex[2].t = fV1; - ptex[3].s = fU1; ptex[3].t = fV0; + ptex[0].st.s = fU0; ptex[0].st.t = fV0; + ptex[1].st.s = fU0; ptex[1].st.t = fV1; + ptex[2].st.s = fU1; ptex[2].st.t = fV1; + ptex[3].st.s = fU1; ptex[3].st.t = fV0; pcol[0] = glcol; pcol[1] = glcol; pcol[2] = glcol; @@ -1445,7 +1390,7 @@ void CDrawPort::PutTextCXY( const CTString &strText, PIX pixX0, PIX pixY0, const COLOR colBlend/*=0xFFFFFFFF*/) const { PIX pixTextWidth = GetTextWidth(strText); - PIX pixTextHeight = dp_FontData->fd_pixCharHeight * dp_fTextScaling; + PIX pixTextHeight = (PIX) (dp_FontData->fd_pixCharHeight * dp_fTextScaling); PutText( strText, pixX0-pixTextWidth/2, pixY0-pixTextHeight/2, colBlend); } @@ -1500,11 +1445,7 @@ void CDrawPort::PutTexture( class CTextureObject *pTO, // check API and adjust position for D3D by half pixel const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); FLOAT fI0 = pixI0; FLOAT fI1 = pixI1; FLOAT fJ0 = pixJ0; FLOAT fJ1 = pixJ1; @@ -1555,10 +1496,10 @@ void CDrawPort::PutTexture( class CTextureObject *pTO, pvtx[1].x = fI0; pvtx[1].y = fJ1; pvtx[1].z = 0; pvtx[2].x = fI1; pvtx[2].y = fJ1; pvtx[2].z = 0; pvtx[3].x = fI1; pvtx[3].y = fJ0; pvtx[3].z = 0; - ptex[0].s = fU0; ptex[0].t = fV0; - ptex[1].s = fU0; ptex[1].t = fV1; - ptex[2].s = fU1; ptex[2].t = fV1; - ptex[3].s = fU1; ptex[3].t = fV0; + ptex[0].st.s = fU0; ptex[0].st.t = fV0; + ptex[1].st.s = fU0; ptex[1].st.t = fV1; + ptex[2].st.s = fU1; ptex[2].st.t = fV1; + ptex[3].st.s = fU1; ptex[3].st.t = fV0; pcol[0] = glcolUL; pcol[1] = glcolDL; pcol[2] = glcolDR; @@ -1609,10 +1550,10 @@ void CDrawPort::AddTexture( const FLOAT fI0, const FLOAT fJ0, const FLOAT fI1, c pvtx[1].x = fI0; pvtx[1].y = fJ1; pvtx[1].z = 0; pvtx[2].x = fI1; pvtx[2].y = fJ1; pvtx[2].z = 0; pvtx[3].x = fI1; pvtx[3].y = fJ0; pvtx[3].z = 0; - ptex[0].s = 0; ptex[0].t = 0; - ptex[1].s = 0; ptex[1].t = 1; - ptex[2].s = 1; ptex[2].t = 1; - ptex[3].s = 1; ptex[3].t = 0; + ptex[0].st.s = 0; ptex[0].st.t = 0; + ptex[1].st.s = 0; ptex[1].st.t = 1; + ptex[2].st.s = 1; ptex[2].st.t = 1; + ptex[3].st.s = 1; ptex[3].st.t = 0; pcol[0] = glCol; pcol[1] = glCol; pcol[2] = glCol; pcol[3] = glCol; pelm[0] = iStart+0; pelm[1] = iStart+1; pelm[2] = iStart+2; pelm[3] = iStart+2; pelm[4] = iStart+3; pelm[5] = iStart+0; @@ -1633,10 +1574,10 @@ void CDrawPort::AddTexture( const FLOAT fI0, const FLOAT fJ0, const FLOAT fI1, c pvtx[1].x = fI0; pvtx[1].y = fJ1; pvtx[1].z = 0; pvtx[2].x = fI1; pvtx[2].y = fJ1; pvtx[2].z = 0; pvtx[3].x = fI1; pvtx[3].y = fJ0; pvtx[3].z = 0; - ptex[0].s = fU0; ptex[0].t = fV0; - ptex[1].s = fU0; ptex[1].t = fV1; - ptex[2].s = fU1; ptex[2].t = fV1; - ptex[3].s = fU1; ptex[3].t = fV0; + ptex[0].st.s = fU0; ptex[0].st.t = fV0; + ptex[1].st.s = fU0; ptex[1].st.t = fV1; + ptex[2].st.s = fU1; ptex[2].st.t = fV1; + ptex[3].st.s = fU1; ptex[3].st.t = fV0; pcol[0] = glCol; pcol[1] = glCol; pcol[2] = glCol; @@ -1688,10 +1629,10 @@ void CDrawPort::AddTexture( const FLOAT fI0, const FLOAT fJ0, const FLOAT fU0, c pvtx[1].x = fI1; pvtx[1].y = fJ1; pvtx[1].z = 0; pvtx[2].x = fI2; pvtx[2].y = fJ2; pvtx[2].z = 0; pvtx[3].x = fI3; pvtx[3].y = fJ3; pvtx[3].z = 0; - ptex[0].s = fU0; ptex[0].t = fV0; - ptex[1].s = fU1; ptex[1].t = fV1; - ptex[2].s = fU2; ptex[2].t = fV2; - ptex[3].s = fU3; ptex[3].t = fV3; + ptex[0].st.s = fU0; ptex[0].st.t = fV0; + ptex[1].st.s = fU1; ptex[1].st.t = fV1; + ptex[2].st.s = fU2; ptex[2].st.t = fV2; + ptex[3].st.s = fU3; ptex[3].st.t = fV3; pcol[0] = glCol0; pcol[1] = glCol1; pcol[2] = glCol2; diff --git a/Sources/Engine/Graphics/DrawPort_Particles.cpp b/Sources/Engine/Graphics/DrawPort_Particles.cpp index 5166682..6b85ef7 100644 --- a/Sources/Engine/Graphics/DrawPort_Particles.cpp +++ b/Sources/Engine/Graphics/DrawPort_Particles.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -18,11 +18,11 @@ extern const FLOAT *pfSinTable; extern const FLOAT *pfCosTable; -extern CEntity *_Particle_penCurrentViewer = NULL; -extern INDEX _Particle_iCurrentDrawPort = 0; -extern FLOAT _Particle_fCurrentMip = 0.0f; -extern BOOL _Particle_bHasFog = FALSE; -extern BOOL _Particle_bHasHaze = FALSE; +CEntity *_Particle_penCurrentViewer = NULL; +INDEX _Particle_iCurrentDrawPort = 0; +FLOAT _Particle_fCurrentMip = 0.0f; +BOOL _Particle_bHasFog = FALSE; +BOOL _Particle_bHasHaze = FALSE; // variables used for rendering particles static CProjection3D *_pprProjection; @@ -163,14 +163,14 @@ void Particle_SetTexturePart( MEX mexWidth, MEX mexHeight, INDEX iCol, INDEX iRo MEX2D( mexWidth*(iCol+1), mexHeight*(iRow+1))); // prepare coordinates of the rectangle - _atex[0].s = boxTextureClipped.Min()(1) *_fTextureCorrectionU; - _atex[0].t = boxTextureClipped.Min()(2) *_fTextureCorrectionV; - _atex[1].s = boxTextureClipped.Min()(1) *_fTextureCorrectionU; - _atex[1].t = boxTextureClipped.Max()(2) *_fTextureCorrectionV; - _atex[2].s = boxTextureClipped.Max()(1) *_fTextureCorrectionU; - _atex[2].t = boxTextureClipped.Max()(2) *_fTextureCorrectionV; - _atex[3].s = boxTextureClipped.Max()(1) *_fTextureCorrectionU; - _atex[3].t = boxTextureClipped.Min()(2) *_fTextureCorrectionV; + _atex[0].st.s = boxTextureClipped.Min()(1) *_fTextureCorrectionU; + _atex[0].st.t = boxTextureClipped.Min()(2) *_fTextureCorrectionV; + _atex[1].st.s = boxTextureClipped.Min()(1) *_fTextureCorrectionU; + _atex[1].st.t = boxTextureClipped.Max()(2) *_fTextureCorrectionV; + _atex[2].st.s = boxTextureClipped.Max()(1) *_fTextureCorrectionU; + _atex[2].st.t = boxTextureClipped.Max()(2) *_fTextureCorrectionV; + _atex[3].st.s = boxTextureClipped.Max()(1) *_fTextureCorrectionU; + _atex[3].st.t = boxTextureClipped.Min()(2) *_fTextureCorrectionV; } @@ -200,19 +200,19 @@ void Particle_RenderSquare( const FLOAT3D &vPos, FLOAT fSize, ANGLE aRotation, C // if haze is active if( _Particle_bHasHaze) { // get haze strength at particle position - ptexFogHaze[0].s = (-vProjected(3)+_haze_fAdd)*_haze_fMul; - const ULONG ulH = 255-GetHazeAlpha(ptexFogHaze[0].s); + ptexFogHaze[0].st.s = (-vProjected(3)+_haze_fAdd)*_haze_fMul; + const ULONG ulH = 255-GetHazeAlpha(ptexFogHaze[0].st.s); if( ulH<4) return; if( _colAttMask) { // apply haze color (if not transparent) const COLOR colH = _colAttMask | RGBAToColor( ulH,ulH,ulH,ulH); col = MulColors( col, colH); - } else ptexFogHaze[0].t = 0; + } else ptexFogHaze[0].st.t = 0; } // if fog is active if( _Particle_bHasFog) { // get fog strength at particle position - ptexFogHaze[0].s = -vProjected(3)*_fog_fMulZ; - ptexFogHaze[0].t = (vProjected%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; + ptexFogHaze[0].st.s = -vProjected(3)*_fog_fMulZ; + ptexFogHaze[0].st.t = (vProjected%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; const ULONG ulF = 255-GetFogAlpha(ptexFogHaze[0]); if( ulF<4) return; if( _colAttMask) { // apply fog color (if not transparent) @@ -303,24 +303,24 @@ void Particle_RenderLine( const FLOAT3D &vPos0, const FLOAT3D &vPos1, FLOAT fWid // if haze is active if( _Particle_bHasHaze) { // get haze strength at particle positions - ptexFogHaze[0].s = (-vProjected0(3)+_haze_fAdd)*_haze_fMul; - ptexFogHaze[1].s = (-vProjected1(3)+_haze_fAdd)*_haze_fMul; - const ULONG ulH0 = 255-GetHazeAlpha(ptexFogHaze[0].s); - const ULONG ulH1 = 255-GetHazeAlpha(ptexFogHaze[1].s); + ptexFogHaze[0].st.s = (-vProjected0(3)+_haze_fAdd)*_haze_fMul; + ptexFogHaze[1].st.s = (-vProjected1(3)+_haze_fAdd)*_haze_fMul; + const ULONG ulH0 = 255-GetHazeAlpha(ptexFogHaze[0].st.s); + const ULONG ulH1 = 255-GetHazeAlpha(ptexFogHaze[1].st.s); if( (ulH0|ulH1)<4) return; if( _colAttMask) { // apply haze color (if not transparent) COLOR colH; colH = _colAttMask | RGBAToColor( ulH0,ulH0,ulH0,ulH0); col0 = MulColors( col0, colH); colH = _colAttMask | RGBAToColor( ulH1,ulH1,ulH1,ulH1); col1 = MulColors( col1, colH); - } else ptexFogHaze[0].t = ptexFogHaze[1].t = 0; + } else ptexFogHaze[0].st.t = ptexFogHaze[1].st.t = 0; } // if fog is active if( _Particle_bHasFog) { // get fog strength at particle position - ptexFogHaze[0].s = -vProjected0(3)*_fog_fMulZ; - ptexFogHaze[0].t = (vProjected0%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; - ptexFogHaze[1].s = -vProjected1(3)*_fog_fMulZ; - ptexFogHaze[1].t = (vProjected1%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; + ptexFogHaze[0].st.s = -vProjected0(3)*_fog_fMulZ; + ptexFogHaze[0].st.t = (vProjected0%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; + ptexFogHaze[1].st.s = -vProjected1(3)*_fog_fMulZ; + ptexFogHaze[1].st.t = (vProjected1%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; const ULONG ulF0 = 255-GetFogAlpha(ptexFogHaze[0]); const ULONG ulF1 = 255-GetFogAlpha(ptexFogHaze[1]); if( (ulF0|ulF1)<4) return; @@ -419,14 +419,14 @@ void Particle_RenderQuad3D( const FLOAT3D &vPos0, const FLOAT3D &vPos1, const FL // if haze is active if( _Particle_bHasHaze) { // get haze strength at particle position - ptexFogHaze[0].s = (-vProjected0(3)+_haze_fAdd)*_haze_fMul; - ptexFogHaze[1].s = (-vProjected1(3)+_haze_fAdd)*_haze_fMul; - ptexFogHaze[2].s = (-vProjected2(3)+_haze_fAdd)*_haze_fMul; - ptexFogHaze[3].s = (-vProjected3(3)+_haze_fAdd)*_haze_fMul; - const ULONG ulH0 = 255-GetHazeAlpha(ptexFogHaze[0].s); - const ULONG ulH1 = 255-GetHazeAlpha(ptexFogHaze[1].s); - const ULONG ulH2 = 255-GetHazeAlpha(ptexFogHaze[2].s); - const ULONG ulH3 = 255-GetHazeAlpha(ptexFogHaze[3].s); + ptexFogHaze[0].st.s = (-vProjected0(3)+_haze_fAdd)*_haze_fMul; + ptexFogHaze[1].st.s = (-vProjected1(3)+_haze_fAdd)*_haze_fMul; + ptexFogHaze[2].st.s = (-vProjected2(3)+_haze_fAdd)*_haze_fMul; + ptexFogHaze[3].st.s = (-vProjected3(3)+_haze_fAdd)*_haze_fMul; + const ULONG ulH0 = 255-GetHazeAlpha(ptexFogHaze[0].st.s); + const ULONG ulH1 = 255-GetHazeAlpha(ptexFogHaze[1].st.s); + const ULONG ulH2 = 255-GetHazeAlpha(ptexFogHaze[2].st.s); + const ULONG ulH3 = 255-GetHazeAlpha(ptexFogHaze[3].st.s); if( (ulH0|ulH1|ulH2|ulH3)<4) return; if( _colAttMask) { // apply haze color (if not transparent) COLOR colH; @@ -434,19 +434,19 @@ void Particle_RenderQuad3D( const FLOAT3D &vPos0, const FLOAT3D &vPos1, const FL colH = _colAttMask | RGBAToColor( ulH1,ulH1,ulH1,ulH1); col1 = MulColors( col1, colH); colH = _colAttMask | RGBAToColor( ulH2,ulH2,ulH2,ulH2); col2 = MulColors( col2, colH); colH = _colAttMask | RGBAToColor( ulH3,ulH3,ulH3,ulH3); col3 = MulColors( col3, colH); - } else ptexFogHaze[0].t = ptexFogHaze[1].t = ptexFogHaze[2].t = ptexFogHaze[3].t = 0; + } else ptexFogHaze[0].st.t = ptexFogHaze[1].st.t = ptexFogHaze[2].st.t = ptexFogHaze[3].st.t = 0; } // if fog is active if( _Particle_bHasFog) { // get fog strength at particle position - ptexFogHaze[0].s = -vProjected0(3)*_fog_fMulZ; - ptexFogHaze[0].t = (vProjected0%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; - ptexFogHaze[1].s = -vProjected1(3)*_fog_fMulZ; - ptexFogHaze[1].t = (vProjected1%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; - ptexFogHaze[2].s = -vProjected2(3)*_fog_fMulZ; - ptexFogHaze[2].t = (vProjected2%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; - ptexFogHaze[3].s = -vProjected3(3)*_fog_fMulZ; - ptexFogHaze[3].t = (vProjected3%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; + ptexFogHaze[0].st.s = -vProjected0(3)*_fog_fMulZ; + ptexFogHaze[0].st.t = (vProjected0%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; + ptexFogHaze[1].st.s = -vProjected1(3)*_fog_fMulZ; + ptexFogHaze[1].st.t = (vProjected1%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; + ptexFogHaze[2].st.s = -vProjected2(3)*_fog_fMulZ; + ptexFogHaze[2].st.t = (vProjected2%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; + ptexFogHaze[3].st.s = -vProjected3(3)*_fog_fMulZ; + ptexFogHaze[3].st.t = (vProjected3%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; const ULONG ulF0 = 255-GetFogAlpha(ptexFogHaze[0]); const ULONG ulF1 = 255-GetFogAlpha(ptexFogHaze[1]); const ULONG ulF2 = 255-GetFogAlpha(ptexFogHaze[2]); @@ -511,10 +511,10 @@ void Particle_Flush(void) gfxSetTextureWrapping( GFX_CLAMP, GFX_CLAMP); if( _Particle_bHasHaze) { gfxSetTexture( _haze_ulTexture, _haze_tpLocal); - glcolFH.abgr = ByteSwap( AdjustColor( _haze_hp.hp_colColor, _slTexHueShift, _slTexSaturation)); + glcolFH.ul.abgr = ByteSwap( AdjustColor( _haze_hp.hp_colColor, _slTexHueShift, _slTexSaturation)); } else { gfxSetTexture( _fog_ulTexture, _fog_tpLocal); - glcolFH.abgr = ByteSwap( AdjustColor( _fog_fp.fp_colColor, _slTexHueShift, _slTexSaturation)); + glcolFH.ul.abgr = ByteSwap( AdjustColor( _fog_fp.fp_colColor, _slTexHueShift, _slTexSaturation)); } // prepare haze rendering parameters gfxDisableAlphaTest(); diff --git a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp index b4ec5e9..0b95103 100644 --- a/Sources/Engine/Graphics/DrawPort_RenderScene.cpp +++ b/Sources/Engine/Graphics/DrawPort_RenderScene.cpp @@ -1,10 +1,10 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include -#include +#include #include #include #include @@ -25,7 +25,15 @@ #define W word ptr #define B byte ptr +#if (defined USE_PORTABLE_C) +#define ASMOPT 0 +#elif (defined __MSVC_INLINE__) #define ASMOPT 1 +#elif (defined __GNU_INLINE__) +#define ASMOPT 1 +#else +#define ASMOPT 0 +#endif #define MAXTEXUNITS 4 #define SHADOWTEXTURE 3 @@ -123,11 +131,17 @@ static void FlushElements(void) // batch elements of one polygon -static __forceinline void AddElements( ScenePolygon *pspo) +static +#if (!defined __GNUC__) +__forceinline +#endif +void AddElements( ScenePolygon *pspo) { const INDEX ctElems = pspo->spo_ctElements; INDEX *piDst = _aiElements.Push(ctElems); -#if ASMOPT == 1 + +#if (ASMOPT == 1) + #if (defined __MSVC_INLINE__) __asm { mov eax,D [pspo] mov ecx,D [ctElems] @@ -157,6 +171,45 @@ elemRest: mov D [edi],eax elemDone: } + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "pushl %%ebx \n\t" // Save GCC's register. + "movl %%eax, %%ebx \n\t" + + "movd %%ebx, %%mm1 \n\t" + "movq %%mm1, %%mm0 \n\t" + "psllq $32, %%mm1 \n\t" + "por %%mm0, %%mm1 \n\t" + "shrl $1, %%ecx \n\t" + "jz 1f \n\t" // elemRest + "0: \n\t" // elemLoop + "movq (%%esi), %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "movq %%mm0, (%%edi) \n\t" + "addl $8, %%esi \n\t" + "addl $8, %%edi \n\t" + "decl %%ecx \n\t" + "jnz 0b \n\t" // elemLoop + "1: \n\t" // elemRest + "emms \n\t" + "testl $1, %%edx \n\t" + "jz 2f \n\t" // elemDone + "movl (%%esi), %%eax \n\t" + "addl %%ebx, %%eax \n\t" + "movl %%eax, (%%edi) \n\t" + "2: \n\t" // elemDone + "popl %%ebx \n\t" // restore GCC's register. + : // no outputs. + : "c" (ctElems), "d" (ctElems), "D" (piDst), + "S" (pspo->spo_piElements), "a" (pspo->spo_iVtx0Pass) + : "cc", "memory" + ); + + #else + #error Please write inline ASM for your platform. + + #endif + #else const INDEX iVtx0Pass = pspo->spo_iVtx0Pass; const INDEX *piSrc = pspo->spo_piElements; @@ -427,6 +480,10 @@ static void RSBinToGroups( ScenePolygon *pspoFirst) // determine maximum used groups ASSERT( _ctGroupsCount); + +#if ASMOPT == 1 + + #if (defined __MSVC_INLINE__) __asm { mov eax,2 bsr ecx,D [_ctGroupsCount] @@ -434,6 +491,38 @@ static void RSBinToGroups( ScenePolygon *pspoFirst) mov D [_ctGroupsCount],eax } + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "bsrl (%%esi), %%ecx \n\t" + "shll %%cl, %%eax \n\t" + "movl %%eax, (%%esi) \n\t" + : // no outputs. + : "a" (2), "S" (&_ctGroupsCount) + : "ecx", "cc", "memory" + ); + + #else + #error Please write inline ASM for your platform. + + #endif + +#else + // emulate x86's bsr opcode...not fast. :/ + register INDEX val = _ctGroupsCount; + register INDEX bsr = 0; + if (val != 0) + { + while (bsr < 32) + { + if (val & (1 << bsr)) + break; + bsr++; + } + } + + _ctGroupsCount = 2 << bsr; +#endif + // done with bining _pfGfxProfile.StopTimer( CGfxProfile::PTI_RS_BINTOGROUPS); } @@ -657,7 +746,7 @@ static void RSSetPolygonColors( ScenePolygon *pspoGroup, UBYTE ubAlpha) for( ScenePolygon *pspo = pspoGroup; pspo != NULL; pspo = pspo->spo_pspoSucc) { col = ByteSwap( AdjustColor( pspo->spo_cColor|ubAlpha, _slTexHueShift, _slTexSaturation)); pcol = &_acolPass[pspo->spo_iVtx0Pass]; - for( INDEX i=0; ispo_ctVtx; i++) pcol[i].abgr = col; + for( INDEX i=0; ispo_ctVtx; i++) pcol[i].ul.abgr = col; } gfxSetColorArray( &_acolPass[0]); _pfGfxProfile.StopTimer( CGfxProfile::PTI_RS_SETCOLORS); @@ -669,7 +758,7 @@ static void RSSetConstantColors( COLOR col) _pfGfxProfile.StartTimer( CGfxProfile::PTI_RS_SETCOLORS); col = ByteSwap( AdjustColor( col, _slTexHueShift, _slTexSaturation)); GFXColor *pcol = &_acolPass[0]; - for( INDEX i=0; i<_acolPass.Count(); i++) pcol[i].abgr = col; + for( INDEX i=0; i<_acolPass.Count(); i++) pcol[i].ul.abgr = col; gfxSetColorArray( &_acolPass[0]); _pfGfxProfile.StopTimer( CGfxProfile::PTI_RS_SETCOLORS); } @@ -703,7 +792,7 @@ static void RSSetTextureColors( ScenePolygon *pspoGroup, ULONG ulLayerMask) // store colTotal = ByteSwap(colTotal); GFXColor *pcol= &_acolPass[pspo->spo_iVtx0Pass]; - for( INDEX i=0; ispo_ctVtx; i++) pcol[i].abgr = colTotal; + for( INDEX i=0; ispo_ctVtx; i++) pcol[i].ul.abgr = colTotal; } // set color array gfxSetColorArray( &_acolPass[0]); @@ -747,23 +836,33 @@ static void RSSetTextureCoords( ScenePolygon *pspoGroup, INDEX iLayer, INDEX iUn const FLOAT fRVz = fVz - 2*vN(3)*fNV; const FLOAT fRVxT = fRVx*mViewer(1,1) + fRVy*mViewer(2,1) + fRVz*mViewer(3,1); const FLOAT fRVzT = fRVx*mViewer(1,3) + fRVy*mViewer(2,3) + fRVz*mViewer(3,3); - ptex[i].s = fRVxT*0.5f +0.5f; - ptex[i].t = fRVzT*0.5f +0.5f; + ptex[i].st.s = fRVxT*0.5f +0.5f; + ptex[i].st.t = fRVzT*0.5f +0.5f; } // advance to next polygon continue; } - // diffuse mapping - const FLOAT3D &vO = pspo->spo_amvMapping[iLayer].mv_vO; - -#if ASMOPT == 1 +// !!! FIXME: rcg11232001 This inline conversion is broken. Use the +// !!! FIXME: rcg11232001 C version for now with GCC. +#if ((ASMOPT == 1) && (!defined __GNU_INLINE__) && (!defined __INTEL_COMPILER)) + #if (defined __MSVC_INLINE__) __asm { mov esi,D [pspo] mov edi,D [iMappingOffset] + +// (This doesn't work with the Intel C++ compiler. :( --ryan.) +#ifdef _MSC_VER lea eax,[esi].spo_amvMapping[edi].mv_vO lea ebx,[esi].spo_amvMapping[edi].mv_vU lea ecx,[esi].spo_amvMapping[edi].mv_vV +#else + lea ebx,[esi].spo_amvMapping[edi] + lea eax,[ebx].mv_vO + lea ecx,[ebx].mv_vV + lea ebx,[ebx].mv_vU +#endif + mov edx,D [esi].spo_ctVtx mov esi,D [pvtx] mov edi,D [ptex] @@ -790,14 +889,66 @@ vtxLoop: faddp st(1),st(0) // vU(1)*fDX+vU(2)*fDY+vU(3)*fDZ, vV(1)*fDX+vV(2)*fDY, vV(3)*fDZ fxch st(1) faddp st(2),st(0) // vU(1)*fDX+vU(2)*fDY+vU(3)*fDZ, vV(1)*fDX+vV(2)*fDY+vV(3)*fDZ - fstp D [edi]GFXTexCoord.s - fstp D [edi]GFXTexCoord.t + fstp D [edi]GFXTexCoord.st.s + fstp D [edi]GFXTexCoord.st.t add esi,4*4 add edi,2*4 dec edx jnz vtxLoop } + +/* + // !!! FIXME: rcg11232001 This inline conversion is broken. Use the + // !!! FIXME: rcg11232001 C version for now on Linux. + #elif (defined __GNU_INLINE__) + STUBBED("debug this"); + __asm__ __volatile__ ( + "0: \n\t" // vtxLoop + "flds (%%ebx) \n\t" + "flds (%%esi) \n\t" + "fsubs (%%eax) \n\t" + "fmul %%st(0), %%st(1) \n\t" + "fmuls (%%ecx) \n\t" // vV(1)*fDX, vU(1)*fDX + "flds 4(%%ebx) \n\t" + "flds 4(%%esi) \n\t" // GFXVertex.y + "fsubs 4(%%eax) \n\t" + "fmul %%st(0), %%st(1) \n\t" + "fmuls 4(%%ecx) \n\t" // vV(2)*fDY, vU(2)*fDY, vV(1)*fDX, vU(1)*fDX + "flds 8(%%ebx) \n\t" + "flds 8(%%esi) \n\t" // GFXVertex.z + "fsubs 8(%%eax) \n\t" + "fmul %%st(0), %%st(1) \n\t" + "fmuls 8(%%ecx) \n\t" // vV(3)*fDZ, vU(3)*fDZ, vV(2)*fDY, vU(2)*fDY, vV(1)*fDX, vU(1)*fDX + "fxch %%st(5) \n\t" + "faddp %%st(0), %%st(3) \n\t" // vU(3)*fDZ, vV(2)*fDY, vU(1)*fDX+vU(2)*fDY, vV(1)*fDX, vV(3)*fDZ + "fxch %%st(1) \n\t" + "faddp %%st(0), %%st(3) \n\t" // vU(3)*fD Z, vU(1)*fDX+vU(2)*fDY, vV(1)*fDX+vV(2)*fDY, vV(3)*fDZ + "faddp %%st(0), %%st(1) \n\t" // vU(1)*fDX+vU(2)*fDY+vU(3)*fDZ, vV(1)*fDX+vV(2)*fDY, vV(3)*fDZ + "fxch %%st(1) \n\t" + "faddp %%st(0), %%st(2) \n\t" // vU(1)*fDX+vU(2)*fDY+vU(3)*fDZ, vV(1)*fDX+vV(2)*fDY+vV(3)*fDZ + "fstps 0(%%edi) \n\t" // GFXTexCoord.st.s + "fstps 4(%%edi) \n\t" // GFXTexCoord.st.t + "addl $16, %%esi \n\t" + "addl $8, %%edi \n\t" + "decl %%edx \n\t" + "jnz 0b \n\t" // vtxLoop + : // no outputs. + : "a" (&pspo->spo_amvMapping[iMappingOffset].mv_vO.vector), + "b" (&pspo->spo_amvMapping[iMappingOffset].mv_vU.vector), + "c" (&pspo->spo_amvMapping[iMappingOffset].mv_vV.vector), + "d" (pspo->spo_ctVtx), "S" (pvtx), "D" (ptex) + : "cc", "memory" + ); +*/ + + #else + #error Please write inline ASM for your platform. + + #endif + #else + + // diffuse mapping const FLOAT3D &vO = pspo->spo_amvMapping[iLayer].mv_vO; const FLOAT3D &vU = pspo->spo_amvMapping[iLayer].mv_vU; const FLOAT3D &vV = pspo->spo_amvMapping[iLayer].mv_vV; @@ -805,10 +956,11 @@ vtxLoop: const FLOAT fDX = pvtx[i].x -vO(1); const FLOAT fDY = pvtx[i].y -vO(2); const FLOAT fDZ = pvtx[i].z -vO(3); - ptex[i].s = vU(1)*fDX + vU(2)*fDY + vU(3)*fDZ; - ptex[i].t = vV(1)*fDX + vV(2)*fDY + vV(3)*fDZ; + ptex[i].st.s = vU(1)*fDX + vU(2)*fDY + vU(3)*fDZ; + ptex[i].st.t = vV(1)*fDX + vV(2)*fDY + vV(3)*fDZ; } #endif + } // init array @@ -827,8 +979,8 @@ static void RSSetFogCoordinates( ScenePolygon *pspoGroup) const GFXVertex *pvtx = &_avtxPass[pspo->spo_iVtx0Pass]; GFXTexCoord *ptex = &_atexPass[0][pspo->spo_iVtx0Pass]; for( INDEX i=0; ispo_ctVtx; i++) { - ptex[i].s = pvtx[i].z *_fFogMul; - ptex[i].t = (_fog_vHDirView(1)*pvtx[i].x + _fog_vHDirView(2)*pvtx[i].y + ptex[i].st.s = pvtx[i].z *_fFogMul; + ptex[i].st.t = (_fog_vHDirView(1)*pvtx[i].x + _fog_vHDirView(2)*pvtx[i].y + _fog_vHDirView(3)*pvtx[i].z + _fog_fAddH) * _fog_fMulH; } } @@ -846,8 +998,8 @@ static void RSSetHazeCoordinates( ScenePolygon *pspoGroup) const GFXVertex *pvtx = &_avtxPass[pspo->spo_iVtx0Pass]; GFXTexCoord *ptex = &_atexPass[0][pspo->spo_iVtx0Pass]; for( INDEX i=0; ispo_ctVtx; i++) { - ptex[i].s = (pvtx[i].z + _fHazeAdd) *_fHazeMul; - ptex[i].t = 0; + ptex[i].st.s = (pvtx[i].z + _fHazeAdd) *_fHazeMul; + ptex[i].st.t = 0; } } gfxSetTexCoordArray( &_atexPass[0][0], FALSE); @@ -1179,7 +1331,7 @@ __forceinline void RSRenderFog( ScenePolygon *pspoFirst) const GFXTexCoord *ptex = &_atexPass[0][pspo->spo_iVtx0Pass]; for( INDEX i=0; ispo_ctVtx; i++) { // polygon is in fog, stop searching - if( InFog(ptex[i].t)) goto hasFog; + if( InFog(ptex[i].st.t)) goto hasFog; } // hasn't got any fog, so skip it continue; @@ -1203,7 +1355,7 @@ __forceinline void RSRenderHaze( ScenePolygon *pspoFirst) const GFXTexCoord *ptex = &_atexPass[0][pspo->spo_iVtx0Pass]; for( INDEX i=0; ispo_ctVtx; i++) { // polygon is in haze, stop searching - if( InHaze(ptex[i].s)) goto hasHaze; + if( InHaze(ptex[i].st.s)) goto hasHaze; } // hasn't got any haze, so skip it continue; @@ -1694,16 +1846,13 @@ void RenderScene( CDrawPort *pDP, ScenePolygon *pspoFirst, CAnyProjection3D &prP { // check API eAPI = _pGfx->gl_eCurrentAPI; + ASSERT( GfxValidApi(eAPI) ); + #ifdef SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); -#else // SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_NONE); -#endif // SE1_D3D - if( eAPI!=GAT_OGL -#ifdef SE1_D3D - && eAPI!=GAT_D3D -#endif // SE1_D3D - ) return; + if( eAPI!=GAT_OGL && eAPI!=GAT_D3D) return; +#else + if( eAPI!=GAT_OGL) return; +#endif // some cvars cannot be altered in multiplayer mode! if( _bMultiPlayer) { diff --git a/Sources/Engine/Graphics/Fog.cpp b/Sources/Engine/Graphics/Fog.cpp index f73ae71..823f9f6 100644 --- a/Sources/Engine/Graphics/Fog.cpp +++ b/Sources/Engine/Graphics/Fog.cpp @@ -1,10 +1,10 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Engine/StdH.h" #include -#include -#include +#include +#include #include #include #include @@ -54,6 +54,11 @@ ULONG PrepareTexture( UBYTE *pubTexture, PIX pixSizeI, PIX pixSizeJ) { // need to upload from RGBA format const PIX pixTextureSize = pixSizeI*pixSizeJ; + + #if (defined USE_PORTABLE_C) + STUBBED("PrepareTexture"); + + #elif (defined __MSVC_INLINE__) __asm { mov esi,D [pubTexture] mov edi,D [pubTexture] @@ -69,6 +74,29 @@ pixLoop: dec ecx jnz pixLoop } + + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "leal 0(%%esi, %%ecx), %%edi \n\t" + "0: \n\t" // pixLoop + "movzbl (%%esi), %%eax \n\t" + "orl $0xFFFFFF00, %%eax \n\t" + "bswapl %%eax \n\t" + "movl %%eax, (%%edi) \n\t" + "addl $1, %%esi \n\t" + "addl $4, %%edi \n\t" + "decl %%ecx \n\t" + "jnz 0b \n\t" // pixLoop + : // no outputs. + : "S" (pubTexture), "D" (pubTexture), "c" (pixTextureSize) + : "eax", "cc", "memory" + ); + + #else + #error Write inline ASM for your platform. + + #endif + // determine internal format extern INDEX gap_bAllowGrayTextures; extern INDEX tex_bFineFog; @@ -259,17 +287,17 @@ void StartFog( CFogParameters &fp, const FLOAT3D &vViewPosAbs, const FLOATmatrix // determine where fog starts and ends _fog_fStart = LowerLimit(0.0f); _fog_fEnd = UpperLimit(0.0f); + + INDEX pix; if( _fog_pubTable[pixSizeL-1]) { // going from bottom - INDEX pix=pixSizeH-1; - for( ; pix>0; pix--) { + for( pix=pixSizeH-1; pix>0; pix--) { if( (_fog_pubTable[(pix+1)*pixSizeL-1]*_fog_ulAlpha)>>8) break; } if( pix<(pixSizeH-1)) _fog_fEnd = (FLOAT)(pix+1) / (FLOAT)(pixSizeH-1); } else { // going from top - INDEX pix=0; - for( ; pix>8) break; } if( pix>0) _fog_fStart = (FLOAT)(pix-1) / (FLOAT)(pixSizeH-1); diff --git a/Sources/Engine/Graphics/Fog_internal.h b/Sources/Engine/Graphics/Fog_internal.h index 694d1d6..d232f4e 100644 --- a/Sources/Engine/Graphics/Fog_internal.h +++ b/Sources/Engine/Graphics/Fog_internal.h @@ -61,10 +61,10 @@ extern void StopHaze(void); __forceinline ULONG GetFogAlpha( const GFXTexCoord &tex) { // point sampling of height - PIX pixT = FloatToInt( tex.t * _fog_pixSizeH); + PIX pixT = FloatToInt( tex.st.t * _fog_pixSizeH); pixT = Clamp( pixT, 0L, _fog_pixSizeH-1L) * _fog_pixSizeL; // linear interpolation of depth - const PIX pixSF = FloatToInt( tex.s*(FLOAT)_fog_pixSizeL*255.499f); + const PIX pixSF = FloatToInt( tex.st.s*(FLOAT)_fog_pixSizeL*255.499f); const PIX pixS1 = Clamp( (PIX)((pixSF>>8)+0), 0L, _fog_pixSizeL-1L); const PIX pixS2 = Clamp( (PIX)((pixSF>>8)+1), 0L, _fog_pixSizeL-1L); const ULONG ulF = pixSF & 255; diff --git a/Sources/Engine/Graphics/Font.cpp b/Sources/Engine/Graphics/Font.cpp index 2a8affc..b9e9107 100644 --- a/Sources/Engine/Graphics/Font.cpp +++ b/Sources/Engine/Graphics/Font.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Graphics/GfxLibrary.cpp b/Sources/Engine/Graphics/GfxLibrary.cpp index 59e6dff..19d29bb 100644 --- a/Sources/Engine/Graphics/GfxLibrary.cpp +++ b/Sources/Engine/Graphics/GfxLibrary.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,16 @@ #include #include +// !!! FIXME: rcg10112001 This just screams to be broken up into subclasses. +// !!! FIXME: rcg10112001 That would get rid of all the #ifdef'ing and +// !!! FIXME: rcg10112001 the need to continually assert that the current +// !!! FIXME: rcg10112001 driver type is valid. + + +// !!! FIXME: rcg11052001 ... and I could get rid of this, too... +#ifdef PLATFORM_UNIX +#include +#endif // control for partial usage of compiled vertex arrays extern BOOL CVA_b2D = FALSE; @@ -71,7 +82,7 @@ static UWORD _auwGammaTable[256*3]; // table for clipping [-512..+1024] to [0..255] static UBYTE aubClipByte[256*2+ 256 +256*3]; -extern const UBYTE *pubClipByte = &aubClipByte[256*2]; +const UBYTE *pubClipByte = &aubClipByte[256*2]; // fast square root and 1/sqrt tables UBYTE aubSqrt[SQRTTABLESIZE]; @@ -86,7 +97,7 @@ static BOOL GFX_bRenderingScene = FALSE; static ULONG GFX_ulLastDrawPortID = 0; // last size of vertex buffers -extern INDEX _iLastVertexBufferSize = 0; +INDEX _iLastVertexBufferSize = 0; // pretouch flag extern BOOL _bNeedPretouch; @@ -96,176 +107,185 @@ static ULONG _ulWhite = 0xFFFFFFFF; // fast sin/cos table static FLOAT afSinTable[256+256+64]; -extern const FLOAT *pfSinTable = afSinTable +256; -extern const FLOAT *pfCosTable = afSinTable +256+64; +const FLOAT *pfSinTable = afSinTable +256; +const FLOAT *pfCosTable = afSinTable +256+64; // texture/shadow control -extern INDEX tex_iNormalQuality = 00; // 0=optimal, 1=16bit, 2=32bit, 3=compressed (1st num=opaque tex, 2nd=alpha tex) -extern INDEX tex_iAnimationQuality = 11; // 0=optimal, 1=16bit, 2=32bit, 3=compressed (1st num=opaque tex, 2nd=alpha tex) -extern INDEX tex_iNormalSize = 9; // log2 of texture area /2 for max texture size allowed -extern INDEX tex_iAnimationSize = 7; -extern INDEX tex_iEffectSize = 7; -extern INDEX tex_bDynamicMipmaps = FALSE; // how many mipmaps will be bilineary filtered (0-15) -extern INDEX tex_iDithering = 3; // 0=none, 1-3=low, 4-7=medium, 8-10=high -extern INDEX tex_bFineEffect = FALSE; // 32bit effect? (works only if base texture hasn't been dithered) -extern INDEX tex_bFineFog = TRUE; // should fog be 8/32bit? (or just plain 4/16bit) -extern INDEX tex_iFogSize = 7; // limit fog texture size -extern INDEX tex_iFiltering = 0; // -6 - +6; negative = sharpen, positive = blur, 0 = none -extern INDEX tex_iEffectFiltering = +4; // filtering of fire effect textures -extern INDEX tex_bProgressiveFilter = FALSE; // filter mipmaps in creation time (not afterwards) -extern INDEX tex_bColorizeMipmaps = FALSE; // DEBUG: colorize texture's mipmap levels in various colors -extern INDEX tex_bCompressAlphaChannel = FALSE; // for compressed textures, compress alpha channel too -extern INDEX tex_bAlternateCompression = FALSE; // basically, this is fix for GFs (compress opaque texture as translucent) - -extern INDEX shd_iStaticSize = 8; -extern INDEX shd_iDynamicSize = 8; -extern INDEX shd_bFineQuality = FALSE; -extern INDEX shd_iFiltering = 3; // >0 = blurring, 0 = no filtering -extern INDEX shd_iDithering = 1; // 0=none, 1,2=low, 3,4=medium, 5=high -extern INDEX shd_iAllowDynamic = 1; // 0=disallow, 1=allow on polys w/o 'NoDynamicLights' flag, 2=allow unconditionally -extern INDEX shd_bDynamicMipmaps = TRUE; -extern FLOAT shd_tmFlushDelay = 30.0f; // in seconds -extern FLOAT shd_fCacheSize = 8.0f; // in megabytes -extern INDEX shd_bCacheAll = FALSE; // cache all shadowmap at the level loading time (careful - memory eater!) -extern INDEX shd_bAllowFlats = TRUE; // allow optimization of single-color shadowmaps -extern INDEX shd_iForceFlats = 0; // force all shadowmaps to be flat (internal!) - 0=don't, 1=w/o overbrighting, 2=w/ overbrighting -extern INDEX shd_bShowFlats = FALSE; // colorize flat shadows -extern INDEX shd_bColorize = FALSE; // colorize shadows by size (gradieng from red=big to green=little) +INDEX tex_iNormalQuality = 00; // 0=optimal, 1=16bit, 2=32bit, 3=compressed (1st num=opaque tex, 2nd=alpha tex) +INDEX tex_iAnimationQuality = 11; // 0=optimal, 1=16bit, 2=32bit, 3=compressed (1st num=opaque tex, 2nd=alpha tex) +INDEX tex_iNormalSize = 9; // log2 of texture area /2 for max texture size allowed +INDEX tex_iAnimationSize = 7; +INDEX tex_iEffectSize = 7; +INDEX tex_bDynamicMipmaps = FALSE; // how many mipmaps will be bilineary filtered (0-15) +INDEX tex_iDithering = 3; // 0=none, 1-3=low, 4-7=medium, 8-10=high +INDEX tex_bCompressAlphaChannel = FALSE; // for compressed textures, compress alpha channel too +INDEX tex_bAlternateCompression = FALSE; // basically, this is fix for GFs (compress opaque texture as translucent) +INDEX tex_bFineEffect = FALSE; // 32bit effect? (works only if base texture hasn't been dithered) +INDEX tex_bFineFog = TRUE; // should fog be 8/32bit? (or just plain 4/16bit) +INDEX tex_iFogSize = 7; // limit fog texture size +INDEX tex_iFiltering = 0; // -6 - +6; negative = sharpen, positive = blur, 0 = none +INDEX tex_iEffectFiltering = +4; // filtering of fire effect textures +INDEX tex_bProgressiveFilter = FALSE; // filter mipmaps in creation time (not afterwards) +INDEX tex_bColorizeMipmaps = FALSE; // DEBUG: colorize texture's mipmap levels in various colors +INDEX shd_iStaticSize = 8; +INDEX shd_iDynamicSize = 8; +INDEX shd_bFineQuality = FALSE; +INDEX shd_iFiltering = 3; // >0 = blurring, 0 = no filtering +INDEX shd_iDithering = 1; // 0=none, 1,2=low, 3,4=medium, 5=high +INDEX shd_iAllowDynamic = 1; // 0=disallow, 1=allow on polys w/o 'NoDynamicLights' flag, 2=allow unconditionally +INDEX shd_bDynamicMipmaps = TRUE; +FLOAT shd_tmFlushDelay = 30.0f; // in seconds +FLOAT shd_fCacheSize = 8.0f; // in megabytes +INDEX shd_bCacheAll = FALSE; // cache all shadowmap at the level loading time (careful - memory eater!) +INDEX shd_bAllowFlats = TRUE; // allow optimization of single-color shadowmaps +INDEX shd_iForceFlats = 0; // force all shadowmaps to be flat (internal!) - 0=don't, 1=w/o overbrighting, 2=w/ overbrighting +INDEX shd_bShowFlats = FALSE; // show shadows that have been optimized as flat +INDEX shd_bColorize = FALSE; // colorize shadows by size (gradieng from red=big to green=little) // OpenGL control -extern INDEX ogl_iTextureCompressionType = 1; // 0=none, 1=default (ARB), 2=S3TC, 3=FXT1, 4=old S3TC -extern INDEX ogl_bUseCompiledVertexArrays = 101; // =XYZ; X=2D, Y=world, Z=models -extern INDEX ogl_bAllowQuadArrays = FALSE; -extern INDEX ogl_bExclusive = TRUE; -extern INDEX ogl_bGrabDepthBuffer = FALSE; -extern INDEX ogl_iMaxBurstSize = 0; // unlimited -extern INDEX ogl_bTruformLinearNormals = TRUE; -extern INDEX ogl_bAlternateClipPlane = FALSE; // signal when user clip plane requires a texture unit +INDEX ogl_iTextureCompressionType = 1; // 0=none, 1=default (ARB), 2=S3TC, 3=FXT1, 4=old S3TC +INDEX ogl_bUseCompiledVertexArrays = 101; // =XYZ; X=2D, Y=world, Z=models +INDEX ogl_bAllowQuadArrays = FALSE; +INDEX ogl_bExclusive = TRUE; +INDEX ogl_bGrabDepthBuffer = FALSE; +INDEX ogl_iMaxBurstSize = 0; // unlimited +INDEX ogl_bTruformLinearNormals = TRUE; +INDEX ogl_bAlternateClipPlane = FALSE; // signal when user clip plane requires a texture unit -extern INDEX ogl_iTBufferEffect = 0; // 0=none, 1=partial FSAA, 2=Motion Blur -extern INDEX ogl_iTBufferSamples = 2; // 2, 4 or 8 (for now) -extern INDEX ogl_iFinish = 1; // 0=never, 1=before rendering of next frame, 2=at the end of this frame, 3=at projection change +INDEX ogl_iTBufferEffect = 0; // 0=none, 1=partial FSAA, 2=Motion Blur +INDEX ogl_iTBufferSamples = 2; // 2, 4 or 8 (for now) +INDEX ogl_iFinish = 1; // 0=never, 1=before rendering of next frame, 2=at the end of this frame, 3=at projection change // Direct3D control -extern INDEX d3d_bUseHardwareTnL = TRUE; -extern INDEX d3d_bAlternateDepthReads = FALSE; // should check delayed depth reads at the end of current frame (FALSE) or at begining of the next (TRUE) -extern INDEX d3d_iVertexBuffersSize = 1024; // KBs reserved for vertex buffers -extern INDEX d3d_iVertexRangeTreshold = 99; // minimum vertices in buffer that triggers range optimization -extern INDEX d3d_bFastUpload = TRUE; // use internal format conversion routines -extern INDEX d3d_iMaxBurstSize = 0; // 0=unlimited -extern INDEX d3d_iFinish = 0; +INDEX d3d_bUseHardwareTnL = TRUE; +INDEX d3d_bAlternateDepthReads = FALSE; // should check delayed depth reads at the end of current frame (FALSE) or at begining of the next (TRUE) +INDEX d3d_bOptimizeVertexBuffers = TRUE; // enables circular buffers +INDEX d3d_iVertexBuffersSize = 1024; // KBs reserved for vertex buffers +INDEX d3d_iVertexRangeTreshold = 99; // minimum vertices in buffer that triggers range optimization +INDEX d3d_iMaxBurstSize = 0; // 0=unlimited +INDEX d3d_iFinish = 0; // API common controls -extern INDEX gap_iUseTextureUnits = 4; -extern INDEX gap_iTextureFiltering = 21; // bilinear by default -extern INDEX gap_iTextureAnisotropy = 1; // 1=isotropic, 2=min anisotropy -extern FLOAT gap_fTextureLODBias = 0.0f; -extern INDEX gap_bOptimizeStateChanges = TRUE; -extern INDEX gap_iOptimizeDepthReads = 1; // 0=imediately, 1=after frame, 2=every 0.1 seconds -extern INDEX gap_iOptimizeClipping = 2; // 0=no, 1=mirror plane only, 2=mirror and frustum -extern INDEX gap_bAllowGrayTextures = TRUE; -extern INDEX gap_bAllowSingleMipmap = TRUE; -extern INDEX gap_iSwapInterval = 0; -extern INDEX gap_iRefreshRate = 0; -extern INDEX gap_iDithering = 2; // 16-bit dithering: 0=none, 1=no alpha, 2=all -extern INDEX gap_bForceTruform = 0; // 0 = only for models that allow truform, 1=for every model -extern INDEX gap_iTruformLevel = 3; // 0 = no tesselation -extern INDEX gap_iDepthBits = 0; // 0 (as color depth), 16, 24 or 32 -extern INDEX gap_iStencilBits = 0; // 0 (no stencil buffer), 4 or 8 +INDEX gap_iUseTextureUnits = 4; +INDEX gap_iTextureFiltering = 21; // bilinear by default +INDEX gap_iTextureAnisotropy = 1; // 1=isotropic, 2=min anisotropy +FLOAT gap_fTextureLODBias = 0.0f; +INDEX gap_bOptimizeStateChanges = TRUE; +INDEX gap_iOptimizeDepthReads = 1; // 0=imediately, 1=after frame, 2=every 0.1 seconds +INDEX gap_iOptimizeClipping = 2; // 0=no, 1=mirror plane only, 2=mirror and frustum +INDEX gap_bAllowGrayTextures = TRUE; +INDEX gap_bAllowSingleMipmap = TRUE; +INDEX gap_iSwapInterval = 0; +INDEX gap_iRefreshRate = 0; +INDEX gap_iDithering = 2; // 16-bit dithering: 0=none, 1=no alpha, 2=all +INDEX gap_bForceTruform = 0; // 0 = only for models that allow truform, 1=for every model +INDEX gap_iTruformLevel = 3; // 0 = no tesselation +INDEX gap_iDepthBits = 0; // 0 (as color depth), 16, 24 or 32 +INDEX gap_iStencilBits = 0; // 0 (no stencil buffer), 4 or 8 // models control -extern INDEX mdl_bShowTriangles = FALSE; -extern INDEX mdl_bShowStrips = FALSE; -extern INDEX mdl_bTruformWeapons = FALSE; -extern INDEX mdl_bCreateStrips = TRUE; -extern INDEX mdl_bRenderDetail = TRUE; -extern INDEX mdl_bRenderSpecular = TRUE; -extern INDEX mdl_bRenderReflection = TRUE; -extern INDEX mdl_bAllowOverbright = TRUE; -extern INDEX mdl_bFineQuality = TRUE; -extern INDEX mdl_iShadowQuality = 1; -extern FLOAT mdl_fLODMul = 1.0f; -extern FLOAT mdl_fLODAdd = 0.0f; -extern INDEX mdl_iLODDisappear = 1; // 0=never, 1=ignore bias, 2=with bias +INDEX mdl_bShowTriangles = FALSE; +INDEX mdl_bShowStrips = FALSE; +INDEX mdl_bTruformWeapons = FALSE; +INDEX mdl_bCreateStrips = TRUE; +INDEX mdl_bRenderDetail = TRUE; +INDEX mdl_bRenderSpecular = TRUE; +INDEX mdl_bRenderReflection = TRUE; +INDEX mdl_bAllowOverbright = TRUE; +INDEX mdl_bFineQuality = TRUE; +INDEX mdl_iShadowQuality = 1; +FLOAT mdl_fLODMul = 1.0f; +FLOAT mdl_fLODAdd = 0.0f; +INDEX mdl_iLODDisappear = 1; // 0=never, 1=ignore bias, 2=with bias + // ska controls -extern INDEX ska_bShowSkeleton = FALSE; -extern INDEX ska_bShowColision = FALSE; -extern FLOAT ska_fLODMul = 1.0f; -extern FLOAT ska_fLODAdd = 0.0f; +INDEX ska_bShowSkeleton = FALSE; +INDEX ska_bShowColision = FALSE; +FLOAT ska_fLODMul = 1.0f; +FLOAT ska_fLODAdd = 0.0f; // terrain controls -extern INDEX ter_bShowQuadTree = FALSE; -extern INDEX ter_bShowWireframe = FALSE; -extern INDEX ter_bLerpVertices = TRUE; -extern INDEX ter_bShowInfo = FALSE; -extern INDEX ter_bOptimizeRendering = TRUE; -extern INDEX ter_bTempFreezeCast = FALSE; -extern INDEX ter_bNoRegeneration = FALSE; +INDEX ter_bShowQuadTree = FALSE; +INDEX ter_bShowWireframe = FALSE; +INDEX ter_bLerpVertices = TRUE; +INDEX ter_bShowInfo = FALSE; +INDEX ter_bOptimizeRendering = TRUE; +INDEX ter_bTempFreezeCast = FALSE; +INDEX ter_bNoRegeneration = FALSE; + +// !!! FIXME : rcg11232001 Hhmm...I'm failing an assertion in the +// !!! FIXME : rcg11232001 Advanced Rendering Options menu because +// !!! FIXME : rcg11232001 Scripts/CustomOptions/GFX-AdvancedRendering.cfg +// !!! FIXME : rcg11232001 references non-existing cvars, so I'm adding them +// !!! FIXME : rcg11232001 here for now. +static INDEX mdl_bRenderBump = TRUE; +static FLOAT ogl_fTextureAnisotropy = 0.0f; +static FLOAT tex_fNormalSize = 0.0f; // rendering control -extern INDEX wld_bAlwaysAddAll = FALSE; -extern INDEX wld_bRenderMirrors = TRUE; -extern INDEX wld_bRenderEmptyBrushes = TRUE; -extern INDEX wld_bRenderShadowMaps = TRUE; -extern INDEX wld_bRenderTextures = TRUE; -extern INDEX wld_bRenderDetailPolygons = TRUE; -extern INDEX wld_bTextureLayers = 111; -extern INDEX wld_bShowTriangles = FALSE; -extern INDEX wld_bShowDetailTextures = FALSE; -extern INDEX wld_iDetailRemovingBias = 3; -extern FLOAT wld_fEdgeOffsetI = 0.0f; //0.125f; -extern FLOAT wld_fEdgeAdjustK = 1.0f; //1.0001f; +INDEX wld_bAlwaysAddAll = FALSE; +INDEX wld_bRenderMirrors = TRUE; +INDEX wld_bRenderEmptyBrushes = TRUE; +INDEX wld_bRenderShadowMaps = TRUE; +INDEX wld_bRenderTextures = TRUE; +INDEX wld_bRenderDetailPolygons = TRUE; +INDEX wld_bTextureLayers = 111; +INDEX wld_bShowTriangles = FALSE; +INDEX wld_bShowDetailTextures = FALSE; +INDEX wld_iDetailRemovingBias = 3; +FLOAT wld_fEdgeOffsetI = 0.0f; //0.125f; +FLOAT wld_fEdgeAdjustK = 1.0f; //1.0001f; -extern INDEX gfx_bRenderWorld = TRUE; -extern INDEX gfx_bRenderParticles = TRUE; -extern INDEX gfx_bRenderModels = TRUE; -extern INDEX gfx_bRenderPredicted = FALSE; -extern INDEX gfx_bRenderFog = TRUE; -extern INDEX gfx_iLensFlareQuality = 3; // 0=none, 1=corona only, 2=corona and reflections, 3=corona, reflections and glare +INDEX gfx_bRenderWorld = TRUE; +INDEX gfx_bRenderParticles = TRUE; +INDEX gfx_bRenderModels = TRUE; +INDEX gfx_bRenderPredicted = FALSE; +INDEX gfx_bRenderFog = TRUE; +INDEX gfx_iLensFlareQuality = 3; // 0=none, 1=corona only, 2=corona and reflections, 3=corona, reflections and glare -extern INDEX gfx_bDecoratedText = TRUE; -extern INDEX gfx_bClearScreen = FALSE; -extern FLOAT gfx_tmProbeDecay = 30.0f; // seconds -extern INDEX gfx_iProbeSize = 256; // in KBs +INDEX gfx_bDecoratedText = TRUE; +INDEX gfx_bClearScreen = FALSE; +FLOAT gfx_tmProbeDecay = 30.00f; // seconds +INDEX gfx_iProbeSize = 256; // in KBs -extern INDEX gfx_ctMonitors = 0; -extern INDEX gfx_bMultiMonDisabled = FALSE; -extern INDEX gfx_bDisableMultiMonSupport = TRUE; +INDEX gfx_ctMonitors = 0; +INDEX gfx_bMultiMonDisabled = FALSE; +INDEX gfx_bDisableMultiMonSupport = TRUE; -extern INDEX gfx_bDisableWindowsKeys = TRUE; +INDEX gfx_bDisableWindowsKeys = TRUE; -extern INDEX wed_bIgnoreTJunctions = FALSE; -extern INDEX wed_bUseBaseForReplacement = FALSE; +INDEX wed_bIgnoreTJunctions = FALSE; +INDEX wed_bUseBaseForReplacement = FALSE; // some nifty features -extern INDEX gfx_iHueShift = 0; // 0-359 -extern FLOAT gfx_fSaturation = 1.0f; // 0.0f = min, 1.0f = default +INDEX gfx_iHueShift = 0; // 0-359 +FLOAT gfx_fSaturation = 1.0f; // 0.0f = min, 1.0f = default // the following vars can be influenced by corresponding gfx_ vars -extern INDEX tex_iHueShift = 0; // added to gfx_ -extern FLOAT tex_fSaturation = 1.0f; // multiplied by gfx_ -extern INDEX shd_iHueShift = 0; // added to gfx_ -extern FLOAT shd_fSaturation = 1.0f; // multiplied by gfx_ +INDEX tex_iHueShift = 0; // added to gfx_ +FLOAT tex_fSaturation = 1.0f; // multiplied by gfx_ +INDEX shd_iHueShift = 0; // added to gfx_ +FLOAT shd_fSaturation = 1.0f; // multiplied by gfx_ // gamma table control -extern FLOAT gfx_fBrightness = 0.0f; // -0.9 - 0.9 -extern FLOAT gfx_fContrast = 1.0f; // 0.1 - 1.9 -extern FLOAT gfx_fGamma = 1.0f; // 0.1 - 9.0 -extern FLOAT gfx_fBiasR = 1.0f; // 0.0 - 1.0 -extern FLOAT gfx_fBiasG = 1.0f; // 0.0 - 1.0 -extern FLOAT gfx_fBiasB = 1.0f; // 0.0 - 1.0 -extern INDEX gfx_iLevels = 256; // 2 - 256 +FLOAT gfx_fBrightness = 0.0f; // -0.9 - 0.9 +FLOAT gfx_fContrast = 1.0f; // 0.1 - 1.9 +FLOAT gfx_fGamma = 1.0f; // 0.1 - 9.0 +FLOAT gfx_fBiasR = 1.0f; // 0.0 - 1.0 +FLOAT gfx_fBiasG = 1.0f; // 0.0 - 1.0 +FLOAT gfx_fBiasB = 1.0f; // 0.0 - 1.0 +INDEX gfx_iLevels = 256; // 2 - 256 // stereo rendering control -extern INDEX gfx_iStereo = 0; // 0=off, 1=red/cyan -extern INDEX gfx_bStereoInvert = FALSE; // is left eye RED or CYAN -extern INDEX gfx_iStereoOffset = 10; // view offset (or something:) -extern FLOAT gfx_fStereoSeparation = 0.25f; // distance between eyes +INDEX gfx_iStereo = 0; // 0=off, 1=red/cyan +INDEX gfx_bStereoInvert = FALSE; // is left eye RED or CYAN +INDEX gfx_iStereoOffset = 10; // view offset (or something:) +FLOAT gfx_fStereoSeparation = 0.25f; // distance between eyes // cached integers for faster calculation -extern SLONG _slTexSaturation = 256; // 0 = min, 256 = default -extern SLONG _slTexHueShift = 0; -extern SLONG _slShdSaturation = 256; -extern SLONG _slShdHueShift = 0; +SLONG _slTexSaturation = 256; // 0 = min, 256 = default +SLONG _slTexHueShift = 0; +SLONG _slShdSaturation = 256; +SLONG _slShdHueShift = 0; // 'supported' console variable flags static INDEX sys_bHasTextureCompression = 0; @@ -295,6 +315,7 @@ extern INDEX sys_bUsingDirect3D = 0; //#define LLMHF_INJECTED 0x00000001 +#ifdef PLATFORM_WIN32 /* * Structure used by WH_KEYBOARD_LL */ @@ -360,6 +381,11 @@ void EnableWindowsKeys(void) // if( _hLLKeyHook!=NULL) UnhookWindowsHookEx(_hLLKeyHook); } +#else + #define DisableWindowsKeys() + #define EnableWindowsKeys() +#endif + // texture size reporting static CTString ReportQuality( INDEX iQuality) @@ -409,17 +435,17 @@ static void TexturesInfo(void) }} // report - const PIX pixNormDim = sqrt((FLOAT)TS.ts_pixNormSize); - const PIX pixAnimDim = sqrt((FLOAT)TS.ts_pixAnimSize); + const PIX pixNormDim = (PIX) (sqrt(TS.ts_pixNormSize)); + const PIX pixAnimDim = (PIX) (sqrt(TS.ts_pixAnimSize)); const PIX pixEffDim = 1L<gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); -#else // SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_NONE); -#endif // SE1_D3D CPrintF( "\n"); + ASSERT( GfxValidApi(eAPI) ); + +#ifdef PLATFORM_WIN32 // in case of driver hasn't been initialized yet - if( (_pGfx->go_hglRC==NULL + if( (_pGfx->go_hglRC==NULL #ifdef SE1_D3D && _pGfx->gl_pd3dDevice==NULL #endif // SE1_D3D @@ -483,6 +507,14 @@ static void GAPInfo(void) CPrintF( TRANS("Display driver hasn't been initialized.\n\n")); return; } +#else + // in case of driver hasn't been initialized yet + if (_pGfx->go_hglRC==NULL || eAPI==GAT_NONE) { + // be brief, be quick + CPrintF( TRANS("Display driver hasn't been initialized.\n\n")); + return; + } +#endif // report API CPrintF( "- Graphics API: "); @@ -494,9 +526,9 @@ static void GAPInfo(void) // report renderer CDisplayAdapter &da = _pGfx->gl_gaAPI[eAPI].ga_adaAdapter[_pGfx->gl_iCurrentAdapter]; - if( eAPI==GAT_OGL) CPrintF( "- Vendor: %s\n", da.da_strVendor); - CPrintF( "- Renderer: %s\n", da.da_strRenderer); - CPrintF( "- Version: %s\n", da.da_strVersion); + if( eAPI==GAT_OGL) CPrintF( "- Vendor: %s\n", (const char *) da.da_strVendor); + CPrintF( "- Renderer: %s\n", (const char *) da.da_strRenderer); + CPrintF( "- Version: %s\n", (const char *) da.da_strVersion); CPrintF( "\n"); // Z-buffer depth @@ -549,7 +581,7 @@ static void GAPInfo(void) if( gap_bForceTruform) CPrintF( "(for all models)\n"); else CPrintF( "(only for Truform-ready models)\n"); CTString strNormalMode = ogl_bTruformLinearNormals ? "linear" : "quadratic"; - CPrintF( "- Tesselation level: %d of %d (%s normals)\n", _pGfx->gl_iTessellationLevel, _pGfx->gl_iMaxTessellationLevel, strNormalMode); + CPrintF( "- Tesselation level: %d of %d (%s normals)\n", _pGfx->gl_iTessellationLevel, _pGfx->gl_iMaxTessellationLevel, (const char *) strNormalMode); } else CPrintF( "disabled\n"); } else CPrintF( "not supported\n"); @@ -574,7 +606,7 @@ static void GAPInfo(void) CTString strEffect = "Partial anti-aliasing"; if( ogl_iTBufferEffect<1) strEffect = "none"; if( ogl_iTBufferEffect>1) strEffect = "Motion blur"; - CPrintF( "%s (%d buffers used)\n", strEffect, _pGfx->go_ctSampleBuffers); + CPrintF( "%s (%d buffers used)\n", (const char *) strEffect, _pGfx->go_ctSampleBuffers); } } @@ -588,8 +620,8 @@ static void GAPInfo(void) CTString strSep=""; CPrintF( "enabled (for "); if( CVA_bWorld) { CPrintF( "world"); strSep="/"; } - if( CVA_bModels) { CPrintF( "%smodels", strSep); strSep="/"; } - if( CVA_b2D) { CPrintF( "%sparticles", strSep); } + if( CVA_bModels) { CPrintF( "%smodels", (const char *) strSep); strSep="/"; } + if( CVA_b2D) { CPrintF( "%sparticles", (const char *) strSep); } CPrintF( ")\n"); } else CPrintF( "disabled\n"); } else CPrintF( "not supported\n"); @@ -600,9 +632,9 @@ static void GAPInfo(void) else { CTString strSep=""; if( _pGfx->gl_ulFlags & GLF_EXTC_ARB) { CPrintF( "ARB"); strSep=", "; } - if( _pGfx->gl_ulFlags & GLF_EXTC_S3TC) { CPrintF( "%sS3TC", strSep); strSep=", "; } - if( _pGfx->gl_ulFlags & GLF_EXTC_FXT1) { CPrintF( "%sFTX1", strSep); strSep=", "; } - if( _pGfx->gl_ulFlags & GLF_EXTC_LEGACY) { CPrintF( "%sold S3TC", strSep); } + if( _pGfx->gl_ulFlags & GLF_EXTC_S3TC) { CPrintF( "%sS3TC", (const char *) strSep); strSep=", "; } + if( _pGfx->gl_ulFlags & GLF_EXTC_FXT1) { CPrintF( "%sFTX1", (const char *) strSep); strSep=", "; } + if( _pGfx->gl_ulFlags & GLF_EXTC_LEGACY) { CPrintF( "%sold S3TC", (const char *) strSep); } CPrintF( "\n- Current texture compression system: "); switch( ogl_iTextureCompressionType) { case 0: CPrintF( "none\n"); break; @@ -632,13 +664,13 @@ static void GAPInfo(void) } */ // report OpenGL externsions CPrintF("\n"); - CPrintF("- Published extensions: %s", ReformatExtensionsString(_pGfx->go_strExtensions)); - if( _pGfx->go_strWinExtensions != "") CPrintF("%s", ReformatExtensionsString(_pGfx->go_strWinExtensions)); - CPrintF("\n- Supported extensions: %s\n", ReformatExtensionsString(_pGfx->go_strSupportedExtensions)); + CPrintF("- Published extensions: %s", (const char *) ReformatExtensionsString(_pGfx->go_strExtensions)); + if( _pGfx->go_strWinExtensions != "") CPrintF("%s", (const char *) ReformatExtensionsString(_pGfx->go_strWinExtensions)); + CPrintF("\n- Supported extensions: %s\n", (const char *) ReformatExtensionsString(_pGfx->go_strSupportedExtensions)); } +#ifdef PLATFORM_WIN32 // Direct3D only stuff -#ifdef SE1_D3D if( eAPI==GAT_D3D) { // HW T&L @@ -913,6 +945,46 @@ static void PrepareTables(void) aubGouraudConv[h*128+p] = (UBYTE)GouraudNormal(v); } } + + +// !!! FIXME: rcg01082002 +// You can't count on these arrays to be identical on every system, due to +// floating point unit differences. This includes Linux and win32 on the +// x86 platform, and win32 debug builds vs. win32 release builds. Hell, I +// wouldn't be surprised if they gave different values between AMD and Intel +// processors. The tables generate identically between a win32 release and +// Linux release build at this point...except the Gouraud table, which has +// several minor variances. I recommend you get a table you like, use the +// below code to dump it to disk, and then make it a static array that you +// never need to calculate at runtime in the first place. Then you can remove +// this code and this godawful long comment. :) +#if 0 + FILE *feh; + + feh = fopen("aubClipByte.bin", "wb"); + fwrite(aubClipByte, sizeof (aubClipByte), 1, feh); + fclose(feh); + + feh = fopen("aubSqrt.bin", "wb"); + fwrite(aubSqrt, sizeof (aubSqrt), 1, feh); + fclose(feh); + + feh = fopen("auw1oSqrt.bin", "wb"); + fwrite(auw1oSqrt, sizeof (auw1oSqrt), 1, feh); + fclose(feh); + + feh = fopen("afSinTable.bin", "wb"); + fwrite(afSinTable, sizeof (afSinTable), 1, feh); + fclose(feh); + + feh = fopen("aubGouraudConv.bin", "wb"); + fwrite(aubGouraudConv, sizeof (aubGouraudConv), 1, feh); + fclose(feh); + +printf("w00t.\n"); +exit(0); +#endif + } @@ -1019,6 +1091,10 @@ void CGfxLibrary::Init(void) { ASSERT( this!=NULL); + // we will never allow glide splash screen + putenv( "FX_GLIDE_NO_SPLASH=1"); + +#ifdef PLATFORM_WIN32 // report desktop settings CPrintF(TRANS("Desktop settings...\n")); @@ -1033,190 +1109,193 @@ void CGfxLibrary::Init(void) CPrintF(TRANS(" Virtual screen: %dx%d\n"), GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN)); CPrintF(TRANS(" Monitors directly reported: %d\n"), gfx_ctMonitors); +#else + + gfx_ctMonitors = 1; + +#endif + CPrintF("\n"); gfx_bMultiMonDisabled = FALSE; _pfGfxProfile.Reset(); - // we will never allow glide splash screen - putenv( "FX_GLIDE_NO_SPLASH=1"); - // declare some console vars - _pShell->DeclareSymbol("user void MonitorsOn(void);", &MonitorsOn); - _pShell->DeclareSymbol("user void MonitorsOff(void);", &MonitorsOff); + _pShell->DeclareSymbol("user void MonitorsOn(void);", (void *) &MonitorsOn); + _pShell->DeclareSymbol("user void MonitorsOff(void);", (void *) &MonitorsOff); - _pShell->DeclareSymbol("user void GAPInfo(void);", &GAPInfo); - _pShell->DeclareSymbol("user void TexturesInfo(void);", &TexturesInfo); - _pShell->DeclareSymbol("user void UncacheShadows(void);", &UncacheShadows); - _pShell->DeclareSymbol("user void RecacheShadows(void);", &RecacheShadows); - _pShell->DeclareSymbol("user void RefreshTextures(void);", &RefreshTextures); - _pShell->DeclareSymbol("user void ReloadModels(void);", &ReloadModels); + _pShell->DeclareSymbol("user void GAPInfo(void);", (void *) &GAPInfo); + _pShell->DeclareSymbol("user void TexturesInfo(void);", (void *) &TexturesInfo); + _pShell->DeclareSymbol("user void UncacheShadows(void);", (void *) &UncacheShadows); + _pShell->DeclareSymbol("user void RecacheShadows(void);", (void *) &RecacheShadows); + _pShell->DeclareSymbol("user void RefreshTextures(void);", (void *) &RefreshTextures); + _pShell->DeclareSymbol("user void ReloadModels(void);", (void *) &ReloadModels); - _pShell->DeclareSymbol("persistent user INDEX ogl_bUseCompiledVertexArrays;", &ogl_bUseCompiledVertexArrays); - _pShell->DeclareSymbol("persistent user INDEX ogl_bExclusive;", &ogl_bExclusive); - _pShell->DeclareSymbol("persistent user INDEX ogl_bAllowQuadArrays;", &ogl_bAllowQuadArrays); - _pShell->DeclareSymbol("persistent user INDEX ogl_iTextureCompressionType;", &ogl_iTextureCompressionType); - _pShell->DeclareSymbol("persistent user INDEX ogl_iMaxBurstSize;", &ogl_iMaxBurstSize); - _pShell->DeclareSymbol("persistent user INDEX ogl_bGrabDepthBuffer;", &ogl_bGrabDepthBuffer); - _pShell->DeclareSymbol("persistent user INDEX ogl_iFinish;", &ogl_iFinish); + _pShell->DeclareSymbol("persistent user INDEX ogl_bUseCompiledVertexArrays;", (void *) &ogl_bUseCompiledVertexArrays); + _pShell->DeclareSymbol("persistent user INDEX ogl_bExclusive;", (void *) &ogl_bExclusive); + _pShell->DeclareSymbol("persistent user INDEX ogl_bAllowQuadArrays;", (void *) &ogl_bAllowQuadArrays); + _pShell->DeclareSymbol("persistent user INDEX ogl_iTextureCompressionType;", (void *) &ogl_iTextureCompressionType); + _pShell->DeclareSymbol("persistent user INDEX ogl_iMaxBurstSize;", (void *) &ogl_iMaxBurstSize); + _pShell->DeclareSymbol("persistent user INDEX ogl_bGrabDepthBuffer;", (void *) &ogl_bGrabDepthBuffer); + _pShell->DeclareSymbol("persistent user INDEX ogl_iFinish;", (void *) &ogl_iFinish); - _pShell->DeclareSymbol("persistent user INDEX ogl_iTBufferEffect;", &ogl_iTBufferEffect); - _pShell->DeclareSymbol("persistent user INDEX ogl_iTBufferSamples;", &ogl_iTBufferSamples); - _pShell->DeclareSymbol("persistent user INDEX ogl_bTruformLinearNormals;", &ogl_bTruformLinearNormals); - _pShell->DeclareSymbol("persistent user INDEX ogl_bAlternateClipPlane;", &ogl_bAlternateClipPlane); + _pShell->DeclareSymbol("persistent user INDEX ogl_iTBufferEffect;", (void *) &ogl_iTBufferEffect); + _pShell->DeclareSymbol("persistent user INDEX ogl_iTBufferSamples;", (void *) &ogl_iTBufferSamples); + _pShell->DeclareSymbol("persistent user INDEX ogl_bTruformLinearNormals;", (void *) &ogl_bTruformLinearNormals); + _pShell->DeclareSymbol("persistent user INDEX ogl_bAlternateClipPlane;", (void *) &ogl_bAlternateClipPlane); - _pShell->DeclareSymbol("persistent user INDEX d3d_bUseHardwareTnL;", &d3d_bUseHardwareTnL); - _pShell->DeclareSymbol("persistent user INDEX d3d_iMaxBurstSize;", &d3d_iMaxBurstSize); - _pShell->DeclareSymbol("persistent user INDEX d3d_iVertexBuffersSize;", &d3d_iVertexBuffersSize); - _pShell->DeclareSymbol("persistent user INDEX d3d_iVertexRangeTreshold;", &d3d_iVertexRangeTreshold); - _pShell->DeclareSymbol("persistent user INDEX d3d_bAlternateDepthReads;", &d3d_bAlternateDepthReads); - _pShell->DeclareSymbol("persistent INDEX d3d_bFastUpload;", &d3d_bFastUpload); - _pShell->DeclareSymbol("persistent user INDEX d3d_iFinish;", &d3d_iFinish); + _pShell->DeclareSymbol("persistent user INDEX d3d_bUseHardwareTnL;", (void *) &d3d_bUseHardwareTnL); + _pShell->DeclareSymbol("persistent user INDEX d3d_iMaxBurstSize;", (void *) &d3d_iMaxBurstSize); + _pShell->DeclareSymbol("persistent user INDEX d3d_iVertexBuffersSize;", (void *) &d3d_iVertexBuffersSize); + _pShell->DeclareSymbol("persistent user INDEX d3d_iVertexRangeTreshold;", (void *) &d3d_iVertexRangeTreshold); + _pShell->DeclareSymbol("persistent user INDEX d3d_bAlternateDepthReads;", (void *) &d3d_bAlternateDepthReads); + _pShell->DeclareSymbol("persistent user INDEX d3d_bOptimizeVertexBuffers;", (void *) &d3d_bOptimizeVertexBuffers); + _pShell->DeclareSymbol("persistent user INDEX d3d_iFinish;", (void *) &d3d_iFinish); - _pShell->DeclareSymbol("persistent user INDEX gap_iUseTextureUnits;", &gap_iUseTextureUnits); - _pShell->DeclareSymbol("persistent user INDEX gap_iTextureFiltering;", &gap_iTextureFiltering); - _pShell->DeclareSymbol("persistent user INDEX gap_iTextureAnisotropy;", &gap_iTextureAnisotropy); - _pShell->DeclareSymbol("persistent user FLOAT gap_fTextureLODBias;", &gap_fTextureLODBias); - _pShell->DeclareSymbol("persistent user INDEX gap_bAllowGrayTextures;", &gap_bAllowGrayTextures); - _pShell->DeclareSymbol("persistent user INDEX gap_bAllowSingleMipmap;", &gap_bAllowSingleMipmap); - _pShell->DeclareSymbol("persistent user INDEX gap_bOptimizeStateChanges;", &gap_bOptimizeStateChanges); - _pShell->DeclareSymbol("persistent user INDEX gap_iOptimizeDepthReads;", &gap_iOptimizeDepthReads); - _pShell->DeclareSymbol("persistent user INDEX gap_iOptimizeClipping;", &gap_iOptimizeClipping); - _pShell->DeclareSymbol("persistent user INDEX gap_iSwapInterval;", &gap_iSwapInterval); - _pShell->DeclareSymbol("persistent user INDEX gap_iRefreshRate;", &gap_iRefreshRate); - _pShell->DeclareSymbol("persistent user INDEX gap_iDithering;", &gap_iDithering); - _pShell->DeclareSymbol("persistent user INDEX gap_bForceTruform;", &gap_bForceTruform); - _pShell->DeclareSymbol("persistent user INDEX gap_iTruformLevel;", &gap_iTruformLevel); - _pShell->DeclareSymbol("persistent user INDEX gap_iDepthBits;", &gap_iDepthBits); - _pShell->DeclareSymbol("persistent user INDEX gap_iStencilBits;", &gap_iStencilBits); + _pShell->DeclareSymbol("persistent user INDEX gap_iUseTextureUnits;", (void *) &gap_iUseTextureUnits); + _pShell->DeclareSymbol("persistent user INDEX gap_iTextureFiltering;", (void *) &gap_iTextureFiltering); + _pShell->DeclareSymbol("persistent user INDEX gap_iTextureAnisotropy;", (void *) &gap_iTextureAnisotropy); + _pShell->DeclareSymbol("persistent user FLOAT gap_fTextureLODBias;", (void *) &gap_fTextureLODBias); + _pShell->DeclareSymbol("persistent user INDEX gap_bAllowGrayTextures;", (void *) &gap_bAllowGrayTextures); + _pShell->DeclareSymbol("persistent user INDEX gap_bAllowSingleMipmap;", (void *) &gap_bAllowSingleMipmap); + _pShell->DeclareSymbol("persistent user INDEX gap_bOptimizeStateChanges;", (void *) &gap_bOptimizeStateChanges); + _pShell->DeclareSymbol("persistent user INDEX gap_iOptimizeDepthReads;", (void *) &gap_iOptimizeDepthReads); + _pShell->DeclareSymbol("persistent user INDEX gap_iOptimizeClipping;", (void *) &gap_iOptimizeClipping); + _pShell->DeclareSymbol("persistent user INDEX gap_iSwapInterval;", (void *) &gap_iSwapInterval); + _pShell->DeclareSymbol("persistent user INDEX gap_iRefreshRate;", (void *) &gap_iRefreshRate); + _pShell->DeclareSymbol("persistent user INDEX gap_iDithering;", (void *) &gap_iDithering); + _pShell->DeclareSymbol("persistent user INDEX gap_bForceTruform;", (void *) &gap_bForceTruform); + _pShell->DeclareSymbol("persistent user INDEX gap_iTruformLevel;", (void *) &gap_iTruformLevel); + _pShell->DeclareSymbol("persistent user INDEX gap_iDepthBits;", (void *) &gap_iDepthBits); + _pShell->DeclareSymbol("persistent user INDEX gap_iStencilBits;", (void *) &gap_iStencilBits); - _pShell->DeclareSymbol("void MdlPostFunc(INDEX);", &MdlPostFunc); + _pShell->DeclareSymbol("void MdlPostFunc(INDEX);", (void *) &MdlPostFunc); - _pShell->DeclareSymbol(" user INDEX gfx_bRenderPredicted;", &gfx_bRenderPredicted); - _pShell->DeclareSymbol(" user INDEX gfx_bRenderModels;", &gfx_bRenderModels); - _pShell->DeclareSymbol(" user INDEX mdl_bShowTriangles;", &mdl_bShowTriangles); - _pShell->DeclareSymbol(" user INDEX mdl_bCreateStrips;", &mdl_bCreateStrips); - _pShell->DeclareSymbol(" user INDEX mdl_bShowStrips;", &mdl_bShowStrips); - _pShell->DeclareSymbol("persistent user FLOAT mdl_fLODMul;", &mdl_fLODMul); - _pShell->DeclareSymbol("persistent user FLOAT mdl_fLODAdd;", &mdl_fLODAdd); - _pShell->DeclareSymbol("persistent user INDEX mdl_iLODDisappear;", &mdl_iLODDisappear); - _pShell->DeclareSymbol("persistent user INDEX mdl_bRenderDetail;", &mdl_bRenderDetail); - _pShell->DeclareSymbol("persistent user INDEX mdl_bRenderSpecular;", &mdl_bRenderSpecular); - _pShell->DeclareSymbol("persistent user INDEX mdl_bRenderReflection;", &mdl_bRenderReflection); - _pShell->DeclareSymbol("persistent user INDEX mdl_bAllowOverbright;", &mdl_bAllowOverbright); - _pShell->DeclareSymbol("persistent user INDEX mdl_bFineQuality post:MdlPostFunc;", &mdl_bFineQuality); - _pShell->DeclareSymbol("persistent user INDEX mdl_iShadowQuality;", &mdl_iShadowQuality); - _pShell->DeclareSymbol(" INDEX mdl_bTruformWeapons;", &mdl_bTruformWeapons); - - _pShell->DeclareSymbol(" user INDEX ska_bShowSkeleton;", &ska_bShowSkeleton); - _pShell->DeclareSymbol(" user INDEX ska_bShowColision;", &ska_bShowColision); - _pShell->DeclareSymbol("persistent user FLOAT ska_fLODMul;", &ska_fLODMul); - _pShell->DeclareSymbol("persistent user FLOAT ska_fLODAdd;", &ska_fLODAdd); - - _pShell->DeclareSymbol(" user INDEX ter_bShowQuadTree;", &ter_bShowQuadTree); - _pShell->DeclareSymbol(" user INDEX ter_bShowWireframe;", &ter_bShowWireframe); - _pShell->DeclareSymbol(" user INDEX ter_bLerpVertices;", &ter_bLerpVertices); - _pShell->DeclareSymbol(" user INDEX ter_bShowInfo;", &ter_bShowInfo); - _pShell->DeclareSymbol(" user INDEX ter_bOptimizeRendering;", &ter_bOptimizeRendering); - _pShell->DeclareSymbol(" user INDEX ter_bTempFreezeCast; ", &ter_bTempFreezeCast); - _pShell->DeclareSymbol(" user INDEX ter_bNoRegeneration; ", &ter_bNoRegeneration); - - - + _pShell->DeclareSymbol(" user INDEX gfx_bRenderPredicted;", (void *) &gfx_bRenderPredicted); + _pShell->DeclareSymbol(" user INDEX gfx_bRenderModels;", (void *) &gfx_bRenderModels); + _pShell->DeclareSymbol(" user INDEX mdl_bShowTriangles;", (void *) &mdl_bShowTriangles); + _pShell->DeclareSymbol(" user INDEX mdl_bCreateStrips;", (void *) &mdl_bCreateStrips); + _pShell->DeclareSymbol(" user INDEX mdl_bShowStrips;", (void *) &mdl_bShowStrips); + _pShell->DeclareSymbol("persistent user FLOAT mdl_fLODMul;", (void *) &mdl_fLODMul); + _pShell->DeclareSymbol("persistent user FLOAT mdl_fLODAdd;", (void *) &mdl_fLODAdd); + _pShell->DeclareSymbol("persistent user INDEX mdl_iLODDisappear;", (void *) &mdl_iLODDisappear); + _pShell->DeclareSymbol("persistent user INDEX mdl_bRenderDetail;", (void *) &mdl_bRenderDetail); + _pShell->DeclareSymbol("persistent user INDEX mdl_bRenderSpecular;", (void *) &mdl_bRenderSpecular); + _pShell->DeclareSymbol("persistent user INDEX mdl_bRenderReflection;", (void *) &mdl_bRenderReflection); + _pShell->DeclareSymbol("persistent user INDEX mdl_bAllowOverbright;", (void *) &mdl_bAllowOverbright); + _pShell->DeclareSymbol("persistent user INDEX mdl_bFineQuality post:MdlPostFunc;", (void *) &mdl_bFineQuality); + _pShell->DeclareSymbol("persistent user INDEX mdl_iShadowQuality;", (void *) &mdl_iShadowQuality); - _pShell->DeclareSymbol("persistent user FLOAT gfx_tmProbeDecay;", &gfx_tmProbeDecay); - _pShell->DeclareSymbol("persistent user INDEX gfx_iProbeSize;", &gfx_iProbeSize); - _pShell->DeclareSymbol("persistent user INDEX gfx_bClearScreen;", &gfx_bClearScreen); - _pShell->DeclareSymbol("persistent user INDEX gfx_bDisableMultiMonSupport;", &gfx_bDisableMultiMonSupport); - _pShell->DeclareSymbol("persistent user INDEX gfx_bDisableWindowsKeys;", &gfx_bDisableWindowsKeys); - _pShell->DeclareSymbol("persistent user INDEX gfx_bDecoratedText;", &gfx_bDecoratedText); - _pShell->DeclareSymbol(" const user INDEX gfx_ctMonitors;", &gfx_ctMonitors); - _pShell->DeclareSymbol(" const user INDEX gfx_bMultiMonDisabled;", &gfx_bMultiMonDisabled); - _pShell->DeclareSymbol("persistent user INDEX tex_iNormalQuality;", &tex_iNormalQuality); - _pShell->DeclareSymbol("persistent user INDEX tex_iAnimationQuality;", &tex_iAnimationQuality); - _pShell->DeclareSymbol("persistent user INDEX tex_bFineEffect;", &tex_bFineEffect); - _pShell->DeclareSymbol("persistent user INDEX tex_bFineFog;", &tex_bFineFog); - _pShell->DeclareSymbol("persistent user INDEX tex_iNormalSize;", &tex_iNormalSize); - _pShell->DeclareSymbol("persistent user INDEX tex_iAnimationSize;", &tex_iAnimationSize); - _pShell->DeclareSymbol("persistent user INDEX tex_iEffectSize;", &tex_iEffectSize); - _pShell->DeclareSymbol("persistent user INDEX tex_iFogSize;", &tex_iFogSize); + + // !!! FIXME : rcg11232001 Hhmm...I'm failing an assertion in the + // !!! FIXME : rcg11232001 Advanced Rendering Options menu because + // !!! FIXME : rcg11232001 Scripts/CustomOptions/GFX-AdvancedRendering.cfg + // !!! FIXME : rcg11232001 references non-existing cvars, so I'm adding + // !!! FIXME : rcg11232001 them here for now. +// _pShell->DeclareSymbol("persistent user INDEX mdl_bRenderBump;", (void *) &mdl_bRenderBump); +// _pShell->DeclareSymbol("persistent user FLOAT ogl_fTextureAnisotropy;", (void *) &ogl_fTextureAnisotropy); + _pShell->DeclareSymbol("persistent user FLOAT tex_fNormalSize;", (void *) &tex_fNormalSize); + + + + + _pShell->DeclareSymbol(" INDEX mdl_bTruformWeapons;", (void *) &mdl_bTruformWeapons); + + _pShell->DeclareSymbol("persistent user FLOAT gfx_tmProbeDecay;", (void *) &gfx_tmProbeDecay); + _pShell->DeclareSymbol("persistent user INDEX gfx_iProbeSize;", (void *) &gfx_iProbeSize); + _pShell->DeclareSymbol("persistent user INDEX gfx_bClearScreen;", (void *) &gfx_bClearScreen); + _pShell->DeclareSymbol("persistent user INDEX gfx_bDisableMultiMonSupport;", (void *) &gfx_bDisableMultiMonSupport); + + _pShell->DeclareSymbol("persistent user INDEX gfx_bDisableWindowsKeys;", (void *) &gfx_bDisableWindowsKeys); + _pShell->DeclareSymbol("persistent user INDEX gfx_bDecoratedText;", (void *) &gfx_bDecoratedText); + _pShell->DeclareSymbol(" const user INDEX gfx_ctMonitors;", (void *) &gfx_ctMonitors); + _pShell->DeclareSymbol(" const user INDEX gfx_bMultiMonDisabled;", (void *) &gfx_bMultiMonDisabled); + + _pShell->DeclareSymbol("persistent user INDEX tex_iNormalQuality;", (void *) &tex_iNormalQuality); + _pShell->DeclareSymbol("persistent user INDEX tex_iAnimationQuality;", (void *) &tex_iAnimationQuality); + _pShell->DeclareSymbol("persistent user INDEX tex_iNormalSize;", (void *) &tex_iNormalSize); + _pShell->DeclareSymbol("persistent user INDEX tex_iAnimationSize;", (void *) &tex_iAnimationSize); + _pShell->DeclareSymbol("persistent user INDEX tex_iEffectSize;", (void *) &tex_iEffectSize); + _pShell->DeclareSymbol("persistent user INDEX tex_bFineEffect;", (void *) &tex_bFineEffect); + _pShell->DeclareSymbol("persistent user INDEX tex_bFineFog;", (void *) &tex_bFineFog); + _pShell->DeclareSymbol("persistent user INDEX tex_iFogSize;", (void *) &tex_iFogSize); + _pShell->DeclareSymbol("persistent user INDEX tex_bCompressAlphaChannel;", &tex_bCompressAlphaChannel); _pShell->DeclareSymbol("persistent user INDEX tex_bAlternateCompression;", &tex_bAlternateCompression); _pShell->DeclareSymbol("persistent user INDEX tex_bDynamicMipmaps;", &tex_bDynamicMipmaps); - _pShell->DeclareSymbol("persistent user INDEX tex_iDithering;", &tex_iDithering); - _pShell->DeclareSymbol("persistent user INDEX tex_iFiltering;", &tex_iFiltering); - _pShell->DeclareSymbol("persistent user INDEX tex_iEffectFiltering;", &tex_iEffectFiltering); - _pShell->DeclareSymbol("persistent user INDEX tex_bProgressiveFilter;", &tex_bProgressiveFilter); - _pShell->DeclareSymbol(" user INDEX tex_bColorizeMipmaps;", &tex_bColorizeMipmaps); + _pShell->DeclareSymbol("persistent user INDEX tex_iDithering;", (void *) &tex_iDithering); + _pShell->DeclareSymbol("persistent user INDEX tex_iFiltering;", (void *) &tex_iFiltering); + _pShell->DeclareSymbol("persistent user INDEX tex_iEffectFiltering;", (void *) &tex_iEffectFiltering); + _pShell->DeclareSymbol("persistent user INDEX tex_bProgressiveFilter;", (void *) &tex_bProgressiveFilter); + _pShell->DeclareSymbol(" user INDEX tex_bColorizeMipmaps;", (void *) &tex_bColorizeMipmaps); - _pShell->DeclareSymbol("persistent user INDEX shd_iStaticSize;", &shd_iStaticSize); - _pShell->DeclareSymbol("persistent user INDEX shd_iDynamicSize;", &shd_iDynamicSize); - _pShell->DeclareSymbol("persistent user INDEX shd_bFineQuality;", &shd_bFineQuality); - _pShell->DeclareSymbol("persistent user INDEX shd_iAllowDynamic;", &shd_iAllowDynamic); - _pShell->DeclareSymbol("persistent user INDEX shd_bDynamicMipmaps;", &shd_bDynamicMipmaps); - _pShell->DeclareSymbol("persistent user INDEX shd_iFiltering;", &shd_iFiltering); - _pShell->DeclareSymbol("persistent user INDEX shd_iDithering;", &shd_iDithering); - _pShell->DeclareSymbol("persistent user FLOAT shd_tmFlushDelay;", &shd_tmFlushDelay); - _pShell->DeclareSymbol("persistent user FLOAT shd_fCacheSize;", &shd_fCacheSize); - _pShell->DeclareSymbol("persistent user INDEX shd_bCacheAll;", &shd_bCacheAll); - _pShell->DeclareSymbol("persistent user INDEX shd_bAllowFlats;", &shd_bAllowFlats); - _pShell->DeclareSymbol("persistent INDEX shd_iForceFlats;", &shd_iForceFlats); - _pShell->DeclareSymbol(" user INDEX shd_bShowFlats;", &shd_bShowFlats); - _pShell->DeclareSymbol(" user INDEX shd_bColorize;", &shd_bColorize); + _pShell->DeclareSymbol("persistent user INDEX shd_iStaticSize;", (void *) &shd_iStaticSize); + _pShell->DeclareSymbol("persistent user INDEX shd_iDynamicSize;", (void *) &shd_iDynamicSize); + _pShell->DeclareSymbol("persistent user INDEX shd_bFineQuality;", (void *) &shd_bFineQuality); + _pShell->DeclareSymbol("persistent user INDEX shd_iAllowDynamic;", (void *) &shd_iAllowDynamic); + _pShell->DeclareSymbol("persistent user INDEX shd_bDynamicMipmaps;", (void *) &shd_bDynamicMipmaps); + _pShell->DeclareSymbol("persistent user INDEX shd_iFiltering;", (void *) &shd_iFiltering); + _pShell->DeclareSymbol("persistent user INDEX shd_iDithering;", (void *) &shd_iDithering); + _pShell->DeclareSymbol("persistent user FLOAT shd_tmFlushDelay;", (void *) &shd_tmFlushDelay); + _pShell->DeclareSymbol("persistent user FLOAT shd_fCacheSize;", (void *) &shd_fCacheSize); + _pShell->DeclareSymbol("persistent user INDEX shd_bCacheAll;", (void *) &shd_bCacheAll); + _pShell->DeclareSymbol("persistent user INDEX shd_bAllowFlats;", (void *) &shd_bAllowFlats); + _pShell->DeclareSymbol("persistent INDEX shd_iForceFlats;", (void *) &shd_iForceFlats); + _pShell->DeclareSymbol(" user INDEX shd_bShowFlats;", (void *) &shd_bShowFlats); + _pShell->DeclareSymbol(" user INDEX shd_bColorize;", (void *) &shd_bColorize); - _pShell->DeclareSymbol(" user INDEX gfx_bRenderParticles;", &gfx_bRenderParticles); - _pShell->DeclareSymbol(" user INDEX gfx_bRenderFog;", &gfx_bRenderFog); - _pShell->DeclareSymbol(" user INDEX gfx_bRenderWorld;", &gfx_bRenderWorld); - _pShell->DeclareSymbol("persistent user INDEX gfx_iLensFlareQuality;", &gfx_iLensFlareQuality); - _pShell->DeclareSymbol("persistent user INDEX wld_bTextureLayers;", &wld_bTextureLayers); - _pShell->DeclareSymbol("persistent user INDEX wld_bRenderMirrors;", &wld_bRenderMirrors); - _pShell->DeclareSymbol("persistent user FLOAT wld_fEdgeOffsetI;", &wld_fEdgeOffsetI); - _pShell->DeclareSymbol("persistent user FLOAT wld_fEdgeAdjustK;", &wld_fEdgeAdjustK); - _pShell->DeclareSymbol("persistent user INDEX wld_iDetailRemovingBias;", &wld_iDetailRemovingBias); - _pShell->DeclareSymbol(" user INDEX wld_bRenderEmptyBrushes;", &wld_bRenderEmptyBrushes); - _pShell->DeclareSymbol(" user INDEX wld_bRenderShadowMaps;", &wld_bRenderShadowMaps); - _pShell->DeclareSymbol(" user INDEX wld_bRenderTextures;", &wld_bRenderTextures); + _pShell->DeclareSymbol(" user INDEX gfx_bRenderParticles;", (void *) &gfx_bRenderParticles); + _pShell->DeclareSymbol(" user INDEX gfx_bRenderFog;", (void *) &gfx_bRenderFog); + _pShell->DeclareSymbol(" user INDEX gfx_bRenderWorld;", (void *) &gfx_bRenderWorld); + _pShell->DeclareSymbol("persistent user INDEX gfx_iLensFlareQuality;", (void *) &gfx_iLensFlareQuality); + _pShell->DeclareSymbol("persistent user INDEX wld_bTextureLayers;", (void *) &wld_bTextureLayers); + _pShell->DeclareSymbol("persistent user INDEX wld_bRenderMirrors;", (void *) &wld_bRenderMirrors); + _pShell->DeclareSymbol("persistent user FLOAT wld_fEdgeOffsetI;", (void *) &wld_fEdgeOffsetI); + _pShell->DeclareSymbol("persistent user FLOAT wld_fEdgeAdjustK;", (void *) &wld_fEdgeAdjustK); + _pShell->DeclareSymbol("persistent user INDEX wld_iDetailRemovingBias;", (void *) &wld_iDetailRemovingBias); + _pShell->DeclareSymbol(" user INDEX wld_bRenderEmptyBrushes;", (void *) &wld_bRenderEmptyBrushes); + _pShell->DeclareSymbol(" user INDEX wld_bRenderShadowMaps;", (void *) &wld_bRenderShadowMaps); + _pShell->DeclareSymbol(" user INDEX wld_bRenderTextures;", (void *) &wld_bRenderTextures); _pShell->DeclareSymbol(" user INDEX wld_bRenderDetailPolygons;", &wld_bRenderDetailPolygons); - _pShell->DeclareSymbol(" user INDEX wld_bShowTriangles;", &wld_bShowTriangles); - _pShell->DeclareSymbol(" user INDEX wld_bShowDetailTextures;", &wld_bShowDetailTextures); + _pShell->DeclareSymbol(" user INDEX wld_bShowTriangles;", (void *) &wld_bShowTriangles); + _pShell->DeclareSymbol(" user INDEX wld_bShowDetailTextures;", (void *) &wld_bShowDetailTextures); - _pShell->DeclareSymbol(" user INDEX wed_bIgnoreTJunctions;", &wed_bIgnoreTJunctions); - _pShell->DeclareSymbol("persistent user INDEX wed_bUseBaseForReplacement;", &wed_bUseBaseForReplacement); + _pShell->DeclareSymbol(" user INDEX wed_bIgnoreTJunctions;", (void *) &wed_bIgnoreTJunctions); + _pShell->DeclareSymbol("persistent user INDEX wed_bUseBaseForReplacement;", (void *) &wed_bUseBaseForReplacement); + _pShell->DeclareSymbol("persistent user INDEX tex_iHueShift;", (void *) &tex_iHueShift); + _pShell->DeclareSymbol("persistent user FLOAT tex_fSaturation;", (void *) &tex_fSaturation); + _pShell->DeclareSymbol("persistent user INDEX shd_iHueShift;", (void *) &shd_iHueShift); + _pShell->DeclareSymbol("persistent user FLOAT shd_fSaturation;", (void *) &shd_fSaturation); + _pShell->DeclareSymbol("persistent user INDEX gfx_iHueShift;", (void *) &gfx_iHueShift); + _pShell->DeclareSymbol("persistent user FLOAT gfx_fSaturation;", (void *) &gfx_fSaturation); + _pShell->DeclareSymbol("persistent user FLOAT gfx_fBrightness;", (void *) &gfx_fBrightness); + _pShell->DeclareSymbol("persistent user FLOAT gfx_fContrast;", (void *) &gfx_fContrast); + _pShell->DeclareSymbol("persistent user FLOAT gfx_fGamma;", (void *) &gfx_fGamma); + _pShell->DeclareSymbol("persistent user FLOAT gfx_fBiasR;", (void *) &gfx_fBiasR); + _pShell->DeclareSymbol("persistent user FLOAT gfx_fBiasG;", (void *) &gfx_fBiasG); + _pShell->DeclareSymbol("persistent user FLOAT gfx_fBiasB;", (void *) &gfx_fBiasB); + _pShell->DeclareSymbol("persistent user INDEX gfx_iLevels;", (void *) &gfx_iLevels); - _pShell->DeclareSymbol("persistent user INDEX tex_iHueShift;", &tex_iHueShift); - _pShell->DeclareSymbol("persistent user FLOAT tex_fSaturation;", &tex_fSaturation); - _pShell->DeclareSymbol("persistent user INDEX shd_iHueShift;", &shd_iHueShift); - _pShell->DeclareSymbol("persistent user FLOAT shd_fSaturation;", &shd_fSaturation); - _pShell->DeclareSymbol("persistent user INDEX gfx_iHueShift;", &gfx_iHueShift); - _pShell->DeclareSymbol("persistent user FLOAT gfx_fSaturation;", &gfx_fSaturation); - _pShell->DeclareSymbol("persistent user FLOAT gfx_fBrightness;", &gfx_fBrightness); - _pShell->DeclareSymbol("persistent user FLOAT gfx_fContrast;", &gfx_fContrast); - _pShell->DeclareSymbol("persistent user FLOAT gfx_fGamma;", &gfx_fGamma); - _pShell->DeclareSymbol("persistent user FLOAT gfx_fBiasR;", &gfx_fBiasR); - _pShell->DeclareSymbol("persistent user FLOAT gfx_fBiasG;", &gfx_fBiasG); - _pShell->DeclareSymbol("persistent user FLOAT gfx_fBiasB;", &gfx_fBiasB); - _pShell->DeclareSymbol("persistent user INDEX gfx_iLevels;", &gfx_iLevels); + _pShell->DeclareSymbol("persistent user INDEX gfx_iStereo;", (void *) &gfx_iStereo); + _pShell->DeclareSymbol("persistent user INDEX gfx_bStereoInvert;", (void *) &gfx_bStereoInvert); + _pShell->DeclareSymbol("persistent user INDEX gfx_iStereoOffset;", (void *) &gfx_iStereoOffset); + _pShell->DeclareSymbol("persistent user FLOAT gfx_fStereoSeparation;", (void *) &gfx_fStereoSeparation); - _pShell->DeclareSymbol("persistent user INDEX gfx_iStereo;", &gfx_iStereo); - _pShell->DeclareSymbol("persistent user INDEX gfx_bStereoInvert;", &gfx_bStereoInvert); - _pShell->DeclareSymbol("persistent user INDEX gfx_iStereoOffset;", &gfx_iStereoOffset); - _pShell->DeclareSymbol("persistent user FLOAT gfx_fStereoSeparation;", &gfx_fStereoSeparation); - - _pShell->DeclareSymbol( "INDEX sys_bHasTextureCompression;", &sys_bHasTextureCompression); - _pShell->DeclareSymbol( "INDEX sys_bHasTextureAnisotropy;", &sys_bHasTextureAnisotropy); - _pShell->DeclareSymbol( "INDEX sys_bHasAdjustableGamma;", &sys_bHasAdjustableGamma); - _pShell->DeclareSymbol( "INDEX sys_bHasTextureLODBias;", &sys_bHasTextureLODBias); - _pShell->DeclareSymbol( "INDEX sys_bHasMultitexturing;", &sys_bHasMultitexturing); - _pShell->DeclareSymbol( "INDEX sys_bHas32bitTextures;", &sys_bHas32bitTextures); - _pShell->DeclareSymbol( "INDEX sys_bHasSwapInterval;", &sys_bHasSwapInterval); - _pShell->DeclareSymbol( "INDEX sys_bHasHardwareTnL;", &sys_bHasHardwareTnL); - _pShell->DeclareSymbol( "INDEX sys_bHasTruform;", &sys_bHasTruform); - _pShell->DeclareSymbol( "INDEX sys_bHasCVAs;", &sys_bHasCVAs); - _pShell->DeclareSymbol( "INDEX sys_bUsingOpenGL;", &sys_bUsingOpenGL); - _pShell->DeclareSymbol( "INDEX sys_bUsingDirect3D;", &sys_bUsingDirect3D); + _pShell->DeclareSymbol( "INDEX sys_bHasTextureCompression;", (void *) &sys_bHasTextureCompression); + _pShell->DeclareSymbol( "INDEX sys_bHasTextureAnisotropy;", (void *) &sys_bHasTextureAnisotropy); + _pShell->DeclareSymbol( "INDEX sys_bHasAdjustableGamma;", (void *) &sys_bHasAdjustableGamma); + _pShell->DeclareSymbol( "INDEX sys_bHasTextureLODBias;", (void *) &sys_bHasTextureLODBias); + _pShell->DeclareSymbol( "INDEX sys_bHasMultitexturing;", (void *) &sys_bHasMultitexturing); + _pShell->DeclareSymbol( "INDEX sys_bHas32bitTextures;", (void *) &sys_bHas32bitTextures); + _pShell->DeclareSymbol( "INDEX sys_bHasSwapInterval;", (void *) &sys_bHasSwapInterval); + _pShell->DeclareSymbol( "INDEX sys_bHasHardwareTnL;", (void *) &sys_bHasHardwareTnL); + _pShell->DeclareSymbol( "INDEX sys_bHasTruform;", (void *) &sys_bHasTruform); + _pShell->DeclareSymbol( "INDEX sys_bHasCVAs;", (void *) &sys_bHasCVAs); + _pShell->DeclareSymbol( "INDEX sys_bUsingOpenGL;", (void *) &sys_bUsingOpenGL); + _pShell->DeclareSymbol( "INDEX sys_bUsingDirect3D;", (void *) &sys_bUsingDirect3D); // initialize gfx APIs support InitAPIs(); @@ -1326,6 +1405,28 @@ BOOL CGfxLibrary::StartDisplayMode( enum GfxAPIType eAPI, INDEX iAdapter, PIX pi CDS_ResetMode(); } // startup OpenGL + +// !!! FIXME : Do something with this. +#ifdef PLATFORM_UNIX + gl_dmCurrentDisplayMode.dm_pixSizeI = pixSizeI; + gl_dmCurrentDisplayMode.dm_pixSizeJ = pixSizeJ; + Uint8 bpp; + switch(eColorDepth) { + case DD_DEFAULT: + gl_iCurrentDepth = 0; + break; + case DD_16BIT: + gl_iCurrentDepth = 16; + break; + case DD_32BIT: + gl_iCurrentDepth = 32; + break; + default: + ASSERT(FALSE); + NOTHING; + } +#endif + bSuccess = InitDriver_OGL(iAdapter!=0); // try to setup sub-driver if( !bSuccess) { @@ -1390,21 +1491,25 @@ void CGfxLibrary::StopDisplayMode(void) MonitorsOn(); // re-enable multimonitor support if disabled CDS_ResetMode(); } -#ifdef SE1_D3D + +#ifdef PLATFORM_WIN32 else if( gl_eCurrentAPI==GAT_D3D) { // Direct3D EndDriver_D3D(); MonitorsOn(); } -#endif // SE1_D3D +#endif + else { // none ASSERT( gl_eCurrentAPI==GAT_NONE); } // free driver DLL - if( gl_hiDriver!=NONE) FreeLibrary(gl_hiDriver); - gl_hiDriver = NONE; + if (gl_hiDriver != NULL) + delete gl_hiDriver; + + gl_hiDriver = NULL; // reset some vars gl_ctRealTextureUnits = 0; @@ -1508,10 +1613,17 @@ void CGfxLibrary::CreateWindowCanvas(void *hWnd, CViewPort **ppvpNew, CDrawPort { RECT rectWindow; // rectangle for the client area of the window - // get the dimensions from the window + // get the dimensions from the window +// !!! FIXME : rcg11052001 Abstract this. +#ifdef PLATFORM_WIN32 GetClientRect( (HWND)hWnd, &rectWindow); PIX pixWidth = rectWindow.right - rectWindow.left; - PIX pixHeight = rectWindow.bottom - rectWindow.top; + PIX pixHeight = rectWindow.bottom - rectWindow.top; +#else + SDL_Surface *screen = SDL_GetVideoSurface(); + PIX pixWidth = screen->w; + PIX pixHeight = screen->h; +#endif *ppvpNew = NULL; *ppdpNew = NULL; @@ -1534,6 +1646,7 @@ void CGfxLibrary::DestroyWindowCanvas(CViewPort *pvpOld) { ///////////////////////////////////////////////////////////////////// // Work canvas functions +#ifdef PLATFORM_WIN32 #define WorkCanvasCLASS "WorkCanvas Window" static BOOL _bClassRegistered = FALSE; @@ -1588,15 +1701,14 @@ void CGfxLibrary::DestroyWorkCanvas(CDrawPort *pdpOld) DestroyWindowCanvas(pvp); ::DestroyWindow(hwnd); } - - +#endif // optimize memory used by cached shadow maps #define SHADOWMAXBYTES (256*256*4*4/3) static SLONG slCachedShadowMemory=0, slDynamicShadowMemory=0; static INDEX ctCachedShadows=0, ctFlatShadows=0, ctDynamicShadows=0; -extern BOOL _bShadowsUpdated = TRUE; +BOOL _bShadowsUpdated = TRUE; void CGfxLibrary::ReduceShadows(void) { @@ -1686,11 +1798,11 @@ void CGfxLibrary::ReduceShadows(void) // some vars for probing -extern INDEX _ctProbeTexs = 0; -extern INDEX _ctProbeShdU = 0; -extern INDEX _ctProbeShdB = 0; -extern INDEX _ctFullShdU = 0; -extern SLONG _slFullShdUBytes = 0; +INDEX _ctProbeTexs = 0; +INDEX _ctProbeShdU = 0; +INDEX _ctProbeShdB = 0; +INDEX _ctFullShdU = 0; +SLONG _slFullShdUBytes = 0; static BOOL GenerateGammaTable(void); @@ -1743,8 +1855,14 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp) } } // swap buffers + +// !!! FIXME: Move this to platform-specific directories. +#ifdef PLATFORM_WIN32 CTempDC tdc(pvp->vp_hWnd); pwglSwapBuffers(tdc.hdc); +#else + SDL_GL_SwapBuffers(); +#endif // force finishing of all rendering operations (if required) if( ogl_iFinish==3) gfxFinish(); @@ -1854,6 +1972,7 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp) //pvp->vp_Raster.ra_MainDrawPort.FillZBuffer(ZBUF_BACK); // adjust gamma table if supported ... +#ifdef PLATFORM_WIN32 if( gl_ulFlags & GLF_ADJUSTABLEGAMMA) { // ... and required const BOOL bTableSet = GenerateGammaTable(); @@ -1869,8 +1988,10 @@ void CGfxLibrary::SwapBuffers(CViewPort *pvp) #endif // SE1_D3D } } + else +#endif // if not supported - else { + { // just reset settings to default gfx_fBrightness = 0; gfx_fContrast = 1; @@ -1974,7 +2095,7 @@ static BOOL GenerateGammaTable(void) } // adjust brightness - INDEX iAdd = 256* 256*gfx_fBrightness; + INDEX iAdd = (INDEX) (256* 256*gfx_fBrightness); for( i=0; i<256; i++) { _auwGammaTable[i] = Clamp( _auwGammaTable[i]+iAdd, 0L, 65280L); } @@ -1984,7 +2105,7 @@ static BOOL GenerateGammaTable(void) const FLOAT fLevels = 256 * 256.0f/gfx_iLevels; for( i=0; i<256; i++) { INDEX iVal = _auwGammaTable[i]; - iVal = ((INDEX)(iVal/fLevels)) *fLevels; + iVal = (INDEX) (((INDEX)(iVal/fLevels)) *fLevels); _auwGammaTable[i] = ClampUp( iVal, 0xFF00L); } } diff --git a/Sources/Engine/Graphics/GfxLibrary.h b/Sources/Engine/Graphics/GfxLibrary.h index 9cf9c7f..cdd617b 100644 --- a/Sources/Engine/Graphics/GfxLibrary.h +++ b/Sources/Engine/Graphics/GfxLibrary.h @@ -14,12 +14,7 @@ #include #include #include - -#include - -#include #include -#include // common element arrays extern CStaticStackArray _avtxCommon; @@ -28,10 +23,11 @@ extern CStaticStackArray _acolCommon; extern CStaticStackArray _aiCommonElements; extern CStaticStackArray _aiCommonQuads; +#include +#include +#include -#include - - +// WARNING: Changing these constants breaks inline asm on GNU systems! #define SQRTTABLESIZE 8192 #define SQRTTABLESIZELOG2 13 @@ -45,8 +41,10 @@ struct CTVERTEX { ULONG ulColor; // color FLOAT fU,fV; // texture coordinates }; -#define D3DFVF_CTVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) +#ifdef SE1_D3D +#define D3DFVF_CTVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) +#endif // Gfx API type enum GfxAPIType @@ -60,6 +58,17 @@ enum GfxAPIType }; +__forceinline bool GfxValidApi(GfxAPIType eAPI) +{ +#ifdef SE1_D3D + return(eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); +#else + return(eAPI==GAT_OGL || eAPI==GAT_NONE); +#endif +} + + + // vertex type (for lock/unlock function) enum VtxType { @@ -108,7 +117,7 @@ class ENGINE_API CGfxLibrary public: CGfxAPI gl_gaAPI[2]; CViewPort *gl_pvpActive; // active viewport - HINSTANCE gl_hiDriver; // DLL handle + CDynamicLoader *gl_hiDriver; // DLL handle GfxAPIType gl_eCurrentAPI; // (0=none, 1=OpenGL, 2=DirectX8) CDisplayMode gl_dmCurrentDisplayMode; @@ -177,8 +186,10 @@ private: void StopDisplayMode(void); // OpenGL specific + void *OGL_GetProcAddress(const char *procname); // rcg10112001 BOOL InitDriver_OGL( BOOL b3Dfx=FALSE); // DLL init and function call adjustments void EndDriver_OGL(void); + void PlatformEndDriver_OGL(void); // rcg10112001 void TestExtension_OGL( ULONG ulFlag, const char *strName); // if exist, add OpenGL extension to flag and list void AddExtension_OGL( ULONG ulFlag, const char *strName); // unconditionally add OpenGL extension to flag and list #ifdef PLATFORM_WIN32 @@ -191,6 +202,7 @@ private: void SwapBuffers_OGL( CViewPort *pvpToSwap); // Direct3D specific +#ifdef SE1_D3D BOOL InitDriver_D3D(void); void EndDriver_D3D(void); BOOL InitDisplay_D3D( INDEX iAdapter, PIX pixSizeI, PIX pixSizeJ, enum DisplayDepth eColorDepth); @@ -198,6 +210,7 @@ private: BOOL SetCurrentViewport_D3D( CViewPort *pvp); void UploadPattern_D3D( ULONG ulPatternEven); void SwapBuffers_D3D( CViewPort *pvpToSwap); +#endif public: @@ -341,6 +354,6 @@ ENGINE_API extern CGfxLibrary *_pGfx; // forced texture upload quality (0 = default, 16 = force 16-bit, 32 = force 32-bit) ENGINE_API extern INDEX _iTexForcedQuality; - #endif /* include-once check. */ + diff --git a/Sources/Engine/Graphics/GfxProfile.cpp b/Sources/Engine/Graphics/GfxProfile.cpp index 3ba5370..3feb05c 100644 --- a/Sources/Engine/Graphics/GfxProfile.cpp +++ b/Sources/Engine/Graphics/GfxProfile.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Graphics/Gfx_Direct3D.cpp b/Sources/Engine/Graphics/Gfx_Direct3D.cpp index 8ccf6d3..c9e63bc 100644 --- a/Sources/Engine/Graphics/Gfx_Direct3D.cpp +++ b/Sources/Engine/Graphics/Gfx_Direct3D.cpp @@ -675,8 +675,7 @@ void CGfxLibrary::InitContext_D3D() gl_pd3dIdx = NULL; gl_pd3dVtx = NULL; gl_pd3dNor = NULL; - INDEX i=0; - for( ; i0 && gl_ctTexBuffers<=GFX_MAXLAYERS); ASSERT( gl_ctColBuffers>0 && gl_ctColBuffers<=GFX_MAXLAYERS); gl_ctVertices = 0; diff --git a/Sources/Engine/Graphics/Gfx_OpenGL.cpp b/Sources/Engine/Graphics/Gfx_OpenGL.cpp index 1af0f1b..78ef9c1 100644 --- a/Sources/Engine/Graphics/Gfx_OpenGL.cpp +++ b/Sources/Engine/Graphics/Gfx_OpenGL.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -63,8 +63,8 @@ extern GfxBlend GFX_eBlendDst; extern GfxComp GFX_eDepthFunc; extern GfxFace GFX_eCullFace; extern INDEX GFX_iTexModulation[GFX_MAXTEXUNITS]; -extern BOOL glbUsingVARs = FALSE; // vertex_array_range +BOOL glbUsingVARs = FALSE; // vertex_array_range // define gl function pointers #define DLLFUNCTION(dll, output, name, inputs, params, required) \ @@ -83,9 +83,12 @@ void (__stdcall *pglActiveTextureARB)(GLenum texunit) = NULL; void (__stdcall *pglClientActiveTextureARB)(GLenum texunit) = NULL; // t-buffer support +#ifdef PLATFORM_WIN32 char *(__stdcall *pwglGetExtensionsStringARB)(HDC hdc); BOOL (__stdcall *pwglChoosePixelFormatARB)(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); BOOL (__stdcall *pwglGetPixelFormatAttribivARB)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +#endif + void (__stdcall *pglTBufferMask3DFX)(GLuint mask); // NV occlusion query @@ -102,301 +105,6 @@ void (__stdcall *pglPNTrianglesiATI)( GLenum pname, GLint param); void (__stdcall *pglPNTrianglesfATI)( GLenum pname, GLfloat param); -void WIN_CheckError(BOOL bRes, const char *strDescription) -{ - if( bRes) return; - DWORD dwWindowsErrorCode = GetLastError(); - if( dwWindowsErrorCode==ERROR_SUCCESS) return; // ignore stupid 'successful' error - WarningMessage("%s: %s", strDescription, GetWindowsError(dwWindowsErrorCode)); -} - - -static void FailFunction_t(const char *strName) { - ThrowF_t(TRANS("Required function %s not found."), strName); -} - - -static void OGL_SetFunctionPointers_t(HINSTANCE hiOGL) -{ - const char *strName; - // get gl function pointers - #define DLLFUNCTION(dll, output, name, inputs, params, required) \ - strName = #name; \ - p##name = (output (__stdcall*) inputs) GetProcAddress( hi##dll, strName); \ - if( required && p##name == NULL) FailFunction_t(strName); - #include "gl_functions.h" - #undef DLLFUNCTION -} - - -static void OGL_ClearFunctionPointers(void) -{ - // clear gl function pointers - #define DLLFUNCTION(dll, output, name, inputs, params, required) p##name = NULL; - #include "gl_functions.h" - #undef DLLFUNCTION -} - - - - -#define BACKOFF pwglMakeCurrent( NULL, NULL); \ - pwglDeleteContext( hglrc); \ - ReleaseDC( dummyhwnd, hdc); \ - DestroyWindow( dummyhwnd); \ - UnregisterClassA( classname, hInstance); - - - -// helper for choosing t-buffer's pixel format -static BOOL _TBCapability = FALSE; -static INDEX ChoosePixelFormatTB( HDC hdc, const PIXELFORMATDESCRIPTOR *ppfd, - PIX pixResWidth, PIX pixResHeight) -{ - _TBCapability = FALSE; - char *extensions = NULL; - char *wglextensions = NULL; - HGLRC hglrc; - HWND dummyhwnd; - WNDCLASSA cls; - HINSTANCE hInstance = GetModuleHandle(NULL); - LPCSTR classname = "dummyOGLwin"; - cls.style = CS_OWNDC; - cls.lpfnWndProc = DefWindowProc; - cls.cbClsExtra = 0; - cls.cbWndExtra = 0; - cls.hInstance = hInstance; - cls.hIcon = LoadIcon(NULL, IDI_APPLICATION); - cls.hCursor = LoadCursor(NULL, IDC_WAIT); - cls.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - cls.lpszMenuName = NULL; - cls.lpszClassName = classname; - // didn't manage to register class? - if( !RegisterClassA(&cls)) return 0; - - // create window fullscreen - //CPrintF( " Dummy window: %d x %d\n", pixResWidth, pixResHeight); - dummyhwnd = CreateWindowExA( WS_EX_TOPMOST, classname, "Dummy OGL window", - WS_POPUP|WS_VISIBLE, 0, 0, pixResWidth, pixResHeight, - NULL, NULL, hInstance, NULL); - // didn't make it? - if( dummyhwnd == NULL) { - UnregisterClassA( classname, hInstance); - return 0; - } - //CPrintF( " Dummy passed...\n"); - hdc = GetDC(dummyhwnd); - // try to choose pixel format - int iPixelFormat = pwglChoosePixelFormat( hdc, ppfd); - if( !iPixelFormat) { - ReleaseDC( dummyhwnd, hdc); - DestroyWindow(dummyhwnd); - UnregisterClassA( classname, hInstance); - return 0; - } - //CPrintF( " Choose pixel format passed...\n"); - // try to set pixel format - if( !pwglSetPixelFormat( hdc, iPixelFormat, ppfd)) { - ReleaseDC( dummyhwnd, hdc); - DestroyWindow(dummyhwnd); - UnregisterClassA( classname, hInstance); - return 0; - } - //CPrintF( " Set pixel format passed...\n"); - - // create context using the default accelerated pixelformat that was passed - hglrc = pwglCreateContext(hdc); - pwglMakeCurrent( hdc, hglrc); - // update the value list with information passed from the ppfd. - aiAttribList[ 9] = ppfd->cColorBits; - aiAttribList[11] = ppfd->cDepthBits; - aiAttribList[15] = _pGfx->go_ctSampleBuffers; - - // get the extension list. - extensions = (char*)pglGetString(GL_EXTENSIONS); - // get the wgl extension list. - if( strstr((const char*)extensions, "WGL_EXT_extensions_string ") != NULL) - { // windows extension string supported - pwglGetExtensionsStringARB = (char* (__stdcall*)(HDC))pwglGetProcAddress( "wglGetExtensionsStringARB"); - if( pwglGetExtensionsStringARB == NULL) { - BACKOFF - return 0; - } - //CPrintF( " WGL extension string passed...\n"); - // get WGL extension string - wglextensions = (char*)pwglGetExtensionsStringARB(hdc); - } - else { - BACKOFF - return 0; - } - - // check for the pixel format and multisample extension strings - if( (strstr((const char*)wglextensions, "WGL_ARB_pixel_format ") != NULL) && - (strstr((const char*)extensions, "GL_3DFX_multisample ") != NULL)) { - // 3dfx extensions present - _TBCapability = TRUE; - pwglChoosePixelFormatARB = (BOOL (__stdcall*)(HDC,const int*,const FLOAT*,UINT,int*,UINT*))pwglGetProcAddress( "wglChoosePixelFormatARB"); - pwglGetPixelFormatAttribivARB = (BOOL (__stdcall*)(HDC,int,int,UINT,int*,int*) )pwglGetProcAddress( "wglGetPixelFormatAttribivARB"); - pglTBufferMask3DFX = (void (__stdcall*)(GLuint))pwglGetProcAddress("glTBufferMask3DFX"); - if( pwglChoosePixelFormatARB==NULL && pglTBufferMask3DFX==NULL) { - BACKOFF - return 0; - } - //CPrintF( " WGL choose pixel format present...\n"); - int iAttribListNum = {WGL_NUMBER_PIXEL_FORMATS_EXT}; - int iMaxFormats = 1; // default number to return - if( pwglGetPixelFormatAttribivARB!=NULL) { - // get total number of formats supported. - pwglGetPixelFormatAttribivARB( hdc, NULL, NULL, 1, &iAttribListNum, &iMaxFormats); - //CPrintF( "Max formats: %d\n", iMaxFormats); - } - UINT uiNumFormats; - int *piFormats = (int*)AllocMemory( sizeof(UINT) *iMaxFormats); - // try to get all formats that fit the pixel format criteria - if( !pwglChoosePixelFormatARB( hdc, piAttribList, NULL, iMaxFormats, piFormats, &uiNumFormats)) { - FreeMemory(piFormats); - BACKOFF - return 0; - } - //CPrintF( " WGL choose pixel format passed...\n"); - // return the first match for now - iPixelFormat = 0; - if( uiNumFormats>0) { - iPixelFormat = piFormats[0]; - //CPrintF( "Num formats: %d\n", uiNumFormats); - //CPrintF( "First format: %d\n", iPixelFormat); - } - FreeMemory(piFormats); - } - else - { // wglChoosePixelFormatARB extension does not exist :( - iPixelFormat = 0; - } - BACKOFF - return iPixelFormat; -} - - -// prepares pixel format for OpenGL context -BOOL CGfxLibrary::SetupPixelFormat_OGL( HDC hdc, BOOL bReport/*=FALSE*/) -{ - int iPixelFormat = 0; - const PIX pixResWidth = gl_dmCurrentDisplayMode.dm_pixSizeI; - const PIX pixResHeight = gl_dmCurrentDisplayMode.dm_pixSizeJ; - const DisplayDepth dd = gl_dmCurrentDisplayMode.dm_ddDepth; - - PIXELFORMATDESCRIPTOR pfd; - memset( &pfd, 0, sizeof(pfd)); - pfd.nSize = sizeof(pfd); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; - pfd.iPixelType = PFD_TYPE_RGBA; - - // clamp depth/stencil values - extern INDEX gap_iDepthBits; - extern INDEX gap_iStencilBits; - if( gap_iDepthBits <12) gap_iDepthBits = 0; - else if( gap_iDepthBits <22) gap_iDepthBits = 16; - else if( gap_iDepthBits <28) gap_iDepthBits = 24; - else gap_iDepthBits = 32; - if( gap_iStencilBits<3) gap_iStencilBits = 0; - else if( gap_iStencilBits<7) gap_iStencilBits = 4; - else gap_iStencilBits = 8; - - // set color/depth buffer values - pfd.cColorBits = (dd!=DD_16BIT) ? 32 : 16; - pfd.cDepthBits = gap_iDepthBits; - pfd.cStencilBits = gap_iStencilBits; - - // must be required and works only in full screen via GDI functions - ogl_iTBufferEffect = Clamp( ogl_iTBufferEffect, 0L, 2L); - if( ogl_iTBufferEffect>0 && pixResWidth>0 && pixResHeight>0) - { // lets T-buffer ... :) - //CPrintF( "TBuffer init...\n"); - ogl_iTBufferSamples = (1L) << FastLog2(ogl_iTBufferSamples); - if( ogl_iTBufferSamples<2) ogl_iTBufferSamples = 4; - go_ctSampleBuffers = ogl_iTBufferSamples; - go_iCurrentWriteBuffer = 0; - iPixelFormat = ChoosePixelFormatTB( hdc, &pfd, pixResWidth, pixResHeight); - // need to reset the desktop resolution because CPFTB() resets it - BOOL bSuccess = CDS_SetMode( pixResWidth, pixResHeight, dd); - if( !bSuccess) iPixelFormat = 0; - // check T-buffer support - if( _TBCapability) pglGetIntegerv( GL_SAMPLES_3DFX, (GLint*)&go_ctSampleBuffers); - if( !iPixelFormat) { ogl_iTBufferEffect=0; CPrintF( TRANS("TBuffer initialization failed.\n")); } - else CPrintF( TRANS("TBuffer initialization passed (%d buffers in use).\n"), go_ctSampleBuffers); - } - - // if T-buffer didn't make it, let's try thru regular path - if( !iPixelFormat) { - go_ctSampleBuffers = 0; - go_iCurrentWriteBuffer = 0; - iPixelFormat = pwglChoosePixelFormat( hdc, &pfd); - } - - if( !iPixelFormat) { - WIN_CHECKERROR( 0, "ChoosePixelFormat"); - return FALSE; - } - if( !pwglSetPixelFormat( hdc, iPixelFormat, &pfd)) { - WIN_CHECKERROR( 0, "SetPixelFormat"); - return FALSE; - } - - // test acceleration - memset( &pfd, 0, sizeof(pfd)); - if( !pwglDescribePixelFormat( hdc, iPixelFormat, sizeof(pfd), &pfd)) return FALSE; - BOOL bGenericFormat = pfd.dwFlags & PFD_GENERIC_FORMAT; - BOOL bGenericAccelerated = pfd.dwFlags & PFD_GENERIC_ACCELERATED; - BOOL bHasAcceleration = (bGenericFormat && bGenericAccelerated) || // MCD - (!bGenericFormat && !bGenericAccelerated); // ICD - if( bHasAcceleration) gl_ulFlags |= GLF_HASACCELERATION; - else gl_ulFlags &= ~GLF_HASACCELERATION; - - // done if report pixel format info isn't required - if( !bReport) return TRUE; - - // prepare pixel type description - CTString strPixelType; - if( pfd.iPixelType==PFD_TYPE_RGBA) strPixelType = "TYPE_RGBA"; - else if( pfd.iPixelType&PFD_TYPE_COLORINDEX) strPixelType = "TYPE_COLORINDEX"; - else strPixelType = "unknown"; - // prepare flags description - CTString strFlags = ""; - if( pfd.dwFlags&PFD_DRAW_TO_WINDOW) strFlags += "DRAW_TO_WINDOW "; - if( pfd.dwFlags&PFD_DRAW_TO_BITMAP) strFlags += "DRAW_TO_BITMAP "; - if( pfd.dwFlags&PFD_SUPPORT_GDI) strFlags += "SUPPORT_GDI "; - if( pfd.dwFlags&PFD_SUPPORT_OPENGL) strFlags += "SUPPORT_OPENGL "; - if( pfd.dwFlags&PFD_GENERIC_ACCELERATED) strFlags += "GENERIC_ACCELERATED "; - if( pfd.dwFlags&PFD_GENERIC_FORMAT) strFlags += "GENERIC_FORMAT "; - if( pfd.dwFlags&PFD_NEED_PALETTE) strFlags += "NEED_PALETTE "; - if( pfd.dwFlags&PFD_NEED_SYSTEM_PALETTE) strFlags += "NEED_SYSTEM_PALETTE "; - if( pfd.dwFlags&PFD_DOUBLEBUFFER) strFlags += "DOUBLEBUFFER "; - if( pfd.dwFlags&PFD_STEREO) strFlags += "STEREO "; - if( pfd.dwFlags&PFD_SWAP_LAYER_BUFFERS) strFlags += "SWAP_LAYER_BUFFERS "; - if( pfd.dwFlags&PFD_DEPTH_DONTCARE) strFlags += "DEPTH_DONTCARE "; - if( pfd.dwFlags&PFD_DOUBLEBUFFER_DONTCARE) strFlags += "DOUBLEBUFFER_DONTCARE "; - if( pfd.dwFlags&PFD_STEREO_DONTCARE) strFlags += "STEREO_DONTCARE "; - if( pfd.dwFlags&PFD_SWAP_COPY) strFlags += "SWAP_COPY "; - if( pfd.dwFlags&PFD_SWAP_EXCHANGE) strFlags += "SWAP_EXCHANGE "; - if( strFlags=="") strFlags = "none"; - - // output pixel format description to console (for debugging purposes) - CPrintF( TRANS("\nPixel Format Description:\n")); - CPrintF( TRANS(" Number: %d (%s)\n"), iPixelFormat, strPixelType); - CPrintF( TRANS(" Flags: %s\n"), strFlags); - CPrintF( TRANS(" Color bits: %d (%d:%d:%d:%d)\n"), pfd.cColorBits, - pfd.cRedBits, pfd.cGreenBits, pfd.cBlueBits, pfd.cAlphaBits); - CPrintF( TRANS(" Depth bits: %d (%d for stencil)\n"), pfd.cDepthBits, pfd.cStencilBits); - gl_iCurrentDepth = pfd.cDepthBits; // keep depth bits - - // all done - CPrintF( "\n"); - return TRUE; -} - - // test if an extension exists static BOOL HasExtension( const char *strAllExtensions, const char *strExtension) { @@ -431,26 +139,6 @@ void CGfxLibrary::TestExtension_OGL( ULONG ulFlag, const char *strName) } -// creates OpenGL drawing context -BOOL CGfxLibrary::CreateContext_OGL(HDC hdc) -{ - if( !SetupPixelFormat_OGL( hdc, TRUE)) return FALSE; - go_hglRC = pwglCreateContext(hdc); - if( go_hglRC==NULL) { - WIN_CHECKERROR(0, "CreateContext"); - return FALSE; - } - if( !pwglMakeCurrent(hdc, go_hglRC)) { - // NOTE: This error is sometimes reported without a reason on 3dfx hardware - // so we just have to ignore it. - //WIN_CHECKERROR(0, "MakeCurrent after CreateContext"); - return FALSE; - } - return TRUE; -} - - - // prepares OpenGL drawing context void CGfxLibrary::InitContext_OGL(void) { @@ -490,6 +178,7 @@ void CGfxLibrary::InitContext_OGL(void) GFX_fMaxDepthRange = 1.0f; // (re)set some OpenGL defaults gfxPolygonMode( GFX_FILL); + pglFrontFace( GL_CCW); pglShadeModel( GL_SMOOTH); pglEnable( GL_SCISSOR_TEST); pglDrawBuffer( GL_BACK); @@ -519,7 +208,7 @@ void CGfxLibrary::InitContext_OGL(void) // report CPrintF( TRANS("\n* OpenGL context created: *----------------------------------\n")); - CPrintF( " (%s, %s, %s)\n\n", da.da_strVendor, da.da_strRenderer, da.da_strVersion); + CPrintF( " (%s, %s, %s)\n\n", (const char *) da.da_strVendor, (const char *) da.da_strRenderer, (const char *) da.da_strVersion); // test for used extensions GLint gliRet; @@ -528,31 +217,39 @@ void CGfxLibrary::InitContext_OGL(void) // check for WGL extensions, too go_strWinExtensions = ""; +#ifdef PLATFORM_WIN32 pwglGetExtensionsStringARB = (char* (__stdcall*)(HDC))pwglGetProcAddress("wglGetExtensionsStringARB"); if( pwglGetExtensionsStringARB != NULL) { AddExtension_OGL( NONE, "WGL_ARB_extensions_string"); // register CTempDC tdc(gl_pvpActive->vp_hWnd); go_strWinExtensions = (char*)pwglGetExtensionsStringARB(tdc.hdc); } +#endif // multitexture is supported only thru GL_EXT_texture_env_combine extension gl_ctTextureUnits = 1; gl_ctRealTextureUnits = 1; pglActiveTextureARB = NULL; pglClientActiveTextureARB = NULL; + +// This renders badly on the current Intel Macs...my bug, probably. !!! FIXME +#if PLATFORM_MACOSX + CPrintF("Forcibly disabled multitexturing for now on Mac OS X."); +#else if( HasExtension( go_strExtensions, "GL_ARB_multitexture")) { pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, (int*)&gl_ctRealTextureUnits); // get number of texture units - if( gl_ctRealTextureUnits>1 && HasExtension( go_strExtensions, "GL_EXT_texture_env_combine")) { + if( gl_ctRealTextureUnits>1 && (HasExtension( go_strExtensions, "GL_EXT_texture_env_combine") || HasExtension( go_strExtensions, "GL_ARB_texture_env_combine")) ) { AddExtension_OGL( NONE, "GL_ARB_multitexture"); AddExtension_OGL( NONE, "GL_EXT_texture_env_combine"); - pglActiveTextureARB = (void (__stdcall*)(GLenum))pwglGetProcAddress( "glActiveTextureARB"); - pglClientActiveTextureARB = (void (__stdcall*)(GLenum))pwglGetProcAddress( "glClientActiveTextureARB"); + pglActiveTextureARB = (void (__stdcall*)(GLenum))OGL_GetProcAddress( "glActiveTextureARB"); + pglClientActiveTextureARB = (void (__stdcall*)(GLenum))OGL_GetProcAddress( "glClientActiveTextureARB"); ASSERT( pglActiveTextureARB!=NULL && pglClientActiveTextureARB!=NULL); gl_ctTextureUnits = Min( GFX_MAXTEXUNITS, gl_ctRealTextureUnits); } else { CPrintF( TRANS(" GL_TEXTURE_ENV_COMBINE extension missing - multi-texturing cannot be used.\n")); } } +#endif // find all supported texture compression extensions TestExtension_OGL( GLF_EXTC_ARB, "GL_ARB_texture_compression"); @@ -597,8 +294,8 @@ void CGfxLibrary::InitContext_OGL(void) pglUnlockArraysEXT = NULL; if( HasExtension( go_strExtensions, "GL_EXT_compiled_vertex_array")) { AddExtension_OGL( GLF_EXT_COMPILEDVERTEXARRAY, "GL_EXT_compiled_vertex_array"); - pglLockArraysEXT = (void (__stdcall*)(GLint,GLsizei))pwglGetProcAddress( "glLockArraysEXT"); - pglUnlockArraysEXT = (void (__stdcall*)(void) )pwglGetProcAddress( "glUnlockArraysEXT"); + pglLockArraysEXT = (void (__stdcall*)(GLint,GLsizei))OGL_GetProcAddress( "glLockArraysEXT"); + pglUnlockArraysEXT = (void (__stdcall*)(void) )OGL_GetProcAddress( "glUnlockArraysEXT"); ASSERT( pglLockArraysEXT!=NULL && pglUnlockArraysEXT!=NULL); } @@ -607,8 +304,8 @@ void CGfxLibrary::InitContext_OGL(void) pwglGetSwapIntervalEXT = NULL; if( HasExtension( go_strExtensions, "WGL_EXT_swap_control")) { AddExtension_OGL( GLF_VSYNC, "WGL_EXT_swap_control"); - pwglSwapIntervalEXT = (GLboolean (__stdcall*)(GLint))pwglGetProcAddress( "wglSwapIntervalEXT"); - pwglGetSwapIntervalEXT = (GLint (__stdcall*)(void) )pwglGetProcAddress( "wglGetSwapIntervalEXT"); + pwglSwapIntervalEXT = (GLboolean (__stdcall*)(GLint))OGL_GetProcAddress( "wglSwapIntervalEXT"); + pwglGetSwapIntervalEXT = (GLint (__stdcall*)(void) )OGL_GetProcAddress( "wglGetSwapIntervalEXT"); ASSERT( pwglSwapIntervalEXT!=NULL && pwglGetSwapIntervalEXT!=NULL); } @@ -623,8 +320,8 @@ void CGfxLibrary::InitContext_OGL(void) gl_iMaxTessellationLevel = 0; if( HasExtension( go_strExtensions, "GL_ATI_pn_triangles")) { AddExtension_OGL( NONE, "GL_ATI_pn_triangles"); - pglPNTrianglesiATI = (void (__stdcall*)(GLenum,GLint ))pwglGetProcAddress( "glPNTrianglesiATI"); - pglPNTrianglesfATI = (void (__stdcall*)(GLenum,GLfloat))pwglGetProcAddress( "glPNTrianglesfATI"); + pglPNTrianglesiATI = (void (__stdcall*)(GLenum,GLint ))OGL_GetProcAddress( "glPNTrianglesiATI"); + pglPNTrianglesfATI = (void (__stdcall*)(GLenum,GLfloat))OGL_GetProcAddress( "glPNTrianglesfATI"); ASSERT( pglPNTrianglesiATI!=NULL && pglPNTrianglesfATI!=NULL); // check max possible tessellation pglGetIntegerv( GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI, &gliRet); @@ -632,6 +329,7 @@ void CGfxLibrary::InitContext_OGL(void) OGL_CHECKERROR; } +#ifdef PLATFORM_WIN32 // if T-buffer is supported if( _TBCapability) { // add extension and disable t-buffer usage by default @@ -639,6 +337,7 @@ void CGfxLibrary::InitContext_OGL(void) pglDisable( GL_MULTISAMPLE_3DFX); OGL_CHECKERROR; } +#endif // test for clamp to edge TestExtension_OGL( GLF_EXT_EDGECLAMP, "GL_EXT_texture_edge_clamp"); @@ -804,6 +503,14 @@ BOOL CGfxLibrary::InitDriver_OGL( BOOL b3Dfx/*=FALSE*/) return TRUE; } +static void ClearFunctionPointers(void) +{ + // clear gl function pointers + #define DLLFUNCTION(dll, output, name, inputs, params, required) p##name = NULL; + #include "gl_functions.h" + #undef DLLFUNCTION +} + // shutdown OpenGL driver void CGfxLibrary::EndDriver_OGL(void) @@ -815,78 +522,12 @@ void CGfxLibrary::EndDriver_OGL(void) td.td_tpLocal.Clear(); td.Unbind(); }} - } - // unbind fog, haze and flat texture + } // unbind fog/haze gfxDeleteTexture( _fog_ulTexture); gfxDeleteTexture( _haze_ulTexture); - ASSERT( _ptdFlat!=NULL); - _ptdFlat->td_tpLocal.Clear(); - _ptdFlat->Unbind(); - // shut the driver down - if( go_hglRC!=NULL) { - if( pwglMakeCurrent!=NULL) { - BOOL bRes = pwglMakeCurrent(NULL, NULL); - WIN_CHECKERROR( bRes, "MakeCurrent(NULL, NULL)"); - } - ASSERT( pwglDeleteContext!=NULL); - BOOL bRes = pwglDeleteContext(go_hglRC); - WIN_CHECKERROR( bRes, "DeleteContext"); - go_hglRC = NULL; - } - OGL_ClearFunctionPointers(); -} - - - -// prepare current viewport for rendering thru OpenGL -BOOL CGfxLibrary::SetCurrentViewport_OGL(CViewPort *pvp) -{ - // if must init entire opengl - if( gl_ulFlags & GLF_INITONNEXTWINDOW) - { - gl_ulFlags &= ~GLF_INITONNEXTWINDOW; - // reopen window - pvp->CloseCanvas(); - pvp->OpenCanvas(); - // init now - CTempDC tdc(pvp->vp_hWnd); - if( !CreateContext_OGL(tdc.hdc)) return FALSE; - gl_pvpActive = pvp; // remember as current viewport (must do that BEFORE InitContext) - InitContext_OGL(); - pvp->vp_ctDisplayChanges = gl_ctDriverChanges; - return TRUE; - } - - // if window was not set for this driver - if( pvp->vp_ctDisplayChangesCloseCanvas(); - pvp->OpenCanvas(); - // set it - CTempDC tdc(pvp->vp_hWnd); - if( !SetupPixelFormat_OGL(tdc.hdc)) return FALSE; - pvp->vp_ctDisplayChanges = gl_ctDriverChanges; - } - - if( gl_pvpActive!=NULL) { - // fail, if only one window is allowed (3dfx driver), already initialized and trying to set non-primary viewport - const BOOL bOneWindow = (gl_gaAPI[GAT_OGL].ga_adaAdapter[gl_iCurrentAdapter].da_ulFlags & DAF_ONEWINDOW); - if( bOneWindow && gl_pvpActive->vp_hWnd!=NULL && gl_pvpActive->vp_hWnd!=pvp->vp_hWnd) return FALSE; - // no need to set context if it is the same window as last time - if( gl_pvpActive->vp_hWnd==pvp->vp_hWnd) return TRUE; - } - - // try to set context to this window - pwglMakeCurrent( NULL, NULL); - CTempDC tdc(pvp->vp_hWnd); - // fail, if cannot set context to this window - if( !pwglMakeCurrent( tdc.hdc, go_hglRC)) return FALSE; - - // remember as current window - gl_pvpActive = pvp; - return TRUE; + PlatformEndDriver_OGL(); + ClearFunctionPointers(); } diff --git a/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp b/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp index b22d2ee..298c6c7 100644 --- a/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp +++ b/Sources/Engine/Graphics/Gfx_OpenGL_Textures.cpp @@ -1,12 +1,13 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include -#include +#include #include #include +#include #include #include @@ -105,7 +106,7 @@ extern void MimicTexParams_OGL( CTexParams &tpLocal) // upload context for current texture to accelerator's memory // (returns format in which texture was really uploaded) -extern void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV, +void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV, GLenum eInternalFormat, BOOL bUseSubImage) { // safeties @@ -151,6 +152,22 @@ extern void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV, if( pixSizeU==0) pixSizeU=1; if( pixSizeV==0) pixSizeV=1; pixSize = pixSizeU*pixSizeV; + + #if (defined USE_PORTABLE_C) + // Basically average every other pixel... + pixSize *= 4; + + UWORD w = 0; + UBYTE *dptr = (UBYTE *) pulDst; + UBYTE *sptr = (UBYTE *) pulSrc; + for (PIX i = 0; i < pixSize; i++) + { + *dptr = (UBYTE) ( (((UWORD) sptr[0]) + ((UWORD) sptr[1])) >> 1 ); + dptr++; + sptr += 2; + } + + #elif (defined __MSVC_INLINE__) __asm { pxor mm0,mm0 mov esi,D [pulSrc] @@ -171,6 +188,33 @@ extern void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV, jnz pixLoop emms } + + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "pxor %%mm0,%%mm0 \n\t" + "0: \n\t" // pixLoop + "movd 0(%%esi), %%mm1 \n\t" + "movd 4(%%esi), %%mm2 \n\t" + "punpcklbw %%mm0,%%mm1 \n\t" + "punpcklbw %%mm0,%%mm2 \n\t" + "paddw %%mm2,%%mm1 \n\t" + "psrlw $1,%%mm1 \n\t" + "packuswb %%mm0,%%mm1 \n\t" + "movd %%mm1, (%%edi) \n\t" + "addl $8,%%esi \n\t" + "addl $4,%%edi \n\t" + "decl %%ecx \n\t" + "jnz 0b \n\t" // pixLoop + "emms \n\t" + : + : "S" (pulSrc), "D" (pulDst), "c" (pixSize) + : "memory", "cc" + ); + + #else + #error Please write inline ASM for your platform. + #endif + // upload mipmap if( bUseSubImage) { pglTexSubImage2D( GL_TEXTURE_2D, iMip, 0, 0, pixSizeU, pixSizeV, diff --git a/Sources/Engine/Graphics/Gfx_wrapper.cpp b/Sources/Engine/Graphics/Gfx_wrapper.cpp index 0cd6cfa..c0555d1 100644 --- a/Sources/Engine/Graphics/Gfx_wrapper.cpp +++ b/Sources/Engine/Graphics/Gfx_wrapper.cpp @@ -25,38 +25,38 @@ extern INDEX gap_iDithering; // cached states -extern BOOL GFX_bDepthTest = FALSE; -extern BOOL GFX_bDepthWrite = FALSE; -extern BOOL GFX_bAlphaTest = FALSE; -extern BOOL GFX_bDithering = TRUE; -extern BOOL GFX_bBlending = TRUE; -extern BOOL GFX_bClipping = TRUE; -extern BOOL GFX_bClipPlane = FALSE; -extern BOOL GFX_bColorArray = FALSE; -extern BOOL GFX_bTruform = FALSE; -extern BOOL GFX_bFrontFace = TRUE; -extern BOOL GFX_bViewMatrix = TRUE; -extern INDEX GFX_iActiveTexUnit = 0; -extern FLOAT GFX_fMinDepthRange = 0.0f; -extern FLOAT GFX_fMaxDepthRange = 0.0f; +BOOL GFX_bDepthTest = FALSE; +BOOL GFX_bDepthWrite = FALSE; +BOOL GFX_bAlphaTest = FALSE; +BOOL GFX_bDithering = TRUE; +BOOL GFX_bBlending = TRUE; +BOOL GFX_bClipping = TRUE; +BOOL GFX_bClipPlane = FALSE; +BOOL GFX_bColorArray = FALSE; +BOOL GFX_bTruform = FALSE; +BOOL GFX_bFrontFace = TRUE; +BOOL GFX_bViewMatrix = TRUE; +INDEX GFX_iActiveTexUnit = 0; +FLOAT GFX_fMinDepthRange = 0.0f; +FLOAT GFX_fMaxDepthRange = 0.0f; -extern GfxBlend GFX_eBlendSrc = GFX_ONE; -extern GfxBlend GFX_eBlendDst = GFX_ZERO; -extern GfxComp GFX_eDepthFunc = GFX_LESS_EQUAL; -extern GfxFace GFX_eCullFace = GFX_NONE; -extern BOOL GFX_abTexture[GFX_MAXTEXUNITS] = { FALSE, FALSE, FALSE, FALSE }; -extern INDEX GFX_iTexModulation[GFX_MAXTEXUNITS] = { 0, 0, 0, 0 }; +GfxBlend GFX_eBlendSrc = GFX_ONE; +GfxBlend GFX_eBlendDst = GFX_ZERO; +GfxComp GFX_eDepthFunc = GFX_LESS_EQUAL; +GfxFace GFX_eCullFace = GFX_NONE; +BOOL GFX_abTexture[GFX_MAXTEXUNITS] = { FALSE, FALSE, FALSE, FALSE }; +INDEX GFX_iTexModulation[GFX_MAXTEXUNITS] = { 0, 0, 0, 0 }; // last ortho/frustum values (frustum has negative sign, because of orgho-frustum switching!) -extern FLOAT GFX_fLastL = 0; -extern FLOAT GFX_fLastR = 0; -extern FLOAT GFX_fLastT = 0; -extern FLOAT GFX_fLastB = 0; -extern FLOAT GFX_fLastN = 0; -extern FLOAT GFX_fLastF = 0; +FLOAT GFX_fLastL = 0; +FLOAT GFX_fLastR = 0; +FLOAT GFX_fLastT = 0; +FLOAT GFX_fLastB = 0; +FLOAT GFX_fLastN = 0; +FLOAT GFX_fLastF = 0; // number of vertices currently in buffer -extern INDEX GFX_ctVertices = 0; +INDEX GFX_ctVertices = 0; // for D3D: mark need for clipping (when wants to be disable but cannot be because of user clip plane) static BOOL _bWantsClipping = TRUE; @@ -66,62 +66,62 @@ static ULONG _ulCurrentColorMask = (CT_RMASK|CT_GMASK|CT_BMASK|CT_AMASK); static BOOL _bCVAReallyLocked = FALSE; // clip plane and last view matrix for D3D -extern FLOAT D3D_afClipPlane[4] = {0,0,0,0}; -extern FLOAT D3D_afViewMatrix[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; +FLOAT D3D_afClipPlane[4] = {0,0,0,0}; +FLOAT D3D_afViewMatrix[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; static FLOAT _afActiveClipPlane[4] = {0,0,0,0}; // Truform/N-Patches -extern INDEX truform_iLevel = -1; -extern BOOL truform_bLinear = FALSE; +INDEX truform_iLevel = -1; +BOOL truform_bLinear = FALSE; // functions' pointers -extern void (*gfxEnableDepthWrite)(void) = NULL; -extern void (*gfxEnableDepthBias)(void) = NULL; -extern void (*gfxEnableDepthTest)(void) = NULL; -extern void (*gfxEnableAlphaTest)(void) = NULL; -extern void (*gfxEnableBlend)(void) = NULL; -extern void (*gfxEnableDither)(void) = NULL; -extern void (*gfxEnableTexture)(void) = NULL; -extern void (*gfxEnableClipping)(void) = NULL; -extern void (*gfxEnableClipPlane)(void) = NULL; -extern void (*gfxDisableDepthWrite)(void) = NULL; -extern void (*gfxDisableDepthBias)(void) = NULL; -extern void (*gfxDisableDepthTest)(void) = NULL; -extern void (*gfxDisableAlphaTest)(void) = NULL; -extern void (*gfxDisableBlend)(void) = NULL; -extern void (*gfxDisableDither)(void) = NULL; -extern void (*gfxDisableTexture)(void) = NULL; -extern void (*gfxDisableClipping)(void) = NULL; -extern void (*gfxDisableClipPlane)(void) = NULL; -extern void (*gfxBlendFunc)( GfxBlend eSrc, GfxBlend eDst) = NULL; -extern void (*gfxDepthFunc)( GfxComp eFunc) = NULL; -extern void (*gfxDepthRange)( FLOAT fMin, FLOAT fMax) = NULL; -extern void (*gfxCullFace)( GfxFace eFace) = NULL; -extern void (*gfxFrontFace)( GfxFace eFace) = NULL; -extern void (*gfxClipPlane)( const DOUBLE *pdPlane) = NULL; -extern void (*gfxSetOrtho)( const FLOAT fLeft, const FLOAT fRight, const FLOAT fTop, const FLOAT fBottom, const FLOAT fNear, const FLOAT fFar, const BOOL bSubPixelAdjust) = NULL; -extern void (*gfxSetFrustum)( const FLOAT fLeft, const FLOAT fRight, const FLOAT fTop, const FLOAT fBottom, const FLOAT fNear, const FLOAT fFar) = NULL; -extern void (*gfxSetTextureMatrix)( const FLOAT *pfMatrix) = NULL; -extern void (*gfxSetViewMatrix)( const FLOAT *pfMatrix) = NULL; -extern void (*gfxPolygonMode)( GfxPolyMode ePolyMode) = NULL; -extern void (*gfxSetTextureWrapping)( enum GfxWrap eWrapU, enum GfxWrap eWrapV) = NULL; -extern void (*gfxSetTextureModulation)( INDEX iScale) = NULL; -extern void (*gfxGenerateTexture)( ULONG &ulTexObject) = NULL; -extern void (*gfxDeleteTexture)( ULONG &ulTexObject) = NULL; -extern void (*gfxSetVertexArray)( GFXVertex4 *pvtx, INDEX ctVtx) = NULL; -extern void (*gfxSetNormalArray)( GFXNormal *pnor) = NULL; -extern void (*gfxSetTexCoordArray)( GFXTexCoord *ptex, BOOL b4) = NULL; -extern void (*gfxSetColorArray)( GFXColor *pcol) = NULL; -extern void (*gfxDrawElements)( INDEX ctElem, INDEX *pidx) = NULL; -extern void (*gfxSetConstantColor)(COLOR col) = NULL; -extern void (*gfxEnableColorArray)(void) = NULL; -extern void (*gfxDisableColorArray)(void) = NULL; -extern void (*gfxFinish)(void) = NULL; -extern void (*gfxLockArrays)(void) = NULL; -extern void (*gfxEnableTruform)( void) = NULL; -extern void (*gfxDisableTruform)(void) = NULL; -extern void (*gfxSetColorMask)( ULONG ulColorMask) = NULL; +void (*gfxEnableDepthWrite)(void) = NULL; +void (*gfxEnableDepthBias)(void) = NULL; +void (*gfxEnableDepthTest)(void) = NULL; +void (*gfxEnableAlphaTest)(void) = NULL; +void (*gfxEnableBlend)(void) = NULL; +void (*gfxEnableDither)(void) = NULL; +void (*gfxEnableTexture)(void) = NULL; +void (*gfxEnableClipping)(void) = NULL; +void (*gfxEnableClipPlane)(void) = NULL; +void (*gfxDisableDepthWrite)(void) = NULL; +void (*gfxDisableDepthBias)(void) = NULL; +void (*gfxDisableDepthTest)(void) = NULL; +void (*gfxDisableAlphaTest)(void) = NULL; +void (*gfxDisableBlend)(void) = NULL; +void (*gfxDisableDither)(void) = NULL; +void (*gfxDisableTexture)(void) = NULL; +void (*gfxDisableClipping)(void) = NULL; +void (*gfxDisableClipPlane)(void) = NULL; +void (*gfxBlendFunc)( GfxBlend eSrc, GfxBlend eDst) = NULL; +void (*gfxDepthFunc)( GfxComp eFunc) = NULL; +void (*gfxDepthRange)( FLOAT fMin, FLOAT fMax) = NULL; +void (*gfxCullFace)( GfxFace eFace) = NULL; +void (*gfxFrontFace)( GfxFace eFace) = NULL; +void (*gfxClipPlane)( const DOUBLE *pdPlane) = NULL; +void (*gfxSetOrtho)( const FLOAT fLeft, const FLOAT fRight, const FLOAT fTop, const FLOAT fBottom, const FLOAT fNear, const FLOAT fFar, const BOOL bSubPixelAdjust) = NULL; +void (*gfxSetFrustum)( const FLOAT fLeft, const FLOAT fRight, const FLOAT fTop, const FLOAT fBottom, const FLOAT fNear, const FLOAT fFar) = NULL; +void (*gfxSetTextureMatrix)( const FLOAT *pfMatrix) = NULL; +void (*gfxSetViewMatrix)( const FLOAT *pfMatrix) = NULL; +void (*gfxPolygonMode)( GfxPolyMode ePolyMode) = NULL; +void (*gfxSetTextureWrapping)( enum GfxWrap eWrapU, enum GfxWrap eWrapV) = NULL; +void (*gfxSetTextureModulation)( INDEX iScale) = NULL; +void (*gfxGenerateTexture)( ULONG &ulTexObject) = NULL; +void (*gfxDeleteTexture)( ULONG &ulTexObject) = NULL; +void (*gfxSetVertexArray)( GFXVertex4 *pvtx, INDEX ctVtx) = NULL; +void (*gfxSetNormalArray)( GFXNormal *pnor) = NULL; +void (*gfxSetTexCoordArray)( GFXTexCoord *ptex, BOOL b4) = NULL; +void (*gfxSetColorArray)( GFXColor *pcol) = NULL; +void (*gfxDrawElements)( INDEX ctElem, INDEX *pidx) = NULL; +void (*gfxSetConstantColor)(COLOR col) = NULL; +void (*gfxEnableColorArray)(void) = NULL; +void (*gfxDisableColorArray)(void) = NULL; +void (*gfxFinish)(void) = NULL; +void (*gfxLockArrays)(void) = NULL; +void (*gfxEnableTruform)( void) = NULL; +void (*gfxDisableTruform)(void) = NULL; +void (*gfxSetColorMask)( ULONG ulColorMask) = NULL; @@ -134,7 +134,7 @@ static void none_void(void) // error checkers (this is for debug version only) -extern void OGL_CheckError(void) +void OGL_CheckError(void) { #ifndef NDEBUG const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; @@ -144,7 +144,7 @@ extern void OGL_CheckError(void) } #ifdef SE1_D3D -extern void D3D_CheckError(HRESULT hr) +void D3D_CheckError(HRESULT hr) { #ifndef NDEBUG const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; @@ -160,10 +160,10 @@ extern void D3D_CheckError(HRESULT hr) static LPDIRECT3DTEXTURE8 *_ppd3dCurrentTexture; #endif // SE1_D3D -extern INDEX GetTexturePixRatio_OGL( GLuint uiBindNo); -extern INDEX GetFormatPixRatio_OGL( GLenum eFormat); -extern void MimicTexParams_OGL( CTexParams &tpLocal); -extern void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV, +INDEX GetTexturePixRatio_OGL( GLuint uiBindNo); +INDEX GetFormatPixRatio_OGL( GLenum eFormat); +void MimicTexParams_OGL( CTexParams &tpLocal); +void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV, GLenum eInternalFormat, BOOL bUseSubImage); #ifdef SE1_D3D @@ -175,16 +175,12 @@ extern void UploadTexture_D3D( LPDIRECT3DTEXTURE8 *ppd3dTexture, ULONG *pulText #endif // SE1_D3D // update texture LOD bias -extern FLOAT _fCurrentLODBias = 0; // LOD bias adjuster -extern void UpdateLODBias( const FLOAT fLODBias) +FLOAT _fCurrentLODBias = 0; // LOD bias adjuster +void UpdateLODBias( const FLOAT fLODBias) { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); -#else // SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); // only if supported and needed if( _fCurrentLODBias==fLODBias && _pGfx->gl_fMaxTextureLODBias==0) return; _fCurrentLODBias = fLODBias; @@ -219,14 +215,15 @@ extern void UpdateLODBias( const FLOAT fLODBias) D3D_CHECKERROR(hr); } } -#endif // SE1_D3D +#endif + _sfStats.StopTimer(CStatForm::STI_GFXAPI); } // get current texture filtering mode -extern void gfxGetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree) +void gfxGetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree) { iFilterType = _tpGlobal[0].tp_iFilter; iAnisotropyDegree = _tpGlobal[0].tp_iAnisotropy; @@ -234,7 +231,7 @@ extern void gfxGetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree // set texture filtering mode -extern void gfxSetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree) +void gfxSetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree) { // clamp vars INDEX iMagTex = iFilterType /100; iMagTex = Clamp( iMagTex, 0L, 2L); // 0=same as iMinTex, 1=nearest, 2=linear @@ -274,12 +271,12 @@ extern void gfxSetTextureFiltering( INDEX &iFilterType, INDEX &iAnisotropyDegree } // done _sfStats.StopTimer(CStatForm::STI_GFXAPI); -#endif // SE1_D3D +#endif } // set new texture LOD biasing -extern void gfxSetTextureBiasing( FLOAT &fLODBias) +void gfxSetTextureBiasing( FLOAT &fLODBias) { // adjust LOD biasing if needed fLODBias = Clamp( fLODBias, -_pGfx->gl_fMaxTextureLODBias, +_pGfx->gl_fMaxTextureLODBias); @@ -292,15 +289,11 @@ extern void gfxSetTextureBiasing( FLOAT &fLODBias) // set texture unit as active -extern void gfxSetTextureUnit( INDEX iUnit) +void gfxSetTextureUnit( INDEX iUnit) { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); -#else // SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); ASSERT( iUnit>=0 && iUnit<4); // supports 4 layers (for now) // check consistency @@ -329,7 +322,7 @@ extern void gfxSetTextureUnit( INDEX iUnit) // set texture as current -extern void gfxSetTexture( ULONG &ulTexObject, CTexParams &tpLocal) +void gfxSetTexture( ULONG &ulTexObject, CTexParams &tpLocal) { // clamp texture filtering if needed static INDEX _iLastTextureFiltering = 0; @@ -343,11 +336,7 @@ extern void gfxSetTexture( ULONG &ulTexObject, CTexParams &tpLocal) // determine API and enable texturing const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT(GfxValidApi(eAPI)); gfxEnableTexture(); _sfStats.StartTimer(CStatForm::STI_BINDTEXTURE); @@ -376,15 +365,11 @@ extern void gfxSetTexture( ULONG &ulTexObject, CTexParams &tpLocal) // upload texture -extern void gfxUploadTexture( ULONG *pulTexture, PIX pixWidth, PIX pixHeight, ULONG ulFormat, BOOL bNoDiscard) +void gfxUploadTexture( ULONG *pulTexture, PIX pixWidth, PIX pixHeight, ULONG ulFormat, BOOL bNoDiscard) { // determine API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -409,18 +394,14 @@ extern void gfxUploadTexture( ULONG *pulTexture, PIX pixWidth, PIX pixHeight, UL // returns size of uploaded texture -extern SLONG gfxGetTextureSize( ULONG ulTexObject, BOOL bHasMipmaps/*=TRUE*/) +SLONG gfxGetTextureSize( ULONG ulTexObject, BOOL bHasMipmaps/*=TRUE*/) { // nothing used if nothing uploaded - if( ulTexObject==NULL) return 0; + if( ulTexObject==0) return 0; // determine API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); SLONG slMipSize; _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -472,18 +453,12 @@ extern SLONG gfxGetTextureSize( ULONG ulTexObject, BOOL bHasMipmaps/*=TRUE*/) // returns bytes/pixels ratio for uploaded texture -extern INDEX gfxGetTexturePixRatio( ULONG ulTextureObject) +INDEX gfxGetTexturePixRatio( ULONG ulTextureObject) { // determine API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D - if( eAPI==GAT_OGL) { - return GetTexturePixRatio_OGL( (GLuint)ulTextureObject); - } + ASSERT( GfxValidApi(eAPI) ); + if( eAPI==GAT_OGL) return GetTexturePixRatio_OGL( (GLuint)ulTextureObject); #ifdef SE1_D3D else if( eAPI==GAT_D3D) return GetTexturePixRatio_D3D( (LPDIRECT3DTEXTURE8)ulTextureObject); #endif // SE1_D3D @@ -492,18 +467,12 @@ extern INDEX gfxGetTexturePixRatio( ULONG ulTextureObject) // returns bytes/pixels ratio for uploaded texture -extern INDEX gfxGetFormatPixRatio( ULONG ulTextureFormat) +INDEX gfxGetFormatPixRatio( ULONG ulTextureFormat) { // determine API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D - if( eAPI==GAT_OGL) { - return GetFormatPixRatio_OGL( (GLenum)ulTextureFormat); - } + ASSERT( GfxValidApi(eAPI) ); + if( eAPI==GAT_OGL) return GetFormatPixRatio_OGL( (GLenum)ulTextureFormat); #ifdef SE1_D3D else if( eAPI==GAT_D3D) return GetFormatPixRatio_D3D( (D3DFORMAT)ulTextureFormat); #endif // SE1_D3D @@ -515,11 +484,11 @@ extern INDEX gfxGetFormatPixRatio( ULONG ulTextureFormat) // PATTERN TEXTURE FOR LINES CTexParams _tpPattern; -extern ULONG _ulPatternTexture = NONE; -extern ULONG _ulLastUploadedPattern = 0; +ULONG _ulPatternTexture = NONE; +ULONG _ulLastUploadedPattern = 0; // upload pattern to accelerator memory -extern void gfxSetPattern( ULONG ulPattern) +void gfxSetPattern( ULONG ulPattern) { // set pattern to be current texture _tpPattern.tp_bSingleMipmap = TRUE; @@ -546,7 +515,7 @@ extern void gfxSetPattern( ULONG ulPattern) // for D3D - (type 0=vtx, 1=nor, 2=col, 3=tex) -extern void SetVertexArray_D3D( INDEX iType, ULONG *pulVtx); +void SetVertexArray_D3D( INDEX iType, ULONG *pulVtx); extern void gfxUnlockArrays(void) @@ -569,8 +538,8 @@ extern void gfxUnlockArrays(void) // OpenGL workarounds -// initialization of commond quad elements array -extern void AddQuadElements( const INDEX ctQuads) +// initialization of common quad elements array +void AddQuadElements( const INDEX ctQuads) { const INDEX iStart = _aiCommonQuads.Count() /6*4; INDEX *piQuads = _aiCommonQuads.Push(ctQuads*6); @@ -603,7 +572,7 @@ static void FlushArrays( INDEX *piElements, INDEX ctElements) // render quad elements to screen buffer -extern void gfxFlushQuads(void) +void gfxFlushQuads(void) { // if there is something to draw const INDEX ctElements = _avtxCommon.Count()*6/4; @@ -621,7 +590,7 @@ extern void gfxFlushQuads(void) // render elements to screen buffer -extern void gfxFlushElements(void) +void gfxFlushElements(void) { const INDEX ctElements = _aiCommonElements.Count(); if( ctElements>0) FlushArrays( &_aiCommonElements[0], ctElements); @@ -631,7 +600,7 @@ extern void gfxFlushElements(void) // set truform parameters -extern void gfxSetTruform( INDEX iLevel, BOOL bLinearNormals) +void gfxSetTruform( INDEX iLevel, BOOL bLinearNormals) { // skip if Truform isn't supported if( _pGfx->gl_iMaxTessellationLevel<1) { @@ -645,11 +614,7 @@ extern void gfxSetTruform( INDEX iLevel, BOOL bLinearNormals) // determine API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_D3D || eAPI == GAT_NONE); -#else // SE1_D3D - ASSERT(eAPI == GAT_OGL || eAPI == GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(eAPI) ); _sfStats.StartTimer(CStatForm::STI_GFXAPI); @@ -715,7 +680,7 @@ static void none_SetColorMask( ULONG ulColorMask) { NOTHING; }; // functions initialization for OGL, D3D or NONE (dummy) -extern void GFX_SetFunctionPointers( INDEX iAPI) +void GFX_SetFunctionPointers( INDEX iAPI) { // OpenGL? if( iAPI==(INDEX)GAT_OGL) diff --git a/Sources/Engine/Graphics/Gfx_wrapper.h b/Sources/Engine/Graphics/Gfx_wrapper.h index 4bbce12..e11a596 100644 --- a/Sources/Engine/Graphics/Gfx_wrapper.h +++ b/Sources/Engine/Graphics/Gfx_wrapper.h @@ -1,6 +1,10 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#pragma once +#ifndef SE_INCL_GFX_WRAPPER_H +#define SE_INCL_GFX_WRAPPER_H +#ifdef PRAGMA_ONCE + #pragma once +#endif enum GfxBlend @@ -259,9 +263,12 @@ extern void gfxFlushQuads(void); // check GFX errors only in debug builds #ifndef NDEBUG extern void OGL_CheckError(void); - extern void D3D_CheckError(HRESULT hr); #define OGL_CHECKERROR OGL_CheckError(); + + #ifdef SE1_D3D + extern void D3D_CheckError(HRESULT hr); #define D3D_CHECKERROR(hr) D3D_CheckError(hr); + #endif #else #define OGL_CHECKERROR (void)(0); #define D3D_CHECKERROR(hr) (void)(0); @@ -292,3 +299,7 @@ extern void d3dSetVertexShader(DWORD dwHandle); } while(ref>0); \ object = NONE; \ } + +#endif /* include-once wrapper. */ + + diff --git a/Sources/Engine/Graphics/Graphics.cpp b/Sources/Engine/Graphics/Graphics.cpp index f4c2cf5..73cf443 100644 --- a/Sources/Engine/Graphics/Graphics.cpp +++ b/Sources/Engine/Graphics/Graphics.cpp @@ -1,14 +1,24 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +// !!! FIXME: One of the GNU inline asm blocks has a bug that causes the +// !!! FIXME: title on the main menu to render incorrectly. (Generating an +// !!! FIXME: incorrect mipmap?) The intel compiler works fine with the +// !!! FIXME: MSVC inline asm, but GCC and Intel both have the problem when +// !!! FIXME: using the GNU inline asm. -#include +#include "Engine/StdH.h" + +#include #include #include #include #include #include +#if USE_MMX_INTRINSICS +#include +#endif + // asm shortcuts #define O offset #define Q qword ptr @@ -174,7 +184,12 @@ void FlipBitmap( UBYTE *pubSrc, UBYTE *pubDst, PIX pixWidth, PIX pixHeight, INDE // makes one level lower mipmap (bilinear or nearest-neighbour with border preservance) +#if (defined __GNUC__) +static __int64 mmRounder = 0x0002000200020002ll; +#else static __int64 mmRounder = 0x0002000200020002; +#endif + static void MakeOneMipmap( ULONG *pulSrcMipmap, ULONG *pulDstMipmap, PIX pixWidth, PIX pixHeight, BOOL bBilinear) { // some safety checks @@ -186,6 +201,59 @@ static void MakeOneMipmap( ULONG *pulSrcMipmap, ULONG *pulDstMipmap, PIX pixWidt if( bBilinear) // type of filtering? { // BILINEAR + + #if (defined USE_PORTABLE_C) + UBYTE *src = (UBYTE *) pulSrcMipmap; + UBYTE *dest = (UBYTE *) pulDstMipmap; + for (int i = 0 ; i < pixHeight; i++) + { + for (int j = 0; j < pixWidth; j++) + { + // Grab pixels from image + UWORD upleft[4]; + UWORD upright[4]; + UWORD downleft[4]; + UWORD downright[4]; + upleft[0] = *(src + 0); + upleft[1] = *(src + 1); + upleft[2] = *(src + 2); + upleft[3] = *(src + 3); + upright[0] = *(src + 4); + upright[1] = *(src + 5); + upright[2] = *(src + 6); + upright[3] = *(src + 7); + + downleft[0] = *(src + pixWidth*8 + 0); + downleft[1] = *(src + pixWidth*8 + 1); + downleft[2] = *(src + pixWidth*8 + 2); + downleft[3] = *(src + pixWidth*8 + 3); + downright[0] = *(src + pixWidth*8 + 4); + downright[1] = *(src + pixWidth*8 + 5); + downright[2] = *(src + pixWidth*8 + 6); + downright[3] = *(src + pixWidth*8 + 7); + + UWORD answer[4]; + answer[0] = upleft[0] + upright[0] + downleft[0] + downright[0] + 2; + answer[1] = upleft[1] + upright[1] + downleft[1] + downright[1] + 2; + answer[2] = upleft[2] + upright[2] + downleft[2] + downright[2] + 2; + answer[3] = upleft[3] + upright[3] + downleft[3] + downright[3] + 2; + answer[0] /= 4; + answer[1] /= 4; + answer[2] /= 4; + answer[3] /= 4; + + *(dest + 0) = answer[0]; + *(dest + 1) = answer[1]; + *(dest + 2) = answer[2]; + *(dest + 3) = answer[3]; + + src += 8; + dest += 4; + } + src += 8*pixWidth; + } + + #elif (defined __MSVC_INLINE__) __asm { pxor mm0,mm0 mov ebx,D [pixWidth] @@ -221,11 +289,92 @@ pixLoopN: jnz rowLoop emms } - } - else - { // NEAREST-NEIGHBOUR but with border preserving - ULONG ulRowModulo = pixWidth*2 *BYTES_PER_TEXEL; - __asm { + + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "pushl %%ebx \n\t" // Save GCC's register. + "movl %%ecx, %%ebx \n\t" + + "pxor %%mm0, %%mm0 \n\t" + + "0: \n\t" // rowLoop + "movl %%ebx, %%ecx \n\t" + + "1: \n\t" // pixLoopN + "movd 0(%%esi), %%mm1 \n\t" // up-left + "movd 4(%%esi), %%mm2 \n\t" // up-right + "movd 0(%%esi, %%ebx, 8), %%mm3 \n\t" // down-left + "movd 4(%%esi, %%ebx, 8), %%mm4 \n\t" // down-right + "punpcklbw %%mm0, %%mm1 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "paddw %%mm2, %%mm1 \n\t" + "paddw %%mm3, %%mm1 \n\t" + "paddw %%mm4, %%mm1 \n\t" + "paddw (%%eax), %%mm1 \n\t" + "psrlw $2, %%mm1 \n\t" + "packuswb %%mm0, %%mm1 \n\t" + "movd %%mm1, (%%edi) \n\t" + + // advance to next pixel + "addl $8, %%esi \n\t" + "addl $4, %%edi \n\t" + "decl %%ecx \n\t" + "jnz 1b \n\t" // pixLoopN + + // advance to next row + // skip one row in source mip-map + "leal 0(%%esi, %%ebx, 8), %%esi \n\t" + "decl %%edx \n\t" + "jnz 0b \n\t" // rowLoop + "popl %%ebx \n\t" // restore GCC's register. + "emms \n\t" + : // no outputs. + : "a" (&mmRounder), "c" (pixWidth), "S" (pulSrcMipmap), + "D" (pulDstMipmap), "d" (pixHeight) + : "cc", "memory" + ); + + #else + #error Write inline asm for your platform. + #endif + } + else + { // NEAREST-NEIGHBOUR but with border preserving + ULONG ulRowModulo = pixWidth*2 *BYTES_PER_TEXEL; + + #if (defined USE_PORTABLE_C) + + PIX offset = 0; + ulRowModulo /= 4; + + for (int q = 0; q < 2; q++) + { + for (PIX i = pixHeight / 2; i > 0; i--) + { + for (PIX j = pixWidth / 2; j > 0; j--) + { + *pulDstMipmap = *(pulSrcMipmap + offset); + pulSrcMipmap += 2; + pulDstMipmap++; + } + + for (PIX j = pixWidth / 2; j > 0; j--) + { + *pulDstMipmap = *(pulSrcMipmap + offset + 1); + pulSrcMipmap += 2; + pulDstMipmap++; + } + + pulSrcMipmap += ulRowModulo; + } + + offset = pixWidth * 2; + } + + #elif (defined __MSVC_INLINE__) + __asm { xor ebx,ebx mov esi,D [pulSrcMipmap] mov edi,D [pulDstMipmap] @@ -269,6 +418,74 @@ halfEnd: jne halfLoop fullEnd: } + + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "pushl %%ebx \n\t" // Save GCC's register. + "movl %%ecx, %%ebx \n\t" + + // setup upper half + "pushl %%edx \n\t" // pixHeight + "pushl %%eax \n\t" // ulRowModulo + "pushl %%ebx \n\t" // pixWidth + "xorl %%ebx, %%ebx \n\t" + "shrl $1, %%edx \n\t" + + "0: \n\t" // halfLoop + "movl (%%esp), %%ecx \n\t" + "shrl $1, %%ecx \n\t" + + "1: \n\t" // leftLoop + "movl 0(%%esi, %%ebx, 8), %%eax \n\t" // upper-left (or lower-left) + "movl %%eax, (%%edi) \n\t" + + // advance to next pixel + "addl $8, %%esi \n\t" + "addl $4, %%edi \n\t" + "subl $1, %%ecx \n\t" + "jg 1b \n\t" // leftLoop + + // do right row half + "movl (%%esp), %%ecx \n\t" + "shrl $1, %%ecx \n\t" + "jz 3f \n\t" // halfEnd + + "2: \n\t" // rightLoop + "movl 4(%%esi, %%ebx, 8), %%eax \n\t" // upper-right (or lower-right) + "movl %%eax, (%%edi) \n\t" + + // advance to next pixel + "addl $8, %%esi \n\t" + "addl $4, %%edi \n\t" + "subl $1, %%ecx \n\t" + "jg 2b \n\t" // rightLoop + + "3: \n\t" // halfEnd + // advance to next row + "addl 4(%%esp), %%esi \n\t" // skip one row in source mip-map + "subl $1, %%edx \n\t" + "jg 0b \n\t" // halfLoop + + // do eventual lower half loop (if not yet done) + "movl 8(%%esp), %%edx \n\t" + "shrl $1, %%edx \n\t" + "jz 4f \n\t" // fullEnd + "cmpl (%%esp), %%ebx \n\t" + "movl (%%esp), %%ebx \n\t" + "jne 0b \n\t" // halfLoop + + "4: \n\t" // fullEnd + "addl $12, %%esp \n\t" + "popl %%ebx \n\t" // restore GCC's register. + : // no outputs. + : "S" (pulSrcMipmap), "D" (pulDstMipmap), "d" (pixHeight), + "c" (pixWidth), "a" (ulRowModulo) + : "cc", "memory" + ); + + #else + #error Write inline asm for your platform. + #endif } } @@ -410,9 +627,15 @@ static ULONG ulDither2[4][4] = { static __int64 mmErrDiffMask=0; +#if (defined __GNUC__) +static __int64 mmW3 = 0x0003000300030003ll; +static __int64 mmW5 = 0x0005000500050005ll; +static __int64 mmW7 = 0x0007000700070007ll; +#else static __int64 mmW3 = 0x0003000300030003; static __int64 mmW5 = 0x0005000500050005; static __int64 mmW7 = 0x0007000700070007; +#endif static __int64 mmShift = 0; static __int64 mmMask = 0; static ULONG *pulDitherTable; @@ -443,48 +666,88 @@ void DitherBitmap( INDEX iDitherType, ULONG *pulSrc, ULONG *pulDst, PIX pixWidth case 1: pulDitherTable = &ulDither2[0][0]; mmShift = 2; +#ifdef __GNUC__ + mmMask = 0x3F3F3F3F3F3F3F3Fll; +#else mmMask = 0x3F3F3F3F3F3F3F3F; +#endif goto ditherOrder; case 2: pulDitherTable = &ulDither2[0][0]; mmShift = 1; +#ifdef __GNUC__ + mmMask = 0x7F7F7F7F7F7F7F7Fll; +#else mmMask = 0x7F7F7F7F7F7F7F7F; +#endif goto ditherOrder; case 3: +#ifdef __GNUC__ + mmErrDiffMask = 0x0003000300030003ll; +#else mmErrDiffMask = 0x0003000300030003; +#endif goto ditherError; // medium dithers case 4: pulDitherTable = &ulDither2[0][0]; mmShift = 0; +#ifdef __GNUC__ + mmMask = 0xFFFFFFFFFFFFFFFFll; +#else mmMask = 0xFFFFFFFFFFFFFFFF; +#endif goto ditherOrder; case 5: pulDitherTable = &ulDither3[0][0]; mmShift = 1; +#ifdef __GNUC__ + mmMask = 0x7F7F7F7F7F7F7F7Fll; +#else mmMask = 0x7F7F7F7F7F7F7F7F; +#endif goto ditherOrder; case 6: pulDitherTable = &ulDither4[0][0]; mmShift = 1; +#ifdef __GNUC__ + mmMask = 0x7F7F7F7F7F7F7F7Fll; +#else mmMask = 0x7F7F7F7F7F7F7F7F; +#endif goto ditherOrder; case 7: +#ifdef __GNUC__ + mmErrDiffMask = 0x0007000700070007ll; +#else mmErrDiffMask = 0x0007000700070007; +#endif goto ditherError; // high dithers case 8: pulDitherTable = &ulDither3[0][0]; mmShift = 0; +#ifdef __GNUC__ + mmMask = 0xFFFFFFFFFFFFFFFFll; +#else mmMask = 0xFFFFFFFFFFFFFFFF; +#endif goto ditherOrder; case 9: pulDitherTable = &ulDither4[0][0]; mmShift = 0; +#ifdef __GNUC__ + mmMask = 0xFFFFFFFFFFFFFFFFll; +#else mmMask = 0xFFFFFFFFFFFFFFFF; +#endif goto ditherOrder; case 10: +#ifdef __GNUC__ + mmErrDiffMask = 0x000F000F000F000Fll; +#else mmErrDiffMask = 0x000F000F000F000F; +#endif goto ditherError; default: // improper dither type @@ -497,6 +760,10 @@ void DitherBitmap( INDEX iDitherType, ULONG *pulSrc, ULONG *pulDst, PIX pixWidth // ------------------------------- ordered matrix dithering routine ditherOrder: +#if (defined USE_PORTABLE_C) + STUBBED("ordered matrix dithering routine"); + +#elif (defined __MSVC_INLINE__) __asm { mov esi,D [pulSrc] mov edi,D [pulDst] @@ -541,6 +808,69 @@ nextRowO: jnz rowLoopO emms; } + +#elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + // reset dither line offset + "pushl %%ebx \n\t" // save GCC's register. + "movl (" ASMSYM(pulDitherTable) "), %%ebx \n\t" + "pushl %%ecx \n\t" // slModulo + "pushl %%eax \n\t" // pixWidth + "xorl %%eax, %%eax \n\t" + + "rowLoopO: \n\t" + // get horizontal dither patterns + "movq 0(%%ebx, %%eax, 4), %%mm4 \n\t" + "movq 8(%%ebx, %%eax, 4), %%mm5 \n\t" + "psrlw (" ASMSYM(mmShift) "), %%mm4 \n\t" + "psrlw (" ASMSYM(mmShift) "), %%mm5 \n\t" + "pand (" ASMSYM(mmMask) "), %%mm4 \n\t" + "pand (" ASMSYM(mmMask) "), %%mm5 \n\t" + + // process row + "movl (%%esp), %%ecx \n\t" + "pixLoopO: \n\t" + "movq 0(%%esi), %%mm1 \n\t" + "movq 8(%%esi), %%mm2 \n\t" + "paddusb %%mm4, %%mm1 \n\t" + "paddusb %%mm5, %%mm2 \n\t" + "movq %%mm1, 0(%%edi) \n\t" + "movq %%mm2, 8(%%edi) \n\t" + + // advance to next pixel + "addl $16, %%esi \n\t" + "addl $16, %%edi \n\t" + "subl $4, %%ecx \n\t" + "jg pixLoopO \n\t" // !!!! possible memory leak? + "je nextRowO \n\t" + + // backup couple of pixels + "leal 0(%%esi, %%ecx, 4), %%esi \n\t" + "leal 0(%%edi, %%ecx, 4), %%edi \n\t" + + "nextRowO: \n\t" + // get next dither line patterns + "addl 4(%%esp), %%esi \n\t" + "addl 4(%%esp), %%edi \n\t" + "addl $4, %%eax \n\t" + "andl $15, %%eax \n\t" + + // advance to next row + "decl %%edx \n\t" + "jnz rowLoopO \n\t" + "emms \n\t" + "addl $8, %%esp \n\t" + "popl %%ebx \n\t" // restore GCC's register. + : // no outputs. + : "S" (pulSrc), "D" (pulDst), "d" (pixHeight), + "a" (pixWidth), "c" (slModulo) + : "cc", "memory" + ); + +#else + #error Write inline asm for your platform. +#endif + goto theEnd; // ------------------------------- error diffusion dithering routine @@ -550,6 +880,10 @@ ditherError: if( pulDst!=pulSrc) memcpy( pulDst, pulSrc, pixCanvasWidth*pixCanvasHeight *BYTES_PER_TEXEL); // slModulo+=4; // now, dither destination +#if (defined USE_PORTABLE_C) + STUBBED("error diffusion dithering routine"); + +#elif (defined __MSVC_INLINE__) __asm { pxor mm0,mm0 mov esi,D [pulDst] @@ -643,6 +977,121 @@ pixLoopER: allDoneE: emms; } + +#elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "pushl %%ebx \n\t" // Save GCC's register. + "movl %%ecx, %%ebx \n\t" + "pxor %%mm0, %%mm0 \n\t" + "decl %%edx \n\t" // need not to dither last row + + "rowLoopE: \n\t" + // left to right + "movl %%eax, %%ecx \n\t" + "decl %%ecx \n\t" + + "pixLoopEL: \n\t" + "movd (%%esi), %%mm1 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "pand (" ASMSYM(mmErrDiffMask) "), %%mm1 \n\t" + + // determine errors + "movq %%mm1, %%mm3 \n\t" + "movq %%mm1, %%mm5 \n\t" + "movq %%mm1, %%mm7 \n\t" + "pmullw (" ASMSYM(mmW3) "), %%mm3 \n\t" + "pmullw (" ASMSYM(mmW5) "), %%mm5 \n\t" + "pmullw (" ASMSYM(mmW7) "), %%mm7 \n\t" + "psrlw $4, %%mm3 \n\t" // *3/16 + "psrlw $4, %%mm5 \n\t" // *5/16 + "psrlw $4, %%mm7 \n\t" // *7/16 + "psubw %%mm3,%%mm1 \n\t" + "psubw %%mm5,%%mm1 \n\t" + "psubw %%mm7,%%mm1 \n\t" // *rest/16 + "packuswb %%mm0,%%mm1 \n\t" + "packuswb %%mm0,%%mm3 \n\t" + "packuswb %%mm0,%%mm5 \n\t" + "packuswb %%mm0,%%mm7 \n\t" + + // spread errors + "paddusb 4(%%esi), %%mm7 \n\t" + "paddusb -4(%%esi, %%ebx, 4), %%mm3 \n\t" + "paddusb 0(%%esi, %%ebx, 4), %%mm5 \n\t" + "paddusb 4(%%esi, %%ebx, 4), %%mm1 \n\t" // !!!! possible memory leak? + "movd %%mm7, 4(%%esi) \n\t" + "movd %%mm3, -4(%%esi, %%ebx, 4) \n\t" + "movd %%mm5, 0(%%esi, %%ebx, 4) \n\t" + "movd %%mm1, 4(%%esi, %%ebx, 4) \n\t" + + // advance to next pixel + "addl $4, %%esi \n\t" + "decl %%ecx \n\t" + "jnz pixLoopEL \n\t" + + // advance to next row + "addl %%edi, %%esi \n\t" + "decl %%edx \n\t" + "jz allDoneE \n\t" + + // right to left + "movl %%eax, %%ecx \n\t" + "decl %%ecx \n\t" + + "pixLoopER: \n\t" + "movd (%%esi), %%mm1 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "pand (" ASMSYM(mmErrDiffMask) "), %%mm1 \n\t" + + // determine errors + "movq %%mm1, %%mm3 \n\t" + "movq %%mm1, %%mm5 \n\t" + "movq %%mm1, %%mm7 \n\t" + "pmullw (" ASMSYM(mmW3) "), %%mm3 \n\t" + "pmullw (" ASMSYM(mmW5) "), %%mm5 \n\t" + "pmullw (" ASMSYM(mmW7) "), %%mm7 \n\t" + "psrlw $4, %%mm3 \n\t" // *3/16 + "psrlw $4, %%mm5 \n\t" // *5/16 + "psrlw $4, %%mm7 \n\t" // *7/16 + "psubw %%mm3, %%mm1 \n\t" + "psubw %%mm5, %%mm1 \n\t" + "psubw %%mm7, %%mm1 \n\t" // *rest/16 + "packuswb %%mm0, %%mm1 \n\t" + "packuswb %%mm0, %%mm3 \n\t" + "packuswb %%mm0, %%mm5 \n\t" + "packuswb %%mm0, %%mm7 \n\t" + + // spread errors + "paddusb -4(%%esi), %%mm7 \n\t" + "paddusb -4(%%esi, %%ebx, 4), %%mm1 \n\t" + "paddusb 0(%%esi, %%ebx, 4), %%mm5 \n\t" + "paddusb 4(%%esi, %%ebx, 4), %%mm3 \n\t" // !!!! possible memory leak? + "movd %%mm7, -4(%%esi) \n\t" + "movd %%mm1, -4(%%esi, %%ebx, 4) \n\t" + "movd %%mm5, 0(%%esi, %%ebx, 4) \n\t" + "movd %%mm3, 4(%%esi, %%ebx, 4) \n\t" + + // revert to previous pixel + "subl $4, %%esi \n\t" + "decl %%ecx \n\t" + "jnz pixLoopER \n\t" + + // advance to next row + "leal 0(%%esi, %%ebx, 4), %%esi \n\t" + "decl %%edx \n\t" + "jnz rowLoopE \n\t" + "allDoneE: \n\t" + "popl %%ebx \n\t" + "emms \n\t" + : // no outputs. + : "S" (pulDst), "c" (pixCanvasWidth), "d" (pixHeight), "a" (pixWidth), + "D" (slWidthModulo) + : "cc", "memory" + ); + +#else + #error Write inline asm for your platform. +#endif + goto theEnd; // all done @@ -691,11 +1140,27 @@ static __int64 mmCm; // middle #define mmCc mmMc // corner #define mmCe mmEch // edge static __int64 mmInvDiv; + +#if (defined __GNUC__) +static __int64 mmAdd = 0x0007000700070007ll; +#else static __int64 mmAdd = 0x0007000700070007; +#endif // temp rows for in-place filtering support -static ULONG aulRows[2048]; +extern "C" { static ULONG aulRows[2048]; } +static void *force_syms_to_exist = NULL; +void asm_force_mmAdd() { force_syms_to_exist = &mmAdd; } +void asm_force_aulRows() { force_syms_to_exist = &aulRows; } +void asm_force_mmMc() { force_syms_to_exist = &mmMc; } +void asm_force_mmMe() { force_syms_to_exist = &mmMe; } +void asm_force_mmMm() { force_syms_to_exist = &mmMm; } +void asm_force_mmEch() { force_syms_to_exist = &mmEch; } +void asm_force_mmEm() { force_syms_to_exist = &mmEm; } +void asm_force_mmW3() { force_syms_to_exist = &mmW3; } +void asm_force_mmW5() { force_syms_to_exist = &mmW5; } +void asm_force_mmW7() { force_syms_to_exist = &mmW7; } // FilterBitmap() INTERNAL: generates convolution filter matrix if needed static INDEX iLastFilter; @@ -732,7 +1197,88 @@ static void GenerateConvolutionMatrix( INDEX iFilter) mm = iCm & 0xFFFF; mmCm = (mm<<48) | (mm<<32) | (mm<<16) | mm; } - + +extern "C" { + static ULONG *FB_pulSrc = NULL; + static ULONG *FB_pulDst = NULL; + static PIX FB_pixWidth = 0; + static PIX FB_pixHeight = 0; + static PIX FB_pixCanvasWidth = 0; + static SLONG FB_slModulo1 = 0; + static SLONG FB_slCanvasWidth = 0; +} + + +#if USE_PORTABLE_C +typedef SWORD ExtPix[4]; + +static inline void extpix_fromi64(ExtPix &pix, const __int64 i64) +{ + //memcpy(pix, i64, sizeof (ExtPix)); + pix[0] = ((i64 >> 0) & 0xFFFF); + pix[1] = ((i64 >> 16) & 0xFFFF); + pix[2] = ((i64 >> 32) & 0xFFFF); + pix[3] = ((i64 >> 48) & 0xFFFF); +} + +static inline void extend_pixel(const ULONG ul, ExtPix &pix) +{ + pix[0] = ((ul >> 0) & 0xFF); + pix[1] = ((ul >> 8) & 0xFF); + pix[2] = ((ul >> 16) & 0xFF); + pix[3] = ((ul >> 24) & 0xFF); +} + +static inline ULONG unextend_pixel(const ExtPix &pix) +{ + return + ( + (((ULONG) ((pix[0] >= 255) ? 255 : ((pix[0] <= 0) ? 0 : pix[0]))) << 0) | + (((ULONG) ((pix[1] >= 255) ? 255 : ((pix[1] <= 0) ? 0 : pix[1]))) << 8) | + (((ULONG) ((pix[2] >= 255) ? 255 : ((pix[2] <= 0) ? 0 : pix[2]))) << 16) | + (((ULONG) ((pix[3] >= 255) ? 255 : ((pix[3] <= 0) ? 0 : pix[3]))) << 24) + ); +} + +static inline void extpix_add(ExtPix &p1, const ExtPix &p2) +{ + p1[0] = (SWORD) (((SLONG) p1[0]) + ((SLONG) p2[0])); + p1[1] = (SWORD) (((SLONG) p1[1]) + ((SLONG) p2[1])); + p1[2] = (SWORD) (((SLONG) p1[2]) + ((SLONG) p2[2])); + p1[3] = (SWORD) (((SLONG) p1[3]) + ((SLONG) p2[3])); +} + +static inline void extpix_mul(ExtPix &p1, const ExtPix &p2) +{ + p1[0] = (SWORD) (((SLONG) p1[0]) * ((SLONG) p2[0])); + p1[1] = (SWORD) (((SLONG) p1[1]) * ((SLONG) p2[1])); + p1[2] = (SWORD) (((SLONG) p1[2]) * ((SLONG) p2[2])); + p1[3] = (SWORD) (((SLONG) p1[3]) * ((SLONG) p2[3])); +} + +static inline void extpix_adds(ExtPix &p1, const ExtPix &p2) +{ + SLONG x0 = (((SLONG) ((SWORD) p1[0])) + ((SLONG) ((SWORD) p2[0]))); + SLONG x1 = (((SLONG) ((SWORD) p1[1])) + ((SLONG) ((SWORD) p2[1]))); + SLONG x2 = (((SLONG) ((SWORD) p1[2])) + ((SLONG) ((SWORD) p2[2]))); + SLONG x3 = (((SLONG) ((SWORD) p1[3])) + ((SLONG) ((SWORD) p2[3]))); + + p1[0] = (SWORD) ((x0 <= -32768) ? -32768 : ((x0 >= 32767) ? 32767 : x0)); + p1[1] = (SWORD) ((x1 <= -32768) ? -32768 : ((x1 >= 32767) ? 32767 : x1)); + p1[2] = (SWORD) ((x2 <= -32768) ? -32768 : ((x2 >= 32767) ? 32767 : x2)); + p1[3] = (SWORD) ((x3 <= -32768) ? -32768 : ((x3 >= 32767) ? 32767 : x3)); +} + +static inline void extpix_mulhi(ExtPix &p1, const ExtPix &p2) +{ + p1[0] = (SWORD) (((((SLONG) p1[0]) * ((SLONG) p2[0])) >> 16) & 0xFFFF); + p1[1] = (SWORD) (((((SLONG) p1[1]) * ((SLONG) p2[1])) >> 16) & 0xFFFF); + p1[2] = (SWORD) (((((SLONG) p1[2]) * ((SLONG) p2[2])) >> 16) & 0xFFFF); + p1[3] = (SWORD) (((((SLONG) p1[3]) * ((SLONG) p2[3])) >> 16) & 0xFFFF); +} +#endif + + // applies filter to bitmap void FilterBitmap( INDEX iFilter, ULONG *pulSrc, ULONG *pulDst, PIX pixWidth, PIX pixHeight, PIX pixCanvasWidth, PIX pixCanvasHeight) @@ -760,6 +1306,536 @@ void FilterBitmap( INDEX iFilter, ULONG *pulSrc, ULONG *pulDst, PIX pixWidth, PI SLONG slCanvasWidth = pixCanvasWidth *BYTES_PER_TEXEL; // lets roll ... +#if (defined USE_MMX_INTRINSICS) + slModulo1 /= BYTES_PER_TEXEL; // C++ handles incrementing by sizeof type + slCanvasWidth /= BYTES_PER_TEXEL; // C++ handles incrementing by sizeof type + + ULONG *src = pulSrc; + ULONG *dst = pulDst; + ULONG *rowptr = aulRows; + + __m64 rmm0 = _mm_setzero_si64(); + __m64 rmmCm = _mm_set_pi32(((int *)((char*)&mmCm))[0],((int *)((char*)&mmCm))[1]); + __m64 rmmCe = _mm_set_pi32(((int *)((char*)&mmCe))[0],((int *)((char*)&mmCe))[1]); + __m64 rmmCc = _mm_set_pi32(((int *)((char*)&mmCc))[0],((int *)((char*)&mmCc))[1]); + __m64 rmmEch = _mm_set_pi32(((int *)((char*)&mmEch))[0],((int *)((char*)&mmEch))[1]); + __m64 rmmEcl = _mm_set_pi32(((int *)((char*)&mmEcl))[0],((int *)((char*)&mmEcl))[1]); + __m64 rmmEe = _mm_set_pi32(((int *)((char*)&mmEe))[0],((int *)((char*)&mmEe))[1]); + __m64 rmmEm = _mm_set_pi32(((int *)((char*)&mmEm))[0],((int *)((char*)&mmEm))[1]); + __m64 rmmMm = _mm_set_pi32(((int *)((char*)&mmMm))[0],((int *)((char*)&mmMm))[1]); + __m64 rmmMe = _mm_set_pi32(((int *)((char*)&mmMe))[0],((int *)((char*)&mmMe))[1]); + __m64 rmmMc = _mm_set_pi32(((int *)((char*)&mmMc))[0],((int *)((char*)&mmMc))[1]); + __m64 rmmAdd = _mm_set_pi32(((int *)((char*)&mmAdd))[0],((int *)((char*)&mmAdd))[1]); + __m64 rmmInvDiv = _mm_set_pi32(((int *)((char*)&mmInvDiv))[0],((int *)((char*)&mmInvDiv))[1]); + + // ----------------------- process upper left corner + __m64 rmm1 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[0]), rmm0); + __m64 rmm2 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[1]), rmm0); + __m64 rmm3 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth]), rmm0); + __m64 rmm4 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth+1]), rmm0); + __m64 rmm5 = _mm_setzero_si64(); + __m64 rmm6 = _mm_setzero_si64(); + __m64 rmm7 = _mm_setzero_si64(); + + rmm2 = _mm_add_pi16(rmm2, rmm3); + rmm1 = _mm_mullo_pi16(rmm1, rmmCm); + rmm2 = _mm_mullo_pi16(rmm2, rmmCe); + rmm4 = _mm_mullo_pi16(rmm4, rmmCc); + rmm1 = _mm_add_pi16(rmm1, rmm2); + rmm1 = _mm_add_pi16(rmm1, rmm4); + rmm1 = _mm_adds_pi16(rmm1, rmmAdd); + rmm1 = _mm_mulhi_pi16(rmm1, rmmInvDiv); + rmm1 = _mm_packs_pu16(rmm1, rmm0); + *(rowptr++) = _mm_cvtsi64_si32(rmm1); + src++; + + // ----------------------- process upper edge pixels + for (PIX i = pixWidth - 2; i != 0; i--) + { + rmm1 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-1]), rmm0); + rmm2 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[0]), rmm0); + rmm3 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[1]), rmm0); + rmm4 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth-1]), rmm0); + rmm5 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth]), rmm0); + rmm6 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth+1]), rmm0); + + rmm1 = _mm_add_pi16(rmm1, rmm3); + rmm4 = _mm_add_pi16(rmm4, rmm6); + rmm1 = _mm_mullo_pi16(rmm1, rmmEch); + rmm2 = _mm_mullo_pi16(rmm2, rmmEm); + rmm4 = _mm_mullo_pi16(rmm4, rmmEcl); + rmm5 = _mm_mullo_pi16(rmm5, rmmEe); + rmm1 = _mm_add_pi16(rmm1, rmm2); + rmm1 = _mm_add_pi16(rmm1, rmm4); + rmm1 = _mm_add_pi16(rmm1, rmm5); + rmm1 = _mm_adds_pi16(rmm1, rmmAdd); + rmm1 = _mm_mulhi_pi16(rmm1, rmmInvDiv); + rmm1 = _mm_packs_pu16(rmm1, rmm0); + *(rowptr++) = _mm_cvtsi64_si32(rmm1); + src++; + } + + // ----------------------- process upper right corner + + rmm1 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-1]), rmm0); + rmm2 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[0]), rmm0); + rmm3 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth-1]), rmm0); + rmm4 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth]), rmm0); + + rmm1 = _mm_add_pi16(rmm1, rmm4); + rmm1 = _mm_mullo_pi16(rmm1, rmmCe); + rmm2 = _mm_mullo_pi16(rmm2, rmmCm); + rmm3 = _mm_mullo_pi16(rmm3, rmmCc); + rmm1 = _mm_add_pi16(rmm1, rmm2); + rmm1 = _mm_add_pi16(rmm1, rmm3); + rmm1 = _mm_adds_pi16(rmm1, rmmAdd); + rmm1 = _mm_mulhi_pi16(rmm1, rmmInvDiv); + rmm1 = _mm_packs_pu16(rmm1, rmm0); + *rowptr = _mm_cvtsi64_si32(rmm1); + +// ----------------------- process bitmap middle pixels + + dst += slCanvasWidth; + src += slModulo1; + + // for each row + for (size_t i = pixHeight-2; i != 0; i--) // rowLoop + { + rowptr = aulRows; + + // process left edge pixel + rmm1 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-pixCanvasWidth]), rmm0); + rmm2 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[(-pixCanvasWidth)+1]), rmm0); + rmm3 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[0]), rmm0); + rmm4 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[1]), rmm0); + rmm5 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth]), rmm0); + rmm6 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth+1]), rmm0); + rmm1 = _mm_add_pi16(rmm1, rmm5); + rmm2 = _mm_add_pi16(rmm2, rmm6); + rmm1 = _mm_mullo_pi16(rmm1, rmmEch); + rmm2 = _mm_mullo_pi16(rmm2, rmmEcl); + rmm3 = _mm_mullo_pi16(rmm3, rmmEm); + rmm4 = _mm_mullo_pi16(rmm4, rmmEe); + rmm1 = _mm_add_pi16(rmm1, rmm2); + rmm1 = _mm_add_pi16(rmm1, rmm3); + rmm1 = _mm_add_pi16(rmm1, rmm4); + rmm1 = _mm_adds_pi16(rmm1, rmmAdd); + rmm1 = _mm_mulhi_pi16(rmm1, rmmInvDiv); + rmm1 = _mm_packs_pu16(rmm1, rmm0); + dst[-pixCanvasWidth] = *rowptr; + *(rowptr++) = _mm_cvtsi64_si32(rmm1); + src++; + dst++; + + // for each pixel in current row + for (size_t j = pixWidth-2; j != 0; j--) // pixLoop + { + // prepare upper convolution row + rmm1 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[(-pixCanvasWidth)-1]), rmm0); + rmm2 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-pixCanvasWidth]), rmm0); + rmm3 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[(-pixCanvasWidth)+1]), rmm0); + + // prepare middle convolution row + rmm4 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-1]), rmm0); + rmm5 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[0]), rmm0); + rmm6 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[1]), rmm0); + + // free some registers + rmm1 = _mm_add_pi16(rmm1, rmm3); + rmm2 = _mm_add_pi16(rmm2, rmm4); + rmm5 = _mm_mullo_pi16(rmm5, rmmMm); + + // prepare lower convolution row + rmm3 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth-1]), rmm0); + rmm4 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth]), rmm0); + rmm7 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth+1]), rmm0); + + // calc weightened value + rmm2 = _mm_add_pi16(rmm2, rmm6); + rmm1 = _mm_add_pi16(rmm1, rmm3); + rmm2 = _mm_add_pi16(rmm2, rmm4); + rmm1 = _mm_add_pi16(rmm1, rmm7); + rmm2 = _mm_mullo_pi16(rmm2, rmmMe); + rmm1 = _mm_mullo_pi16(rmm1, rmmMc); + rmm2 = _mm_add_pi16(rmm2, rmm5); + rmm1 = _mm_add_pi16(rmm1, rmm2); + + // calc and store wightened value + rmm1 = _mm_adds_pi16(rmm1, rmmAdd); + rmm1 = _mm_mulhi_pi16(rmm1, rmmInvDiv); + rmm1 = _mm_packs_pu16(rmm1, rmm0); + dst[-pixCanvasWidth] = *rowptr; + *(rowptr++) = _mm_cvtsi64_si32(rmm1); + + // advance to next pixel + src++; + dst++; + } + + // process right edge pixel + rmm1 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[(-pixCanvasWidth)-1]), rmm0); + rmm2 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-pixCanvasWidth]), rmm0); + rmm3 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-1]), rmm0); + rmm4 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[0]), rmm0); + rmm5 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth-1]), rmm0); + rmm6 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[pixCanvasWidth]), rmm0); + + rmm1 = _mm_add_pi16(rmm1, rmm5); + rmm2 = _mm_add_pi16(rmm2, rmm6); + rmm1 = _mm_mullo_pi16(rmm1, rmmEcl); + rmm2 = _mm_mullo_pi16(rmm2, rmmEch); + rmm3 = _mm_mullo_pi16(rmm3, rmmEe); + rmm4 = _mm_mullo_pi16(rmm4, rmmEm); + rmm1 = _mm_add_pi16(rmm1, rmm2); + rmm1 = _mm_add_pi16(rmm1, rmm3); + rmm1 = _mm_add_pi16(rmm1, rmm4); + rmm1 = _mm_adds_pi16(rmm1, rmmAdd); + rmm1 = _mm_mulhi_pi16(rmm1, rmmInvDiv); + rmm1 = _mm_packs_pu16(rmm1, rmm0); + dst[-pixCanvasWidth] = *rowptr; + *rowptr = _mm_cvtsi64_si32(rmm1); + + // advance to next row + src += slModulo1; + dst += slModulo1; + } + + // ----------------------- process lower left corner + rowptr = aulRows; + rmm1 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-pixCanvasWidth]), rmm0); + rmm2 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[(-pixCanvasWidth)+1]), rmm0); + rmm3 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[0]), rmm0); + rmm4 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[1]), rmm0); + + rmm1 = _mm_add_pi16(rmm1, rmm4); + rmm1 = _mm_mullo_pi16(rmm1, rmmCe); + rmm2 = _mm_mullo_pi16(rmm2, rmmCc); + rmm3 = _mm_mullo_pi16(rmm3, rmmCm); + rmm1 = _mm_add_pi16(rmm1, rmm2); + rmm1 = _mm_add_pi16(rmm1, rmm3); + rmm1 = _mm_adds_pi16(rmm1, rmmAdd); + rmm1 = _mm_mulhi_pi16(rmm1, rmmInvDiv); + rmm1 = _mm_packs_pu16(rmm1, rmm0); + dst[-pixCanvasWidth] = *rowptr; + dst[0] = _mm_cvtsi64_si32(rmm1); + + src++; + dst++; + rowptr++; + + // ----------------------- process lower edge pixels + for (size_t i = pixWidth-2; i != 0; i--) // lowerLoop + { + // for each pixel + rmm1 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[(-pixCanvasWidth)-1]), rmm0); + rmm2 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-pixCanvasWidth]), rmm0); + rmm3 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[(-pixCanvasWidth)+1]), rmm0); + rmm4 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-1]), rmm0); + rmm5 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[0]), rmm0); + rmm6 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[1]), rmm0); + + rmm1 = _mm_add_pi16(rmm1, rmm3); + rmm4 = _mm_add_pi16(rmm4, rmm6); + rmm1 = _mm_mullo_pi16(rmm1, rmmEcl); + rmm2 = _mm_mullo_pi16(rmm2, rmmEe); + rmm4 = _mm_mullo_pi16(rmm4, rmmEch); + rmm5 = _mm_mullo_pi16(rmm5, rmmEm); + rmm1 = _mm_add_pi16(rmm1, rmm2); + rmm1 = _mm_add_pi16(rmm1, rmm4); + rmm1 = _mm_add_pi16(rmm1, rmm5); + rmm1 = _mm_adds_pi16(rmm1, rmmAdd); + rmm1 = _mm_mulhi_pi16(rmm1, rmmInvDiv); + rmm1 = _mm_packs_pu16(rmm1, rmm0); + dst[-pixCanvasWidth] = *rowptr; + dst[0] = _mm_cvtsi64_si32(rmm1); + + // advance to next pixel + src++; + dst++; + rowptr++; + } + + // ----------------------- lower right corners + rmm1 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[(-pixCanvasWidth)-1]), rmm0); + rmm2 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-pixCanvasWidth]), rmm0); + rmm3 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[-1]), rmm0); + rmm4 = _mm_unpacklo_pi8(_mm_cvtsi32_si64(src[0]), rmm0); + + rmm2 = _mm_add_pi16(rmm2, rmm3); + rmm1 = _mm_mullo_pi16(rmm1, rmmCc); + rmm2 = _mm_mullo_pi16(rmm2, rmmCe); + rmm4 = _mm_mullo_pi16(rmm4, rmmCm); + rmm1 = _mm_add_pi16(rmm1, rmm2); + rmm1 = _mm_add_pi16(rmm1, rmm4); + rmm1 = _mm_adds_pi16(rmm1, rmmAdd); + rmm1 = _mm_mulhi_pi16(rmm1, rmmInvDiv); + rmm1 = _mm_packs_pu16(rmm1, rmm0); + dst[-pixCanvasWidth] = *rowptr; + dst[0] = _mm_cvtsi64_si32(rmm1); + + _mm_empty(); // we're done, clear out the MMX registers! + + +#elif (defined USE_PORTABLE_C) + slModulo1 /= BYTES_PER_TEXEL; // C++ handles incrementing by sizeof type + slCanvasWidth /= BYTES_PER_TEXEL; // C++ handles incrementing by sizeof type + + ULONG *src = pulSrc; + ULONG *dst = pulDst; + ULONG *rowptr = aulRows; + + ExtPix rmm1, rmm2, rmm3, rmm4, rmm5, rmm6, rmm7; + #define EXTPIXFROMINT64(x) ExtPix r##x; extpix_fromi64(r##x, x); + EXTPIXFROMINT64(mmCm); + EXTPIXFROMINT64(mmCe); + EXTPIXFROMINT64(mmCc); + EXTPIXFROMINT64(mmEch); + EXTPIXFROMINT64(mmEcl); + EXTPIXFROMINT64(mmEe); + EXTPIXFROMINT64(mmEm); + EXTPIXFROMINT64(mmMm); + EXTPIXFROMINT64(mmMe); + EXTPIXFROMINT64(mmMc); + EXTPIXFROMINT64(mmAdd); + EXTPIXFROMINT64(mmInvDiv); + #undef EXTPIXFROMINT64 + + // ----------------------- process upper left corner + extend_pixel(src[0], rmm1); + extend_pixel(src[1], rmm2); + extend_pixel(src[pixCanvasWidth], rmm3); + extend_pixel(src[pixCanvasWidth+1], rmm4); + + extpix_add(rmm2, rmm3); + extpix_mul(rmm1, rmmCm); + extpix_mul(rmm2, rmmCe); + extpix_mul(rmm4, rmmCc); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm4); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + *(rowptr++) = unextend_pixel(rmm1); + + src++; + + // ----------------------- process upper edge pixels + for (PIX i = pixWidth - 2; i != 0; i--) + { + extend_pixel(src[-1], rmm1); + extend_pixel(src[0], rmm2); + extend_pixel(src[1], rmm3); + extend_pixel(src[pixCanvasWidth-1], rmm4); + extend_pixel(src[pixCanvasWidth], rmm5); + extend_pixel(src[pixCanvasWidth+1], rmm6); + + extpix_add(rmm1, rmm3); + extpix_add(rmm4, rmm6); + extpix_mul(rmm1, rmmEch); + extpix_mul(rmm2, rmmEm); + extpix_mul(rmm4, rmmEcl); + extpix_mul(rmm5, rmmEe); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm4); + extpix_add(rmm1, rmm5); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + *(rowptr++) = unextend_pixel(rmm1); + src++; + } + + // ----------------------- process upper right corner + + extend_pixel(src[-1], rmm1); + extend_pixel(src[0], rmm2); + extend_pixel(src[pixCanvasWidth-1], rmm3); + extend_pixel(src[pixCanvasWidth], rmm4); + + extpix_add(rmm1, rmm4); + extpix_mul(rmm1, rmmCe); + extpix_mul(rmm2, rmmCm); + extpix_mul(rmm3, rmmCc); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm3); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + *rowptr = unextend_pixel(rmm1); + +// ----------------------- process bitmap middle pixels + + dst += slCanvasWidth; + src += slModulo1; + + // for each row + for (size_t i = pixHeight-2; i != 0; i--) // rowLoop + { + rowptr = aulRows; + + // process left edge pixel + extend_pixel(src[-pixCanvasWidth], rmm1); + extend_pixel(src[(-pixCanvasWidth)+1], rmm2); + extend_pixel(src[0], rmm3); + extend_pixel(src[1], rmm4); + extend_pixel(src[pixCanvasWidth], rmm5); + extend_pixel(src[pixCanvasWidth+1], rmm6); + + extpix_add(rmm1, rmm5); + extpix_add(rmm2, rmm6); + extpix_mul(rmm1, rmmEch); + extpix_mul(rmm2, rmmEcl); + extpix_mul(rmm3, rmmEm); + extpix_mul(rmm4, rmmEe); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm3); + extpix_add(rmm1, rmm4); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + *(rowptr++) = unextend_pixel(rmm1); + src++; + dst++; + + // for each pixel in current row + for (size_t j = pixWidth-2; j != 0; j--) // pixLoop + { + // prepare upper convolution row + extend_pixel(src[(-pixCanvasWidth)-1], rmm1); + extend_pixel(src[-pixCanvasWidth], rmm2); + extend_pixel(src[(-pixCanvasWidth)+1], rmm3); + + // prepare middle convolution row + extend_pixel(src[-1], rmm4); + extend_pixel(src[0], rmm5); + extend_pixel(src[1], rmm6); + + // free some registers + extpix_add(rmm1, rmm3); + extpix_add(rmm2, rmm4); + extpix_mul(rmm5, rmmMm); + + // prepare lower convolution row + extend_pixel(src[pixCanvasWidth-1], rmm3); + extend_pixel(src[pixCanvasWidth], rmm4); + extend_pixel(src[pixCanvasWidth+1], rmm7); + + // calc weightened value + extpix_add(rmm2, rmm6); + extpix_add(rmm1, rmm3); + extpix_add(rmm2, rmm4); + extpix_add(rmm1, rmm7); + extpix_mul(rmm2, rmmMe); + extpix_mul(rmm1, rmmMc); + extpix_add(rmm2, rmm5); + extpix_add(rmm1, rmm2); + + // calc and store wightened value + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + *(rowptr++) = unextend_pixel(rmm1); + + // advance to next pixel + src++; + dst++; + } + + // process right edge pixel + extend_pixel(src[(-pixCanvasWidth)-1], rmm1); + extend_pixel(src[-pixCanvasWidth], rmm2); + extend_pixel(src[-1], rmm3); + extend_pixel(src[0], rmm4); + extend_pixel(src[pixCanvasWidth-1], rmm5); + extend_pixel(src[pixCanvasWidth], rmm6); + + extpix_add(rmm1, rmm5); + extpix_add(rmm2, rmm6); + extpix_mul(rmm1, rmmEcl); + extpix_mul(rmm2, rmmEch); + extpix_mul(rmm3, rmmEe); + extpix_mul(rmm4, rmmEm); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm3); + extpix_add(rmm1, rmm4); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + *rowptr = unextend_pixel(rmm1); + + // advance to next row + src += slModulo1; + dst += slModulo1; + } + + // ----------------------- process lower left corner + rowptr = aulRows; + extend_pixel(src[-pixCanvasWidth], rmm1); + extend_pixel(src[(-pixCanvasWidth)+1], rmm2); + extend_pixel(src[0], rmm3); + extend_pixel(src[1], rmm4); + + extpix_add(rmm1, rmm4); + extpix_mul(rmm1, rmmCe); + extpix_mul(rmm2, rmmCc); + extpix_mul(rmm3, rmmCm); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm3); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + dst[0] = unextend_pixel(rmm1); + + src++; + dst++; + rowptr++; + + // ----------------------- process lower edge pixels + for (size_t i = pixWidth-2; i != 0; i--) // lowerLoop + { + // for each pixel + extend_pixel(src[(-pixCanvasWidth)-1], rmm1); + extend_pixel(src[-pixCanvasWidth], rmm2); + extend_pixel(src[(-pixCanvasWidth)+1], rmm3); + extend_pixel(src[-1], rmm4); + extend_pixel(src[0], rmm5); + extend_pixel(src[1], rmm6); + + extpix_add(rmm1, rmm3); + extpix_add(rmm4, rmm6); + extpix_mul(rmm1, rmmEcl); + extpix_mul(rmm2, rmmEe); + extpix_mul(rmm4, rmmEch); + extpix_mul(rmm5, rmmEm); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm4); + extpix_add(rmm1, rmm5); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + dst[0] = unextend_pixel(rmm1); + + // advance to next pixel + src++; + dst++; + rowptr++; + } + + // ----------------------- lower right corners + extend_pixel(src[(-pixCanvasWidth)-1], rmm1); + extend_pixel(src[-pixCanvasWidth], rmm2); + extend_pixel(src[-1], rmm3); + extend_pixel(src[0], rmm4); + + extpix_add(rmm2, rmm3); + extpix_mul(rmm1, rmmCc); + extpix_mul(rmm2, rmmCe); + extpix_mul(rmm4, rmmCm); + extpix_add(rmm1, rmm2); + extpix_add(rmm1, rmm4); + extpix_adds(rmm1, rmmAdd); + extpix_mulhi(rmm1, rmmInvDiv); + dst[-pixCanvasWidth] = *rowptr; + dst[0] = unextend_pixel(rmm1); + +#elif (defined __MSVC_INLINE__) __asm { cld mov eax,D [pixCanvasWidth] // EAX = positive row offset @@ -1072,6 +2148,341 @@ lowerLoop: emms } +#elif (defined __GNU_INLINE__) + + FB_pulSrc = pulSrc; + FB_pulDst = pulDst; + FB_pixWidth = pixWidth; + FB_pixHeight = pixHeight; + FB_pixCanvasWidth = pixCanvasWidth; + FB_slModulo1 = slModulo1; + FB_slCanvasWidth = slCanvasWidth; + + __asm__ __volatile__ ( + "pushl %%ebx \n\t" + "cld \n\t" + "movl (" ASMSYM(FB_pixCanvasWidth) "), %%eax \n\t" // EAX = positive row offset + "movl %%eax, %%edx \n\t" + "negl %%edx \n\t" // EDX = negative row offset + "pxor %%mm0, %%mm0 \n\t" + "movl (" ASMSYM(FB_pulSrc) "), %%esi \n\t" + "movl (" ASMSYM(FB_pulDst) "), %%edi \n\t" + "xorl %%ebx, %%ebx \n\t" + +// ----------------------- process upper left corner + + "movd 0(%%esi), %%mm1 \n\t" + "movd 4(%%esi), %%mm2 \n\t" + "movd 0(%%esi, %%eax, 4), %%mm3 \n\t" + "movd 4(%%esi, %%eax, 4), %%mm4 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "paddw %%mm3, %%mm2 \n\t" + "pmullw (" ASMSYM(mmCm) "), %%mm1 \n\t" + "pmullw (" ASMSYM(mmEch) "), %%mm2 \n\t" + "pmullw (" ASMSYM(mmMc) "), %%mm4 \n\t" + "paddw %%mm2, %%mm1 \n\t" + "paddw %%mm4, %%mm1 \n\t" + "paddsw (" ASMSYM(mmAdd) "), %%mm1 \n\t" + "pmulhw (" ASMSYM(mmInvDiv) "), %%mm1 \n\t" + "packuswb %%mm0, %%mm1 \n\t" + "movd %%mm1, " ASMSYM(aulRows) "(%%ebx) \n\t" + "add $4, %%esi \n\t" + "add $4, %%ebx \n\t" + +// ----------------------- process upper edge pixels + + "movl (" ASMSYM(FB_pixWidth) "), %%ecx \n\t" + "subl $2, %%ecx \n\t" + + // for each pixel + "0: \n\t" // upperLoop + "movd -4(%%esi), %%mm1 \n\t" + "movd 0(%%esi), %%mm2 \n\t" + "movd 4(%%esi), %%mm3 \n\t" + "movd -4(%%esi, %%eax, 4), %%mm4 \n\t" + "movd 0(%%esi, %%eax, 4), %%mm5 \n\t" + "movd 4(%%esi, %%eax, 4), %%mm6 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm5 \n\t" + "punpcklbw %%mm0, %%mm6 \n\t" + "paddw %%mm3, %%mm1 \n\t" + "paddw %%mm6, %%mm4 \n\t" + "pmullw (" ASMSYM(mmEch) "), %%mm1 \n\t" + "pmullw (" ASMSYM(mmEm) "), %%mm2 \n\t" + "pmullw (" ASMSYM(mmMc) "), %%mm4 \n\t" + "pmullw (" ASMSYM(mmMe) "), %%mm5 \n\t" + "paddw %%mm2, %%mm1 \n\t" + "paddw %%mm4, %%mm1 \n\t" + "paddw %%mm5, %%mm1 \n\t" + "paddsw (" ASMSYM(mmAdd) "), %%mm1 \n\t" + "pmulhw (" ASMSYM(mmInvDiv) "), %%mm1 \n\t" + "packuswb %%mm0, %%mm1 \n\t" + "movd %%mm1, " ASMSYM(aulRows) "(%%ebx) \n\t" + + // advance to next pixel + "addl $4, %%esi \n\t" + "addl $4, %%ebx \n\t" + "decl %%ecx \n\t" + "jnz 0b \n\t" // upperLoop + +// ----------------------- process upper right corner + + "movd -4(%%esi), %%mm1 \n\t" + "movd 0(%%esi), %%mm2 \n\t" + "movd -4(%%esi, %%eax, 4), %%mm3 \n\t" + "movd 0(%%esi, %%eax, 4), %%mm4 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "paddw %%mm4, %%mm1 \n\t" + "pmullw (" ASMSYM(mmEch) "), %%mm1 \n\t" + "pmullw (" ASMSYM(mmCm) "), %%mm2 \n\t" + "pmullw (" ASMSYM(mmMc) "), %%mm3 \n\t" + "paddw %%mm2, %%mm1 \n\t" + "paddw %%mm3, %%mm1 \n\t" + "paddsw (" ASMSYM(mmAdd) "), %%mm1 \n\t" + "pmulhw (" ASMSYM(mmInvDiv) "), %%mm1 \n\t" + "packuswb %%mm0, %%mm1 \n\t" + "movd %%mm1, " ASMSYM(aulRows) "(%%ebx) \n\t" + +// ----------------------- process bitmap middle pixels + + "addl (" ASMSYM(FB_slModulo1) "), %%esi \n\t" + "addl (" ASMSYM(FB_slCanvasWidth) "), %%edi \n\t" + "movl (" ASMSYM(FB_pixHeight) "), %%ebx \n\t" + "subl $2, %%ebx \n\t" + + // for each row + "1: \n\t" // rowLoop + "pushl %%ebx \n\t" + "xorl %%ebx, %%ebx \n\t" + // process left edge pixel + "movd 0(%%esi, %%edx, 4), %%mm1 \n\t" + "movd 4(%%esi, %%edx, 4), %%mm2 \n\t" + "movd 0(%%esi), %%mm3 \n\t" + "movd 4(%%esi), %%mm4 \n\t" + "movd 0(%%esi, %%eax, 4), %%mm5 \n\t" + "movd 4(%%esi, %%eax, 4), %%mm6 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm5 \n\t" + "punpcklbw %%mm0, %%mm6 \n\t" + "paddw %%mm5, %%mm1 \n\t" + "paddw %%mm6, %%mm2 \n\t" + "pmullw (" ASMSYM(mmEch) "), %%mm1 \n\t" + "pmullw (" ASMSYM(mmMc) "), %%mm2 \n\t" + "pmullw (" ASMSYM(mmEm) "), %%mm3 \n\t" + "pmullw (" ASMSYM(mmMe) "), %%mm4 \n\t" + "paddw %%mm2, %%mm1 \n\t" + "paddw %%mm3, %%mm1 \n\t" + "paddw %%mm4, %%mm1 \n\t" + "paddsw (" ASMSYM(mmAdd) "), %%mm1 \n\t" + "pmulhw (" ASMSYM(mmInvDiv) "), %%mm1 \n\t" + "packuswb %%mm0, %%mm1 \n\t" + "movd " ASMSYM(aulRows) "(%%ebx), %%mm2 \n\t" + "movd %%mm1, " ASMSYM(aulRows) "(%%ebx) \n\t" + "movd %%mm2, 0(%%edi, %%edx, 4) \n\t" + "add $4, %%esi \n\t" + "add $4, %%edi \n\t" + "add $4, %%ebx \n\t" + + // for each pixel in current row + "mov (" ASMSYM(FB_pixWidth) "), %%ecx \n\t" + "sub $2, %%ecx \n\t" + "2: \n\t" // pixLoop + // prepare upper convolution row + "movd -4(%%esi, %%edx, 4), %%mm1 \n\t" + "movd 0(%%esi, %%edx, 4), %%mm2 \n\t" + "movd 4(%%esi, %%edx, 4), %%mm3 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + // prepare middle convolution row + "movd -4(%%esi), %%mm4 \n\t" + "movd 0(%%esi), %%mm5 \n\t" + "movd 4(%%esi), %%mm6 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm5 \n\t" + "punpcklbw %%mm0, %%mm6 \n\t" + // free some registers + "paddw %%mm3, %%mm1 \n\t" + "paddw %%mm4, %%mm2 \n\t" + "pmullw (" ASMSYM(mmMm) "), %%mm5 \n\t" + // prepare lower convolution row + "movd -4(%%esi, %%eax, 4), %%mm3 \n\t" + "movd 0(%%esi, %%eax, 4), %%mm4 \n\t" + "movd 4(%%esi, %%eax, 4), %%mm7 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm7 \n\t" + // calc weightened value + "paddw %%mm6, %%mm2 \n\t" + "paddw %%mm3, %%mm1 \n\t" + "paddw %%mm4, %%mm2 \n\t" + "paddw %%mm7, %%mm1 \n\t" + "pmullw (" ASMSYM(mmMe) "), %%mm2 \n\t" + "pmullw (" ASMSYM(mmMc) "), %%mm1 \n\t" + "paddw %%mm5, %%mm2 \n\t" + "paddw %%mm2, %%mm1 \n\t" + // calc and store wightened value + "paddsw (" ASMSYM(mmAdd) "), %%mm1 \n\t" + "pmulhw (" ASMSYM(mmInvDiv) "), %%mm1 \n\t" + "packuswb %%mm0, %%mm1 \n\t" + "movd " ASMSYM(aulRows) "(%%ebx), %%mm2 \n\t" + "movd %%mm1, " ASMSYM(aulRows) "(%%ebx) \n\t" + "movd %%mm2, (%%edi, %%edx, 4) \n\t" + // advance to next pixel + "addl $4, %%esi \n\t" + "addl $4, %%edi \n\t" + "addl $4, %%ebx \n\t" + "decl %%ecx \n\t" + "jnz 2b \n\t" // pixLoop + + // process right edge pixel + "movd -4(%%esi, %%edx, 4), %%mm1 \n\t" + "movd 0(%%esi, %%edx, 4), %%mm2 \n\t" + "movd -4(%%esi), %%mm3 \n\t" + "movd 0(%%esi), %%mm4 \n\t" + "movd -4(%%esi, %%eax, 4), %%mm5 \n\t" + "movd 0(%%esi, %%eax, 4), %%mm6 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm5 \n\t" + "punpcklbw %%mm0, %%mm6 \n\t" + "paddw %%mm5, %%mm1 \n\t" + "paddw %%mm6, %%mm2 \n\t" + "pmullw (" ASMSYM(mmMc) "), %%mm1 \n\t" + "pmullw (" ASMSYM(mmEch) "), %%mm2 \n\t" + "pmullw (" ASMSYM(mmMe) "), %%mm3 \n\t" + "pmullw (" ASMSYM(mmEm) "), %%mm4 \n\t" + "paddw %%mm2, %%mm1 \n\t" + "paddw %%mm3, %%mm1 \n\t" + "paddw %%mm4, %%mm1 \n\t" + "paddsw (" ASMSYM(mmAdd) "), %%mm1 \n\t" + "pmulhw (" ASMSYM(mmInvDiv) "), %%mm1 \n\t" + "packuswb %%mm0, %%mm1 \n\t" + "movd " ASMSYM(aulRows) "(%%ebx), %%mm2 \n\t" + "movd %%mm1, " ASMSYM(aulRows) "(%%ebx) \n\t" + "movd %%mm2, 0(%%edi, %%edx, 4) \n\t" + + // advance to next row + "addl (" ASMSYM(FB_slModulo1) "), %%esi \n\t" // slModulo1 + "addl (" ASMSYM(FB_slModulo1) "), %%edi \n\t" // slModulo1 + "popl %%ebx \n\t" + "decl %%ebx \n\t" + "jnz 1b \n\t" // rowLoop + +// ----------------------- process lower left corner + + "xorl %%ebx, %%ebx \n\t" + "movd 0(%%esi, %%edx, 4), %%mm1 \n\t" + "movd 4(%%esi, %%edx, 4), %%mm2 \n\t" + "movd 0(%%esi), %%mm3 \n\t" + "movd 4(%%esi), %%mm4 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "paddw %%mm4, %%mm1 \n\t" + "pmullw (" ASMSYM(mmEch) "), %%mm1 \n\t" + "pmullw (" ASMSYM(mmMc) "), %%mm2 \n\t" + "pmullw (" ASMSYM(mmCm) "), %%mm3 \n\t" + "paddw %%mm2, %%mm1 \n\t" + "paddw %%mm3, %%mm1 \n\t" + "paddsw (" ASMSYM(mmAdd) "), %%mm1 \n\t" + "pmulhw (" ASMSYM(mmInvDiv) "), %%mm1 \n\t" + "packuswb %%mm0, %%mm1 \n\t" + "movd " ASMSYM(aulRows) "(%%ebx), %%mm2 \n\t" + "movd %%mm1, (%%edi) \n\t" + "movd %%mm2, 0(%%edi, %%edx, 4) \n\t" + "add $4, %%esi \n\t" + "add $4, %%edi \n\t" + "add $4, %%ebx \n\t" + +// ----------------------- process lower edge pixels + + "movl (" ASMSYM(FB_pixWidth) "), %%ecx \n\t" // pixWidth + "subl $2, %%ecx \n\t" + // for each pixel + "3: \n\t" // lowerLoop + "movd -4(%%esi, %%edx, 4), %%mm1 \n\t" + "movd 0(%%esi, %%edx, 4), %%mm2 \n\t" + "movd 4(%%esi, %%edx, 4), %%mm3 \n\t" + "movd -4(%%esi), %%mm4 \n\t" + "movd 0(%%esi), %%mm5 \n\t" + "movd 4(%%esi), %%mm6 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "punpcklbw %%mm0, %%mm5 \n\t" + "punpcklbw %%mm0, %%mm6 \n\t" + "paddw %%mm3, %%mm1 \n\t" + "paddw %%mm6, %%mm4 \n\t" + "pmullw (" ASMSYM(mmMc) "), %%mm1 \n\t" + "pmullw (" ASMSYM(mmMe) "), %%mm2 \n\t" + "pmullw (" ASMSYM(mmEch) "), %%mm4 \n\t" + "pmullw (" ASMSYM(mmEm) "), %%mm5 \n\t" + "paddw %%mm2, %%mm1 \n\t" + "paddw %%mm4, %%mm1 \n\t" + "paddw %%mm5, %%mm1 \n\t" + "paddsw (" ASMSYM(mmAdd) "), %%mm1 \n\t" + "pmulhw (" ASMSYM(mmInvDiv) "), %%mm1 \n\t" + "packuswb %%mm0, %%mm1 \n\t" + "movd " ASMSYM(aulRows) "(%%ebx), %%mm2 \n\t" + "movd %%mm1, (%%edi) \n\t" + "movd %%mm2, 0(%%edi, %%edx, 4) \n\t" + // advance to next pixel + "addl $4, %%esi \n\t" + "addl $4, %%edi \n\t" + "addl $4, %%ebx \n\t" + "decl %%ecx \n\t" + "jnz 3b \n\t" // lowerLoop + +// ----------------------- lower right corners + + "movd -4(%%esi, %%edx, 4), %%mm1 \n\t" + "movd 0(%%esi, %%edx, 4), %%mm2 \n\t" + "movd -4(%%esi), %%mm3 \n\t" + "movd 0(%%esi), %%mm4 \n\t" + "punpcklbw %%mm0, %%mm1 \n\t" + "punpcklbw %%mm0, %%mm2 \n\t" + "punpcklbw %%mm0, %%mm3 \n\t" + "punpcklbw %%mm0, %%mm4 \n\t" + "paddw %%mm3, %%mm2 \n\t" + "pmullw (" ASMSYM(mmMc) "), %%mm1 \n\t" + "pmullw (" ASMSYM(mmEch) "), %%mm2 \n\t" + "pmullw (" ASMSYM(mmCm) "), %%mm4 \n\t" + "paddw %%mm2, %%mm1 \n\t" + "paddw %%mm4, %%mm1 \n\t" + "paddsw (" ASMSYM(mmAdd) "), %%mm1 \n\t" + "pmulhw (" ASMSYM(mmInvDiv) "), %%mm1 \n\t" + "packuswb %%mm0, %%mm1 \n\t" + "movd " ASMSYM(aulRows) "(%%ebx), %%mm2 \n\t" + "movd %%mm1, (%%edi) \n\t" + "movd %%mm2, 0(%%edi, %%edx, 4) \n\t" + "emms \n\t" + "popl %%ebx \n\t" + : // no outputs. + : // inputs are all globals. + : "eax", "ecx", "edx", "edi", "esi", "cc", "memory" + ); + +#else + #error Write inline asm for your platform. +#endif + // all done (finally) _pfGfxProfile.StopTimer( CGfxProfile::PTI_FILTERBITMAP); } @@ -1119,7 +2530,7 @@ void MakeMipmapTable( PIX pixU, PIX pixV, MipmapTable &mmt) static ULONG *_pulTexture; static PIX _pixTexWidth, _pixTexHeight; -extern BOOL _bSomeDarkExists = FALSE; +BOOL _bSomeDarkExists = FALSE; // set texture that will be used for all subsequent triangles diff --git a/Sources/Engine/Graphics/ImageInfo.cpp b/Sources/Engine/Graphics/ImageInfo.cpp index 0a91c49..de11af8 100644 --- a/Sources/Engine/Graphics/ImageInfo.cpp +++ b/Sources/Engine/Graphics/ImageInfo.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -43,10 +43,52 @@ struct PCXHeader SBYTE Filler[54]; }; +static __forceinline CTStream &operator>>(CTStream &strm, PCXHeader &t) { + strm>>t.MagicID; + strm>>t.Version; + strm>>t.Encoding; + strm>>t.PixelBits; + strm>>t.Xmin; + strm>>t.Ymin; + strm>>t.Xmax; + strm>>t.Ymax; + strm>>t.Hres; + strm>>t.Vres; + strm.Read_t(t.Palette, sizeof (t.Palette)); + strm>>t.Reserved; + strm>>t.Planes; + strm>>t.BytesPerLine; + strm>>t.PaletteInfo; + strm>>t.HscreenSize; + strm>>t.VscreenSize; + strm.Read_t(t.Filler, sizeof (t.Filler)); +} + +static __forceinline CTStream &operator<<(CTStream &strm, const PCXHeader &t) { + strm<>(CTStream &strm, TGAHeader &t) { + strm>>t.IdLength; + strm>>t.ColorMapType; + strm>>t.ImageType; + strm>>t.ColorMapSpec[5]; + strm>>t.Xorigin; + strm>>t.Yorigin; + strm>>t.Width; + strm>>t.Height; + strm>>t.BitsPerPixel; + strm>>t.Descriptor; + return(strm); +} + +static __forceinline CTStream &operator<<(CTStream &strm, const TGAHeader &t) { + strm<ExpectID_t( CChunkID("CTII")); if( inFile->GetSize_t() != 5*4) throw( "Invalid image info file."); - *inFile >> (PIX)ii_Width; - *inFile >> (PIX)ii_Height; - *inFile >> (SLONG)ii_BitsPerPixel; + SLONG tmp; + *inFile >> tmp; + ii_Width = (PIX) tmp; + *inFile >> tmp; + ii_Height = (PIX) tmp; + *inFile >> tmp; + ii_BitsPerPixel = (SLONG) tmp; // read image contents (all channels) ULONG pic_size = ii_Width*ii_Height * ii_BitsPerPixel/8; ii_Picture = (UBYTE*)AllocMemory( pic_size); inFile->ReadFullChunk_t( CChunkID("IPIC"), ii_Picture, pic_size); + + #if PLATFORM_BIGENDIAN + STUBBED("Byte order"); + #endif } // writes image info raw format to file @@ -104,6 +181,10 @@ void CImageInfo::Write_t( CTStream *outFile) const // throw char * // write image contents (all channels) ULONG pic_size = ii_Width*ii_Height * ii_BitsPerPixel/8; outFile->WriteFullChunk_t( CChunkID("IPIC"), ii_Picture, pic_size); + + #if PLATFORM_BIGENDIAN + STUBBED("Byte order"); + #endif } @@ -208,7 +289,7 @@ INDEX CImageInfo::GetGfxFileInfo_t( const CTFileName &strFileName) // throw char // lets assume it's a TGA file GfxFile.Open_t( strFileName, CTStream::OM_READ); - GfxFile.Read_t( &TGAhdr, sizeof( struct TGAHeader)); + GfxFile>>TGAhdr; GfxFile.Close(); // check for supported targa format @@ -224,7 +305,7 @@ INDEX CImageInfo::GetGfxFileInfo_t( const CTFileName &strFileName) // throw char // we miss Targa, so lets check for supported PCX format GfxFile.Open_t( strFileName, CTStream::OM_READ); - GfxFile.Read_t( &PCXhdr, sizeof( struct PCXHeader)); + GfxFile>>PCXhdr; GfxFile.Close(); // check for supported PCX format @@ -265,13 +346,15 @@ void CImageInfo::LoadTGA_t( const CTFileName &strFileName) // throw char * // load entire TGA file to memory, as is, and close it (no further usage) pTGABuffer = (UBYTE*)AllocMemory( slFileSize); +STUBBED("Byte swapping TGA data"); + TGAFile.Read_t( pTGABuffer, slFileSize); TGAFile.Close(); // TGA header starts at the begining of the TGA file pTGAHdr = (struct TGAHeader*)pTGABuffer; // TGA image bytes definition follows up - pTGAImage = pTGABuffer + sizeof(struct TGAHeader) + pTGAHdr->IdLenght; + pTGAImage = pTGABuffer + sizeof(struct TGAHeader) + pTGAHdr->IdLength; // detremine picture size dimensions ii_Width = (SLONG)pTGAHdr->Width; @@ -420,6 +503,7 @@ void CImageInfo::LoadPCX_t( const CTFileName &strFileName) // throw char * // load entire PCX file to memory, as is, and close it (no further usage) pPCXBuffer = (UBYTE*)AllocMemory( slFileSize); +STUBBED("Byte swapping PCX data"); PCXFile.Read_t( pPCXBuffer, slFileSize); PCXFile.Close(); diff --git a/Sources/Engine/Graphics/MultiMonitor.cpp b/Sources/Engine/Graphics/MultiMonitor.cpp index bfbd797..f5681e3 100644 --- a/Sources/Engine/Graphics/MultiMonitor.cpp +++ b/Sources/Engine/Graphics/MultiMonitor.cpp @@ -1,7 +1,11 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" + +#ifdef PLATFORM_WIN32 #include +#endif + #include #include #include @@ -11,12 +15,13 @@ // idea and original code courtesy of Christian Studer // added dynamic function loading and exception throwing -#pragma comment(lib, "advapi32.lib") - extern INDEX gfx_bDisableMultiMonSupport; extern INDEX gfx_ctMonitors; extern INDEX gfx_bMultiMonDisabled; +#ifdef PLATFORM_WIN32 +#pragma comment(lib, "advapi32.lib") + typedef BOOL EnumDisplayDevices_t( PVOID Unused, // not used; must be NULL DWORD iDevNum, // specifies display device @@ -121,6 +126,7 @@ void Mon_DisableEnable9x_t(BOOL bDisable) ThrowF_t(TRANS("Cannot change settings for at least one secondary monitor\n")); } } +#endif void MonitorsOff(void) { @@ -129,6 +135,7 @@ void MonitorsOff(void) return; } +#ifdef PLATFORM_WIN32 // check for WinNT or Win2k BOOL bNT = FALSE; OSVERSIONINFO osv; @@ -158,10 +165,14 @@ void MonitorsOff(void) CPrintF(TRANS(" Multimonitor support was allowed.\n")); } } +#else + CPrintF(TRANS("Multimonitor is not supported on this platform.\n")); +#endif } void MonitorsOn(void) { +#ifdef PLATFORM_WIN32 // if multimon was disabled if (gfx_bMultiMonDisabled) { CPrintF(TRANS("Multimonitor support was disabled.\n")); @@ -174,4 +185,8 @@ void MonitorsOn(void) CPrintF(TRANS(" error: %s\n"), strError); } } +#else + CPrintF(TRANS("Multimonitor is not supported on this platform.\n")); +#endif } + diff --git a/Sources/Engine/Graphics/OpenGL.h b/Sources/Engine/Graphics/OpenGL.h index 7b5f88c..0629a73 100644 --- a/Sources/Engine/Graphics/OpenGL.h +++ b/Sources/Engine/Graphics/OpenGL.h @@ -65,6 +65,10 @@ extern void (__stdcall *pglPNTrianglesfATI)( GLenum pname, GLfloat param); // additional tools ----------------------------------------------------- +#include +#include +#include + // set color from croteam format inline void glCOLOR( COLOR col) @@ -76,14 +80,14 @@ inline void glCOLOR( COLOR col) ((col >> 8) & 0x0000FF00) | ((col >> 24) ) ); -#elif (defined _MSC_VER) +#elif (defined __MSVC_INLINE__) __asm { mov eax,dword ptr [col] bswap eax mov dword ptr [col],eax } -#elif (defined __GNUC__) +#elif (defined __GNU_INLINE__) __asm__ __volatile__ ( "bswapl %%eax \n\t" : "=a" (col) diff --git a/Sources/Engine/Graphics/Raster.cpp b/Sources/Engine/Graphics/Raster.cpp index 6b37b2b..92ed498 100644 --- a/Sources/Engine/Graphics/Raster.cpp +++ b/Sources/Engine/Graphics/Raster.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Graphics/SDL/SDLAdapter.cpp b/Sources/Engine/Graphics/SDL/SDLAdapter.cpp new file mode 100644 index 0000000..17260c1 --- /dev/null +++ b/Sources/Engine/Graphics/SDL/SDLAdapter.cpp @@ -0,0 +1,23 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#include +#include + +#include "SDL.h" +#include + +ULONG DetermineDesktopWidth(void) +{ + SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN); + + assert(modes != NULL); + + if ((modes == NULL) || (modes == (SDL_Rect **) -1)) + return(600); // (*shrug*) + + return(modes[0]->w); +} // DetermineDesktopWidth + +// end of SDLAdapter.cpp ... + + diff --git a/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp b/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp new file mode 100644 index 0000000..5375a37 --- /dev/null +++ b/Sources/Engine/Graphics/SDL/SDLOpenGL.cpp @@ -0,0 +1,104 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#include +#include "SDL.h" + +static void FailFunction_t(const char *strName) { + ThrowF_t(TRANS("Required function %s not found."), strName); +} + +static void SetFunctionPointers_t(HINSTANCE hiOGL) +{ + const char *strName; + // get gl function pointers + + #define DLLFUNCTION(dll, output, name, inputs, params, required) \ + strName = #name; \ + p##name = (output (__stdcall*) inputs) SDL_GL_GetProcAddress(strName); \ + if( required && p##name == NULL) FailFunction_t(strName); + #include "Engine/Graphics/gl_functions.h" + #undef DLLFUNCTION +} + +BOOL CGfxLibrary::InitDriver_OGL(BOOL init3dfx) +{ + ASSERT( gl_hiDriver==NONE); + + if (SDL_Init(SDL_INIT_VIDEO) == -1) { + CPrintF( TRANS("Error starting OpenGL: %s\n"), SDL_GetError()); + return(FALSE); + } + + SDL_EnableUNICODE(1); + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + + // !!! FIXME: Is it safe to add new cvars for a specific platform? + const char *envlib = getenv("SERIOUS_GLLIBRARY"); + CTString strDriverFileName = ((envlib) ? envlib : "libGL.so.1"); + + if (SDL_GL_LoadLibrary(strDriverFileName) == -1) { + CPrintF(TRANS("Cannot load OpenGL driver '%s'"), (const char *) strDriverFileName); + SDL_QuitSubSystem(SDL_INIT_VIDEO); + return(FALSE); + } + + // prepare functions + SetFunctionPointers_t(gl_hiDriver); + + // done + return TRUE; +} + + +void CGfxLibrary::PlatformEndDriver_OGL(void) +{ + SDL_QuitSubSystem(SDL_INIT_VIDEO); +} + + +void *CGfxLibrary::OGL_GetProcAddress(const char *procname) +{ + return(SDL_GL_GetProcAddress(procname)); +} + + +// prepare current viewport for rendering thru OpenGL +BOOL CGfxLibrary::SetCurrentViewport_OGL(CViewPort *pvp) +{ + // if must init entire opengl + if( gl_ulFlags & GLF_INITONNEXTWINDOW) + { + gl_ulFlags &= ~GLF_INITONNEXTWINDOW; + // reopen window + pvp->CloseCanvas(); + pvp->OpenCanvas(); + // init now + gl_pvpActive = pvp; // remember as current viewport (must do that BEFORE InitContext) + go_hglRC = (void *) 0x0001; // !!! FIXME : This needs to be not null, but this is a hack. + + // init now + InitContext_OGL(); + gl_ulFlags |= GLF_HASACCELERATION; // might be a lie, though... + pvp->vp_ctDisplayChanges = gl_ctDriverChanges; + return TRUE; + } + + // if window was not set for this driver + if( pvp->vp_ctDisplayChangesCloseCanvas(); + pvp->OpenCanvas(); + + // set it + pvp->vp_ctDisplayChanges = gl_ctDriverChanges; + } + + // remember as current window + gl_pvpActive = pvp; + return TRUE; +} + +// end of SDLOpenGL.cpp ... + + diff --git a/Sources/Engine/Graphics/Shader.cpp b/Sources/Engine/Graphics/Shader.cpp index e728d98..b24d377 100644 --- a/Sources/Engine/Graphics/Shader.cpp +++ b/Sources/Engine/Graphics/Shader.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include #include @@ -39,7 +39,7 @@ static COLOR _colModel = 0x000000FF; // Model color static GFXColor _colLight = 0x000000FF; // Light color static FLOAT3D _vLightDir = FLOAT3D(0,0,0); // Light direction -static COLOR _colConstant = NULL; // current set color +static COLOR _colConstant = 0; // current set color static COLOR *_paColors = NULL; // array of colors to chose from static FLOAT *_paFloats = NULL; // array of floats to chose from static ULONG _ulFlags = 0; @@ -178,7 +178,7 @@ void shaCalculateLight(void) colAmbient = 0xFFFFFFFF; } colConstant.MultiplyRGBA(colLight,colAmbient); - shaSetConstantColor(ByteSwap(colConstant.abgr)); + shaSetConstantColor(ByteSwap(colConstant.ul.abgr)); // no vertex colors return; } @@ -187,17 +187,17 @@ void shaCalculateLight(void) _acolVtxColors.PopAll(); _acolVtxColors.Push(_ctVertices); - GFXColor colModel = (GFXColor)_colModel; // Model color - GFXColor &colAmbient = (GFXColor)_colAmbient; // Ambient color - GFXColor &colLight = (GFXColor)_colLight; // Light color - GFXColor &colSurface = (GFXColor)_colConstant; // shader color + GFXColor colModel = _colModel; // Model color + const GFXColor &colAmbient = _colAmbient; // Ambient color + const GFXColor &colLight = _colLight; // Light color + const GFXColor &colSurface = _colConstant; // shader color colModel.MultiplyRGBA(colModel,colSurface); UBYTE ubColShift = 8; - SLONG slar = colAmbient.r; - SLONG slag = colAmbient.g; - SLONG slab = colAmbient.b; + SLONG slar = colAmbient.ub.r; + SLONG slag = colAmbient.ub.g; + SLONG slab = colAmbient.ub.b; if(shaOverBrightningEnabled()) { slar = ClampUp(slar,127L); @@ -214,15 +214,15 @@ void shaCalculateLight(void) // for each vertex color for(INDEX ivx=0;ivx<_ctVertices;ivx++) { // calculate vertex light - FLOAT3D &vNorm = FLOAT3D(_paNormals[ivx].nx,_paNormals[ivx].ny,_paNormals[ivx].nz); + const FLOAT3D &vNorm = FLOAT3D(_paNormals[ivx].nx,_paNormals[ivx].ny,_paNormals[ivx].nz); FLOAT fDot = vNorm % _vLightDir; fDot = Clamp(fDot,0.0f,1.0f); SLONG slDot = NormFloatToByte(fDot); - _acolVtxColors[ivx].r = ClampUp(colModel.r * (slar + ((colLight.r * slDot)>>ubColShift))>>8,255L); - _acolVtxColors[ivx].g = ClampUp(colModel.g * (slag + ((colLight.g * slDot)>>ubColShift))>>8,255L); - _acolVtxColors[ivx].b = ClampUp(colModel.b * (slab + ((colLight.b * slDot)>>ubColShift))>>8,255L); - _acolVtxColors[ivx].a = colModel.a;//slDot; + _acolVtxColors[ivx].ub.r = ClampUp(colModel.ub.r * (slar + ((colLight.ub.r * slDot)>>ubColShift))>>8,255L); + _acolVtxColors[ivx].ub.g = ClampUp(colModel.ub.g * (slag + ((colLight.ub.g * slDot)>>ubColShift))>>8,255L); + _acolVtxColors[ivx].ub.b = ClampUp(colModel.ub.b * (slab + ((colLight.ub.b * slDot)>>ubColShift))>>8,255L); + _acolVtxColors[ivx].ub.a = colModel.ub.a;//slDot; } // Set current vertex color array _pcolVtxColors = &_acolVtxColors[0]; @@ -236,17 +236,17 @@ void shaCalculateLightForSpecular(void) _acolVtxColors.Push(_ctVertices); GFXColor colModel = (GFXColor)_colModel; // Model color - GFXColor &colAmbient = (GFXColor)_colAmbient; // Ambient color - GFXColor &colLight = (GFXColor)_colLight; // Light color - GFXColor &colSurface = (GFXColor)_colConstant; // shader color + const GFXColor &colAmbient = (GFXColor)_colAmbient; // Ambient color + const GFXColor &colLight = (GFXColor)_colLight; // Light color + const GFXColor &colSurface = (GFXColor)_colConstant; // shader color // colModel = MulColors(colModel.r,colSurface.abgr); colModel.MultiplyRGBA(colModel,colSurface); UBYTE ubColShift = 8; - SLONG slar = colAmbient.r; - SLONG slag = colAmbient.g; - SLONG slab = colAmbient.b; + SLONG slar = colAmbient.ub.r; + SLONG slag = colAmbient.ub.g; + SLONG slab = colAmbient.ub.b; if(shaOverBrightningEnabled()) { slar = ClampUp(slar,127L); @@ -263,15 +263,15 @@ void shaCalculateLightForSpecular(void) // for each vertex color for(INDEX ivx=0;ivx<_ctVertices;ivx++) { // calculate vertex light - FLOAT3D &vNorm = FLOAT3D(_paNormals[ivx].nx,_paNormals[ivx].ny,_paNormals[ivx].nz); + const FLOAT3D &vNorm = FLOAT3D(_paNormals[ivx].nx,_paNormals[ivx].ny,_paNormals[ivx].nz); FLOAT fDot = vNorm % _vLightDir; fDot = Clamp(fDot,0.0f,1.0f); SLONG slDot = NormFloatToByte(fDot); - _acolVtxColors[ivx].r = ClampUp(colModel.r * (slar + ((colLight.r * slDot)>>ubColShift))>>8,255L); - _acolVtxColors[ivx].g = ClampUp(colModel.g * (slag + ((colLight.g * slDot)>>ubColShift))>>8,255L); - _acolVtxColors[ivx].b = ClampUp(colModel.b * (slab + ((colLight.b * slDot)>>ubColShift))>>8,255L); - _acolVtxColors[ivx].a = slDot;//colModel.a;//slDot; + _acolVtxColors[ivx].ub.r = ClampUp(colModel.ub.r * (slar + ((colLight.ub.r * slDot)>>ubColShift))>>8,255L); + _acolVtxColors[ivx].ub.g = ClampUp(colModel.ub.g * (slag + ((colLight.ub.g * slDot)>>ubColShift))>>8,255L); + _acolVtxColors[ivx].ub.b = ClampUp(colModel.ub.b * (slab + ((colLight.ub.b * slDot)>>ubColShift))>>8,255L); + _acolVtxColors[ivx].ub.a = slDot;//colModel.ub.a;//slDot; } // Set current wertex array _pcolVtxColors = &_acolVtxColors[0]; @@ -541,13 +541,13 @@ FLOAT3D &shaGetLightDirection(void) // Get current light color COLOR &shaGetLightColor(void) { - return _colLight.abgr; + return _colLight.ul.abgr; } // Get current ambient volor COLOR &shaGetAmbientColor(void) { - return _colAmbient.abgr; + return _colAmbient.ul.abgr; } // Get current set color @@ -769,7 +769,7 @@ void CShader::Clear(void) ShaderFunc = NULL; GetShaderDesc = NULL; // release dll - if(hLibrary!=NULL) FreeLibrary(hLibrary); + if(hLibrary!=NULL) delete hLibrary; } // Count used memory @@ -796,41 +796,58 @@ void CShader::Read_t(CTStream *istrFile) strShaderInfo.ReadFromText_t(*istrFile, "Info: "); // create name of dll - #ifndef NDEBUG - fnmDLL = _fnmApplicationExe.FileDir()+fnmDLL.FileName()+/*_strModExt+*/"D"+fnmDLL.FileExt(); + #ifdef STATICALLY_LINKED + #define fnmExpanded NULL #else - fnmDLL = _fnmApplicationExe.FileDir()+fnmDLL.FileName()+/*_strModExt+*/fnmDLL.FileExt(); + #ifndef NDEBUG + fnmDLL = fnmDLL.FileDir()+"Debug\\"+fnmDLL.FileName()+/*_strModExt+*/"D"+fnmDLL.FileExt(); + #else + fnmDLL = fnmDLL.FileDir()+fnmDLL.FileName()+/*_strModExt+*/fnmDLL.FileExt(); + #endif + fnmDLL = CDynamicLoader::ConvertLibNameToPlatform(fnmDLL); + CTFileName fnmExpanded; + ExpandFilePath(EFP_READ | EFP_NOZIPS,fnmDLL,fnmExpanded); #endif - CTFileName fnmExpanded; - ExpandFilePath(EFP_READ | EFP_NOZIPS,fnmDLL,fnmExpanded); + // !!! FIXME : rcg12142001 Should I move this into CWin32DynamicLoader? + #ifdef PLATFORM_WIN32 // set new error mode - UINT iOldErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS); + const UINT iOldErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS); + #endif + // load dll - hLibrary = LoadLibraryA((const char*)fnmExpanded); + hLibrary = CDynamicLoader::GetInstance(fnmExpanded); + + // !!! FIXME : rcg12142001 Should I move this into CWin32DynamicLoader? + #ifdef PLATFORM_WIN32 // return last error mode SetErrorMode(iOldErrorMode); + #endif + // check if library has loaded - if(hLibrary==NULL) + const char *errmsg = hLibrary->GetError(); + if(errmsg != NULL) { // report error - istrFile->Throw_t("Error loading '%s' library",(const char*)fnmExpanded); + istrFile->Throw_t("Error loading '%s' library: %s",(const char*)fnmExpanded, errmsg); return; } + // get pointer to shader render function - ShaderFunc = (void(*)(void))GetProcAddress(hLibrary,(const char*)strShaderFunc); - // if error accured + ShaderFunc = (void(*)(void))hLibrary->FindSymbol(strShaderFunc); + // if error occured if(ShaderFunc==NULL) { // report error - istrFile->Throw_t("GetProcAddress 'ShaderFunc' Error"); + istrFile->Throw_t("CDynamicLoader::GetSymbol() 'ShaderFunc' Error: %s", hLibrary->GetError()); } // get pointer to shader info function - GetShaderDesc = (void(*)(ShaderDesc&))GetProcAddress(hLibrary,(const char*)strShaderInfo); - // if error accured - if(GetShaderDesc==NULL) { + GetShaderDesc = (void(*)(ShaderDesc&))hLibrary->FindSymbol(strShaderInfo); + // if error occured + if(GetShaderDesc==NULL) + { // report error - istrFile->Throw_t("GetProcAddress 'ShaderDesc' Error"); + istrFile->Throw_t("CDynamicLoader::GetSymbol() 'ShaderDesc' Error: %s", hLibrary->GetError()); } } diff --git a/Sources/Engine/Graphics/Shader.h b/Sources/Engine/Graphics/Shader.h index c3a4a0a..d19797a 100644 --- a/Sources/Engine/Graphics/Shader.h +++ b/Sources/Engine/Graphics/Shader.h @@ -51,7 +51,7 @@ public: CShader(); ~CShader(); - HINSTANCE hLibrary; + CDynamicLoader *hLibrary; void (*ShaderFunc)(void); void (*GetShaderDesc)(ShaderDesc &shDesc); @@ -202,21 +202,14 @@ ENGINE_API void shaSetHazeColorArray(GFXColor *paHazeColors); // Is overbrightning enabled ENGINE_API BOOL shaOverBrightningEnabled(void); -#if (defined _MSC_VER) - #define DECLSPEC_DLLEXPORT _declspec (dllexport) +#ifdef PLATFORM_WIN32 +#define SHADER_DECLSPEC _declspec(dllexport) #else - #define DECLSPEC_DLLEXPORT +#define SHADER_DECLSPEC #endif - -#define SHADER_MAIN(name) \ - extern "C" void DECLSPEC_DLLEXPORT Shader_##name (void);\ - SYMBOLLOCATOR(Shader_##name);\ - extern "C" void DECLSPEC_DLLEXPORT Shader_##name (void) - -#define SHADER_DESC(name,x) \ - extern "C" void DECLSPEC_DLLEXPORT Shader_Desc_##name (x);\ - SYMBOLLOCATOR(Shader_Desc_##name);\ - extern "C" void DECLSPEC_DLLEXPORT Shader_Desc_##name (x) +#define SHADER_MAIN(name) extern "C" void SHADER_DECLSPEC Shader_##name (void) +#define SHADER_DESC(name,x) extern "C" void SHADER_DECLSPEC Shader_Desc_##name (x) #endif /* include-once check. */ + diff --git a/Sources/Engine/Graphics/ShadowMap.cpp b/Sources/Engine/Graphics/ShadowMap.cpp index 0400f27..8dd1f91 100644 --- a/Sources/Engine/Graphics/ShadowMap.cpp +++ b/Sources/Engine/Graphics/ShadowMap.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include @@ -14,7 +14,7 @@ #include #include -#include +#include #define SHADOWMAXBYTES (256*256*4*4/3) @@ -275,7 +275,7 @@ SLONG CShadowMap::Uncache( void) sm_iFirstCachedMipLevel = 31; sm_pulCachedShadowMap = NULL; sm_slMemoryUsed = 0; - sm_tvLastDrawn = 0I64; + sm_tvLastDrawn = (__int64) 0; sm_iRenderFrame = -1; sm_ulFlags = NONE; sm_tpLocal.Clear(); @@ -295,7 +295,7 @@ void CShadowMap::Clear() sm_pulDynamicShadowMap = NULL; sm_iFirstMipLevel = 0; sm_slMemoryUsed = 0; - sm_tvLastDrawn = 0I64; + sm_tvLastDrawn = (__int64) 0; sm_mexOffsetX = 0; sm_mexOffsetY = 0; sm_mexWidth = 0; @@ -329,13 +329,21 @@ void CShadowMap::Read_old_t(CTStream *pstrm) // throw char * // pstrm->ExpectID_t( CChunkID("CTSM")); // read in Read_t() if( pstrm->GetSize_t() != 5*4) throw( TRANS("Invalid shadow cluster map file.")); - *pstrm >> (INDEX)sm_iFirstMipLevel; + INDEX idx; // this was the only way I could coerce GCC into playing. --ryan. + + *pstrm >> idx; + sm_iFirstMipLevel = idx; INDEX iNoOfMipmaps; - *pstrm >> (INDEX)iNoOfMipmaps; - *pstrm >> (MEX)sm_mexOffsetX; - *pstrm >> (MEX)sm_mexOffsetY; - *pstrm >> (MEX)sm_mexWidth; - *pstrm >> (MEX)sm_mexHeight; + *pstrm >> iNoOfMipmaps; + *pstrm >> idx; + sm_mexOffsetX = idx; + *pstrm >> idx; + sm_mexOffsetY = idx; + *pstrm >> idx; + sm_mexWidth = idx; + *pstrm >> idx; + sm_mexHeight = idx; + BOOL bStaticImagePresent, bAnimatingImagePresent; *pstrm >> (INDEX&)bStaticImagePresent; *pstrm >> (INDEX&)bAnimatingImagePresent; diff --git a/Sources/Engine/Graphics/Stereo.cpp b/Sources/Engine/Graphics/Stereo.cpp index 3a6a27c..e324a6a 100644 --- a/Sources/Engine/Graphics/Stereo.cpp +++ b/Sources/Engine/Graphics/Stereo.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include diff --git a/Sources/Engine/Graphics/Texture.cpp b/Sources/Engine/Graphics/Texture.cpp index ffb8554..7ac7595 100644 --- a/Sources/Engine/Graphics/Texture.cpp +++ b/Sources/Engine/Graphics/Texture.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include @@ -14,11 +14,10 @@ #include #include -#include +#include #include -#include - +#include extern INDEX tex_iNormalQuality; extern INDEX tex_iAnimationQuality; @@ -73,11 +72,7 @@ extern void UpdateTextureSettings(void) { // determine API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); -#else - ASSERT( eAPI==GAT_OGL || eAPI==GAT_NONE); -#endif // SE1_D3D + ASSERT(GfxValidApi(eAPI)); // set texture formats and compression TS.ts_tfRGB8 = TS.ts_tfRGBA8 = NONE; @@ -183,7 +178,7 @@ CTextureData::CTextureData() td_ulFlags = NONE; td_mexWidth = 0; td_mexHeight = 0; - td_tvLastDrawn = 0I64; + td_tvLastDrawn = (__int64) 0; td_iFirstMipLevel = 0; td_ctFineMipLevels = 0; @@ -670,11 +665,7 @@ void CTextureData::Read_t( CTStream *inFile) // determine API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); -#else // SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_NONE); -#endif // SE1_D3D + ASSERT(GfxValidApi(eAPI)); // determine driver context presence (must have at least 1 texture unit!) const BOOL bHasContext = (_pGfx->gl_ctRealTextureUnits>0); @@ -746,6 +737,10 @@ void CTextureData::Read_t( CTStream *inFile) if( iVersion==3) { // alloc memory block and read mip-maps inFile->Read_t( td_pulFrames, slTexSize); + #if PLATFORM_BIGENDIAN + for (SLONG i = 0; i < slTexSize/4; i++) + BYTESWAP(td_pulFrames[i]); + #endif } // if current version else { @@ -756,6 +751,10 @@ void CTextureData::Read_t( CTStream *inFile) if( bAlphaChannel) { // read texture with alpha channel from file inFile->Read_t( pulCurrentFrame, pixFrameSizeOnDisk *4); + #if PLATFORM_BIGENDIAN + for (SLONG i = 0; i < pixFrameSizeOnDisk; i++) + BYTESWAP(pulCurrentFrame[i]); + #endif } else { // read texture without alpha channel from file inFile->Read_t( pulCurrentFrame, pixFrameSizeOnDisk *3); @@ -784,7 +783,7 @@ void CTextureData::Read_t( CTStream *inFile) CTFileName fnTex = inFile->GetDescription(); if( fnTex == fnBaseTexture) { // generate exception - ThrowF_t( TRANS("Texture \"%s\" has same name as its base texture."), (CTString&)fnTex); + ThrowF_t( TRANS("Texture \"%s\" has same name as its base texture."), (const char *) (CTString&)fnTex); } else { // obtain base texture td_ptdBaseTexture = _pTextureStock->Obtain_t( fnBaseTexture); @@ -835,9 +834,9 @@ void CTextureData::Read_t( CTStream *inFile) FOREACHINDYNAMICARRAY( td_ptegEffect->teg_atesEffectSources, CTextureEffectSource, itEffectSource) { // read type of effect source - *inFile >> (ULONG) itEffectSource->tes_ulEffectSourceType; + *inFile >> itEffectSource->tes_ulEffectSourceType; // read structure holding effect source properties - inFile->Read_t( &itEffectSource->tes_tespEffectSourceProperties, sizeof(struct TextureEffectSourceProperties)); + *inFile >> itEffectSource->tes_tespEffectSourceProperties; // remember pointer to global effect itEffectSource->tes_ptegGlobalEffect = td_ptegEffect; // read count of effect pixels @@ -848,7 +847,8 @@ void CTextureData::Read_t( CTStream *inFile) // alocate needed ammount of members itEffectSource->tes_atepPixels.New( ctEffectSourcePixels); // read all effect pixels in one block - inFile->Read_t( &itEffectSource->tes_atepPixels[0], sizeof(struct TextureEffectPixel)*ctEffectSourcePixels); + for (INDEX i = 0; i < ctEffectSourcePixels; i++) + *inFile >> itEffectSource->tes_atepPixels[i]; } } // allocate memory for effect frame buffer @@ -868,7 +868,7 @@ void CTextureData::Read_t( CTStream *inFile) else { ThrowF_t( TRANS("Unrecognisable chunk ID (\"%s\") found while reading texture \"%s\"."), - (char*)idChunk, (CTString&)inFile->GetDescription() ); + (char*)idChunk, (const char *) (CTString&)inFile->GetDescription() ); } } // until we didn't reach end of file @@ -953,7 +953,9 @@ void CTextureData::Read_t( CTStream *inFile) break; } } - } // test texture for equality (i.e. determine if texture could be discardable in shade mode when in lowest mipmap) + } + + // test texture for equality (i.e. determine if texture could be discardable in shade mode when in lowest mipmap) if( td_ctFrames<2 && (!gap_bAllowSingleMipmap || td_ctFineMipLevels>1)) { // get last mipmap pointer INDEX ctLastPixels = Max(pixWidth,pixHeight) / Min(pixWidth,pixHeight); @@ -991,6 +993,10 @@ void CTextureData::Read_t( CTStream *inFile) // writes texutre to file void CTextureData::Write_t( CTStream *outFile) // throw char * { + #if PLATFORM_BIGENDIAN + STUBBED("Byte swapping"); + #endif + // cannot write textures that have been mangled somehow _bExport = FALSE; if( td_ptegEffect==NULL && IsModified()) throw( TRANS("Cannot write texture that has modified frames.")); @@ -999,7 +1005,7 @@ void CTextureData::Write_t( CTStream *outFile) // throw char * if( td_ptdBaseTexture != NULL) { CTFileName fnTex = outFile->GetDescription(); if( fnTex == td_ptdBaseTexture->GetName()) { - ThrowF_t( TRANS("Texture \"%s\" has same name as its base texture."), (CTString&)fnTex); + ThrowF_t( TRANS("Texture \"%s\" has same name as its base texture."), (const char *) (CTString&)fnTex); } } @@ -1155,12 +1161,7 @@ void CTextureData::SetAsCurrent( INDEX iFrameNo/*=0*/, BOOL bForceUpload/*=FALSE { // check API const GfxAPIType eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_D3D || eAPI==GAT_NONE); -#else // SE1_D3D - ASSERT( eAPI==GAT_OGL || eAPI==GAT_NONE); -#endif // SE1_D3D - + ASSERT(GfxValidApi(eAPI)); ASSERT( iFrameNo #include #include #include -#include +#include #include -#include +#include #include // asm shortcuts @@ -19,16 +19,58 @@ #define W word ptr #define B byte ptr +#if (defined USE_PORTABLE_C) +#define ASMOPT 0 +#elif (defined __MSVC_INLINE__) #define ASMOPT 1 +#elif (defined __GNU_INLINE__) +#define ASMOPT 1 +#else +#define ASMOPT 0 +#endif +static __int64 mmBaseWidthShift=0; +static __int64 mmBaseWidth=0; +static __int64 mmBaseWidthMask=0; +static __int64 mmBaseHeightMask=0; +static __int64 mmBaseMasks=0; +static __int64 mmShift=0; +#if (defined __GNUC__) +/* + * If these are "const" vars, they get optimized to hardcoded values when gcc + * builds with optimization, which means the linker can't resolve the + * references to them in the inline ASM. That's obnoxious. + */ +static __int64 mm1LO = 0x0000000000000001ll; +static __int64 mm1HI = 0x0000000100000000ll; +static __int64 mm1HILO = 0x0000000100000001ll; +static __int64 mm0001 = 0x0000000000000001ll; +static __int64 mm0010 = 0x0000000000010000ll; +static __int64 mm00M0 = 0x00000000FFFF0000ll; + +static void *force_syms_to_exist = NULL; +void asm_force_mm1LO() { force_syms_to_exist = &mm1LO; } +void asm_force_mm1HI() { force_syms_to_exist = &mm1HI; } +void asm_force_mm1HILO() { force_syms_to_exist = &mm1HILO; } +void asm_force_mm0001() { force_syms_to_exist = &mm0001; } +void asm_force_mm0010() { force_syms_to_exist = &mm0010; } +void asm_force_mm00M0() { force_syms_to_exist = &mm00M0; } +void asm_force_mmBaseWidthShift() { force_syms_to_exist = &mmBaseWidthShift; } +void asm_force_mmBaseWidth() { force_syms_to_exist = &mmBaseWidth; } +void asm_force_mmBaseWidthMask() { force_syms_to_exist = &mmBaseWidthMask; } +void asm_force_mmBaseHeightMask() { force_syms_to_exist = &mmBaseHeightMask; } +void asm_force_mmBaseMasks() { force_syms_to_exist = &mmBaseMasks; } +void asm_force_mmShift() { force_syms_to_exist = &mmShift; } + +#else static const __int64 mm1LO = 0x0000000000000001; static const __int64 mm1HI = 0x0000000100000000; static const __int64 mm1HILO = 0x0000000100000001; static const __int64 mm0001 = 0x0000000000000001; static const __int64 mm0010 = 0x0000000000010000; static const __int64 mm00M0 = 0x00000000FFFF0000; -static __int64 mmBaseWidthShift=0, mmBaseWidth=0, mmBaseWidthMask=0, mmBaseHeightMask=0, mmBaseMasks=0, mmShift=0; +#endif // speed table @@ -187,7 +229,10 @@ inline void PutPixel25UBYTE_FIRE( PIX pixU, PIX pixV, INDEX iHeightMid) // WATER EFFECTS ///////////////////////////////////////////////////////////////////// -#define DISTORSION 3 //3 + +// WARNING: Changing this value will BREAK the inline asm on +// GNU-based platforms (Linux, etc.) YOU HAVE BEEN WARNED. +#define DISTORTION 3 //3 ///////////////// random surfer @@ -201,7 +246,7 @@ void InitializeRandomSurfer(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { Surfer &sf = - ((Surfer&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((Surfer *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); sf.fU = pixU0; sf.fV = pixV0; sf.fAngle = RNDW&7; @@ -210,12 +255,12 @@ void InitializeRandomSurfer(CTextureEffectSource *ptes, void AnimateRandomSurfer(CTextureEffectSource *ptes) { Surfer &sf = - ((Surfer&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((Surfer *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); - PutPixel9SLONG_WATER(sf.fU, sf.fV, 125); + PutPixel9SLONG_WATER((long) sf.fU, (long) sf.fV, 125); sf.fU += 2*sin(sf.fAngle); sf.fV += 2*cos(sf.fAngle); - PutPixel9SLONG_WATER(sf.fU, sf.fV, 250); + PutPixel9SLONG_WATER((long) sf.fU, (long) sf.fV, 250); if((RNDW&15)==0) { sf.fAngle += 3.14f/7.0f; @@ -269,7 +314,7 @@ void AnimateRaindrops(CTextureEffectSource *ptes, int iHeight) rd.iIndex++; if (rd.iIndex < 8) { - PutPixel9SLONG_WATER(rd.pixU, rd.pixV, sin(rd.iIndex/4.0f*(-3.14f))*rd.iHeight); + PutPixel9SLONG_WATER(rd.pixU, rd.pixV, (long) sin(rd.iIndex/4.0f*(-3.14f))*rd.iHeight); } } else { rd.pixU = RNDW&(_pixBufferWidth -1); @@ -302,7 +347,7 @@ void InitializeOscilator(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { Oscilator &os = - ((Oscilator&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((Oscilator *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); os.pixU = pixU0; os.pixV = pixV0; os.fAngle = -3.14f; @@ -311,8 +356,8 @@ void InitializeOscilator(CTextureEffectSource *ptes, void AnimateOscilator(CTextureEffectSource *ptes) { Oscilator &os = - ((Oscilator&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); - PutPixel9SLONG_WATER(os.pixU, os.pixV, sin(os.fAngle)*150); + (*((Oscilator *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); + PutPixel9SLONG_WATER(os.pixU, os.pixV, (long) sin(os.fAngle)*150); os.fAngle += (3.14f/6); } @@ -329,7 +374,7 @@ void InitializeVertLine(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { VertLine &vl = - ((VertLine&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((VertLine *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); vl.pixU = pixU0; vl.pixV = pixV0; vl.fAngle = -3.14f; @@ -343,10 +388,10 @@ void InitializeVertLine(CTextureEffectSource *ptes, void AnimateVertLine(CTextureEffectSource *ptes) { VertLine &vl = - ((VertLine&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((VertLine *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); PIX pixV = vl.pixV; for (int iCnt=0; iCnttes_tespEffectSourceProperties.tesp_achDummy); + (*((HortLine *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); hl.pixU = pixU0; hl.pixV = pixV0; hl.fAngle = -3.14f; @@ -379,10 +424,10 @@ void InitializeHortLine(CTextureEffectSource *ptes, void AnimateHortLine(CTextureEffectSource *ptes) { HortLine &hl = - ((HortLine&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((HortLine *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); PIX pixU = hl.pixU; for (int iCnt=0; iCnttes_tespEffectSourceProperties.tesp_achDummy); + (*((FirePoint *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); ft.pixU = pixU0; ft.pixV = pixV0; } @@ -412,7 +457,7 @@ void InitializeFirePoint(CTextureEffectSource *ptes, void AnimateFirePoint(CTextureEffectSource *ptes) { FirePoint &ft = - ((FirePoint&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FirePoint *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); PutPixel9UBYTE_FIRE(ft.pixU, ft.pixV, 255); } @@ -420,7 +465,7 @@ void InitializeRandomFirePoint(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { FirePoint &ft = - ((FirePoint&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FirePoint *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); ft.pixU = pixU0; ft.pixV = pixV0; } @@ -428,7 +473,7 @@ void InitializeRandomFirePoint(CTextureEffectSource *ptes, void AnimateRandomFirePoint(CTextureEffectSource *ptes) { FirePoint &ft = - ((FirePoint&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FirePoint *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); PutPixel9UBYTE_FIRE(ft.pixU, ft.pixV, RNDW&255); } @@ -436,7 +481,7 @@ void InitializeFireShakePoint(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { FirePoint &ft = - ((FirePoint&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FirePoint *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); ft.pixU = pixU0; ft.pixV = pixV0; } @@ -444,7 +489,7 @@ void InitializeFireShakePoint(CTextureEffectSource *ptes, void AnimateFireShakePoint(CTextureEffectSource *ptes) { FirePoint &ft = - ((FirePoint&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FirePoint *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); UBYTE pixU, pixV; pixU = RNDW%3 - 1; pixV = RNDW%3 - 1; @@ -466,7 +511,7 @@ void InitializeFirePlace(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { FirePlace &fp = - ((FirePlace&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FirePlace *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); fp.pixU = pixU0; fp.pixV = pixV0; fp.ubWidth = abs(pixU1-pixU0); @@ -482,7 +527,7 @@ void AnimateFirePlace(CTextureEffectSource *ptes) { INDEX iIndex; FirePlace &fp = - ((FirePlace&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FirePlace *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); ULONG ulRND = RNDW&255; // match if (ulRND>200) { @@ -543,7 +588,7 @@ void InitializeFireRoler(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { FireRoler &fr = - ((FireRoler&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireRoler *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); fr.pixU = pixU0; fr.pixV = pixV0; if (pixU0==pixU1 && pixV0==pixV1) { @@ -564,15 +609,15 @@ void InitializeFireRoler(CTextureEffectSource *ptes, void AnimateFireRoler(CTextureEffectSource *ptes) { FireRoler &fr = - ((FireRoler&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); - PutPixel9UBYTE_FIRE(cos(fr.fAngle)*fr.fRadiusU + fr.pixU, - sin(fr.fAngle)*fr.fRadiusV + fr.pixV, 255); + (*((FireRoler *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); + PutPixel9UBYTE_FIRE((long) (cos(fr.fAngle)*fr.fRadiusU + fr.pixU), + (long) (sin(fr.fAngle)*fr.fRadiusV + fr.pixV), 255); fr.fAngle += fr.fAngleAdd; - PutPixel9UBYTE_FIRE(cos(fr.fAngle)*fr.fRadiusU + fr.pixU, - sin(fr.fAngle)*fr.fRadiusV + fr.pixV, 200); + PutPixel9UBYTE_FIRE((long) (cos(fr.fAngle)*fr.fRadiusU + fr.pixU), + (long) (sin(fr.fAngle)*fr.fRadiusV + fr.pixV), 200); fr.fAngle += fr.fAngleAdd; - PutPixel9UBYTE_FIRE(cos(fr.fAngle)*fr.fRadiusU + fr.pixU, - sin(fr.fAngle)*fr.fRadiusV + fr.pixV, 150); + PutPixel9UBYTE_FIRE((long) (cos(fr.fAngle)*fr.fRadiusU + fr.pixU), + (long) (sin(fr.fAngle)*fr.fRadiusV + fr.pixV), 150); fr.fAngle += fr.fAngleAdd; } @@ -597,7 +642,7 @@ void InitializeFireFall(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { FireFall &ff = - ((FireFall&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireFall *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); ff.pixU = pixU0; ff.pixV = pixV0; if (pixU0==pixU1) { @@ -619,7 +664,7 @@ void InitializeFireFall(CTextureEffectSource *ptes, void AnimateFireFall(CTextureEffectSource *ptes) { FireFall &ff = - ((FireFall&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireFall *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); // animate fall points for (INDEX iIndex=0; iIndextes_atepPixels[iIndex]); @@ -674,7 +719,7 @@ void InitializeFireFountain(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { FireFountain &ff = - ((FireFountain&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireFountain *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); ff.pixU = pixU0; ff.pixV = pixV0; // fountain width @@ -707,7 +752,7 @@ void InitializeFireFountain(CTextureEffectSource *ptes, void AnimateFireFountain(CTextureEffectSource *ptes) { FireFountain &ff = - ((FireFountain&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireFountain *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); // animate fountain points for (INDEX iIndex=0; iIndextes_atepPixels[iIndex]); @@ -757,7 +802,7 @@ void InitializeFireSideFountain(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { FireSideFountain &fsf = - ((FireSideFountain&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireSideFountain *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); fsf.pixU = pixU0; fsf.pixV = pixV0; // fountain width @@ -786,7 +831,7 @@ void InitializeFireSideFountain(CTextureEffectSource *ptes, void AnimateFireSideFountain(CTextureEffectSource *ptes) { FireSideFountain &fsf = - ((FireSideFountain&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireSideFountain *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); // animate fountain points for (INDEX iIndex=0; iIndextes_atepPixels[iIndex]); @@ -833,7 +878,7 @@ void InitializeFireLightning(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { FireLightning &fl = - ((FireLightning&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireLightning *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); fl.fpixUFrom = (FLOAT) pixU0; fl.fpixVFrom = (FLOAT) pixV0; if (pixU0==pixU1 && pixV0==pixV1) { @@ -863,7 +908,7 @@ void AnimateFireLightning(CTextureEffectSource *ptes) ULONG ulDist; FireLightning &fl = - ((FireLightning&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireLightning *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); // last point -> starting point fLastU = fl.fpixUFrom; fLastV = fl.fpixVFrom; @@ -923,7 +968,7 @@ void InitializeFireLightningBall(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { FireLightningBall &flb = - ((FireLightningBall&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireLightningBall *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); flb.fpixU = (FLOAT) pixU0; flb.fpixV = (FLOAT) pixV0; if (pixU0==pixU1 && pixV0==pixV1) { @@ -944,7 +989,7 @@ void AnimateFireLightningBall(CTextureEffectSource *ptes) ULONG ulDist; FireLightningBall &flb = - ((FireLightningBall&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireLightningBall *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); for (int iBalls=0; iBalls starting point fLastU = flb.fpixU; @@ -1018,7 +1063,7 @@ void InitializeFireSmoke(CTextureEffectSource *ptes, PIX pixU0, PIX pixV0, PIX pixU1, PIX pixV1) { FireSmoke &fs = - ((FireSmoke&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireSmoke *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); fs.fpixU = (FLOAT) pixU0; fs.fpixV = (FLOAT) pixV0; if (pixU0==pixU1 && pixV0==pixV1) { @@ -1041,7 +1086,7 @@ void AnimateFireSmoke(CTextureEffectSource *ptes) UBYTE pixU, pixV; FireSmoke &fs = - ((FireSmoke&) ptes->tes_tespEffectSourceProperties.tesp_achDummy); + (*((FireSmoke *) ptes->tes_tespEffectSourceProperties.tesp_achDummy)); // animate smoke points for (INDEX iIndex=0; iIndextes_atepPixels[iIndex]); @@ -1195,6 +1240,8 @@ static void AnimateWater( SLONG slDensity) #define PIXEL(u,v) pulTextureBase[ ((u)&(SLONG&)mmBaseWidthMask) + ((v)&(SLONG&)mmBaseHeightMask) *pixBaseWidth] +static ULONG _slHeightMapStep_renderWater = 0; +static PIX _pixBaseWidth_renderWater = 0; #pragma warning(disable: 4731) static void RenderWater(void) @@ -1225,7 +1272,7 @@ static void RenderWater(void) SLONG slHeightMapStep, slHeightRowStep; #if ASMOPT == 1 - + #if (defined __MSVC_INLINE__) __asm { push ebx bsf ecx,D [_pixTexWidth] @@ -1235,7 +1282,7 @@ static void RenderWater(void) mov D [slHeightMapStep],eax bsf edx,eax - add edx,DISTORSION+2-1 + add edx,DISTORTION+2-1 mov D [mmShift],edx sub eax,2 @@ -1296,12 +1343,108 @@ pixLoop: pop ebx } + #elif (defined __GNU_INLINE__) + // rcg12152001 needed extra registers. :( + _slHeightMapStep_renderWater = slHeightMapStep; + _pixBaseWidth_renderWater = pixBaseWidth; + + __asm__ __volatile__ ( + "pushl %%ebx \n\t" // GCC needs this. + "movl (" ASMSYM(_pixBaseWidth_renderWater) "),%%ebx \n\t" + + "pushl %%eax \n\t" // pixBaseHeight + "pushl %%ebx \n\t" // pixBaseWidth + "pushl %%ecx \n\t" // pswHeightMap + "pushl %%edx \n\t" // pulTexture + "pushl %%esi \n\t" // pulTextureBase + "pushl %%edi \n\t" // slHeightRowStep + + "bsfl (" ASMSYM(_pixTexWidth) "), %%ecx \n\t" + "decl %%ecx \n\t" + "movl (" ASMSYM(_pixBufferWidth) "), %%eax \n\t" + "sarl %%cl, %%eax \n\t" + "movl %%eax, (" ASMSYM(_slHeightMapStep_renderWater) ") \n\t" + + "bsfl %%eax, %%edx \n\t" + "addl $4, %%edx \n\t" + "movl %%edx, (" ASMSYM(mmShift) ") \n\t" + + "subl $2, %%eax \n\t" + "imul (" ASMSYM(_pixBufferWidth) "), %%eax \n\t" + "movl %%eax, (%%esp) \n\t" // slHeightRowStep + + "movl 16(%%esp), %%eax \n\t" // pixBaseWidth + "movl 20(%%esp), %%edx \n\t" // pixBaseHeight + "shll $16, %%edx \n\t" + "orl %%edx, %%eax \n\t" + "subl $0x00010001, %%eax \n\t" + "movl %%eax, (" ASMSYM(mmBaseMasks) ") \n\t" + + "movl 16(%%esp), %%eax \n\t" // pixBaseWidth + "shl $16, %%eax \n\t" + "orl $1, %%eax \n\t" + "movl %%eax, (" ASMSYM(mmBaseWidth) ") \n\t" + + "movl 12(%%esp), %%ebx \n\t" // pswHeightMap + "movl 4(%%esp), %%esi \n\t" // pulTextureBase + "movl 8(%%esp), %%edi \n\t" // pulTexture + "pxor %%mm6, %%mm6 \n\t" // MM5 = 0 | 0 || pixV | pixU + "movl (" ASMSYM(_pixBufferWidth) "), %%eax \n\t" + "movl (" ASMSYM(_pixTexHeight) "), %%edx \n\t" + + "0: \n\t" // rowLoop + "pushl %%edx \n\t" + "movl (" ASMSYM(_pixTexWidth) "), %%ecx \n\t" + "1: \n\t" // pixLoop + "movd (%%ebx), %%mm1 \n\t" + "movd (%%ebx, %%eax, 2), %%mm3 \n\t" + "movq %%mm1, %%mm2 \n\t" + "psubw %%mm1, %%mm3 \n\t" + "pslld $16, %%mm1 \n\t" + "psubw %%mm1, %%mm2 \n\t" + "pand (" ASMSYM(mm00M0) "), %%mm2 \n\t" + "por %%mm3, %%mm2 \n\t" + "psraw (" ASMSYM(mmShift) "), %%mm2 \n\t" + + "paddw %%mm6, %%mm2 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm2 \n\t" + "pmaddwd (" ASMSYM(mmBaseWidth) "), %%mm2 \n\t" + "movd %%mm2, %%edx \n\t" + "movl (%%esi, %%edx, 4), %%edx \n\t" + "movl %%edx, (%%edi) \n\t" + + // advance to next texture pixel + "addl (" ASMSYM(_slHeightMapStep_renderWater) "), %%ebx \n\t" + "addl $4, %%edi \n\t" + "paddd (" ASMSYM(mm0001) "), %%mm6 \n\t" + "decl %%ecx \n\t" + "jnz 1b \n\t" // pixLoop + + // advance to next texture row + "popl %%edx \n\t" + "addl (%%esp), %%ebx \n\t" // slHeightRowStep + "paddd (" ASMSYM(mm0010) "), %%mm6 \n\t" + "decl %%edx \n\t" + "jnz 0b \n\t" // rowLoop + "addl $24, %%esp \n\t" // lose our locals... + "popl %%ebx \n\t" // restore GCC's register. + "emms \n\t" + : // no outputs. + : "a" (pixBaseHeight), "c" (pswHeightMap), + "d" (pulTexture), "S" (pulTextureBase), "D" (slHeightRowStep) + : "cc", "memory" + ); + + #else + #error fill in for your platform. + #endif + #else PIX pixPos, pixDU, pixDV; - slHeightMapStep = _pixBufferWidth/pixBaseWidth + slHeightMapStep = _pixBufferWidth/pixBaseWidth; slHeightRowStep = (slHeightMapStep-1)*_pixBufferWidth; - mmShift = DISTORSION+ FastLog2(slHeightMapStep) +2; + mmShift = DISTORTION+ FastLog2(slHeightMapStep) +2; for( PIX pixV=0; pixV<_pixTexHeight; pixV++) { // row loop for( PIX pixU=0; pixU<_pixTexWidth; pixU++) @@ -1326,6 +1469,7 @@ pixLoop: #if ASMOPT == 1 + #if (defined __MSVC_INLINE__) __asm { push ebx bsf eax,D [pixBaseWidth] @@ -1358,7 +1502,7 @@ pixLoop2: punpckldq mm0,mm0 psubd mm1,mm0 movq mm0,mm6 - pslld mm0,DISTORSION+1+1 + pslld mm0,DISTORTION+1+1 paddd mm1,mm0 // MM1 = slV_00 | slU_00 movd mm2,D [ebx+ 4] @@ -1370,7 +1514,7 @@ pixLoop2: psubd mm2,mm0 movq mm0,mm6 paddd mm0,Q [mm1LO] - pslld mm0,DISTORSION+1+1 + pslld mm0,DISTORTION+1+1 paddd mm2,mm0 // MM2 = slV_01 | slU_01 movd mm3,D [ebx+ eax*2 +2] @@ -1382,7 +1526,7 @@ pixLoop2: psubd mm3,mm0 movq mm0,mm6 paddd mm0,Q [mm1HI] - pslld mm0,DISTORSION+1+1 + pslld mm0,DISTORTION+1+1 paddd mm3,mm0 // MM3 = slV_10 | slU_10 movd mm4,D [ebx+ eax*2 +4] @@ -1394,11 +1538,11 @@ pixLoop2: psubd mm4,mm0 movq mm0,mm6 paddd mm0,Q [mm1HILO] - pslld mm0,DISTORSION+1+1 + pslld mm0,DISTORTION+1+1 paddd mm4,mm0 // MM4 = slV_11 | slU_11 movq mm0,mm1 - psrad mm0,DISTORSION+1+0 + psrad mm0,DISTORTION+1+0 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1409,7 +1553,7 @@ pixLoop2: movq mm0,mm1 paddd mm0,mm2 - psrad mm0,DISTORSION+1+1 + psrad mm0,DISTORTION+1+1 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1420,7 +1564,7 @@ pixLoop2: movq mm0,mm1 paddd mm0,mm3 - psrad mm0,DISTORSION+1+1 + psrad mm0,DISTORTION+1+1 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1432,7 +1576,7 @@ pixLoop2: paddd mm1,mm2 paddd mm1,mm3 paddd mm1,mm4 - psrad mm1,DISTORSION+1+2 + psrad mm1,DISTORTION+1+2 pand mm1,Q [mmBaseMasks] movq mm7,mm1 psrlq mm7,Q [mmBaseWidthShift] @@ -1457,6 +1601,154 @@ pixLoop2: pop ebx } + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "pushl %%ebx \n\t" // GCC's register. + "movl %%ecx, %%ebx \n\t" + "bsfl %%eax, %%eax \n\t" // pixBaseWidth + "movl $32, %%edx \n\t" + "subl %%eax, %%edx \n\t" + "movl %%edx, (" ASMSYM(mmBaseWidthShift) ") \n\t" + + "movq (" ASMSYM(mmBaseHeightMask) "), %%mm0 \n\t" + "psllq $32, %%mm0 \n\t" + "por (" ASMSYM(mmBaseWidthMask) "), %%mm0 \n\t" + "movq %%mm0, (" ASMSYM(mmBaseMasks) ") \n\t" + + "pxor %%mm6, %%mm6 \n\t" // MM6 = pixV|pixU + + // (These registers were loaded here in the original version...) + //"movl (pswHeightMap), %%ebx \n\t" + //"movl (pulTextureBase), %%esi \n\t" + //"movl (pulTexture), %%edi \n\t" + + "movl (" ASMSYM(_pixBufferHeight) "), %%edx \n\t" + + "0: \n\t" // rowLoop2 + "pushl %%edx \n\t" + "movl (" ASMSYM(_pixTexWidth) "), %%edx \n\t" + "movl (" ASMSYM(_pixBufferWidth) "), %%ecx \n\t" + + "1: \n\t" // pixLoop2 + "mov (" ASMSYM(_pixBufferWidth) "), %%eax \n\t" + + "movd 2(%%ebx), %%mm1 \n\t" + "movd 0(%%ebx, %%eax, 2), %%mm0 \n\t" + "psllq $32, %%mm0 \n\t" + "por %%mm0, %%mm1 \n\t" + "movd (%%ebx), %%mm0 \n\t" + "punpckldq %%mm0, %%mm0 \n\t" + "psubd %%mm0, %%mm1 \n\t" + "movq %%mm6, %%mm0 \n\t" + "pslld $5, %%mm0 \n\t" + "paddd %%mm0, %%mm1 \n\t" // MM1 = slV_00 | slU_00 + + "movd 4(%%ebx), %%mm2 \n\t" + "movd 2(%%ebx, %%eax, 2), %%mm0 \n\t" + "psllq $32, %%mm0 \n\t" + "por %%mm0, %%mm2 \n\t" + "movd 2(%%ebx), %%mm0 \n\t" + "punpckldq %%mm0, %%mm0 \n\t" + "psubd %%mm0, %%mm2 \n\t" + "movq %%mm6, %%mm0 \n\t" + "paddd (" ASMSYM(mm1LO) "), %%mm0 \n\t" + "pslld $5, %%mm0 \n\t" + "paddd %%mm0, %%mm2 \n\t" // MM2 = slV_01 | slU_01 + + "movd 2(%%ebx, %%eax, 2), %%mm3 \n\t" + "movd (%%ebx, %%eax, 4), %%mm0 \n\t" + "psllq $32, %%mm0 \n\t" + "por %%mm0, %%mm3 \n\t" + "movd (%%ebx, %%eax, 2), %%mm0 \n\t" + "punpckldq %%mm0, %%mm0 \n\t" + "psubd %%mm0, %%mm3 \n\t" + "movq %%mm6, %%mm0 \n\t" + "paddd (" ASMSYM(mm1HI) "), %%mm0 \n\t" + "pslld $5, %%mm0 \n\t" + "paddd %%mm0, %%mm3 \n\t" // MM3 = slV_10 | slU_10 + + "movd 4(%%ebx, %%eax, 2), %%mm4 \n\t" + "movd 2(%%ebx, %%eax, 4), %%mm0 \n\t" + "psllq $32, %%mm0 \n\t" + "por %%mm0, %%mm4 \n\t" + "movd 2(%%ebx, %%eax, 2), %%mm0 \n\t" + "punpckldq %%mm0, %%mm0 \n\t" + "psubd %%mm0, %%mm4 \n\t" + "movq %%mm6, %%mm0 \n\t" + "paddd (" ASMSYM(mm1HILO) "), %%mm0 \n\t" + "pslld $5, %%mm0 \n\t" + "paddd %%mm0, %%mm4 \n\t" // MM4 = slV_11 | slU_11 + + "movq %%mm1, %%mm0 \n\t" + "psrad $4, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, (%%edi) \n\t" + + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "psrad $5, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 4(%%edi) \n\t" + + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "psrad $5, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, (%%edi, %%edx, 4) \n\t" + + "paddd %%mm2, %%mm1 \n\t" + "paddd %%mm3, %%mm1 \n\t" + "paddd %%mm4, %%mm1 \n\t" + "psrad $6, %%mm1 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm1 \n\t" + "movq %%mm1, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm1 \n\t" + "movd %%mm1, %%eax \n\t" + "mov (%%esi, %%eax, 4), %%eax \n\t" + "mov %%eax, 4(%%edi, %%edx, 4) \n\t" + + // advance to next texture pixels + "paddd (" ASMSYM(mm1LO) "), %%mm6 \n\t" + "addl $8, %%edi \n\t" + "addl $2, %%ebx \n\t" + "decl %%ecx \n\t" + "jnz 1b \n\t" // pixLoop2 + + // advance to next texture row + "leal (%%edi, %%edx, 4), %%edi \n\t" + "popl %%edx \n\t" + "paddd (" ASMSYM(mm1HI) "), %%mm6 \n\t" + "decl %%edx \n\t" + "jnz 0b \n\t" // rowLoop2 + "popl %%ebx \n\t" // GCC's value. + "emms \n\t" + : // no outputs. + : "a" (pixBaseWidth), "c" (pswHeightMap), + "S" (pulTextureBase), "D" (pulTexture) + : "edx", "cc", "memory" + ); + + #else + #error fill in for you platform. + #endif + + #else SLONG slU_00, slU_01, slU_10, slU_11; @@ -1465,19 +1757,19 @@ pixLoop2: { // row loop for( PIX pixU=0; pixU<_pixBufferWidth; pixU++) { // texel loop - slU_00 = pswHeightMap[_pixBufferWidth*0+1] - pswHeightMap[_pixBufferWidth*0+0] + ((pixU+0)<<(DISTORSION+1+1)); - slV_00 = pswHeightMap[_pixBufferWidth*1+0] - pswHeightMap[_pixBufferWidth*0+0] + ((pixV+0)<<(DISTORSION+1+1)); - slU_01 = pswHeightMap[_pixBufferWidth*0+2] - pswHeightMap[_pixBufferWidth*0+1] + ((pixU+1)<<(DISTORSION+1+1)); - slV_01 = pswHeightMap[_pixBufferWidth*1+1] - pswHeightMap[_pixBufferWidth*0+1] + ((pixV+0)<<(DISTORSION+1+1)); - slU_10 = pswHeightMap[_pixBufferWidth*1+1] - pswHeightMap[_pixBufferWidth*1+0] + ((pixU+0)<<(DISTORSION+1+1)); - slV_10 = pswHeightMap[_pixBufferWidth*2+0] - pswHeightMap[_pixBufferWidth*1+0] + ((pixV+1)<<(DISTORSION+1+1)); - slU_11 = pswHeightMap[_pixBufferWidth*1+2] - pswHeightMap[_pixBufferWidth*1+1] + ((pixU+1)<<(DISTORSION+1+1)); - slV_11 = pswHeightMap[_pixBufferWidth*2+1] - pswHeightMap[_pixBufferWidth*1+1] + ((pixV+1)<<(DISTORSION+1+1)); + slU_00 = pswHeightMap[_pixBufferWidth*0+1] - pswHeightMap[_pixBufferWidth*0+0] + ((pixU+0)<<(DISTORTION+1+1)); + slV_00 = pswHeightMap[_pixBufferWidth*1+0] - pswHeightMap[_pixBufferWidth*0+0] + ((pixV+0)<<(DISTORTION+1+1)); + slU_01 = pswHeightMap[_pixBufferWidth*0+2] - pswHeightMap[_pixBufferWidth*0+1] + ((pixU+1)<<(DISTORTION+1+1)); + slV_01 = pswHeightMap[_pixBufferWidth*1+1] - pswHeightMap[_pixBufferWidth*0+1] + ((pixV+0)<<(DISTORTION+1+1)); + slU_10 = pswHeightMap[_pixBufferWidth*1+1] - pswHeightMap[_pixBufferWidth*1+0] + ((pixU+0)<<(DISTORTION+1+1)); + slV_10 = pswHeightMap[_pixBufferWidth*2+0] - pswHeightMap[_pixBufferWidth*1+0] + ((pixV+1)<<(DISTORTION+1+1)); + slU_11 = pswHeightMap[_pixBufferWidth*1+2] - pswHeightMap[_pixBufferWidth*1+1] + ((pixU+1)<<(DISTORTION+1+1)); + slV_11 = pswHeightMap[_pixBufferWidth*2+1] - pswHeightMap[_pixBufferWidth*1+1] + ((pixV+1)<<(DISTORTION+1+1)); - pulTexture[_pixTexWidth*0+0] = PIXEL( (slU_00 ) >>(DISTORSION+1 ), (slV_00 ) >>(DISTORSION+1 ) ); - pulTexture[_pixTexWidth*0+1] = PIXEL( (slU_00+slU_01 ) >>(DISTORSION+1+1), (slV_00+slV_01 ) >>(DISTORSION+1+1) ); - pulTexture[_pixTexWidth*1+0] = PIXEL( (slU_00 +slU_10 ) >>(DISTORSION+1+1), (slV_00 +slV_10 ) >>(DISTORSION+1+1) ); - pulTexture[_pixTexWidth*1+1] = PIXEL( (slU_00+slU_01+slU_10+slU_11) >>(DISTORSION+1+2), (slV_00+slV_01+slV_10+slV_11) >>(DISTORSION+1+2) ); + pulTexture[_pixTexWidth*0+0] = PIXEL( (slU_00 ) >>(DISTORTION+1 ), (slV_00 ) >>(DISTORTION+1 ) ); + pulTexture[_pixTexWidth*0+1] = PIXEL( (slU_00+slU_01 ) >>(DISTORTION+1+1), (slV_00+slV_01 ) >>(DISTORTION+1+1) ); + pulTexture[_pixTexWidth*1+0] = PIXEL( (slU_00 +slU_10 ) >>(DISTORTION+1+1), (slV_00 +slV_10 ) >>(DISTORTION+1+1) ); + pulTexture[_pixTexWidth*1+1] = PIXEL( (slU_00+slU_01+slU_10+slU_11) >>(DISTORTION+1+2), (slV_00+slV_01+slV_10+slV_11) >>(DISTORTION+1+2) ); // advance to next texel pulTexture+=2; @@ -1494,6 +1786,7 @@ pixLoop2: #if ASMOPT == 1 + #if (defined __MSVC_INLINE__) __asm { push ebx bsf eax,D [pixBaseWidth] @@ -1526,7 +1819,7 @@ pixLoop4: punpckldq mm0,mm0 psubd mm1,mm0 movq mm0,mm6 - pslld mm0,DISTORSION+1+1 + pslld mm0,DISTORTION+1+1 paddd mm1,mm0 // MM1 = slV_00 | slU_00 movd mm2,D [ebx+ 4] @@ -1538,7 +1831,7 @@ pixLoop4: psubd mm2,mm0 movq mm0,mm6 paddd mm0,Q [mm1LO] - pslld mm0,DISTORSION+1+1 + pslld mm0,DISTORTION+1+1 paddd mm2,mm0 // MM2 = slV_01 | slU_01 movd mm3,D [ebx+ eax*2 +2] @@ -1550,7 +1843,7 @@ pixLoop4: psubd mm3,mm0 movq mm0,mm6 paddd mm0,Q [mm1HI] - pslld mm0,DISTORSION+1+1 + pslld mm0,DISTORTION+1+1 paddd mm3,mm0 // MM3 = slV_10 | slU_10 movd mm4,D [ebx+ eax*2 +4] @@ -1562,12 +1855,12 @@ pixLoop4: psubd mm4,mm0 movq mm0,mm6 paddd mm0,Q [mm1HILO] - pslld mm0,DISTORSION+1+1 + pslld mm0,DISTORTION+1+1 paddd mm4,mm0 // MM4 = slV_11 | slU_11 // texel 00 movq mm0,mm1 - psrad mm0,DISTORSION + psrad mm0,DISTORTION pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1580,7 +1873,7 @@ pixLoop4: paddd mm0,mm1 paddd mm0,mm1 paddd mm0,mm2 - psrad mm0,DISTORSION+2 + psrad mm0,DISTORTION+2 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1591,7 +1884,7 @@ pixLoop4: // texel 02 movq mm0,mm1 paddd mm0,mm2 - psrad mm0,DISTORSION+1 + psrad mm0,DISTORTION+1 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1604,7 +1897,7 @@ pixLoop4: paddd mm0,mm2 paddd mm0,mm2 paddd mm0,mm2 - psrad mm0,DISTORSION+2 + psrad mm0,DISTORTION+2 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1618,7 +1911,7 @@ pixLoop4: paddd mm0,mm1 paddd mm0,mm1 paddd mm0,mm3 - psrad mm0,DISTORSION+2 + psrad mm0,DISTORTION+2 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1637,7 +1930,7 @@ pixLoop4: paddd mm0,mm3 paddd mm0,mm3 paddd mm0,mm4 - psrad mm0,DISTORSION+4 + psrad mm0,DISTORTION+4 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1654,7 +1947,7 @@ pixLoop4: paddd mm0,mm2 paddd mm0,mm3 paddd mm0,mm4 - psrad mm0,DISTORSION+3 + psrad mm0,DISTORTION+3 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1673,7 +1966,7 @@ pixLoop4: paddd mm0,mm4 paddd mm0,mm4 paddd mm0,mm4 - psrad mm0,DISTORSION+4 + psrad mm0,DISTORTION+4 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1685,7 +1978,7 @@ pixLoop4: // texel 20 movq mm0,mm1 paddd mm0,mm3 - psrad mm0,DISTORSION+1 + psrad mm0,DISTORTION+1 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1702,7 +1995,7 @@ pixLoop4: paddd mm0,mm3 paddd mm0,mm3 paddd mm0,mm4 - psrad mm0,DISTORSION+3 + psrad mm0,DISTORTION+3 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1715,7 +2008,7 @@ pixLoop4: paddd mm0,mm2 paddd mm0,mm3 paddd mm0,mm4 - psrad mm0,DISTORSION+2 + psrad mm0,DISTORTION+2 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1732,7 +2025,7 @@ pixLoop4: paddd mm0,mm4 paddd mm0,mm4 paddd mm0,mm4 - psrad mm0,DISTORSION+3 + psrad mm0,DISTORTION+3 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1747,7 +2040,7 @@ pixLoop4: paddd mm0,mm3 paddd mm0,mm3 paddd mm0,mm3 - psrad mm0,DISTORSION+2 + psrad mm0,DISTORTION+2 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1766,7 +2059,7 @@ pixLoop4: paddd mm0,mm4 paddd mm0,mm4 paddd mm0,mm4 - psrad mm0,DISTORSION+4 + psrad mm0,DISTORTION+4 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1783,7 +2076,7 @@ pixLoop4: paddd mm0,mm3 paddd mm0,mm2 paddd mm0,mm1 - psrad mm0,DISTORSION+3 + psrad mm0,DISTORTION+3 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1802,7 +2095,7 @@ pixLoop4: paddd mm0,mm3 paddd mm0,mm3 paddd mm0,mm3 - psrad mm0,DISTORSION+4 + psrad mm0,DISTORTION+4 pand mm0,Q [mmBaseMasks] movq mm7,mm0 psrlq mm7,Q [mmBaseWidthShift] @@ -1827,6 +2120,367 @@ pixLoop4: pop ebx } + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "pushl %%ebx \n\t" // GCC's register. + "movl %%ecx, %%ebx \n\t" + "bsfl %%eax, %%eax \n\t" + "movl $32, %%edx \n\t" + "subl %%eax, %%edx \n\t" + "movl %%edx, (" ASMSYM(mmBaseWidthShift) ") \n\t" + + "movq (" ASMSYM(mmBaseHeightMask) "), %%mm0 \n\t" + "psllq $32, %%mm0 \n\t" + "por (" ASMSYM(mmBaseWidthMask) "), %%mm0 \n\t" + "movq %%mm0, (" ASMSYM(mmBaseMasks) ") \n\t" + + "pxor %%mm6, %%mm6 \n\t" // MM6 = pixV|pixU + + // (These registers were loaded here in the original version...) + //"movl (pswHeightMap), %%ebx \n\t" + //"movl (pulTextureBase), %%esi \n\t" + //"movl (pulTexture), %%edi \n\t" + + "movl (" ASMSYM(_pixBufferHeight) "), %%edx \n\t" + "0: \n\t" // rowLoop4 + "pushl %%edx \n\t" + "movl (" ASMSYM(_pixBufferWidth) "), %%ecx \n\t" + "1: \n\t" // pixLoop4 + "movl (" ASMSYM(_pixBufferWidth) "), %%eax \n\t" + "movl (" ASMSYM(_pixTexWidth) "), %%edx \n\t" + + "movd 2(%%ebx), %%mm1 \n\t" + "movd (%%ebx, %%eax, 2), %%mm0 \n\t" + "psllq $32, %%mm0 \n\t" + "por %%mm0, %%mm1 \n\t" + "movd (%%ebx), %%mm0 \n\t" + "punpckldq %%mm0, %%mm0 \n\t" + "psubd %%mm0, %%mm1 \n\t" + "movq %%mm6, %%mm0 \n\t" + "pslld $5, %%mm0 \n\t" + "paddd %%mm0, %%mm1 \n\t" // MM1 = slV_00 | slU_00 + + "movd 4(%%ebx), %%mm2 \n\t" + "movd 2(%%ebx, %%eax, 2), %%mm0 \n\t" + "psllq $32, %%mm0 \n\t" + "por %%mm0, %%mm2 \n\t" + "movd 2(%%ebx), %%mm0 \n\t" + "punpckldq %%mm0, %%mm0 \n\t" + "psubd %%mm0, %%mm2 \n\t" + "movq %%mm6, %%mm0 \n\t" + "paddd (" ASMSYM(mm1LO) "), %%mm0 \n\t" + "pslld $5, %%mm0 \n\t" + "paddd %%mm0, %%mm2 \n\t" // MM2 = slV_01 | slU_01 + + "movd 2(%%ebx, %%eax, 2), %%mm3 \n\t" + "movd (%%ebx, %%eax, 4), %%mm0 \n\t" + "psllq $32, %%mm0 \n\t" + "por %%mm0, %%mm3 \n\t" + "movd (%%ebx, %%eax, 2), %%mm0 \n\t" + "punpckldq %%mm0, %%mm0 \n\t" + "psubd %%mm0, %%mm3 \n\t" + "movq %%mm6, %%mm0 \n\t" + "paddd (" ASMSYM(mm1HI) "), %%mm0 \n\t" + "pslld $5, %%mm0 \n\t" + "paddd %%mm0, %%mm3 \n\t" // MM3 = slV_10 | slU_10 + + "movd 4(%%ebx, %%eax, 2), %%mm4 \n\t" + "movd 2(%%ebx, %%eax, 4), %%mm0 \n\t" + "psllq $32, %%mm0 \n\t" + "por %%mm0, %%mm4 \n\t" + "movd 2(%%ebx, %%eax, 2), %%mm0 \n\t" + "punpckldq %%mm0, %%mm0 \n\t" + "psubd %%mm0, %%mm4 \n\t" + "movq %%mm6, %%mm0 \n\t" + "paddd (" ASMSYM(mm1HILO) "), %%mm0 \n\t" + "pslld $5, %%mm0 \n\t" + "paddd %%mm0, %%mm4 \n\t" // MM4 = slV_11 | slU_11 + + // texel 00 + "movq %%mm1, %%mm0 \n\t" + "psrad $3, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, (%%edi) \n\t" + + // texel 01 + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "psrad $5, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 4(%%edi) \n\t" + + // texel 02 + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "psrad $4, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 8(%%edi) \n\t" + + // texel 03 + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "psrad $5, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 12(%%edi) \n\t" + + // texel 10 + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "psrad $5, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, (%%edi, %%edx, 4) \n\t" + + // texel 11 + "movq %%mm1, %%mm0 \n\t" + "pslld $3, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "psrad $7, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 4(%%edi, %%edx, 4) \n\t" + + // texel 12 + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm0, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "psrad $6, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 8(%%edi, %%edx, 4) \n\t" + + // texel 13 + "movq %%mm2, %%mm0 \n\t" + "pslld $3, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "psrad $7, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 12(%%edi, %%edx, 4) \n\t" + + // texel 20 + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "psrad $4, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, (%%edi, %%edx, 8) \n\t" + + // texel 21 + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "psrad $6, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 4(%%edi, %%edx, 8) \n\t" + + // texel 22 + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "psrad $5, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 8(%%edi, %%edx, 8) \n\t" + + // texel 23 + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "psrad $6, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 12(%%edi, %%edx, 8) \n\t" + + "imull $3, %%edx \n\t" // _pixTexWidth*=3 + + // texel 30 + "movq %%mm1, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "psrad $5, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, (%%edi, %%edx, 4) \n\t" + + // texel 31 + "movq %%mm3, %%mm0 \n\t" + "pslld $3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "psrad $7, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 4(%%edi, %%edx, 4) \n\t" + + // texel 32 + "movq %%mm4, %%mm0 \n\t" + "paddd %%mm0, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "psrad $6, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 8(%%edi, %%edx, 4) \n\t" + + // texel 33 + "movq %%mm4, %%mm0 \n\t" + "pslld $3, %%mm0 \n\t" + "paddd %%mm4, %%mm0 \n\t" + "paddd %%mm1, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm2, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "paddd %%mm3, %%mm0 \n\t" + "psrad $7, %%mm0 \n\t" + "pand (" ASMSYM(mmBaseMasks) "), %%mm0 \n\t" + "movq %%mm0, %%mm7 \n\t" + "psrlq (" ASMSYM(mmBaseWidthShift) "), %%mm7 \n\t" + "paddd %%mm7, %%mm0 \n\t" + "movd %%mm0, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, 12(%%edi, %%edx, 4) \n\t" + + // advance to next texture pixels + "paddd (" ASMSYM(mm1LO) "), %%mm6 \n\t" + "addl $16, %%edi \n\t" + "addl $2, %%ebx \n\t" + "decl %%ecx \n\t" + "jnz 1b \n\t" // pixLoop4 + + // advance to next texture row + "leal (%%edi, %%edx, 4), %%edi \n\t"// +=[_pixTexWidth]*3 + "popl %%edx \n\t" + "paddd (" ASMSYM(mm1HI) "), %%mm6 \n\t" + "decl %%edx \n\t" + "jnz 0b \n\t" // rowLoop4 + "popl %%ebx \n\t" // Restore GCC's value. + "emms \n\t" + : // no outputs. + : "a" (pixBaseWidth), "c" (pswHeightMap), + "S" (pulTextureBase), "D" (pulTexture) + : "edx", "cc", "memory" + ); + + + #else + #error fill in for you platform. + #endif + #else SLONG slU_00, slU_01, slU_10, slU_11; @@ -1836,38 +2490,38 @@ pixLoop4: { // row loop for( PIX pixU=0; pixU<_pixBufferWidth; pixU++) { // texel loop - slU_00 = pswHeightMap[_pixBufferWidth*0+1] - pswHeightMap[_pixBufferWidth*0+0] + ((pixU+0)<<(DISTORSION+2)); - slV_00 = pswHeightMap[_pixBufferWidth*1+0] - pswHeightMap[_pixBufferWidth*0+0] + ((pixV+0)<<(DISTORSION+2)); - slU_01 = pswHeightMap[_pixBufferWidth*0+2] - pswHeightMap[_pixBufferWidth*0+1] + ((pixU+1)<<(DISTORSION+2)); - slV_01 = pswHeightMap[_pixBufferWidth*1+1] - pswHeightMap[_pixBufferWidth*0+1] + ((pixV+0)<<(DISTORSION+2)); - slU_10 = pswHeightMap[_pixBufferWidth*1+1] - pswHeightMap[_pixBufferWidth*1+0] + ((pixU+0)<<(DISTORSION+2)); - slV_10 = pswHeightMap[_pixBufferWidth*2+0] - pswHeightMap[_pixBufferWidth*1+0] + ((pixV+1)<<(DISTORSION+2)); - slU_11 = pswHeightMap[_pixBufferWidth*1+2] - pswHeightMap[_pixBufferWidth*1+1] + ((pixU+1)<<(DISTORSION+2)); - slV_11 = pswHeightMap[_pixBufferWidth*2+1] - pswHeightMap[_pixBufferWidth*1+1] + ((pixV+1)<<(DISTORSION+2)); + slU_00 = pswHeightMap[_pixBufferWidth*0+1] - pswHeightMap[_pixBufferWidth*0+0] + ((pixU+0)<<(DISTORTION+2)); + slV_00 = pswHeightMap[_pixBufferWidth*1+0] - pswHeightMap[_pixBufferWidth*0+0] + ((pixV+0)<<(DISTORTION+2)); + slU_01 = pswHeightMap[_pixBufferWidth*0+2] - pswHeightMap[_pixBufferWidth*0+1] + ((pixU+1)<<(DISTORTION+2)); + slV_01 = pswHeightMap[_pixBufferWidth*1+1] - pswHeightMap[_pixBufferWidth*0+1] + ((pixV+0)<<(DISTORTION+2)); + slU_10 = pswHeightMap[_pixBufferWidth*1+1] - pswHeightMap[_pixBufferWidth*1+0] + ((pixU+0)<<(DISTORTION+2)); + slV_10 = pswHeightMap[_pixBufferWidth*2+0] - pswHeightMap[_pixBufferWidth*1+0] + ((pixV+1)<<(DISTORTION+2)); + slU_11 = pswHeightMap[_pixBufferWidth*1+2] - pswHeightMap[_pixBufferWidth*1+1] + ((pixU+1)<<(DISTORTION+2)); + slV_11 = pswHeightMap[_pixBufferWidth*2+1] - pswHeightMap[_pixBufferWidth*1+1] + ((pixV+1)<<(DISTORTION+2)); - pulTexture[_pixTexWidth*0+0] = PIXEL( (slU_00 ) >>(DISTORSION ), (slV_00 ) >>(DISTORSION ) ); - pulTexture[_pixTexWidth*0+1] = PIXEL( (slU_00* 3+slU_01* 1 ) >>(DISTORSION+2), (slV_00* 3+slV_01* 1 ) >>(DISTORSION+2) ); - pulTexture[_pixTexWidth*0+2] = PIXEL( (slU_00 +slU_01 ) >>(DISTORSION+1), (slV_00 +slV_01 ) >>(DISTORSION+1) ); - pulTexture[_pixTexWidth*0+3] = PIXEL( (slU_00* 1+slU_01* 3 ) >>(DISTORSION+2), (slV_00* 1+slV_01* 3 ) >>(DISTORSION+2) ); + pulTexture[_pixTexWidth*0+0] = PIXEL( (slU_00 ) >>(DISTORTION ), (slV_00 ) >>(DISTORTION ) ); + pulTexture[_pixTexWidth*0+1] = PIXEL( (slU_00* 3+slU_01* 1 ) >>(DISTORTION+2), (slV_00* 3+slV_01* 1 ) >>(DISTORTION+2) ); + pulTexture[_pixTexWidth*0+2] = PIXEL( (slU_00 +slU_01 ) >>(DISTORTION+1), (slV_00 +slV_01 ) >>(DISTORTION+1) ); + pulTexture[_pixTexWidth*0+3] = PIXEL( (slU_00* 1+slU_01* 3 ) >>(DISTORTION+2), (slV_00* 1+slV_01* 3 ) >>(DISTORTION+2) ); - pulTexture[_pixTexWidth*1+0] = PIXEL( (slU_00* 3 +slU_10* 1 ) >>(DISTORSION+2), (slV_00* 3 +slV_10 ) >>(DISTORSION+2) ); - pulTexture[_pixTexWidth*1+1] = PIXEL( (slU_00* 9+slU_01* 3+slU_10* 3+slU_11* 1) >>(DISTORSION+4), (slV_00* 9+slV_01* 3+slV_10* 3+slV_11* 1) >>(DISTORSION+4) ); - pulTexture[_pixTexWidth*1+2] = PIXEL( (slU_00* 3+slU_01* 3+slU_10* 1+slU_11* 1) >>(DISTORSION+3), (slV_00* 3+slV_01* 3+slV_10* 1+slV_11* 1) >>(DISTORSION+3) ); - pulTexture[_pixTexWidth*1+3] = PIXEL( (slU_00* 3+slU_01* 9+slU_10* 1+slU_11* 3) >>(DISTORSION+4), (slV_00* 3+slV_01* 9+slV_10* 1+slV_11* 3) >>(DISTORSION+4) ); + pulTexture[_pixTexWidth*1+0] = PIXEL( (slU_00* 3 +slU_10* 1 ) >>(DISTORTION+2), (slV_00* 3 +slV_10 ) >>(DISTORTION+2) ); + pulTexture[_pixTexWidth*1+1] = PIXEL( (slU_00* 9+slU_01* 3+slU_10* 3+slU_11* 1) >>(DISTORTION+4), (slV_00* 9+slV_01* 3+slV_10* 3+slV_11* 1) >>(DISTORTION+4) ); + pulTexture[_pixTexWidth*1+2] = PIXEL( (slU_00* 3+slU_01* 3+slU_10* 1+slU_11* 1) >>(DISTORTION+3), (slV_00* 3+slV_01* 3+slV_10* 1+slV_11* 1) >>(DISTORTION+3) ); + pulTexture[_pixTexWidth*1+3] = PIXEL( (slU_00* 3+slU_01* 9+slU_10* 1+slU_11* 3) >>(DISTORTION+4), (slV_00* 3+slV_01* 9+slV_10* 1+slV_11* 3) >>(DISTORTION+4) ); - pulTexture[_pixTexWidth*2+0] = PIXEL( (slU_00 +slU_10 ) >>(DISTORSION+1), (slV_00 +slV_10 ) >>(DISTORSION+1) ); - pulTexture[_pixTexWidth*2+1] = PIXEL( (slU_00* 3+slU_01* 1+slU_10* 3+slU_11* 1) >>(DISTORSION+3), (slV_00* 3+slV_01* 1+slV_10* 3+slV_11* 1) >>(DISTORSION+3) ); - pulTexture[_pixTexWidth*2+2] = PIXEL( (slU_00 +slU_01 +slU_10 +slU_11 ) >>(DISTORSION+2), (slV_00 +slV_01 +slV_10 +slV_11 ) >>(DISTORSION+2) ); - pulTexture[_pixTexWidth*2+3] = PIXEL( (slU_00* 1+slU_01* 3+slU_10* 1+slU_11* 3) >>(DISTORSION+3), (slV_00* 1+slV_01* 3+slV_10* 1+slV_11* 3) >>(DISTORSION+3) ); + pulTexture[_pixTexWidth*2+0] = PIXEL( (slU_00 +slU_10 ) >>(DISTORTION+1), (slV_00 +slV_10 ) >>(DISTORTION+1) ); + pulTexture[_pixTexWidth*2+1] = PIXEL( (slU_00* 3+slU_01* 1+slU_10* 3+slU_11* 1) >>(DISTORTION+3), (slV_00* 3+slV_01* 1+slV_10* 3+slV_11* 1) >>(DISTORTION+3) ); + pulTexture[_pixTexWidth*2+2] = PIXEL( (slU_00 +slU_01 +slU_10 +slU_11 ) >>(DISTORTION+2), (slV_00 +slV_01 +slV_10 +slV_11 ) >>(DISTORTION+2) ); + pulTexture[_pixTexWidth*2+3] = PIXEL( (slU_00* 1+slU_01* 3+slU_10* 1+slU_11* 3) >>(DISTORTION+3), (slV_00* 1+slV_01* 3+slV_10* 1+slV_11* 3) >>(DISTORTION+3) ); - pulTexture[_pixTexWidth*3+0] = PIXEL( (slU_00* 1 +slU_10* 3 ) >>(DISTORSION+2), (slV_00* 1 +slV_10* 3 ) >>(DISTORSION+2) ); - pulTexture[_pixTexWidth*3+1] = PIXEL( (slU_00* 3+slU_01* 1+slU_10* 9+slU_11* 3) >>(DISTORSION+4), (slV_00* 3+slV_01* 1+slV_10* 9+slV_11* 3) >>(DISTORSION+4) ); - pulTexture[_pixTexWidth*3+2] = PIXEL( (slU_00* 1+slU_01* 1+slU_10* 3+slU_11* 3) >>(DISTORSION+3), (slV_00* 1+slV_01* 1+slV_10* 3+slV_11* 3) >>(DISTORSION+3) ); - pulTexture[_pixTexWidth*3+3] = PIXEL( (slU_00* 1+slU_01* 3+slU_10* 3+slU_11* 9) >>(DISTORSION+4), (slV_00* 1+slV_01* 3+slV_10* 3+slV_11* 9) >>(DISTORSION+4) ); + pulTexture[_pixTexWidth*3+0] = PIXEL( (slU_00* 1 +slU_10* 3 ) >>(DISTORTION+2), (slV_00* 1 +slV_10* 3 ) >>(DISTORTION+2) ); + pulTexture[_pixTexWidth*3+1] = PIXEL( (slU_00* 3+slU_01* 1+slU_10* 9+slU_11* 3) >>(DISTORTION+4), (slV_00* 3+slV_01* 1+slV_10* 9+slV_11* 3) >>(DISTORTION+4) ); + pulTexture[_pixTexWidth*3+2] = PIXEL( (slU_00* 1+slU_01* 1+slU_10* 3+slU_11* 3) >>(DISTORTION+3), (slV_00* 1+slV_01* 1+slV_10* 3+slV_11* 3) >>(DISTORTION+3) ); + pulTexture[_pixTexWidth*3+3] = PIXEL( (slU_00* 1+slU_01* 3+slU_10* 3+slU_11* 9) >>(DISTORTION+4), (slV_00* 1+slV_01* 3+slV_10* 3+slV_11* 9) >>(DISTORTION+4) ); // advance to next texel pulTexture+=4; - pHeightMap++; + pswHeightMap++; } pulTexture+=_pixTexWidth*3; } @@ -2245,6 +2899,7 @@ static void AnimateFire( SLONG slDensity) #if ASMOPT == 1 + #if (defined __MSVC_INLINE__) __asm { push ebx mov edi,D [ulRNDSeed] ;// EDI = randomizer @@ -2294,6 +2949,67 @@ pixDone: pop ebx } + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "pushl %%ebx \n\t" // GCC's register. + "xorl %%ebx, %%ebx \n\t" + "pushl %%edx \n\t" // slColumnModulo + "pushl %%ecx \n\t" // slBufferMask + "pushl %%eax \n\t" // slDensity + + "0: \n\t" // colLoopFM + "movl (" ASMSYM(_pixBufferHeight) "), %%ecx \n\t" + "subl $2, %%ecx \n\t" + + "1: \n\t" // rowLoopFM + "movl (" ASMSYM(_pixBufferWidth) "), %%edx \n\t" + "addl %%esi, %%edx \n\t" + "movzbl (%%ebx, %%edx), %%eax \n\t" + "addl (" ASMSYM(_pixBufferWidth) "), %%edx \n\t" + "movzbl (%%ebx, %%edx), %%edx \n\t" + "addl %%edx, %%eax \n\t" + "shrl $1, %%eax \n\t" + "cmpl (%%esp), %%eax \n\t" + "jg doCalc_animateFire \n\t" + "movb $0, (%%esi, %%ebx) \n\t" + "jmp pixDone_animateFire \n\t" + + "doCalc_animateFire: \n\t" + "movl %%edi, %%edx \n\t" + "sarl $16, %%edx \n\t" + "andl (%%esp), %%edx \n\t" + "subl %%edx, %%eax \n\t" + "movsbl " ASMSYM(asbMod3Sub1Table) "(%%edx), %%edx \n\t" + "addl %%ebx, %%edx \n\t" + "andl 4(%%esp), %%edx \n\t" // slBufferMask + "movb %%al, (%%esi, %%edx) \n\t" + "imull $262147, %%edi \n\t" + + "pixDone_animateFire: \n\t" + // advance to next row + "addl (" ASMSYM(_pixBufferWidth) "), %%ebx \n\t" + "decl %%ecx \n\t" + "jnz 1b \n\t" // rowLoopFM + + // advance to next column + "subl 8(%%esp), %%ebx \n\t" // slColumnModulo + "cmpl (" ASMSYM(_pixBufferWidth) "), %%ebx \n\t" + "jl 0b \n\t" // colLoopFM + + // all done + "movl %%edi, (" ASMSYM(ulRNDSeed) ") \n\t" + "addl $12, %%esp \n\t" // lose our locals. + "popl %%ebx \n\t" // Restore GCC's var. + : // no outputs. + : "a" (slDensity), "c" (slBufferMask), + "d" (slColumnModulo), "D" (ulRNDSeed), "S" (pubNew) + : "cc", "memory" + ); + + #else + #error fill in for you platform. + #endif + #else // inner rectangle (without 1 pixel border) @@ -2323,6 +3039,8 @@ pixDone: //////////////////////////// displace texture +static UBYTE *_pubHeat_RenderPlasmaFire = NULL; + static void RenderPlasmaFire(void) { // _sfStats.StartTimer(CStatForm::STI_EFFECTRENDER); @@ -2340,6 +3058,7 @@ static void RenderPlasmaFire(void) #if ASMOPT == 1 + #if (defined __MSVC_INLINE__) __asm { push ebx mov ebx,D [pubHeat] @@ -2367,6 +3086,45 @@ pixLoopF: jnz rowLoopF pop ebx } + #elif (defined __GNU_INLINE__) + _pubHeat_RenderPlasmaFire = pubHeat; // ran out of registers. :/ + __asm__ __volatile__ ( + "pushl %%ebx \n\t" + "movl (" ASMSYM(_pubHeat_RenderPlasmaFire) "),%%ebx \n\t" + "pushl %%eax \n\t" // slHeatRowStep + "pushl %%edx \n\t" // slHeatMapStep + "pushl %%ecx \n\t" // slBaseMipShift + "movl (" ASMSYM(_pixTexHeight) "), %%ecx \n\t" + "0: \n\t" // rowLoopF + "pushl %%ecx \n\t" + "movl (" ASMSYM(_pixTexWidth) "), %%edx \n\t" + "movl 4(%%esp), %%ecx \n\t" // slBaseMipShift + "1: \n\t" // pixLoopF + "movzbl (%%ebx), %%eax \n\t" + "shrl %%cl, %%eax \n\t" + "movl (%%esi, %%eax, 4), %%eax \n\t" + "movl %%eax, (%%edi) \n\t" + // advance to next pixel + "addl 8(%%esp), %%ebx \n\t" // slHeatMapStep + "addl $4, %%edi \n\t" + "decl %%edx \n\t" + "jnz 1b \n\t" // pixLoopF + // advance to next row + "popl %%ecx \n\t" + "addl 8(%%esp), %%ebx \n\t" // slHeatRowStep + "decl %%ecx \n\t" + "jnz 0b \n\t" // rowLoopF + "addl $12, %%esp \n\t" // lose our locals. + "popl %%ebx \n\t" // restore GCC's register. + : // no outputs. + : "S" (pulTextureBase), "D" (pulTexture), + "c" (slBaseMipShift), "a" (slHeatRowStep), "d" (slHeatMapStep) + : "cc", "memory" + ); + + #else + #error fill in for you platform. + #endif #else @@ -2489,18 +3247,18 @@ struct TextureEffectSourceType atestFire[] = { }; -void AWaterFast(void) { AnimateWater(2); }; -void AWaterMedium(void) { AnimateWater(3); }; -void AWaterSlow(void) { AnimateWater(5); }; +inline void AWaterFast(void) { AnimateWater(2); }; +inline void AWaterMedium(void) { AnimateWater(3); }; +inline void AWaterSlow(void) { AnimateWater(5); }; -void APlasma(void) { AnimatePlasma(4, ptNormal); }; -void APlasmaUp(void) { AnimatePlasma(4, ptUp); }; -void APlasmaUpTile(void) { AnimatePlasma(4, ptUpTile); }; -void APlasmaDown(void) { AnimatePlasma(5, ptDown); }; -void APlasmaDownTile(void) { AnimatePlasma(5, ptDownTile); }; -void APlasmaUpSlow(void) { AnimatePlasma(6, ptUp); }; +inline void APlasma(void) { AnimatePlasma(4, ptNormal); }; +inline void APlasmaUp(void) { AnimatePlasma(4, ptUp); }; +inline void APlasmaUpTile(void) { AnimatePlasma(4, ptUpTile); }; +inline void APlasmaDown(void) { AnimatePlasma(5, ptDown); }; +inline void APlasmaDownTile(void) { AnimatePlasma(5, ptDownTile); }; +inline void APlasmaUpSlow(void) { AnimatePlasma(6, ptUp); }; -void AFire(void) { AnimateFire(15); }; +inline void AFire(void) { AnimateFire(15); }; struct TextureEffectGlobalType _ategtTextureEffectGlobalPresets[] = { diff --git a/Sources/Engine/Graphics/TextureEffects.h b/Sources/Engine/Graphics/TextureEffects.h index 5674c7d..7fbb72a 100644 --- a/Sources/Engine/Graphics/TextureEffects.h +++ b/Sources/Engine/Graphics/TextureEffects.h @@ -9,13 +9,37 @@ #include #include #include +#include struct TextureEffectPixel { char tepp_achDummy[8]; }; + +static __forceinline CTStream &operator>>(CTStream &strm, TextureEffectPixel &t) { + strm.Read_t(t.tepp_achDummy, sizeof (t.tepp_achDummy)); // char[8] + return(strm); +} + +static __forceinline CTStream &operator<<(CTStream &strm, const TextureEffectPixel &t) { + strm.Write_t(t.tepp_achDummy, sizeof (t.tepp_achDummy)); // char[8] + return(strm); +} + + struct TextureEffectSourceProperties { char tesp_achDummy[64]; }; + +static __forceinline CTStream &operator>>(CTStream &strm, TextureEffectSourceProperties &t) { + strm.Read_t(t.tesp_achDummy, sizeof (t.tesp_achDummy)); // char[64] + return(strm); +} + +static __forceinline CTStream &operator<<(CTStream &strm, const TextureEffectSourceProperties &t) { + strm.Write_t(t.tesp_achDummy, sizeof (t.tesp_achDummy)); // char[64] + return(strm); +} + class CTextureEffectSource { public: class CTextureEffectGlobal *tes_ptegGlobalEffect; // global effect of this effect source diff --git a/Sources/Engine/Graphics/Vertex.h b/Sources/Engine/Graphics/Vertex.h index c460195..83edde1 100644 --- a/Sources/Engine/Graphics/Vertex.h +++ b/Sources/Engine/Graphics/Vertex.h @@ -7,6 +7,15 @@ #endif +#include "Color.h" + +// !!! FIXME: rcg11162001 I have the structures packed to assure positioning. +// !!! FIXME: rcg11162001 This should be fixed on win32, and then this +// !!! FIXME: rcg11162001 ifndef should be removed. +#ifndef PLATFORM_WIN32 +#pragma pack(1) +#endif + struct GFXVertex3 { FLOAT x,y,z; @@ -22,8 +31,8 @@ struct GFXNormal3 struct GFXTexCoord { union { - struct { FLOAT u,v; }; - struct { FLOAT s,t; }; + struct { FLOAT u,v; } uv; + struct { FLOAT s,t; } st; }; }; @@ -37,12 +46,19 @@ struct GFXTexCoord4 struct GFXColor { union { - struct { UBYTE r,g,b,a; }; - struct { ULONG abgr; }; // reverse order - use ByteSwap()! + struct { UBYTE r,g,b,a; } ub; + struct { ULONG abgr; } ul; // reverse order - use ByteSwap()! }; GFXColor() {}; +/* + * rcg10052001 This is a REALLY bad idea; + * never rely on the memory layout of even a + * simple class. It works for MSVC, though, + * so we'll keep it. + */ +#if (defined _MSC_VER) GFXColor( COLOR col) { _asm mov ecx,dword ptr [this] _asm mov eax,dword ptr [col] @@ -56,50 +72,57 @@ struct GFXColor _asm bswap eax _asm mov dword ptr [ecx],eax } +#else + GFXColor( COLOR col) { ul.abgr = ByteSwap(col); } + __forceinline void Set( COLOR col) { ul.abgr = ByteSwap(col); } +#endif void MultiplyRGBA( const GFXColor &col1, const GFXColor &col2) { - r = (ULONG(col1.r)*col2.r)>>8; - g = (ULONG(col1.g)*col2.g)>>8; - b = (ULONG(col1.b)*col2.b)>>8; - a = (ULONG(col1.a)*col2.a)>>8; + ub.r = (ULONG(col1.ub.r)*col2.ub.r)>>8; + ub.g = (ULONG(col1.ub.g)*col2.ub.g)>>8; + ub.b = (ULONG(col1.ub.b)*col2.ub.b)>>8; + ub.a = (ULONG(col1.ub.a)*col2.ub.a)>>8; } void MultiplyRGB( const GFXColor &col1, const GFXColor &col2) { - r = (ULONG(col1.r)*col2.r)>>8; - g = (ULONG(col1.g)*col2.g)>>8; - b = (ULONG(col1.b)*col2.b)>>8; + ub.r = (ULONG(col1.ub.r)*col2.ub.r)>>8; + ub.g = (ULONG(col1.ub.g)*col2.ub.g)>>8; + ub.b = (ULONG(col1.ub.b)*col2.ub.b)>>8; } void MultiplyRGBCopyA1( const GFXColor &col1, const GFXColor &col2) { - r = (ULONG(col1.r)*col2.r)>>8; - g = (ULONG(col1.g)*col2.g)>>8; - b = (ULONG(col1.b)*col2.b)>>8; - a = col1.a; + ub.r = (ULONG(col1.ub.r)*col2.ub.r)>>8; + ub.g = (ULONG(col1.ub.g)*col2.ub.g)>>8; + ub.b = (ULONG(col1.ub.b)*col2.ub.b)>>8; + ub.a = col1.ub.a; } void AttenuateRGB( ULONG ulA) { - r = (ULONG(r)*ulA)>>8; - g = (ULONG(g)*ulA)>>8; - b = (ULONG(b)*ulA)>>8; + ub.r = (ULONG(ub.r)*ulA)>>8; + ub.g = (ULONG(ub.g)*ulA)>>8; + ub.b = (ULONG(ub.b)*ulA)>>8; } void AttenuateA( ULONG ulA) { - a = (ULONG(a)*ulA)>>8; + ub.a = (ULONG(ub.a)*ulA)>>8; } }; #define GFXVertex GFXVertex4 -struct GFXVertex4 -{ - GFXVertex4() - { - } +/* + * rcg10042001 Removed the union; objects with constructors can't be + * safely unioned, and there's not a whole lot of memory lost here anyhow. + */ + +// IF YOU CHANGE THIS STRUCT, YOU WILL BREAK THE INLINE ASSEMBLY +// ON GNU PLATFORMS! THIS INCLUDES CHANGING THE STRUCTURE'S PACKING. +// You have been warned. +struct GFXVertex4 { FLOAT x,y,z; - union { - struct { struct GFXColor col; }; - struct { SLONG shade; }; - }; + struct GFXColor col; + SLONG shade; + void Clear(void) {}; }; @@ -111,6 +134,12 @@ struct GFXNormal4 }; +// !!! FIXME: rcg11162001 I have the structures packed to assure positioning. +// !!! FIXME: rcg11162001 This should be fixed on win32, and then this +// !!! FIXME: rcg11162001 ifndef should be removed. +#ifndef PLATFORM_WIN32 +#pragma pack() +#endif #endif /* include-once check. */ diff --git a/Sources/Engine/Graphics/ViewPort.cpp b/Sources/Engine/Graphics/ViewPort.cpp index e83a011..6334447 100644 --- a/Sources/Engine/Graphics/ViewPort.cpp +++ b/Sources/Engine/Graphics/ViewPort.cpp @@ -1,12 +1,12 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include -#include +#include extern INDEX ogl_bExclusive; @@ -49,21 +49,6 @@ static void SetAsRenderTarget_D3D( CViewPort *pvp) } #endif // SE1_D3D -// helper for OGL - -CTempDC::CTempDC(HWND hWnd) -{ - ASSERT(hWnd!=NULL); - hwnd = hWnd; - hdc = GetDC(hwnd); - ASSERT(hdc!=NULL); -} - -CTempDC::~CTempDC(void) -{ - ReleaseDC(hwnd, hdc); -} - /* * ViewPort functions @@ -92,6 +77,22 @@ CViewPort::~CViewPort(void) } +#ifdef PLATFORM_WIN32 + +CTempDC::CTempDC(HWND hWnd) +{ + ASSERT(hWnd!=NULL); + hwnd = hWnd; + hdc = GetDC(hwnd); + ASSERT(hdc!=NULL); +} + +CTempDC::~CTempDC(void) +{ + ReleaseDC(hwnd, hdc); +} + + #define CViewPortCLASS "ViewPort Window" static BOOL _bClassRegistered = FALSE; @@ -116,11 +117,12 @@ LRESULT CALLBACK CViewPortCLASS_WindowProc( return DefWindowProc(hWnd, Msg, wParam, lParam); } - +#endif // open overlaid window for rendering context void CViewPort::OpenCanvas(void) { +#ifdef PLATFORM_WIN32 // do nothing if not feasable if( vp_hWnd!=NULL || vp_hWndParent==NULL) return; @@ -184,6 +186,11 @@ void CViewPort::OpenCanvas(void) // set as rendering target if( _pGfx->gl_eCurrentAPI==GAT_D3D && vp_pSwapChain!=NULL) SetAsRenderTarget_D3D(this); #endif // SE1_D3D + +#else // !PLATFORM_WIN32 + STUBBED("Move this to another directory."); + vp_hWnd = vp_hWndParent = (void *) 0x0001; +#endif } @@ -214,6 +221,7 @@ void CViewPort::CloseCanvas( BOOL bRelease/*=FALSE*/) // Change size of this viewport, it's raster and all it's drawports void CViewPort::Resize(void) { +#ifdef PLATFORM_WIN32 PIX pixNewWidth, pixNewHeight; RECT rectWindow; @@ -240,7 +248,7 @@ void CViewPort::Resize(void) CreateSwapChain_D3D( this, pixNewWidth, pixNewHeight); SetAsRenderTarget_D3D(this); } -#endif // SE1_D3D +#endif } diff --git a/Sources/Engine/Graphics/ViewPort.h b/Sources/Engine/Graphics/ViewPort.h index 51abab0..3638e4c 100644 --- a/Sources/Engine/Graphics/ViewPort.h +++ b/Sources/Engine/Graphics/ViewPort.h @@ -15,7 +15,6 @@ * ViewPort */ -/* rcg !!! FIXME: This will need to go away. */ #ifdef PLATFORM_WIN32 class CTempDC { public: diff --git a/Sources/Engine/Graphics/Win32/Win32Adapter.cpp b/Sources/Engine/Graphics/Win32/Win32Adapter.cpp new file mode 100644 index 0000000..d2100b3 --- /dev/null +++ b/Sources/Engine/Graphics/Win32/Win32Adapter.cpp @@ -0,0 +1,10 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#include + +ULONG DetermineDesktopWidth(void) +{ + return((ULONG) ::GetSystemMetrics(SM_CXSCREEN)); +} + + diff --git a/Sources/Engine/Graphics/Win32/Win32OpenGL.cpp b/Sources/Engine/Graphics/Win32/Win32OpenGL.cpp new file mode 100644 index 0000000..bf638cd --- /dev/null +++ b/Sources/Engine/Graphics/Win32/Win32OpenGL.cpp @@ -0,0 +1,442 @@ +/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ + +#include + +static void FailFunction_t(const char *strName) { + ThrowF_t(TRANS("Required function %s not found."), strName); +} + +void WIN_CheckError(BOOL bRes, const char *strDescription) +{ + if( bRes) return; + DWORD dwWindowsErrorCode = GetLastError(); + if( dwWindowsErrorCode==ERROR_SUCCESS) return; // ignore stupid 'successful' error + WarningMessage("%s: %s", strDescription, GetWindowsError(dwWindowsErrorCode)); +} + + +static void SetFunctionPointers_t(HINSTANCE hiOGL) +{ + const char *strName; + // get gl function pointers + + #define DLLFUNCTION(dll, output, name, inputs, params, required) \ + strName = #name; \ + p##name = (output (__stdcall*) inputs) GetProcAddress( hi##dll, strName); \ + if( required && p##name == NULL) FailFunction_t(strName); + #include "Engine/Graphics/gl_functions.h" + #undef DLLFUNCTION +} + + +// initialize OpenGL driver +BOOL CGfxLibrary::InitDriver_OGL( BOOL b3Dfx/*=FALSE*/) +{ + ASSERT( gl_hiDriver==NONE); + UINT iOldErrorMode = SetErrorMode( SEM_NOOPENFILEERRORBOX|SEM_FAILCRITICALERRORS); + CTString strDriverFileName = b3Dfx ? "3DFXVGL.DLL" : "OPENGL32.DLL"; + + try + { // if driver doesn't exists on disk + char strBuffer[_MAX_PATH+1]; + char *strDummy; + int iRes = SearchPath( NULL, strDriverFileName, NULL, _MAX_PATH, strBuffer, &strDummy); + if( iRes==0) ThrowF_t(TRANS("OpenGL driver '%s' not present"), strDriverFileName); + + // load opengl library + gl_hiDriver = ::LoadLibrary( strDriverFileName); + + // if it cannot be loaded (although it is present on disk) + if( gl_hiDriver==NONE) { + // if it is 3dfx stand-alone driver + if( b3Dfx) { + // do a fatal error and inform user to deinstall it, + // since this loading attempt probably messed up the entire system + FatalError(TRANS( "3Dfx OpenGL driver '%s' is installed, but cannot be loaded!\n" + "If you previously had a 3Dfx card and it was removed,\n" + "please deinstall the driver and restart windows before\n" + "continuing.\n"), strDriverFileName); + } // fail! + ThrowF_t(TRANS("Cannot load OpenGL driver '%s'"), (const char *) strDriverFileName); + } + // prepare functions + SetFunctionPointers_t(gl_hiDriver); + } + catch( char *strError) + { // didn't make it :( + if( gl_hiDriver!=NONE) FreeLibrary(gl_hiDriver); + gl_hiDriver = NONE; + CPrintF( TRANS("Error starting OpenGL: %s\n"), strError); + SetErrorMode(iOldErrorMode); + return FALSE; + } + + // revert to old error mode + SetErrorMode(iOldErrorMode); + + // if default driver + if( !b3Dfx) { + // use GDI functions + pwglSwapBuffers = ::SwapBuffers; + pwglSetPixelFormat = ::SetPixelFormat; + pwglChoosePixelFormat = ::ChoosePixelFormat; + // NOTE: + // some ICD implementations are not infact in OPENGL32.DLL, but in some + // other installed DLL, which is loaded when original OPENGL32.DLL from MS is + // loaded. For those, we in fact load OPENGL32.DLL from MS, so we must _not_ + // call these functions directly, because they are in MS dll. We must call + // functions from GDI, which in turn call either OPENGL32.DLL, _or_ the client driver, + // as appropriate. + } + // done + return TRUE; +} + + +void CGfxLibrary::PlatformEndDriver_OGL(void) +{ + // shut the driver down + if( go_hglRC!=NULL) { + if( pwglMakeCurrent!=NULL) { + BOOL bRes = pwglMakeCurrent(NULL, NULL); + WIN_CHECKERROR( bRes, "MakeCurrent(NULL, NULL)"); + } + ASSERT( pwglDeleteContext!=NULL); + BOOL bRes = pwglDeleteContext(go_hglRC); + WIN_CHECKERROR( bRes, "DeleteContext"); + go_hglRC = NULL; + } +} + +// creates OpenGL drawing context +BOOL CGfxLibrary::CreateContext_OGL(HDC hdc) +{ + if( !SetupPixelFormat_OGL( hdc, TRUE)) return FALSE; + go_hglRC = pwglCreateContext(hdc); + if( go_hglRC==NULL) { + WIN_CHECKERROR(0, "CreateContext"); + return FALSE; + } + if( !pwglMakeCurrent(hdc, go_hglRC)) { + // NOTE: This error is sometimes reported without a reason on 3dfx hardware + // so we just have to ignore it. + //WIN_CHECKERROR(0, "MakeCurrent after CreateContext"); + return FALSE; + } + return TRUE; +} + + +#define BACKOFF pwglMakeCurrent( NULL, NULL); \ + pwglDeleteContext( hglrc); \ + ReleaseDC( dummyhwnd, hdc); \ + DestroyWindow( dummyhwnd); \ + UnregisterClass( classname, hInstance) + + + // helper for choosing t-buffer's pixel format +static _TBCapability = FALSE; +static INDEX ChoosePixelFormatTB( HDC hdc, const PIXELFORMATDESCRIPTOR *ppfd, + PIX pixResWidth, PIX pixResHeight) +{ + _TBCapability = FALSE; + char *extensions = NULL; + char *wglextensions = NULL; + HGLRC hglrc; + HWND dummyhwnd; + WNDCLASS cls; + HINSTANCE hInstance = GetModuleHandle(NULL); + char *classname = "dummyOGLwin"; + cls.style = CS_OWNDC; + cls.lpfnWndProc = DefWindowProc; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = hInstance; + cls.hIcon = LoadIcon(NULL, IDI_APPLICATION); + cls.hCursor = LoadCursor(NULL, IDC_WAIT); + cls.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = classname; + // didn't manage to register class? + if( !RegisterClass(&cls)) return 0; + + // create window fullscreen + //CPrintF( " Dummy window: %d x %d\n", pixResWidth, pixResHeight); + dummyhwnd = CreateWindowEx( WS_EX_TOPMOST, classname, "Dummy OGL window", + WS_POPUP|WS_VISIBLE, 0, 0, pixResWidth, pixResHeight, + NULL, NULL, hInstance, NULL); + // didn't make it? + if( dummyhwnd == NULL) { + UnregisterClass( classname, hInstance); + return 0; + } + //CPrintF( " Dummy passed...\n"); + hdc = GetDC(dummyhwnd); + // try to choose pixel format + int iPixelFormat = pwglChoosePixelFormat( hdc, ppfd); + if( !iPixelFormat) { + ReleaseDC( dummyhwnd, hdc); + DestroyWindow(dummyhwnd); + UnregisterClass( classname, hInstance); + return 0; + } + //CPrintF( " Choose pixel format passed...\n"); + // try to set pixel format + if( !pwglSetPixelFormat( hdc, iPixelFormat, ppfd)) { + ReleaseDC( dummyhwnd, hdc); + DestroyWindow(dummyhwnd); + UnregisterClass( classname, hInstance); + return 0; + } + //CPrintF( " Set pixel format passed...\n"); + + // create context using the default accelerated pixelformat that was passed + hglrc = pwglCreateContext(hdc); + pwglMakeCurrent( hdc, hglrc); + + // update the value list with information passed from the ppfd. + aiAttribList[ 9] = ppfd->cColorBits; + aiAttribList[11] = ppfd->cDepthBits; + aiAttribList[15] = _pGfx->go_ctSampleBuffers; + + // get the extension list. + extensions = (char*)pglGetString(GL_EXTENSIONS); + // get the wgl extension list. + if( strstr((const char*)extensions, "WGL_EXT_extensions_string ") != NULL) + { // windows extension string supported + pwglGetExtensionsStringARB = (char* (__stdcall*)(HDC))pwglGetProcAddress( "wglGetExtensionsStringARB"); + if( pwglGetExtensionsStringARB == NULL) { + BACKOFF; + return 0; + } + //CPrintF( " WGL extension string passed...\n"); + // get WGL extension string + wglextensions = (char*)pwglGetExtensionsStringARB(hdc); + } + else { + BACKOFF; + return 0; + } + + // check for the pixel format and multisample extension strings + if( (strstr((const char*)wglextensions, "WGL_ARB_pixel_format ") != NULL) && + (strstr((const char*)extensions, "GL_3DFX_multisample ") != NULL)) { + // 3dfx extensions present + _TBCapability = TRUE; + pwglChoosePixelFormatARB = (BOOL (__stdcall*)(HDC,const int*,const FLOAT*,UINT,int*,UINT*))pwglGetProcAddress( "wglChoosePixelFormatARB"); + pwglGetPixelFormatAttribivARB = (BOOL (__stdcall*)(HDC,int,int,UINT,int*,int*) )pwglGetProcAddress( "wglGetPixelFormatAttribivARB"); + pglTBufferMask3DFX = (void (__stdcall*)(GLuint))pwglGetProcAddress("glTBufferMask3DFX"); + if( pwglChoosePixelFormatARB==NULL && pglTBufferMask3DFX==NULL) { + BACKOFF; + return 0; + } + //CPrintF( " WGL choose pixel format present...\n"); + int iAttribListNum = {WGL_NUMBER_PIXEL_FORMATS_EXT}; + int iMaxFormats = 1; // default number to return + if( pwglGetPixelFormatAttribivARB!=NULL) { + // get total number of formats supported. + pwglGetPixelFormatAttribivARB( hdc, NULL, NULL, 1, &iAttribListNum, &iMaxFormats); + //CPrintF( "Max formats: %d\n", iMaxFormats); + } + UINT uiNumFormats; + int *piFormats = (int*)AllocMemory( sizeof(UINT) *iMaxFormats); + // try to get all formats that fit the pixel format criteria + if( !pwglChoosePixelFormatARB( hdc, piAttribList, NULL, iMaxFormats, piFormats, &uiNumFormats)) { + FreeMemory(piFormats); + BACKOFF; + return 0; + } + //CPrintF( " WGL choose pixel format passed...\n"); + // return the first match for now + iPixelFormat = 0; + if( uiNumFormats>0) { + iPixelFormat = piFormats[0]; + //CPrintF( "Num formats: %d\n", uiNumFormats); + //CPrintF( "First format: %d\n", iPixelFormat); + } + FreeMemory(piFormats); + } + else + { // wglChoosePixelFormatARB extension does not exist :( + iPixelFormat = 0; + } + BACKOFF; + return iPixelFormat; +} + + +void *CGfxLibrary::OGL_GetProcAddress(const char *procname) +{ + return(pwglGetProcAddress(procname)); +} + +// prepares pixel format for OpenGL context +BOOL CGfxLibrary::SetupPixelFormat_OGL( HDC hdc, BOOL bReport/*=FALSE*/) +{ + int iPixelFormat = 0; + const PIX pixResWidth = gl_dmCurrentDisplayMode.dm_pixSizeI; + const PIX pixResHeight = gl_dmCurrentDisplayMode.dm_pixSizeJ; + const DisplayDepth dd = gl_dmCurrentDisplayMode.dm_ddDepth; + + PIXELFORMATDESCRIPTOR pfd; + memset( &pfd, 0, sizeof(pfd)); + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + + // clamp depth/stencil values + extern INDEX gap_iDepthBits; + extern INDEX gap_iStencilBits; + if( gap_iDepthBits <12) gap_iDepthBits = 0; + else if( gap_iDepthBits <22) gap_iDepthBits = 16; + else if( gap_iDepthBits <28) gap_iDepthBits = 24; + else gap_iDepthBits = 32; + if( gap_iStencilBits<3) gap_iStencilBits = 0; + else if( gap_iStencilBits<7) gap_iStencilBits = 4; + else gap_iStencilBits = 8; + + // set color/depth buffer values + pfd.cColorBits = (dd!=DD_16BIT) ? 32 : 16; + pfd.cDepthBits = gap_iDepthBits; + pfd.cStencilBits = gap_iStencilBits; + + // must be required and works only in full screen via GDI functions + ogl_iTBufferEffect = Clamp( ogl_iTBufferEffect, 0L, 2L); + if( ogl_iTBufferEffect>0 && pixResWidth>0 && pixResHeight>0) + { // lets T-buffer ... :) + //CPrintF( "TBuffer init...\n"); + ogl_iTBufferSamples = (1L) << FastLog2(ogl_iTBufferSamples); + if( ogl_iTBufferSamples<2) ogl_iTBufferSamples = 4; + go_ctSampleBuffers = ogl_iTBufferSamples; + go_iCurrentWriteBuffer = 0; + iPixelFormat = ChoosePixelFormatTB( hdc, &pfd, pixResWidth, pixResHeight); + // need to reset the desktop resolution because CPFTB() resets it + BOOL bSuccess = CDS_SetMode( pixResWidth, pixResHeight, dd); + if( !bSuccess) iPixelFormat = 0; + // check T-buffer support + if( _TBCapability) pglGetIntegerv( GL_SAMPLES_3DFX, (GLint*)&go_ctSampleBuffers); + if( !iPixelFormat) { ogl_iTBufferEffect=0; CPrintF( TRANS("TBuffer initialization failed.\n")); } + else CPrintF( TRANS("TBuffer initialization passed (%d buffers in use).\n"), go_ctSampleBuffers); + } + + // if T-buffer didn't make it, let's try thru regular path + if( !iPixelFormat) { + go_ctSampleBuffers = 0; + go_iCurrentWriteBuffer = 0; + iPixelFormat = pwglChoosePixelFormat( hdc, &pfd); + } + + if( !iPixelFormat) { + WIN_CHECKERROR( 0, "ChoosePixelFormat"); + return FALSE; + } + if( !pwglSetPixelFormat( hdc, iPixelFormat, &pfd)) { + WIN_CHECKERROR( 0, "SetPixelFormat"); + return FALSE; + } + + // test acceleration + memset( &pfd, 0, sizeof(pfd)); + if( !pwglDescribePixelFormat( hdc, iPixelFormat, sizeof(pfd), &pfd)) return FALSE; + BOOL bGenericFormat = pfd.dwFlags & PFD_GENERIC_FORMAT; + BOOL bGenericAccelerated = pfd.dwFlags & PFD_GENERIC_ACCELERATED; + BOOL bHasAcceleration = (bGenericFormat && bGenericAccelerated) || // MCD + (!bGenericFormat && !bGenericAccelerated); // ICD + if( bHasAcceleration) gl_ulFlags |= GLF_HASACCELERATION; + else gl_ulFlags &= ~GLF_HASACCELERATION; + + // done if report pixel format info isn't required + if( !bReport) return TRUE; + + // prepare pixel type description + CTString strPixelType; + if( pfd.iPixelType==PFD_TYPE_RGBA) strPixelType = "TYPE_RGBA"; + else if( pfd.iPixelType&PFD_TYPE_COLORINDEX) strPixelType = "TYPE_COLORINDEX"; + else strPixelType = "unknown"; + // prepare flags description + CTString strFlags = ""; + if( pfd.dwFlags&PFD_DRAW_TO_WINDOW) strFlags += "DRAW_TO_WINDOW "; + if( pfd.dwFlags&PFD_DRAW_TO_BITMAP) strFlags += "DRAW_TO_BITMAP "; + if( pfd.dwFlags&PFD_SUPPORT_GDI) strFlags += "SUPPORT_GDI "; + if( pfd.dwFlags&PFD_SUPPORT_OPENGL) strFlags += "SUPPORT_OPENGL "; + if( pfd.dwFlags&PFD_GENERIC_ACCELERATED) strFlags += "GENERIC_ACCELERATED "; + if( pfd.dwFlags&PFD_GENERIC_FORMAT) strFlags += "GENERIC_FORMAT "; + if( pfd.dwFlags&PFD_NEED_PALETTE) strFlags += "NEED_PALETTE "; + if( pfd.dwFlags&PFD_NEED_SYSTEM_PALETTE) strFlags += "NEED_SYSTEM_PALETTE "; + if( pfd.dwFlags&PFD_DOUBLEBUFFER) strFlags += "DOUBLEBUFFER "; + if( pfd.dwFlags&PFD_STEREO) strFlags += "STEREO "; + if( pfd.dwFlags&PFD_SWAP_LAYER_BUFFERS) strFlags += "SWAP_LAYER_BUFFERS "; + if( pfd.dwFlags&PFD_DEPTH_DONTCARE) strFlags += "DEPTH_DONTCARE "; + if( pfd.dwFlags&PFD_DOUBLEBUFFER_DONTCARE) strFlags += "DOUBLEBUFFER_DONTCARE "; + if( pfd.dwFlags&PFD_STEREO_DONTCARE) strFlags += "STEREO_DONTCARE "; + if( pfd.dwFlags&PFD_SWAP_COPY) strFlags += "SWAP_COPY "; + if( pfd.dwFlags&PFD_SWAP_EXCHANGE) strFlags += "SWAP_EXCHANGE "; + if( strFlags=="") strFlags = "none"; + + // output pixel format description to console (for debugging purposes) + CPrintF( TRANS("\nPixel Format Description:\n")); + CPrintF( TRANS(" Number: %d (%s)\n"), iPixelFormat, strPixelType); + CPrintF( TRANS(" Flags: %s\n"), strFlags); + CPrintF( TRANS(" Color bits: %d (%d:%d:%d:%d)\n"), pfd.cColorBits, + pfd.cRedBits, pfd.cGreenBits, pfd.cBlueBits, pfd.cAlphaBits); + CPrintF( TRANS(" Depth bits: %d (%d for stencil)\n"), pfd.cDepthBits, pfd.cStencilBits); + gl_iCurrentDepth = pfd.cDepthBits; // keep depth bits + + // all done + CPrintF( "\n"); + return TRUE; +} + + +// prepare current viewport for rendering thru OpenGL +BOOL CGfxLibrary::SetCurrentViewport_OGL(CViewPort *pvp) +{ + // if must init entire opengl + if( gl_ulFlags & GLF_INITONNEXTWINDOW) + { + gl_ulFlags &= ~GLF_INITONNEXTWINDOW; + // reopen window + pvp->CloseCanvas(); + pvp->OpenCanvas(); + // init now + CTempDC tdc(pvp->vp_hWnd); + if( !CreateContext_OGL(tdc.hdc)) return FALSE; + gl_pvpActive = pvp; // remember as current viewport (must do that BEFORE InitContext) + InitContext_OGL(); + pvp->vp_ctDisplayChanges = gl_ctDriverChanges; + return TRUE; + } + + // if window was not set for this driver + if( pvp->vp_ctDisplayChangesCloseCanvas(); + pvp->OpenCanvas(); + // set it + CTempDC tdc(pvp->vp_hWnd); + if( !SetupPixelFormat_OGL(tdc.hdc)) return FALSE; + pvp->vp_ctDisplayChanges = gl_ctDriverChanges; + } + + if( gl_pvpActive!=NULL) { + // fail, if only one window is allowed (3dfx driver), already initialized and trying to set non-primary viewport + const BOOL bOneWindow = (gl_gaAPI[GAT_OGL].ga_adaAdapter[gl_iCurrentAdapter].da_ulFlags & DAF_ONEWINDOW); + if( bOneWindow && gl_pvpActive->vp_hWnd!=NULL && gl_pvpActive->vp_hWnd!=pvp->vp_hWnd) return FALSE; + // no need to set context if it is the same window as last time + if( gl_pvpActive->vp_hWnd==pvp->vp_hWnd) return TRUE; + } + + // try to set context to this window + pwglMakeCurrent( NULL, NULL); + CTempDC tdc(pvp->vp_hWnd); + // fail, if cannot set context to this window + if( !pwglMakeCurrent( tdc.hdc, go_hglRC)) return FALSE; + + // remember as current window + gl_pvpActive = pvp; + return TRUE; +} + + diff --git a/Sources/Engine/Graphics/gl_types.h b/Sources/Engine/Graphics/gl_types.h index 0099ac8..1889166 100644 --- a/Sources/Engine/Graphics/gl_types.h +++ b/Sources/Engine/Graphics/gl_types.h @@ -12,8 +12,6 @@ * */ -/* !!! FIXME: rcg10042001 Christ I hope this are the same on the Linux ABI... */ - typedef enum { /* Boolean values */ GL_FALSE = 0, diff --git a/Sources/Engine/Light/LayerMaker.cpp b/Sources/Engine/Light/LayerMaker.cpp index 54ff3bb..250bccd 100644 --- a/Sources/Engine/Light/LayerMaker.cpp +++ b/Sources/Engine/Light/LayerMaker.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include @@ -21,8 +21,8 @@ //#include //#include -extern INDEX _ctShadowLayers=0; -extern INDEX _ctShadowClusters=0; +INDEX _ctShadowLayers=0; +INDEX _ctShadowClusters=0; // class used for making shadow layers (used only locally) diff --git a/Sources/Engine/Light/LayerMixer.cpp b/Sources/Engine/Light/LayerMixer.cpp index 4898cf2..e776ce5 100644 --- a/Sources/Engine/Light/LayerMixer.cpp +++ b/Sources/Engine/Light/LayerMixer.cpp @@ -1,13 +1,13 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include #include #include -#include +#include #include #include #include @@ -27,8 +27,15 @@ #define W word ptr #define B byte ptr -#define ASMOPT 1 - +#if (defined USE_PORTABLE_C) + #define ASMOPT 0 +#elif (defined __MSVC_INLINE__) + #define ASMOPT 1 +#elif (defined __GNU_INLINE__) + #define ASMOPT 1 +#else + #define ASMOPT 0 +#endif extern INDEX shd_bFineQuality; extern INDEX shd_iFiltering; @@ -143,9 +150,9 @@ inline void CLayerMixer::AddAmbientToCluster( UBYTE *pub) } inline void CLayerMixer::AddToCluster( UBYTE *pub, FLOAT fIntensity) { - IncrementByteWithClip(pub[0], ((UBYTE*)&lm_colLight)[3] *fIntensity); - IncrementByteWithClip(pub[1], ((UBYTE*)&lm_colLight)[2] *fIntensity); - IncrementByteWithClip(pub[2], ((UBYTE*)&lm_colLight)[1] *fIntensity); + IncrementByteWithClip(pub[0], (long) (((UBYTE*)&lm_colLight)[3] *fIntensity)); + IncrementByteWithClip(pub[1], (long) (((UBYTE*)&lm_colLight)[2] *fIntensity)); + IncrementByteWithClip(pub[2], (long) (((UBYTE*)&lm_colLight)[1] *fIntensity)); } @@ -230,31 +237,49 @@ void CLayerMixer::FindLayerMipmap( CBrushShadowLayer *pbsl, UBYTE *&pub, UBYTE & } - +// BEWARE: Changing these #defines WILL screw up the GNU C inline asm... #define FTOX 0x10000000 #define SHIFTX (28-SQRTTABLESIZELOG2) // static variables for easier transfers static const FLOAT3D *_vLight; -static FLOAT _fMinLightDistance, _f1oFallOff; -static INDEX _iPixCt, _iRowCt; +static FLOAT _fMinLightDistance; +static FLOAT _f1oFallOff; +static INDEX _iPixCt; +static INDEX _iRowCt; static SLONG _slModulo; -static ULONG _ulLightFlags, _ulPolyFlags; -static SLONG _slL2Row, _slDDL2oDU, _slDDL2oDV, _slDDL2oDUoDV, _slDL2oDURow, _slDL2oDV; -static SLONG _slLightMax, _slHotSpot, _slLightStep; +static ULONG _ulLightFlags; +static ULONG _ulPolyFlags; +static SLONG _slL2Row; +static SLONG _slDDL2oDU; +static SLONG _slDDL2oDV; +static SLONG _slDDL2oDUoDV; +static SLONG _slDL2oDURow; +static SLONG _slDL2oDV; +static SLONG _slLightMax; +static SLONG _slHotSpot; +static SLONG _slLightStep; static ULONG *_pulLayer; +// !!! FIXME : rcg01072001 These statics are a pain in the ass. +extern "C" { + __int64 mmDDL2oDU_AddAmbientPoint; + __int64 mmDDL2oDV_AddAmbientPoint; +} + // add one layer point light without diffusion and mask void CLayerMixer::AddAmbientPoint(void) { // prepare some local variables - __int64 mmDDL2oDU = _slDDL2oDU; - __int64 mmDDL2oDV = _slDDL2oDV; + mmDDL2oDU_AddAmbientPoint = _slDDL2oDU; + mmDDL2oDV_AddAmbientPoint = _slDDL2oDV; ULONG ulLightRGB = ByteSwap(lm_colLight); _slLightMax<<=7; _slLightStep>>=1; +#if (ASMOPT == 1) + #if (defined __MSVC_INLINE__) __asm { // prepare interpolants movd mm0,D [_slL2Row] @@ -314,33 +339,156 @@ skipPixel: add edi,4 movd eax,mm3 add ebx,eax - paddd mm3,Q [mmDDL2oDU] + paddd mm3,Q [mmDDL2oDU_AddAmbientPoint] dec ecx jnz pixLoop // advance to the next row pop ebx add edi,D [_slModulo] paddd mm1,mm2 - paddd mm2,Q [mmDDL2oDV] + paddd mm2,Q [mmDDL2oDV_AddAmbientPoint] dec ebx jnz rowLoop emms } + + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + // prepare interpolants + "pushl %%ebx \n\t" + "movd (" ASMSYM(_slL2Row) "), %%mm0 \n\t" + "movd (" ASMSYM(_slDL2oDURow) "), %%mm1 \n\t" + "psllq $32, %%mm1 \n\t" + "por %%mm0, %%mm1 \n\t" // MM1 = slDL2oDURow | slL2Row + "movd (" ASMSYM(_slDL2oDV) "), %%mm0 \n\t" + "movd (" ASMSYM(_slDDL2oDUoDV) "), %%mm2 \n\t" + "psllq $32, %%mm2 \n\t" + "por %%mm0, %%mm2 \n\t" // MM2 = slDDL2oDUoDV | slDL2oDV + // prepare color + "pxor %%mm0, %%mm0 \n\t" + "movd %%eax, %%mm7 \n\t" + "punpcklbw %%mm0, %%mm7 \n\t" + "psllw $1, %%mm7 \n\t" + // loop thru rows + "movl (" ASMSYM(_pulLayer) "), %%edi \n\t" + "movl (" ASMSYM(_iRowCt) "), %%ebx \n\t" + "0: \n\t" // rowLoop + "pushl %%ebx \n\t" + "movd %%mm1, %%ebx \n\t" // EBX = slL2Point + "movq %%mm1, %%mm3 \n\t" + "psrlq $32, %%mm3 \n\t" // MM3 = 0 | slDL2oDU + // loop thru pixels in current row + "movl (" ASMSYM(_iPixCt) "), %%ecx \n\t" + "1: \n\t" // pixLoop + // check if pixel need to be drawn + "cmpl $0x10000000, %%ebx \n\t" + "jge 3f \n\t" // skipPixel + // calculate intensities and do actual drawing of shadow pixel ARGB + "movd %%ecx, %%mm4 \n\t" + "movl %%ebx, %%eax \n\t" + "sarl $15, %%eax \n\t" + "andl $8191, %%eax \n\t" + "movzbl " ASMSYM(aubSqrt) "(%%eax), %%eax \n\t" + "movl (" ASMSYM(_slLightMax) "), %%ecx \n\t" + "cmpl (" ASMSYM(_slHotSpot) "), %%eax \n\t" + "jle 2f \n\t" // skipInterpolation + "movl $255, %%ecx \n\t" + "subl %%eax, %%ecx \n\t" + "imull (" ASMSYM(_slLightStep) "), %%ecx \n\t" + "2: \n\t" // skipInterpolation + // calculate rgb pixel to add + "movd %%ecx, %%mm6 \n\t" + "punpcklwd %%mm6, %%mm6 \n\t" + "punpckldq %%mm6, %%mm6 \n\t" + "pmulhw %%mm7, %%mm6 \n\t" + // add dynamic light pixel to underlying pixel + "movd (%%edi), %%mm5 \n\t" + "punpcklbw %%mm0, %%mm5 \n\t" + "paddw %%mm6, %%mm5 \n\t" + "packuswb %%mm0, %%mm5 \n\t" + "movd %%mm5, (%%edi) \n\t" + "movd %%mm4, %%ecx \n\t" + "3: \n\t" // skipPixel + // advance to next pixel + "addl $4, %%edi \n\t" + "movd %%mm3, %%eax \n\t" + "addl %%eax, %%ebx \n\t" + "paddd (" ASMSYM(mmDDL2oDU_AddAmbientPoint) "), %%mm3 \n\t" + "decl %%ecx \n\t" + "jnz 1b \n\t" // pixLoop + // advance to the next row + "popl %%ebx \n\t" + "addl (" ASMSYM(_slModulo) "), %%edi \n\t" + "paddd %%mm2, %%mm1 \n\t" + "paddd (" ASMSYM(mmDDL2oDV_AddAmbientPoint) "), %%mm2 \n\t" + "decl %%ebx \n\t" + "jnz 0b \n\t" // rowLoop + "popl %%ebx \n\t" + "emms \n\t" + : // no outputs. + : "a" (ulLightRGB) + : "ecx", "edx", "edi", "esi", "cc", "memory" + ); + + #else + #error Write inline asm for your platform. + #endif + +#else + + // !!! FIXME WARNING: I have not checked this code, and it could be + // !!! FIXME totally and utterly wrong. --ryan. + STUBBED("may not work"); + + for( PIX pixV=0; pixV<_iRowCt; pixV++) + { + SLONG slL2Point = _slL2Row; + SLONG slDL2oDU = _slDL2oDURow; + for( PIX pixU=0; pixU<_iPixCt; pixU++) + { + // if the point is not masked + if( slL2Point < FTOX ) { + SLONG slL = (slL2Point>>SHIFTX)&(SQRTTABLESIZE-1); // and is just for degenerate cases + SLONG slIntensity = _slLightMax; + slL = aubSqrt[slL]; + if( slL>_slHotSpot) slIntensity = ((255-slL)*_slLightStep)>>8; + // add the intensity to the pixel + AddToCluster( (UBYTE*)_pulLayer, slIntensity/255.0f); + } + // go to the next pixel + _pulLayer++; + slL2Point += slDL2oDU; + slDL2oDU += _slDDL2oDU; + } + // go to the next row + _pulLayer += _slModulo/BYTES_PER_TEXEL; + _slL2Row += _slDL2oDV; + _slDL2oDV += _slDDL2oDV; + _slDL2oDURow += _slDDL2oDUoDV; + } + +#endif +} + + +extern "C" { + static __int64 mmDDL2oDU_addAmbientMaskPoint; + static __int64 mmDDL2oDV_addAmbientMaskPoint; } // add one layer point light without diffusion and with mask void CLayerMixer::AddAmbientMaskPoint( UBYTE *pubMask, UBYTE ubMask) { - -#if ASMOPT == 1 - // prepare some local variables - __int64 mmDDL2oDU = _slDDL2oDU; - __int64 mmDDL2oDV = _slDDL2oDV; + mmDDL2oDU_addAmbientMaskPoint = _slDDL2oDU; + mmDDL2oDV_addAmbientMaskPoint = _slDDL2oDV; ULONG ulLightRGB = ByteSwap(lm_colLight); _slLightMax<<=7; _slLightStep>>=1; + +#if (ASMOPT == 1) + #if (defined __MSVC_INLINE__) __asm { // prepare interpolants movd mm0,D [_slL2Row] @@ -404,7 +552,7 @@ skipPixel: add edi,4 movd eax,mm3 add ebx,eax - paddd mm3,Q [mmDDL2oDU] + paddd mm3,Q [mmDDL2oDU_addAmbientMaskPoint] rol dl,1 adc esi,0 dec ecx @@ -413,13 +561,101 @@ skipPixel: pop ebx add edi,D [_slModulo] paddd mm1,mm2 - paddd mm2,Q [mmDDL2oDV] + paddd mm2,Q [mmDDL2oDV_addAmbientMaskPoint] dec ebx jnz rowLoop emms } -#else + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + // prepare interpolants + "pushl %%ebx \n\t" + "movl %%ecx, %%ebx \n\t" + "movd (" ASMSYM(_slL2Row) "), %%mm0 \n\t" + "movd (" ASMSYM(_slDL2oDURow) "), %%mm1 \n\t" + "psllq $32, %%mm1 \n\t" + "por %%mm0, %%mm1 \n\t" // MM1 = slDL2oDURow | slL2Row + "movd (" ASMSYM(_slDL2oDV) "), %%mm0 \n\t" + "movd (" ASMSYM(_slDDL2oDUoDV) "), %%mm2 \n\t" + "psllq $32, %%mm2 \n\t" + "por %%mm0, %%mm2 \n\t" // MM2 = slDDL2oDUoDV | slDL2oDV + // prepare color + "pxor %%mm0, %%mm0 \n\t" // MM0 = 0 | 0 (for unpacking purposes) + "movd %%eax, %%mm7 \n\t" // eax == ulLightRGB + "punpcklbw %%mm0, %%mm7 \n\t" + "psllw $1, %%mm7 \n\t" + // loop thru rows + "movl (" ASMSYM(_pulLayer) "), %%edi \n\t" + "movzbl (%%ebx), %%edx \n\t" // ebx == &ubMask + "movl (" ASMSYM(_iRowCt) "), %%ebx \n\t" + "0: \n\t" // rowLoop + "pushl %%ebx \n\t" + "movd %%mm1, %%ebx \n\t" // EBX = slL2Point + "movq %%mm1, %%mm3 \n\t" + "psrlq $32, %%mm3 \n\t" // MM3 = 0 | slDL2oDU + // loop thru pixels in current row + "movl (" ASMSYM(_iPixCt) "), %%ecx \n\t" + "1: \n\t" // pixLoop + // check if pixel need to be drawn; i.e. draw if( [esi] & ubMask && (slL2Point>SHIFTX)&(SQRTTABLESIZE-1); // and is just for degenerate cases SLONG slIntensity = _slLightMax; slL = aubSqrt[slL]; @@ -438,11 +674,11 @@ skipPixel: } // go to the next pixel _pulLayer++; - slL2Point += _slDL2oDU; + slL2Point += slDL2oDU; slDL2oDU += _slDDL2oDU; ubMask<<=1; if( ubMask==0) { - pubPoint++; + pubMask++; ubMask = 1; } } @@ -457,6 +693,11 @@ skipPixel: } +extern "C" { + static __int64 mmDDL2oDU_AddDiffusionPoint; + static __int64 mmDDL2oDV_AddDiffusionPoint; +} + // add one layer point light with diffusion and without mask void CLayerMixer::AddDiffusionPoint(void) { @@ -466,12 +707,14 @@ void CLayerMixer::AddDiffusionPoint(void) if( _slLightStep!=0) slMax1oL = (256<<8) / _slLightStep +256; // prepare some local variables - __int64 mmDDL2oDU = _slDDL2oDU; - __int64 mmDDL2oDV = _slDDL2oDV; + mmDDL2oDU_AddDiffusionPoint = _slDDL2oDU; + mmDDL2oDV_AddDiffusionPoint = _slDDL2oDV; ULONG ulLightRGB = ByteSwap(lm_colLight); _slLightMax<<=7; _slLightStep>>=1; +#if ASMOPT == 1 + #if (defined __MSVC_INLINE__) __asm { // prepare interpolants movd mm0,D [_slL2Row] @@ -530,18 +773,113 @@ skipPixel: add edi,4 movd eax,mm3 add ebx,eax - paddd mm3,Q [mmDDL2oDU] + paddd mm3,Q [mmDDL2oDU_AddDiffusionPoint] dec ecx jnz pixLoop // advance to the next row pop ebx add edi,D [_slModulo] paddd mm1,mm2 - paddd mm2,Q [mmDDL2oDV] + paddd mm2,Q [mmDDL2oDV_AddDiffusionPoint] dec ebx jnz rowLoop emms } + + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "pushl %%ebx \n\t" + "movl %%ecx, %%ebx \n\t" + "pushl %%ebx \n\t" + // prepare interpolants + "movd (" ASMSYM(_slL2Row) "), %%mm0 \n\t" + "movd (" ASMSYM(_slDL2oDURow) "), %%mm1 \n\t" + "psllq $32, %%mm1 \n\t" + "por %%mm0, %%mm1 \n\t" // MM1 = slDL2oDURow | slL2Row + "movd (" ASMSYM(_slDL2oDV) "), %%mm0 \n\t" + "movd (" ASMSYM(_slDDL2oDUoDV) "), %%mm2 \n\t" + "psllq $32, %%mm2 \n\t" + "por %%mm0, %%mm2 \n\t" // MM2 = slDDL2oDUoDV | slDL2oDV + + // prepare color + "pxor %%mm0, %%mm0 \n\t" + "movd %%eax, %%mm7 \n\t" + "punpcklbw %%mm0, %%mm7 \n\t" + "psllw $1, %%mm7 \n\t" + // loop thru rows + "movl (" ASMSYM(_pulLayer) "), %%edi \n\t" + "movl (" ASMSYM(_iRowCt) "), %%ebx \n\t" + "0: \n\t" // rowLoop + "pushl %%ebx \n\t" + "movd %%mm1, %%ebx \n\t" // EBX = slL2Point + "movq %%mm1, %%mm3 \n\t" + "psrlq $32, %%mm3 \n\t" // MM3 = 0 | slDL2oDU + // loop thru pixels in current row + "movl (" ASMSYM(_iPixCt) "), %%ecx \n\t" + "1: \n\t" // pixLoop + // check if pixel need to be drawn + "cmpl $0x10000000, %%ebx \n\t" + "jge 3f \n\t" // skipPixel + // calculate intensities and do actual drawing of shadow pixel ARGB + "movd %%ecx, %%mm4 \n\t" + "movl %%ebx, %%eax \n\t" + "sarl $15, %%eax \n\t" + "andl $8191, %%eax \n\t" + "movzwl " ASMSYM(auw1oSqrt) "(, %%eax, 2), %%eax \n\t" + "movl (" ASMSYM(_slLightMax) "), %%ecx \n\t" + "cmpl 4(%%esp), %%eax \n\t" + "jge 2f \n\t" // skipInterpolation + "leal -256(%%eax), %%ecx \n\t" + "imull (" ASMSYM(_slLightStep) "), %%ecx \n\t" + "2: \n\t" // skipInterpolation + // calculate rgb pixel to add + "movd %%ecx, %%mm6 \n\t" + "punpcklwd %%mm6, %%mm6 \n\t" + "punpckldq %%mm6, %%mm6 \n\t" + "pmulhw %%mm7, %%mm6 \n\t" + // add dynamic light pixel to underlying pixel + "movd (%%edi), %%mm5 \n\t" + "punpcklbw %%mm0, %%mm5 \n\t" + "paddw %%mm6, %%mm5 \n\t" + "packuswb %%mm0, %%mm5 \n\t" + "movd %%mm5, (%%edi) \n\t" + "movd %%mm4, %%ecx \n\t" + "3: \n\t" // skipPixel + // advance to next pixel + "addl $4, %%edi \n\t" + "movd %%mm3, %%eax \n\t" + "addl %%eax, %%ebx \n\t" + "paddd (" ASMSYM(mmDDL2oDU_AddDiffusionPoint) "), %%mm3 \n\t" + "decl %%ecx \n\t" + "jnz 1b \n\t" // pixLoop + // advance to the next row + "popl %%ebx \n\t" + "addl (" ASMSYM(_slModulo) "), %%edi \n\t" + "paddd %%mm2, %%mm1 \n\t" + "paddd (" ASMSYM(mmDDL2oDV_AddDiffusionPoint) "), %%mm2 \n\t" + "decl %%ebx \n\t" + "jnz 0b \n\t" // rowLoop + "addl $4, %%esp \n\t" + "popl %%ebx \n\t" + "emms \n\t" + : // no outputs. + : "a" (ulLightRGB), "c" (slMax1oL) + : "edx", "edi", "esi", "cc", "memory" + ); + + #else + #error Write inline assembly for your platform. + #endif + +#else + STUBBED("Some layer junk"); +#endif + +} + +extern "C" { + static __int64 mmDDL2oDU_AddDiffusionMaskPoint; + static __int64 mmDDL2oDV_AddDiffusionMaskPoint; } // add one layer point light with diffusion and mask @@ -552,15 +890,15 @@ void CLayerMixer::AddDiffusionMaskPoint( UBYTE *pubMask, UBYTE ubMask) _slLightStep = FloatToInt(_slLightStep * _fMinLightDistance * _f1oFallOff); if( _slLightStep!=0) slMax1oL = (256<<8) / _slLightStep +256; -#if ASMOPT == 1 - // prepare some local variables - __int64 mmDDL2oDU = _slDDL2oDU; - __int64 mmDDL2oDV = _slDDL2oDV; + mmDDL2oDU_AddDiffusionMaskPoint = _slDDL2oDU; + mmDDL2oDV_AddDiffusionMaskPoint = _slDDL2oDV; ULONG ulLightRGB = ByteSwap(lm_colLight); _slLightMax<<=7; _slLightStep>>=1; +#if (ASMOPT == 1) + #if (defined __MSVC_INLINE__) __asm { // prepare interpolants movd mm0,D [_slL2Row] @@ -623,7 +961,7 @@ skipPixel: add edi,4 movd eax,mm3 add ebx,eax - paddd mm3,Q [mmDDL2oDU] + paddd mm3,Q [mmDDL2oDU_AddDiffusionMaskPoint] rol dl,1 adc esi,0 dec ecx @@ -632,14 +970,100 @@ skipPixel: pop ebx add edi,D [_slModulo] paddd mm1,mm2 - paddd mm2,Q [mmDDL2oDV] + paddd mm2,Q [mmDDL2oDV_AddDiffusionMaskPoint] dec ebx jnz rowLoop emms } -#else + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + // prepare interpolants + "pushl %%edx \n\t" // slMax1oL + "movd (" ASMSYM(_slL2Row) "), %%mm0 \n\t" + "movd (" ASMSYM(_slDL2oDURow) "), %%mm1 \n\t" + "psllq $32, %%mm1 \n\t" + "por %%mm0, %%mm1 \n\t" // MM1 = slDL2oDURow | slL2Row + "movd (" ASMSYM(_slDL2oDV) "), %%mm0 \n\t" + "movd (" ASMSYM(_slDDL2oDUoDV) "), %%mm2 \n\t" + "psllq $32, %%mm2 \n\t" + "por %%mm0, %%mm2 \n\t" // MM2 = slDDL2oDUoDV | slDL2oDV + // prepare color + "pxor %%mm0, %%mm0 \n\t" // MM0 = 0 | 0 (for unpacking purposes) + "movd %%eax, %%mm7 \n\t" // eax == ulLightRGB + "punpcklbw %%mm0, %%mm7 \n\t" + "psllw $1, %%mm7 \n\t" + // loop thru rows + "movl (" ASMSYM(_pulLayer) "), %%edi \n\t" + "movzbl (%%ecx), %%edx \n\t" // ecx == &ubMask + "movl (" ASMSYM(_iRowCt) "), %%ebx \n\t" + "0: \n\t" // rowLoop + "pushl %%ebx \n\t" + "movd %%mm1, %%ebx \n\t" // EBX = slL2Point + "movq %%mm1, %%mm3 \n\t" + "psrlq $32, %%mm3 \n\t" // MM3 = 0 | slDL2oDU + // loop thru pixels in current row + "movl (" ASMSYM(_iPixCt) "), %%ecx \n\t" + "1: \n\t" // pixLoop + // check if pixel need to be drawn; i.e. draw if( [esi] & ubMask && (slL2Pointlm_pixCanvasSizeU * this->lm_pixCanvasSizeV; + #if PLATFORM_LITTLEENDIAN + // Forces C fallback; BYTESWAP itself is a no-op on little endian. + register ULONG swapped = BYTESWAP32_unsigned(colAmbient); + #else + STUBBED("actually need byteswap?"); + // (uses inline asm on MacOS PowerPC) + register ULONG swapped = colAmbient; + BYTESWAP(swapped); + #endif + + for (ULONG *ptr = this->lm_pulShadowMap; count; count--) + { + *ptr = swapped; + ptr++; + } + + #elif (defined __MSVC_INLINE__) __asm { cld mov ebx,D [this] @@ -1279,6 +1828,24 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap) bswap eax rep stosd } + + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "cld \n\t" + "imull %%esi, %%ecx \n\t" + "bswapl %%eax \n\t" + "rep \n\t" + "stosl \n\t" + : // no outputs. + : "c" (this->lm_pixCanvasSizeU), "S" (this->lm_pixCanvasSizeV), + "a" (colAmbient), "D" (this->lm_pulShadowMap) + : "cc", "memory" + ); + + #else + #error Please write inline assembly for your platform. + #endif + _pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_AMBIENTFILL); // find gradient layer @@ -1354,6 +1921,10 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap) // copy from static shadow map to dynamic layer __forceinline void CLayerMixer::CopyShadowLayer(void) { + #if (defined USE_PORTABLE_C) + STUBBED("shadow layer stuff"); + + #elif (defined __MSVC_INLINE__) __asm { cld mov ebx,D [this] @@ -1363,12 +1934,31 @@ __forceinline void CLayerMixer::CopyShadowLayer(void) mov edi,D [ebx].lm_pulShadowMap rep movsd } + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "cld \n\t" + "imull %%eax, %%ecx \n\t" + "rep \n\t" + "movsl \n\t" + : // no outputs. + : "c" (this->lm_pixCanvasSizeU), "a" (this->lm_pixCanvasSizeV), + "S" (this->lm_pulStaticShadowMap), "D" (this->lm_pulShadowMap) + : "cc", "memory" + ); + + #else + #error Please write inline assembly for your platform. + #endif } // copy from static shadow map to dynamic layer __forceinline void CLayerMixer::FillShadowLayer( COLOR col) { + #if (defined USE_PORTABLE_C) + STUBBED("FillShadowLayer"); + + #elif (defined __MSVC_INLINE__) __asm { cld mov ebx,D [this] @@ -1379,6 +1969,23 @@ __forceinline void CLayerMixer::FillShadowLayer( COLOR col) bswap eax // convert to R,G,B,A memory format! rep stosd } + + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "cld \n\t" + "imull %%edx, %%ecx \n\t" + "bswapl %%eax \n\t" // convert to R,G,B,A memory format! + "rep \n\t" + "stosl \n\t" + : // no outputs. + : "c" (this->lm_pixCanvasSizeU), "d" (this->lm_pixCanvasSizeV), + "a" (col), "D" (this->lm_pulShadowMap) + : "cc", "memory" + ); + + #else + #error Please write inline assembly for your platform. + #endif } diff --git a/Sources/Engine/Light/LightSource.cpp b/Sources/Engine/Light/LightSource.cpp index e1af931..52da6f8 100644 --- a/Sources/Engine/Light/LightSource.cpp +++ b/Sources/Engine/Light/LightSource.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -25,13 +25,13 @@ CLightSource::CLightSource(void) { // set invalid properties, must be initialized by its entity - ls_ulFlags = -1; + ls_ulFlags = (ULONG) -1; ls_rHotSpot = -1; ls_rFallOff = -1; ls_colColor = 0; ls_colAmbient = 0; - ls_ubLightAnimationObject = -1; - ls_ubPolygonalMask = -1; + ls_ubLightAnimationObject = (UBYTE) -1; + ls_ubPolygonalMask = (UBYTE) -1; ls_penEntity = NULL; ls_plftLensFlare = NULL; ls_paoLightAnimation = NULL; @@ -384,7 +384,7 @@ static inline BOOL IsPolygonInfluencedByPointLight(CBrushPolygon *pbpo) } -extern CEntity *_penLightUpdating = NULL; +CEntity *_penLightUpdating = NULL; void CLightSource::FindShadowLayersPoint(BOOL bSelectedOnly) { diff --git a/Sources/Engine/Math/AABBox.h b/Sources/Engine/Math/AABBox.h index 6e0c6c4..3f7e4c3 100644 --- a/Sources/Engine/Math/AABBox.h +++ b/Sources/Engine/Math/AABBox.h @@ -76,6 +76,18 @@ public: inline void StretchByFactor(Type tSizing); // stretch the bounding box by a given sizing vector inline void StretchByVector(Vector vSizing); + + friend __forceinline CTStream &operator>>(CTStream &strm, AABBox &b) { + strm>>b.minvect; + strm>>b.maxvect; + return strm; + } + friend __forceinline CTStream &operator<<(CTStream &strm, const AABBox &b) { + strm< &operator-=(FixInt x) { slHolder -= x.slHolder; return *this;}; inline FixInt operator-(FixInt x) const { return FixInt(slHolder-x.slHolder, 1); }; /* Multiplication. */ - inline FixInt operator*(FixInt x) const { return FixInt( (SLONG)((__int64(slHolder)*x.slHolder) >>iFrac), 1); }; + inline FixInt operator*(FixInt x) const { return FixInt( (SLONG)((((__int64) slHolder)*x.slHolder) >>iFrac), 1); }; inline FixInt operator*(SLONG sl) const { return FixInt(slHolder*sl, 1); }; friend inline FixInt operator*(SLONG sl, FixInt x){ return FixInt(x.slHolder*sl, 1); }; inline FixInt &operator*=(FixInt x) { return *this = *this*x; }; /* Division. */ - inline FixInt operator/(FixInt x) const { return FixInt( (SLONG) ( (__int64(slHolder)< operator/(FixInt x) const { return FixInt( (SLONG) ( (((__int64)slHolder)< &operator/=(FixInt x) { return *this = *this/x; }; /* Relational operators. */ diff --git a/Sources/Engine/Math/Float.cpp b/Sources/Engine/Math/Float.cpp index df17605..2f06065 100644 --- a/Sources/Engine/Math/Float.cpp +++ b/Sources/Engine/Math/Float.cpp @@ -1,9 +1,70 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include +#if (defined __GNU_INLINE__) +#define MCW_PC 0x0300 +#define _MCW_PC MCW_PC +#define _PC_24 0x0000 +#define _PC_53 0x0200 +#define _PC_64 0x0300 + +inline ULONG _control87(WORD newcw, WORD mask) +{ +#if __POWERPC__ + static WORD fpw=_PC_64; + if (mask != 0) + { + fpw &= ~mask; + fpw |= (newcw & mask); + } + return(fpw); +#else + WORD fpw = 0; + + // get the current FPU control word... + __asm__ __volatile__ ("fstcw %0" : "=m" (fpw) : : "memory"); + + if (mask != 0) + { + fpw &= ~mask; + fpw |= (newcw & mask); + __asm__ __volatile__ (" fldcw %0" : : "m" (fpw) : "memory"); + } + return(fpw); +#endif +} + +// (for intel compiler...) +#elif ((defined __MSVC_INLINE__) && (!defined _MSC_VER)) +#define MCW_PC 0x0300 +#define _MCW_PC MCW_PC +#define _PC_24 0x0000 +#define _PC_53 0x0200 +#define _PC_64 0x0300 + +inline ULONG _control87(WORD newcw, WORD mask) +{ + WORD fpw = 0; + + // get the current FPU control word... + __asm fstcw word ptr [fpw]; + + if (mask != 0) + { + fpw &= ~mask; + fpw |= (newcw & mask); + __asm fldcw word ptr [fpw]; + } + return(fpw); +} + +#elif (!defined _MSC_VER) +#error Implement for your platform, or add a stub conditional here. +#endif + /* Get current precision setting of FPU. */ enum FPUPrecisionType GetFPUPrecision(void) { @@ -95,7 +156,11 @@ BOOL IsValidFloat(float f) BOOL IsValidDouble(double f) { +#ifdef _MSC_VER return _finite(f) && (*(unsigned __int64*)&f)!=0xcdcdcdcdcdcdcdcdI64; +#else + return _finite(f) && (*(unsigned long long*)&f)!=0xcdcdcdcdcdcdcdcdll; +#endif /* int iClass = _fpclass(f); return iClass==_FPCLASS_NN || diff --git a/Sources/Engine/Math/Functions.cpp b/Sources/Engine/Math/Functions.cpp index 00848f4..cb51f0c 100644 --- a/Sources/Engine/Math/Functions.cpp +++ b/Sources/Engine/Math/Functions.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Math/Functions.h b/Sources/Engine/Math/Functions.h index 0919bd1..d4628fd 100644 --- a/Sources/Engine/Math/Functions.h +++ b/Sources/Engine/Math/Functions.h @@ -41,7 +41,7 @@ inline Type Lerp( const Type x0, const Type x1, const FLOAT fRatio) { if( fRatio==0) return x0; else if( fRatio==1) return x1; - else return x0+(x1-x0)*fRatio; + else return ((Type) (x0+(x1-x0)*fRatio)); } template @@ -274,7 +274,7 @@ inline FLOAT FastRcp( const FLOAT f) inline ULONG NormFloatToByte( const FLOAT f) { /* rcg10042001 !!! FIXME: Move this elsewhere. */ -#ifdef _MSC_VER +#ifdef __MSVC_INLINE__ const FLOAT f255 = 255.0f; ULONG ulRet; __asm { @@ -284,8 +284,8 @@ inline ULONG NormFloatToByte( const FLOAT f) } return ulRet; #else - assert((f >= 0.0) && (f <= 1.0)); - return( (ULONG) (f * 255.0) ); + assert((f >= 0.0f) && (f <= 1.0f)); + return( (ULONG) (f * 255.0f) ); #endif } @@ -300,9 +300,9 @@ inline FLOAT NormByteToFloat( const ULONG ul) inline SLONG FloatToInt( FLOAT f) { #if (defined USE_PORTABLE_C) - return((SLONG) f); /* best of luck to you. */ + return((SLONG) (f + 0.5f)); /* best of luck to you. */ -#elif (defined _MSC_VER) +#elif (defined __MSVC_INLINE__) SLONG slRet; __asm { fld D [f] @@ -310,13 +310,13 @@ inline SLONG FloatToInt( FLOAT f) } return slRet; -#elif (defined __GNUC__) +#elif (defined __GNU_INLINE__) SLONG slRet; __asm__ __volatile__ ( - "flds (%%ebx) \n\t" + "flds (%%eax) \n\t" "fistpl (%%esi) \n\t" : - : "b" (&f), "S" (&slRet) + : "a" (&f), "S" (&slRet) : "memory" ); return(slRet); @@ -328,9 +328,10 @@ inline SLONG FloatToInt( FLOAT f) // log base 2 of any float numero inline FLOAT Log2( FLOAT f) { #if (defined USE_PORTABLE_C) - return (FLOAT)(log10(x)*3.321928094887); // log10(x)/log10(2) + // !!! FIXME: What's wrong with log2()? + return (FLOAT)(log10(f)*3.321928094887); // log10(x)/log10(2) -#elif (defined _MSC_VER) +#elif (defined __MSVC_INLINE__) FLOAT fRet; _asm { fld1 @@ -340,15 +341,15 @@ inline FLOAT Log2( FLOAT f) { } return fRet; -#elif (defined __GNUC__) +#elif (defined __GNU_INLINE__) FLOAT fRet; __asm__ __volatile__ ( "fld1 \n\t" - "flds (%%ebx) \n\t" + "flds (%%eax) \n\t" "fyl2x \n\t" "fstps (%%esi) \n\t" : - : "b" (&f), "S" (&fRet) + : "a" (&f), "S" (&fRet) : "memory" ); return(fRet); @@ -362,9 +363,18 @@ inline FLOAT Log2( FLOAT f) { inline SLONG FastLog2( SLONG x) { #if (defined USE_PORTABLE_C) - #error write me. + register SLONG val = x; + register SLONG retval = 0; + while (retval < 32) + { + if (val & (1 << retval)) + return retval; + retval++; + } -#elif (defined _MSC_VER) + return 0; + +#elif (defined __MSVC_INLINE__) SLONG slRet; __asm { bsr eax,D [x] @@ -372,13 +382,12 @@ inline SLONG FastLog2( SLONG x) } return slRet; -#elif (defined __GNUC__) +#elif (defined __GNU_INLINE__) SLONG slRet; __asm__ __volatile__ ( - "bsrl (%%ebx), %%eax \n\t" - "movl %%eax, (%%esi) \n\t" - : - : "b" (&x), "S" (&slRet) + "bsrl %%ecx, %%eax \n\t" + : "=a" (slRet) + : "c" (x) : "memory" ); return(slRet); @@ -391,9 +400,10 @@ inline SLONG FastLog2( SLONG x) inline SLONG FastMaxLog2( SLONG x) { #if (defined USE_PORTABLE_C) - #error write me. +printf("CHECK THIS: %s:%d\n", __FILE__, __LINE__); + return((SLONG) log2((double) x)); -#elif (defined _MSC_VER) +#elif (defined __MSVC_INLINE__) SLONG slRet; __asm { bsr eax,D [x] @@ -404,16 +414,15 @@ inline SLONG FastMaxLog2( SLONG x) } return slRet; -#elif (defined __GNUC__) +#elif (defined __GNU_INLINE__) SLONG slRet; __asm__ __volatile__ ( - "bsrl (%%ebx), %%eax \n\t" - "bsfl (%%ebx), %%edx \n\t" + "bsrl %%ecx, %%eax \n\t" + "bsfl %%ecx, %%edx \n\t" "cmpl %%eax, %%edx \n\t" "adcl $0, %%eax \n\t" - "movl %%eax, (%%esi) \n\t" - : - : "b" (&x), "S" (&slRet) + : "=a" (slRet) + : "c" (x) : "memory" ); return(slRet); @@ -437,7 +446,7 @@ inline FLOAT Sqrt( FLOAT x) { return (FLOAT)sqrt( ClampDn( x, 0.0f)); } #define ANGLE_SNAP (0.25f) //0x0010 // Wrap angle to be between 0 and 360 degrees inline ANGLE WrapAngle(ANGLE a) { - return (ANGLE) fmod( fmod(a,360.0f) + 360.0f, 360.0f); // 0..360 + return (ANGLE) fmod( fmod(a,360.0) + 360.0, 360.0); // 0..360 } // Normalize angle to be between -180 and +180 degrees @@ -561,6 +570,6 @@ inline FLOAT CalculateRatio(FLOAT fCurr, FLOAT fMin, FLOAT fMax, FLOAT fFadeInRa #undef W #undef B - #endif /* include-once check. */ + diff --git a/Sources/Engine/Math/Geometry.cpp b/Sources/Engine/Math/Geometry.cpp index c8ab137..e2ff33b 100644 --- a/Sources/Engine/Math/Geometry.cpp +++ b/Sources/Engine/Math/Geometry.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Math/Geometry.inl b/Sources/Engine/Math/Geometry.inl index a9b2ee2..3fec265 100644 --- a/Sources/Engine/Math/Geometry.inl +++ b/Sources/Engine/Math/Geometry.inl @@ -1,3 +1,8 @@ +#ifndef SE_INCL_GEOMETRY_INL +#define SE_INCL_GEOMETRY_INL +#ifdef PRAGMA_ONCE + #pragma once +#endif // mirror a position vector by a given plane inline void ReflectPositionVectorByPlane(const FLOATplane3D &plPlane, FLOAT3D &vPoint) @@ -128,3 +133,6 @@ inline void GetMajorAxesForPlane( ASSERT(Abs(plPlane(iMaxNormalAxis))>=Abs(plPlane(iMajorAxis1)) &&Abs(plPlane(iMaxNormalAxis))>=Abs(plPlane(iMajorAxis2))); } + +#endif /* include-once checker ... */ + diff --git a/Sources/Engine/Math/Geometry_DOUBLE.cpp b/Sources/Engine/Math/Geometry_DOUBLE.cpp index bd6f011..b3fcb69 100644 --- a/Sources/Engine/Math/Geometry_DOUBLE.cpp +++ b/Sources/Engine/Math/Geometry_DOUBLE.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Math/Matrix.h b/Sources/Engine/Math/Matrix.h index 9d5626b..975b3b7 100644 --- a/Sources/Engine/Math/Matrix.h +++ b/Sources/Engine/Math/Matrix.h @@ -6,6 +6,8 @@ #pragma once #endif +#include + /* * Template class for matrix of arbitrary dimensions and arbitrary type of members */ @@ -88,7 +90,7 @@ __forceinline Matrix::Matrix(void) */ // set FLOAT 3x3 -Matrix::Matrix(const FLOAT x /*= Type(0)*/) +template<> __forceinline Matrix::Matrix(const FLOAT x /*= Type(0)*/) { // set whole matrix to constant (*this)(1,1)=x; (*this)(1,2)=x; (*this)(1,3)=x; @@ -97,7 +99,7 @@ Matrix::Matrix(const FLOAT x /*= Type(0)*/) } // set DOUBLE 3x3 -Matrix::Matrix(const DOUBLE x /*= Type(0)*/) +template<> __forceinline Matrix::Matrix(const DOUBLE x /*= Type(0)*/) { // set whole matrix to constant (*this)(1,1)=x; (*this)(1,2)=x; (*this)(1,3)=x; @@ -106,7 +108,7 @@ Matrix::Matrix(const DOUBLE x /*= Type(0)*/) } template -Matrix::Matrix(const Type x /*= Type(0)*/) +inline Matrix::Matrix(const Type x /*= Type(0)*/) { ASSERT( iRows!=3 && iColumns!=3); // 3 is optimized special case // set whole matrix to constant @@ -144,7 +146,7 @@ __forceinline const Type &Matrix::operator()(int iRow, in // transposed FLOAT 3x3 -__forceinline Matrix &Matrix::operator!=(const Matrix &matrix2) +template<> __forceinline Matrix &Matrix::operator!=(const Matrix &matrix2) { (*this)(1,1)=matrix2(1,1); (*this)(1,2)=matrix2(2,1); (*this)(1,3)=matrix2(3,1); (*this)(2,1)=matrix2(1,2); (*this)(2,2)=matrix2(2,2); (*this)(2,3)=matrix2(3,2); @@ -153,7 +155,7 @@ __forceinline Matrix &Matrix::operator!=(const Matrix &Matrix::operator!=(const Matrix &matrix2) +template<> __forceinline Matrix &Matrix::operator!=(const Matrix &matrix2) { (*this)(1,1)=matrix2(1,1); (*this)(1,2)=matrix2(2,1); (*this)(1,3)=matrix2(3,1); (*this)(2,1)=matrix2(1,2); (*this)(2,2)=matrix2(2,2); (*this)(2,3)=matrix2(3,2); @@ -184,7 +186,7 @@ __forceinline Matrix &Matrix::oper // sum of two FLOATs 3x3 -__forceinline Matrix &Matrix::operator+=(const Matrix &matrix2) +template<> __forceinline Matrix &Matrix::operator+=(const Matrix &matrix2) { (*this)(1,1)+=matrix2(1,1); (*this)(1,2)+=matrix2(1,2); (*this)(1,3)+=matrix2(1,3); (*this)(2,1)+=matrix2(2,1); (*this)(2,2)+=matrix2(2,2); (*this)(2,3)+=matrix2(2,3); @@ -193,7 +195,7 @@ __forceinline Matrix &Matrix::operator+=(const Matrix &Matrix::operator+=(const Matrix &matrix2) +template<> __forceinline Matrix &Matrix::operator+=(const Matrix &matrix2) { (*this)(1,1)+=matrix2(1,1); (*this)(1,2)+=matrix2(1,2); (*this)(1,3)+=matrix2(1,3); (*this)(2,1)+=matrix2(2,1); (*this)(2,2)+=matrix2(2,2); (*this)(2,3)+=matrix2(2,3); @@ -223,7 +225,7 @@ __forceinline Matrix Matrix::opera // difference of two FLOATs 3x3 -__forceinline Matrix &Matrix::operator-=(const Matrix &matrix2) +template<> __forceinline Matrix &Matrix::operator-=(const Matrix &matrix2) { (*this)(1,1)-=matrix2(1,1); (*this)(1,2)-=matrix2(1,2); (*this)(1,3)-=matrix2(1,3); (*this)(2,1)-=matrix2(2,1); (*this)(2,2)-=matrix2(2,2); (*this)(2,3)-=matrix2(2,3); @@ -232,7 +234,7 @@ __forceinline Matrix &Matrix::operator-=(const Matrix &Matrix::operator-=(const Matrix &matrix2) +template<> __forceinline Matrix &Matrix::operator-=(const Matrix &matrix2) { (*this)(1,1)-=matrix2(1,1); (*this)(1,2)-=matrix2(1,2); (*this)(1,3)-=matrix2(1,3); (*this)(2,1)-=matrix2(2,1); (*this)(2,2)-=matrix2(2,2); (*this)(2,3)-=matrix2(2,3); @@ -271,7 +273,7 @@ __forceinline Matrix Matrix::opera // FLOAT 3x3 -__forceinline Matrix Matrix::operator*(const Matrix &matrix2) const +template<> __forceinline Matrix Matrix::operator*(const Matrix &matrix2) const { Matrix result; result(1,1) = (*this)(1,1) * matrix2(1,1) + (*this)(1,2) * matrix2(2,1) + (*this)(1,3) * matrix2(3,1); @@ -287,7 +289,7 @@ __forceinline Matrix Matrix::operator*(const Matrix Matrix::operator*(const Matrix &matrix2) const +template<> __forceinline Matrix Matrix::operator*(const Matrix &matrix2) const { Matrix result; result(1,1) = (*this)(1,1) * matrix2(1,1) + (*this)(1,2) * matrix2(2,1) + (*this)(1,3) * matrix2(3,1); @@ -333,7 +335,7 @@ __forceinline Matrix &Matrix::oper // multiply FLOAT 3x3 with scalar -__forceinline Matrix &Matrix::operator*=(const FLOAT tMul) +template<> __forceinline Matrix &Matrix::operator*=(const FLOAT tMul) { (*this)(1,1)*=tMul; (*this)(1,2)*=tMul; (*this)(1,3)*=tMul; (*this)(2,1)*=tMul; (*this)(2,2)*=tMul; (*this)(2,3)*=tMul; @@ -342,7 +344,7 @@ __forceinline Matrix &Matrix::operator*=(const FLOAT tMul) } // multiply DOUBLE 3x3 with scalar -__forceinline Matrix &Matrix::operator*=(const DOUBLE tMul) +template<> __forceinline Matrix &Matrix::operator*=(const DOUBLE tMul) { (*this)(1,1)*=tMul; (*this)(1,2)*=tMul; (*this)(1,3)*=tMul; (*this)(2,1)*=tMul; (*this)(2,2)*=tMul; (*this)(2,3)*=tMul; @@ -455,7 +457,7 @@ Vector Matrix::GetColumn(Type iColumn) const // helper functions for converting between FLOAT and DOUBLE matrices -__forceinline DOUBLEmatrix3D FLOATtoDOUBLE(const FLOATmatrix3D &mf) +static __forceinline DOUBLEmatrix3D FLOATtoDOUBLE(const FLOATmatrix3D &mf) { DOUBLEmatrix3D m; m(1,1) = FLOATtoDOUBLE(mf(1,1)); m(1,2) = FLOATtoDOUBLE(mf(1,2)); m(1,3) = FLOATtoDOUBLE(mf(1,3)); @@ -463,7 +465,7 @@ __forceinline DOUBLEmatrix3D FLOATtoDOUBLE(const FLOATmatrix3D &mf) m(3,1) = FLOATtoDOUBLE(mf(3,1)); m(3,2) = FLOATtoDOUBLE(mf(3,2)); m(3,3) = FLOATtoDOUBLE(mf(3,3)); return m; } -__forceinline FLOATmatrix3D DOUBLEtoFLOAT(const DOUBLEmatrix3D &md) { +static __forceinline FLOATmatrix3D DOUBLEtoFLOAT(const DOUBLEmatrix3D &md) { FLOATmatrix3D m; m(1,1) = DOUBLEtoFLOAT(md(1,1)); m(1,2) = DOUBLEtoFLOAT(md(1,2)); m(1,3) = DOUBLEtoFLOAT(md(1,3)); m(2,1) = DOUBLEtoFLOAT(md(2,1)); m(2,2) = DOUBLEtoFLOAT(md(2,2)); m(2,3) = DOUBLEtoFLOAT(md(2,3)); diff --git a/Sources/Engine/Math/OBBox.h b/Sources/Engine/Math/OBBox.h index d2037fd..c4eb5fe 100644 --- a/Sources/Engine/Math/OBBox.h +++ b/Sources/Engine/Math/OBBox.h @@ -10,7 +10,6 @@ #include #include #include -#include /* * Template for oriented bounding box of arbitrary type in 3D @@ -62,7 +61,7 @@ inline void OBBox::SetToNormalizedEmpty(void) { * Constructor for empty bounding box. */ template -inline OBBox::OBBox() { +inline OBBox::OBBox() { SetToNormalizedEmpty(); } diff --git a/Sources/Engine/Math/Object3D.cpp b/Sources/Engine/Math/Object3D.cpp index 55f41db..8c064b6 100644 --- a/Sources/Engine/Math/Object3D.cpp +++ b/Sources/Engine/Math/Object3D.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Math/Object3D.h b/Sources/Engine/Math/Object3D.h index 2351ed5..6ca3630 100644 --- a/Sources/Engine/Math/Object3D.h +++ b/Sources/Engine/Math/Object3D.h @@ -136,7 +136,17 @@ public: /* Clear the object. */ inline void Clear(void) {}; /* Get start and end vertices. */ - inline void GetVertices(CObjectVertex *&povxStart, CObjectVertex *&povxEnd); + inline void GetVertices(CObjectVertex *&povxStart, CObjectVertex *&povxEnd) + { + ASSERT(ope_Edge!=NULL); + if (ope_Backward) { + povxStart = ope_Edge->oed_Vertex1; + povxEnd = ope_Edge->oed_Vertex0; + } else { + povxStart = ope_Edge->oed_Vertex0; + povxEnd = ope_Edge->oed_Vertex1; + } + } }; // a polygon in 3d object diff --git a/Sources/Engine/Math/Object3D_CSG.cpp b/Sources/Engine/Math/Object3D_CSG.cpp index 9464b92..facd62e 100644 --- a/Sources/Engine/Math/Object3D_CSG.cpp +++ b/Sources/Engine/Math/Object3D_CSG.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Math/Object3D_IO.cpp b/Sources/Engine/Math/Object3D_IO.cpp index 2fb0311..3b6bffe 100644 --- a/Sources/Engine/Math/Object3D_IO.cpp +++ b/Sources/Engine/Math/Object3D_IO.cpp @@ -3,7 +3,7 @@ // If you happen to have the Exploration 3D library (in Engine/exploration3d/), you can enable its features here. #define USE_E3D 0 -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Math/ObjectSector.cpp b/Sources/Engine/Math/ObjectSector.cpp index 08cee72..dea7960 100644 --- a/Sources/Engine/Math/ObjectSector.cpp +++ b/Sources/Engine/Math/ObjectSector.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -31,8 +31,8 @@ #define EDX_EPSILON DOUBLE(0.00390625*mth_fCSGEpsilon) // 1/2^8 // use O(nlogn) instead O(n2) algorithms for object optimization -extern INDEX wld_bFastObjectOptimization = 1.0f; -extern FLOAT mth_fCSGEpsilon = 1.0f; +INDEX wld_bFastObjectOptimization = 1; +FLOAT mth_fCSGEpsilon = 1.0f; /* * Compare two vertices. @@ -219,6 +219,10 @@ BOOL FindEdge( CStaticArray &apedSorted, /* * Get start and end vertices. */ +// rcg10162001 wtf...I had to move this into the class definition itself. +// I think it's an optimization bug; I didn't have this problem when I +// didn't give GCC the "-O2" option. +#if 0 void CObjectPolygonEdge::GetVertices(CObjectVertex *&povxStart, CObjectVertex *&povxEnd) { ASSERT(ope_Edge!=NULL); @@ -230,6 +234,8 @@ void CObjectPolygonEdge::GetVertices(CObjectVertex *&povxStart, CObjectVertex *& povxEnd = ope_Edge->oed_Vertex1; } } +#endif + /* * Default constructor. diff --git a/Sources/Engine/Math/Placement.cpp b/Sources/Engine/Math/Placement.cpp index 13b9309..fb5ea2e 100644 --- a/Sources/Engine/Math/Placement.cpp +++ b/Sources/Engine/Math/Placement.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include @@ -12,12 +12,14 @@ CTStream &operator>>(CTStream &strm, CPlacement3D &p3d) { - strm.Read_t(&p3d, sizeof(p3d)); + strm>>p3d.pl_PositionVector; + strm>>p3d.pl_OrientationAngle; return strm; } CTStream &operator<<(CTStream &strm, const CPlacement3D &p3d) { - strm.Write_t(&p3d, sizeof(p3d)); + strm< #include + +#ifdef NETSTRUCTS_PACKED +#pragma pack(1) +#endif + /* * Placement of an object in 3D space */ @@ -51,6 +56,11 @@ public: /* Make this placement be a linear interpolation between given two placements. */ void Lerp(const CPlacement3D &pl0, const CPlacement3D &pl1, FLOAT fFactor); }; + +#ifdef NETSTRUCTS_PACKED +#pragma pack() +#endif + /* Stream operations */ ENGINE_API CTStream &operator>>(CTStream &strm, CPlacement3D &p3d); ENGINE_API CTStream &operator<<(CTStream &strm, const CPlacement3D &p3d); diff --git a/Sources/Engine/Math/Plane.h b/Sources/Engine/Math/Plane.h index d9f309a..af282e9 100644 --- a/Sources/Engine/Math/Plane.h +++ b/Sources/Engine/Math/Plane.h @@ -64,6 +64,17 @@ public: // multiplication by a square matrix (sides swapped -- see implementation for notes) inline Plane &operator*=(const Matrix &matrix2); Plane operator*(const Matrix &matrix2) const; + + friend __forceinline CTStream &operator>>(CTStream &strm, Plane &p) { + strm>>(Vector&)p; + strm>>p.pl_distance; + return strm; + } + friend __forceinline CTStream &operator<<(CTStream &strm, const Plane &p) { + strm<<(const Vector&)p; + strm<::Plane(const Vector &normal, : Vector(normal) { // normalize normal vector - Normalize(); + this->Normalize(); pl_distance = (*this)%point; // distance = normalized_normal * point (dot product) } diff --git a/Sources/Engine/Math/Projection.cpp b/Sources/Engine/Math/Projection.cpp index eca0725..d44e796 100644 --- a/Sources/Engine/Math/Projection.cpp +++ b/Sources/Engine/Math/Projection.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Math/Projection.h b/Sources/Engine/Math/Projection.h index 5cd8392..5903afe 100644 --- a/Sources/Engine/Math/Projection.h +++ b/Sources/Engine/Math/Projection.h @@ -421,19 +421,19 @@ public: inline CAnyProjection3D(void) : ap_CurrentProjection(NULL) {}; /* Copy constructor. */ inline CAnyProjection3D(const CAnyProjection3D &apOriginal) { operator=(apOriginal);} - /* Start beeing CSimpleProjection3D. */ + /* Start being CSimpleProjection3D. */ inline void BeSimple(void); /* Test if CSimpleProjection3D. */ inline BOOL IsSimple(void); - /* Start beeing CIsometricProjection3D. */ + /* Start being CIsometricProjection3D. */ inline void BeIsometric(void); /* Test if CIsometricProjection3D. */ inline BOOL IsIsometric(void); - /* Start beeing CPerspectiveProjection3D. */ + /* Start being CPerspectiveProjection3D. */ inline void BePerspective(void); /* Test if CPerspectiveProjection3D. */ inline BOOL IsPerspective(void); - /* Start beeing CParallelProjection3D. */ + /* Start being CParallelProjection3D. */ inline void BeParallel(void); /* Test if CParallelProjection3D. */ inline BOOL IsParallel(void); @@ -657,7 +657,7 @@ ENGINE_API inline const FLOAT &CIsometricProjection3D::ZoomFactorR(void) const { // CAnyProjection3D ///////////////////////////////////////////////////////////////////// /* - * Start beeing CSimpleProjection3D. + * Start being CSimpleProjection3D. */ ENGINE_API inline void CAnyProjection3D::BeSimple(void) { @@ -665,7 +665,7 @@ ENGINE_API inline void CAnyProjection3D::BeSimple(void) } /* - * Start beeing CIsometricProjection3D. + * Start being CIsometricProjection3D. */ ENGINE_API inline void CAnyProjection3D::BeIsometric(void) { diff --git a/Sources/Engine/Math/Projection_Isometric.cpp b/Sources/Engine/Math/Projection_Isometric.cpp index a6a7117..252bb37 100644 --- a/Sources/Engine/Math/Projection_Isometric.cpp +++ b/Sources/Engine/Math/Projection_Isometric.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include @@ -203,7 +203,7 @@ INDEX CIsometricProjection3D::TestBoxToFrustum(const FLOATobbox3D &box) const INDEX iTest; // check to near - iTest = box.TestAgainstPlane(FLOATplane3D(FLOAT3D(0,0,-1), pr_NearClipDistance)); + iTest = (INDEX) box.TestAgainstPlane(FLOATplane3D(FLOAT3D(0,0,-1), pr_NearClipDistance)); if( iTest<0) { return -1; } else if( iTest==0) { @@ -211,7 +211,7 @@ INDEX CIsometricProjection3D::TestBoxToFrustum(const FLOATobbox3D &box) const } // check to far if( pr_FarClipDistance>0) { - iTest = box.TestAgainstPlane(FLOATplane3D(FLOAT3D(0,0,1), -pr_FarClipDistance)); + iTest = (INDEX) box.TestAgainstPlane(FLOATplane3D(FLOAT3D(0,0,1), -pr_FarClipDistance)); if( iTest<0) { return -1; } else if( iTest==0) { @@ -219,28 +219,28 @@ INDEX CIsometricProjection3D::TestBoxToFrustum(const FLOATobbox3D &box) const } } // check to left - iTest = box.TestAgainstPlane(pr_plClipL); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipL); if( iTest<0) { return -1; } else if( iTest==0) { iPass = 0; } // check to right - iTest = box.TestAgainstPlane(pr_plClipR); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipR); if( iTest<0) { return -1; } else if( iTest==0) { iPass = 0; } // check to up - iTest = box.TestAgainstPlane(pr_plClipU); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipU); if( iTest<0) { return -1; } else if( iTest==0) { iPass = 0; } // check to down - iTest = box.TestAgainstPlane(pr_plClipD); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipD); if( iTest<0) { return -1; } else if( iTest==0) { diff --git a/Sources/Engine/Math/Projection_Parallel.cpp b/Sources/Engine/Math/Projection_Parallel.cpp index 3d51a3b..528f017 100644 --- a/Sources/Engine/Math/Projection_Parallel.cpp +++ b/Sources/Engine/Math/Projection_Parallel.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include @@ -192,7 +192,7 @@ INDEX CParallelProjection3D::TestBoxToFrustum(const FLOATobbox3D &box) const INDEX iTest; // check to near - iTest = box.TestAgainstPlane(FLOATplane3D(FLOAT3D(0,0,-1), pr_NearClipDistance)); + iTest = (INDEX) box.TestAgainstPlane(FLOATplane3D(FLOAT3D(0,0,-1), pr_NearClipDistance)); if( iTest<0) { return -1; } else if( iTest==0) { @@ -200,7 +200,7 @@ INDEX CParallelProjection3D::TestBoxToFrustum(const FLOATobbox3D &box) const } // check to far if( pr_FarClipDistance>0) { - iTest = box.TestAgainstPlane(FLOATplane3D(FLOAT3D(0,0,1), -pr_FarClipDistance)); + iTest = (INDEX) box.TestAgainstPlane(FLOATplane3D(FLOAT3D(0,0,1), -pr_FarClipDistance)); if( iTest<0) { return -1; } else if( iTest==0) { @@ -208,28 +208,28 @@ INDEX CParallelProjection3D::TestBoxToFrustum(const FLOATobbox3D &box) const } } // check to left - iTest = box.TestAgainstPlane(pr_plClipL); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipL); if( iTest<0) { return -1; } else if( iTest==0) { iPass = 0; } // check to right - iTest = box.TestAgainstPlane(pr_plClipR); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipR); if( iTest<0) { return -1; } else if( iTest==0) { iPass = 0; } // check to up - iTest = box.TestAgainstPlane(pr_plClipU); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipU); if( iTest<0) { return -1; } else if( iTest==0) { iPass = 0; } // check to down - iTest = box.TestAgainstPlane(pr_plClipD); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipD); if( iTest<0) { return -1; } else if( iTest==0) { diff --git a/Sources/Engine/Math/Projection_Perspective.cpp b/Sources/Engine/Math/Projection_Perspective.cpp index 3d7528c..d6c979e 100644 --- a/Sources/Engine/Math/Projection_Perspective.cpp +++ b/Sources/Engine/Math/Projection_Perspective.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include @@ -314,7 +314,7 @@ INDEX CPerspectiveProjection3D::TestBoxToFrustum(const FLOATobbox3D &box) const INDEX iTest; // check to near - iTest = box.TestAgainstPlane( FLOATplane3D(FLOAT3D(0,0,-1), pr_NearClipDistance)); + iTest = (INDEX) box.TestAgainstPlane( FLOATplane3D(FLOAT3D(0,0,-1), pr_NearClipDistance)); if( iTest<0) { return -1; } else if( iTest==0) { @@ -322,7 +322,7 @@ INDEX CPerspectiveProjection3D::TestBoxToFrustum(const FLOATobbox3D &box) const } // check to far if( pr_FarClipDistance>0) { - iTest = box.TestAgainstPlane( FLOATplane3D(FLOAT3D(0,0,1), -pr_FarClipDistance)); + iTest = (INDEX) box.TestAgainstPlane( FLOATplane3D(FLOAT3D(0,0,1), -pr_FarClipDistance)); if( iTest<0) { return -1; } else if( iTest==0) { @@ -330,28 +330,28 @@ INDEX CPerspectiveProjection3D::TestBoxToFrustum(const FLOATobbox3D &box) const } } // check to left - iTest = box.TestAgainstPlane(pr_plClipL); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipL); if( iTest<0) { return -1; } else if( iTest==0) { iPass = 0; } // check to right - iTest = box.TestAgainstPlane(pr_plClipR); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipR); if( iTest<0) { return -1; } else if( iTest==0) { iPass = 0; } // check to up - iTest = box.TestAgainstPlane(pr_plClipU); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipU); if( iTest<0) { return -1; } else if( iTest==0) { iPass = 0; } // check to down - iTest = box.TestAgainstPlane(pr_plClipD); + iTest = (INDEX) box.TestAgainstPlane(pr_plClipD); if( iTest<0) { return -1; } else if( iTest==0) { diff --git a/Sources/Engine/Math/Projection_Simple.cpp b/Sources/Engine/Math/Projection_Simple.cpp index 442e162..fac1be3 100644 --- a/Sources/Engine/Math/Projection_Simple.cpp +++ b/Sources/Engine/Math/Projection_Simple.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Math/Projection_Simple_DOUBLE.cpp b/Sources/Engine/Math/Projection_Simple_DOUBLE.cpp index 74be9c3..566b3fd 100644 --- a/Sources/Engine/Math/Projection_Simple_DOUBLE.cpp +++ b/Sources/Engine/Math/Projection_Simple_DOUBLE.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Math/Quaternion.h b/Sources/Engine/Math/Quaternion.h index d586bcc..ee9280c 100644 --- a/Sources/Engine/Math/Quaternion.h +++ b/Sources/Engine/Math/Quaternion.h @@ -24,6 +24,8 @@ public: // conversion from euler angles void FromEuler(const Vector &a); + inline Type EPS(Type orig) const; + // conversion to matrix void ToMatrix(Matrix &m) const; // conversion from matrix @@ -43,7 +45,12 @@ public: // multiplication/division by a scalar inline Quaternion operator*(Type t) const; inline Quaternion &operator*=(Type t); - friend Quaternion operator*(Type t, Quaternion q); + + friend Quaternion operator*(Type t, Quaternion q) + { + return Quaternion(q.q_w*t, q.q_x*t, q.q_y*t, q.q_z*t); + } + inline Quaternion operator/(Type t) const; inline Quaternion &operator/=(Type t); @@ -61,17 +68,88 @@ public: // quaternion norm (euclidian length of a 4d vector) inline Type Norm(void) const; + friend __forceinline CTStream &operator>>(CTStream &strm, Quaternion &q) { + strm>>q.q_w; + strm>>q.q_x; + strm>>q.q_y; + strm>>q.q_z; + return strm; + } + + friend __forceinline CTStream &operator<<(CTStream &strm, const Quaternion &q) { + strm< Exp(const Quaternion &q); - friend Quaternion Log(const Quaternion &q);*/ + friend Quaternion Exp(const Quaternion &q) + { + Type tAngle = (Type)sqrt(q.q_x*q.q_x + q.q_y*q.q_y + q.q_z*q.q_z); + Type tSin = sin(tAngle); + Type tCos = cos(tAngle); + + if (fabs(tSin)<0.001) { + return Quaternion(tCos, q.q_x, q.q_y, q.q_z); + } else { + Type tRatio = tSin/tAngle; + return Quaternion(tCos, q.q_x*tRatio, q.q_y*tRatio, q.q_z*tRatio); + } + } + + friend Quaternion Log(const Quaternion &q) + { + if (fabs(q.q_w)<1.0) { + Type tAngle = acos(q.q_w); + Type tSin = sin(tAngle); + if (fabs(tSin)>=0.001) { + Type tRatio = tAngle/tSin; + return Quaternion(Type(0), q.q_x*tRatio, q.q_y*tRatio, q.q_z*tRatio); + } + } + + return Quaternion(Type(0), q.q_x, q.q_y, q.q_z); + } // spherical linear interpolation - /*friend Quaternion Slerp(Type tT, - const Quaternion &q1, const Quaternion &q2);*/ + friend Quaternion Slerp(Type tT, + const Quaternion &q1, const Quaternion &q2) + { + Type tCos = q1%q2; + + Quaternion qTemp; + + if (tCos Type(0.001)) { + // standard case (slerp) + Type tAngle = acos(tCos); + Type tSin = sin(tAngle); + tF1 = sin((Type(1)-tT)*tAngle)/tSin; + tF2 = sin(tT*tAngle)/tSin; + } else { + // linear interpolation + tF1 = Type(1)-tT; + tF2 = tT; + } + return q1*tF1 + qTemp*tF2; + } + // spherical quadratic interpolation - /*friend Quaternion Squad(Type tT, + friend Quaternion Squad(Type tT, const Quaternion &q1, const Quaternion &q2, - const Quaternion &qa, const Quaternion &qb);*/ + const Quaternion &qa, const Quaternion &qb) + { + return Slerp(2*tT*(1-tT),Slerp(tT,q1,q2),Slerp(tT,qa,qb)); + } }; // inline functions implementation @@ -112,10 +190,14 @@ inline Quaternion &Quaternion::operator*=(Type t) { q_w*=t; q_x*=t; q_y*=t; q_z*=t; return *this; } + +#if 0 template inline Quaternion operator*(Type t, Quaternion q) { return Quaternion(q.q_w*t, q.q_x*t, q.q_y*t, q.q_z*t); } +#endif + template inline Quaternion Quaternion::operator/(Type t) const { return Quaternion(q_w/t, q_x/t, q_y/t, q_z/t); @@ -172,6 +254,7 @@ inline Type Quaternion::Norm(void) const { return (Type)sqrt(q_w*q_w + q_x*q_x + q_y*q_y + q_z*q_z); } +#if 0 // transcendental functions template inline Quaternion Exp(const Quaternion &q) @@ -241,6 +324,7 @@ inline Quaternion Squad(Type tT, { return Slerp(2*tT*(1-tT),Slerp(tT,q1,q2),Slerp(tT,qa,qb)); } +#endif // conversion from euler angles template @@ -267,6 +351,17 @@ void Quaternion::FromEuler(const Vector &a) (*this) = qH*qP*qB; } + +// Check for almost, not really, but should be 0.0 values... +template +Type Quaternion::EPS(Type orig) const +{ + if ((orig <= 10e-6) && (orig >= -10e-6)) + return(0.0); + + return(orig); +} + // conversion to matrix template void Quaternion::ToMatrix(Matrix &m) const @@ -275,9 +370,9 @@ void Quaternion::ToMatrix(Matrix &m) const Type yy = 2*q_y*q_y; Type yz = 2*q_y*q_z; Type zz = 2*q_z*q_z; Type wx = 2*q_w*q_x; Type wy = 2*q_w*q_y; Type wz = 2*q_w*q_z; - m(1,1) = 1.0-(yy+zz); m(1,2) = xy-wz; m(1,3) = xz+wy; - m(2,1) = xy+wz; m(2,2) = 1.0-(xx+zz); m(2,3) = yz-wx; - m(3,1) = xz-wy; m(3,2) = yz+wx; m(3,3) = 1.0-(xx+yy); + m(1,1) = EPS(1.0-(yy+zz)); m(1,2) = EPS(xy-wz); m(1,3) = EPS(xz+wy); + m(2,1) = EPS(xy+wz); m(2,2) = EPS(1.0-(xx+zz)); m(2,3) = EPS(yz-wx); + m(3,1) = EPS(xz-wy); m(3,2) = EPS(yz+wx); m(3,3) = EPS(1.0-(xx+yy)); } // conversion from matrix diff --git a/Sources/Engine/Math/TextureMapping.cpp b/Sources/Engine/Math/TextureMapping.cpp index b9c38a9..bc6ffef 100644 --- a/Sources/Engine/Math/TextureMapping.cpp +++ b/Sources/Engine/Math/TextureMapping.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include @@ -186,7 +186,10 @@ void CMappingDefinition::ReadOld_t(CTStream &strm) // throw char * FLOAT tm_fOffsetU; // texture offsets (in meters) FLOAT tm_fOffsetV; } tmo; - strm.Read_t(&tmo, sizeof(tmo)); + strm>>tmo.tm_ulFlags; + strm>>tmo.tm_aRotation; + strm>>tmo.tm_fOffsetU; + strm>>tmo.tm_fOffsetV; FLOAT fSin = Sin(tmo.tm_aRotation); FLOAT fCos = Cos(tmo.tm_aRotation); @@ -323,12 +326,22 @@ void CMappingDefinition::Transform(const FLOATplane3D &plSourcePlane, // stream operations CTStream &operator>>(CTStream &strm, CMappingDefinition &md) { - strm.Read_t(&md, sizeof(md)); + strm>>md.md_fUoS; + strm>>md.md_fUoT; + strm>>md.md_fVoS; + strm>>md.md_fVoT; + strm>>md.md_fUOffset; + strm>>md.md_fVOffset; return strm; } CTStream &operator<<(CTStream &strm, const CMappingDefinition &md) { - strm.Write_t(&md, sizeof(md)); + strm<>(CTStream &strm, CMappingDefinition &md); // throw char * ENGINE_API CTStream &operator<<(CTStream &strm, const CMappingDefinition &md); // throw char * diff --git a/Sources/Engine/Math/Vector.h b/Sources/Engine/Math/Vector.h index 6004008..63a5bb3 100644 --- a/Sources/Engine/Math/Vector.h +++ b/Sources/Engine/Math/Vector.h @@ -7,7 +7,10 @@ #endif #include +#include +#include #include +#include /* * Template class for vector of arbitrary dimensions and arbitrary type of members @@ -72,11 +75,13 @@ public: /* Stream operations */ friend __forceinline CTStream &operator>>(CTStream &strm, Vector &vector) { - strm.Read_t(&vector, sizeof(vector)); + for (SLONG i = 0; i < iDimensions; i++) + strm>>vector.vector[i]; return strm; } - friend __forceinline CTStream &operator<<(CTStream &strm, Vector &vector) { - strm.Write_t(&vector, sizeof(vector)); + friend __forceinline CTStream &operator<<(CTStream &strm, const Vector &vector) { + for (SLONG i = 0; i < iDimensions; i++) + strm<::Vector(Type x1, Type x2, Type x3, Type /* * Conversion into scalar -- length of vector. */ -__forceinline FLOAT Vector::Length(void) const +template<> __forceinline FLOAT Vector::Length(void) const { return (FLOAT)sqrt( (DOUBLE)((*this)(1)*(*this)(1) + (*this)(2)*(*this)(2) + (*this)(3)*(*this)(3))); } -__forceinline DOUBLE Vector::Length(void) const +template<> __forceinline DOUBLE Vector::Length(void) const { return (DOUBLE)sqrt( (DOUBLE)((*this)(1)*(*this)(1) + (*this)(2)*(*this)(2) + (*this)(3)*(*this)(3))); } @@ -230,7 +235,7 @@ __forceinline Vector &Vector::SafeNormaliz // unary minus FLOAT3D -__forceinline Vector &Vector::Flip(void) +template<> __forceinline Vector &Vector::Flip(void) { (*this)(1) = -(*this)(1); (*this)(2) = -(*this)(2); @@ -239,7 +244,7 @@ __forceinline Vector &Vector::Flip(void) } // unary minus DOUBLE3D -__forceinline Vector &Vector::Flip(void) +template<> __forceinline Vector &Vector::Flip(void) { (*this)(1) = -(*this)(1); (*this)(2) = -(*this)(2); @@ -267,7 +272,7 @@ __forceinline Vector Vector::operator-(voi // sum of two vectors FLOAT3D -__forceinline Vector &Vector::operator+=(const Vector &vector2) +template<> __forceinline Vector &Vector::operator+=(const Vector &vector2) { // add member by member (*this)(1) += vector2(1); @@ -277,7 +282,7 @@ __forceinline Vector &Vector::operator+=(const Vector } // sum of two vectors DOUBLE3D -__forceinline Vector &Vector::operator+=(const Vector &vector2) +template<> __forceinline Vector &Vector::operator+=(const Vector &vector2) { // add member by member (*this)(1) += vector2(1); @@ -306,7 +311,7 @@ __forceinline Vector Vector::operator+(con // difference of two vectors FLOAT3D -__forceinline Vector &Vector::operator-=(const Vector &vector2) +template<> __forceinline Vector &Vector::operator-=(const Vector &vector2) { // add member by member (*this)(1) -= vector2(1); @@ -316,7 +321,7 @@ __forceinline Vector &Vector::operator-=(const Vector } // difference of two vectors DOUBLE3D -__forceinline Vector &Vector::operator-=(const Vector &vector2) +template<> __forceinline Vector &Vector::operator-=(const Vector &vector2) { // add member by member (*this)(1) -= vector2(1); @@ -346,7 +351,7 @@ __forceinline Vector Vector::operator-(con // multiplication with scalar FLOAT3D -__forceinline Vector &Vector::operator*=(const FLOAT scalar) +template<> __forceinline Vector &Vector::operator*=(const FLOAT scalar) { (*this)(1) *= scalar; (*this)(2) *= scalar; @@ -355,7 +360,7 @@ __forceinline Vector &Vector::operator*=(const FLOAT scalar) } // multiplication with scalar DOUBLE3D -__forceinline Vector &Vector::operator*=(const DOUBLE scalar) +template<> __forceinline Vector &Vector::operator*=(const DOUBLE scalar) { (*this)(1) *= scalar; (*this)(2) *= scalar; @@ -380,7 +385,7 @@ __forceinline Vector Vector::operator*(con // division with scalar FLOAT3D -__forceinline Vector &Vector::operator/=(const FLOAT scalar) +template<> __forceinline Vector &Vector::operator/=(const FLOAT scalar) { const FLOAT rcp = 1.0f/scalar; (*this)(1) *= rcp; @@ -390,7 +395,7 @@ __forceinline Vector &Vector::operator/=(const FLOAT scalar) } // division with scalar DOUBLE3D -__forceinline Vector &Vector::operator/=(const DOUBLE scalar) +template<> __forceinline Vector &Vector::operator/=(const DOUBLE scalar) { const DOUBLE rcp = 1.0/scalar; (*this)(1) *= rcp; @@ -421,7 +426,7 @@ __forceinline Vector Vector::operator/(con */ // NOTE: The matrix should have been on the left side of the vector, but the template syntax wouldn't allow that. -__forceinline Vector Vector::operator*(const Matrix &matrix2) const +template<> __forceinline Vector Vector::operator*(const Matrix &matrix2) const { Vector result; result(1) = matrix2(1,1) * (*this)(1) + matrix2(1,2) * (*this)(2) + matrix2(1,3) * (*this)(3); @@ -430,7 +435,7 @@ __forceinline Vector Vector::operator*(const Matrix Vector::operator*(const Matrix &matrix2) const +template<> __forceinline Vector Vector::operator*(const Matrix &matrix2) const { Vector result; result(1) = matrix2(1,1) * (*this)(1) + matrix2(1,2) * (*this)(2) + matrix2(1,3) * (*this)(3); @@ -462,13 +467,13 @@ __forceinline Vector Vector::operator*(con // scalar product - dot product, inner product for FLOAT3D -__forceinline FLOAT Vector::operator%(const Vector &vector2) const +template<> __forceinline FLOAT Vector::operator%(const Vector &vector2) const { return (FLOAT)((*this)(1)*vector2(1) + (*this)(2)*vector2(2) + (*this)(3)*vector2(3)); } // scalar product - dot product, inner product for DOUBLE3D -__forceinline DOUBLE Vector::operator%(const Vector &vector2) const +template<> __forceinline DOUBLE Vector::operator%(const Vector &vector2) const { return (DOUBLE)((*this)(1)*vector2(1) + (*this)(2)*vector2(2) + (*this)(3)*vector2(3)); } @@ -513,13 +518,13 @@ __forceinline Vector Vector::operator*(con // comparation FLOAT3D -__forceinline BOOL Vector::operator==(const Vector &vector2) const +template<> __forceinline BOOL Vector::operator==(const Vector &vector2) const { return( (*this)(1)==vector2(1) && (*this)(2)==vector2(2) && (*this)(3)==vector2(3)); } // comparation DOUBLE3D -__forceinline BOOL Vector::operator==(const Vector &vector2) const +template<> __forceinline BOOL Vector::operator==(const Vector &vector2) const { return( (*this)(1)==vector2(1) && (*this)(2)==vector2(2) && (*this)(3)==vector2(3)); } diff --git a/Sources/Engine/Models/EditModel.cpp b/Sources/Engine/Models/EditModel.cpp index 8fb0a06..ece0825 100644 --- a/Sources/Engine/Models/EditModel.cpp +++ b/Sources/Engine/Models/EditModel.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -178,7 +178,7 @@ void CEditModel::LoadModelAnimationData_t( CTStream *pFile, const FLOATmatrix3D OB3D.LoadAny3DFormat_t( CTString(itFr->cfnn_FileName), mStretch); if( edm_md.md_VerticesCt != OB3D.ob_aoscSectors[0].osc_aovxVertices.Count()) { ThrowF_t( "File %s, one of animation frame files has wrong number of points.", - (CTString)fnnFileNameNode.cfnn_FileName); + (const char *) (CTString)fnnFileNameNode.cfnn_FileName); } if(bOrigin) { @@ -248,7 +248,7 @@ void CEditModel::LoadModelAnimationData_t( CTStream *pFile, const FLOATmatrix3D // only triangles are supported! ASSERT( opo.opo_PolygonEdges.Count() == 3); if( opo.opo_PolygonEdges.Count() != 3) { - ThrowF_t( "Non-triangle polygon encountered in model file %s !", fnmFirstFrame); + ThrowF_t( "Non-triangle polygon encountered in model file %s !", (const char *) fnmFirstFrame); } // get all 3 vetrices of current polygon and sorted them opo.opo_PolygonEdges.Lock(); @@ -437,7 +437,7 @@ void CEditModel::SaveIncludeFile_t( CTFileName fnFileName, CTString strDefinePre { if( edm_md.md_ColorNames[ i] != "") { - sprintf( line, "#define %s_PART_%s ((1L) << %d)\n", strDefinePrefix, edm_md.md_ColorNames[ i], i); + sprintf( line, "#define %s_PART_%s ((1L) << %d)\n", (const char *) strDefinePrefix, (const char *) edm_md.md_ColorNames[ i], i); strmHFile.Write_t( line, strlen( line)); } } @@ -449,7 +449,7 @@ void CEditModel::SaveIncludeFile_t( CTFileName fnFileName, CTString strDefinePre CTString strPatchName = edm_md.md_mpPatches[ iPatch].mp_strName; if( strPatchName != "") { - sprintf( line, "#define %s_PATCH_%s %d\n", strDefinePrefix, strPatchName, i); + sprintf( line, "#define %s_PATCH_%s %d\n", (const char *) strDefinePrefix, (const char *) strPatchName, i); strmHFile.Write_t( line, strlen( line)); } } @@ -462,7 +462,7 @@ void CEditModel::SaveIncludeFile_t( CTFileName fnFileName, CTString strDefinePre for( INDEX iCollisionBox=0; iCollisionBoxam_strName); strupr( achrUpper); - sprintf( line, "#define %s_ATTACHMENT_%s %d\n", strDefinePrefix, achrUpper, iAttachingPlcement); + sprintf( line, "#define %s_ATTACHMENT_%s %d\n", (const char *) strDefinePrefix, achrUpper, iAttachingPlcement); strmHFile.Write_t( line, strlen( line)); iAttachingPlcement++; } @@ -502,15 +502,15 @@ void CEditModel::SaveIncludeFile_t( CTFileName fnFileName, CTString strDefinePre edm_md.GetAnimInfo( iSound, aiInfo); CTString strWithQuotes; - strWithQuotes.PrintF( "\"%s\",", CTString(edm_aasAttachedSounds[iSound].as_fnAttachedSound)); + strWithQuotes.PrintF( "\"%s\",", (const char *) CTString(edm_aasAttachedSounds[iSound].as_fnAttachedSound)); sprintf( line, "//sound SOUND_%s_%-16s %-32s // %s, %s, %s\n", - strDefinePrefix, + (const char *) strDefinePrefix, aiInfo.ai_AnimName, - strWithQuotes, - strAnimationPrefix+aiInfo.ai_AnimName, - strLooping, - strDelay); + (const char *) strWithQuotes, + (const char *) (strAnimationPrefix+aiInfo.ai_AnimName), + (const char *) strLooping, + (const char *) strDelay); strmHFile.Write_t( line, strlen( line)); } } @@ -893,20 +893,20 @@ void CEditModel::CreateScriptFile_t(CTFileName &fnO3D) // throw char * File.PutLine_t( "STRETCH_DETAIL NO"); File.PutLine_t( ""); File.PutLine_t( ";******* Mip models"); - sprintf( line, "DIRECTORY %s", (CTString&)fnO3D.FileDir()); + sprintf( line, "DIRECTORY %s", (const char *) (const CTString&)fnO3D.FileDir()); File.PutLine_t( line); File.PutLine_t( "MIP_MODELS 1"); - sprintf( line, " %s", (CTString&)(fnO3D.FileName() + fnO3D.FileExt())); + sprintf( line, " %s", (const char *) (const CTString&)(fnO3D.FileName() + fnO3D.FileExt())); File.PutLine_t( line); File.PutLine_t( ""); File.PutLine_t( "ANIM_START"); File.PutLine_t( ";******* Start of animation block"); File.PutLine_t( ""); - sprintf( line, "DIRECTORY %s", (CTString&)fnO3D.FileDir()); + sprintf( line, "DIRECTORY %s", (const char *) (const CTString&)fnO3D.FileDir()); File.PutLine_t( line); File.PutLine_t( "ANIMATION Default"); File.PutLine_t( "SPEED 0.1"); - sprintf( line, " %s", (CTString&)(fnO3D.FileName() + fnO3D.FileExt())); + sprintf( line, " %s", (const char *) (const CTString&)(fnO3D.FileName() + fnO3D.FileExt())); File.PutLine_t( line); File.PutLine_t( ""); File.PutLine_t( ";******* End of animation block"); @@ -1750,8 +1750,8 @@ void CEditModel::CreateMipModels_t(CObject3D &objRestFrame, CObject3D &objMipSou INDEX iVertexRemoveRate, INDEX iSurfacePreservingFactor) { // free possible mip-models except main mip model - INDEX iMipModel=1; - for( ; iMipModelmmpi_MappingSurfaces[iSurf]; CTString strExportLine; - strExportLine.PrintF( "%d) %s\n", iSurf, pms->ms_Name); + strExportLine.PrintF( "%d) %s\n", iSurf, (const char *) pms->ms_Name); strExport+=strExportLine; } @@ -2784,7 +2784,7 @@ void CEditModel::CorrectCollisionBoxSize(void) { vCorrectedDiagonale(2) = vCorrectedDiagonale(1); } - // lenght = width + // length = width vCorrectedDiagonale(3) = vCorrectedDiagonale(1); break; } @@ -2795,7 +2795,7 @@ void CEditModel::CorrectCollisionBoxSize(void) { vCorrectedDiagonale(1) = vCorrectedDiagonale(2); } - // lenght = height + // length = height vCorrectedDiagonale(3) = vCorrectedDiagonale(2); break; } @@ -2835,7 +2835,7 @@ FLOAT3D &CEditModel::GetCollisionBoxMax(void) return vMax; }; -// returns HEIGHT_EQ_WIDTH, LENGHT_EQ_WIDTH or LENGHT_EQ_HEIGHT +// returns HEIGHT_EQ_WIDTH, LENGTH_EQ_WIDTH or LENGTH_EQ_HEIGHT INDEX CEditModel::GetCollisionBoxDimensionEquality() { return edm_md.GetCollisionBoxDimensionEquality(edm_iActiveCollisionBox); diff --git a/Sources/Engine/Models/EditModel.h b/Sources/Engine/Models/EditModel.h index 46eb9e5..9dd707a 100644 --- a/Sources/Engine/Models/EditModel.h +++ b/Sources/Engine/Models/EditModel.h @@ -194,7 +194,7 @@ public: void EditRemoveAllPatches( void); INDEX CountPatches(void); ULONG GetExistingPatchesMask(void); - BOOL GetFirstEmptyPatchIndex( INDEX &iMaskBit); // Finds first empty space ready to receive new patch + BOOL GetFirstEmptyPatchIndex( INDEX &iMaskBit); // Finds first empty space ready to recieve new patch BOOL GetFirstValidPatchIndex( INDEX &iMaskBit); // Finds first valid patch index void GetPreviousValidPatchIndex( INDEX &iMaskBit);// Sets previous valid patch index void GetNextValidPatchIndex( INDEX &iMaskBit); // Sets next valid patch index diff --git a/Sources/Engine/Models/MipMaker.cpp b/Sources/Engine/Models/MipMaker.cpp index 3a9ba1b..273b472 100644 --- a/Sources/Engine/Models/MipMaker.cpp +++ b/Sources/Engine/Models/MipMaker.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -158,8 +158,8 @@ void CMipModel::FromObject3D_t( CObject3D &objRestFrame, CObject3D &objMipSource INDEX ctPolygonVertices = opoPolygon.opo_PolygonEdges.Count(); // allocate polygon vertices CMipPolygonVertex *ppvPolygonVertices[ 32]; - INDEX iPolygonVertice=0; - for( ; iPolygonVertice #include @@ -19,12 +19,12 @@ #include -template CStaticArray; -template CStaticArray; -template CStaticArray; -template CStaticArray; -template CStaticArray; -template CDynamicArray; +template class CStaticArray; +template class CStaticArray; +template class CStaticArray; +template class CStaticArray; +template class CStaticArray; +template class CDynamicArray; extern UBYTE aubGouraudConv[16384]; @@ -409,7 +409,7 @@ FLOAT3D CModelData::GetCollisionBoxMax(INDEX iCollisionBox=0) return vMax; }; -// returns HEIGHT_EQ_WIDTH, LENGHT_EQ_WIDTH or LENGHT_EQ_HEIGHT +// returns HEIGHT_EQ_WIDTH, LENGTH_EQ_WIDTH or LENGTH_EQ_HEIGHT INDEX CModelData::GetCollisionBoxDimensionEquality(INDEX iCollisionBox=0) { md_acbCollisionBox.Lock(); @@ -468,6 +468,7 @@ ModelTextureVertex::ModelTextureVertex(void) //------------------------------------------ WRITE void ModelPolygonVertex::Write_t( CTStream *pFile) // throw char * { + // !!! FIXME: Not 64-bit clean! (*pFile) << (INDEX) mpv_ptvTransformedVertex; (*pFile) << (INDEX) mpv_ptvTextureVertex; } @@ -476,6 +477,7 @@ void ModelPolygonVertex::Read_t( CTStream *pFile) // throw char * { INDEX itmp; + // !!! FIXME: Not 64-bit clean! (*pFile) >> itmp; mpv_ptvTransformedVertex = (struct TransformedVertexData *) itmp; (*pFile) >> itmp; @@ -503,6 +505,7 @@ void ModelPolygon::Read_t( CTStream *pFile) // throw char * { pFile->ExpectID_t( CChunkID("MDPL")); pFile->ReadFullChunk_t( CChunkID("IMPV"), &ctVertices, sizeof(INDEX)); + BYTESWAP(ctVertices); mp_PolygonVertices.New( ctVertices); {FOREACHINSTATICARRAY(mp_PolygonVertices, ModelPolygonVertex, it) @@ -643,8 +646,8 @@ void MappingSurface::Write_t( CTStream *pFile) // throw char * void MappingSurface::WriteSettings_t( CTStream *pFile) // throw char * { (*pFile) << ms_Name; - pFile->Write_t( &ms_sstShadingType, sizeof(SurfaceShadingType)); - pFile->Write_t( &ms_sttTranslucencyType, sizeof(SurfaceTranslucencyType)); + (*pFile) << (INDEX &)ms_sstShadingType; + (*pFile) << (INDEX &)ms_sttTranslucencyType; (*pFile) << ms_ulRenderingFlags; (*pFile) << ms_colDiffuse; (*pFile) << ms_colReflections; @@ -657,8 +660,8 @@ void MappingSurface::WriteSettings_t( CTStream *pFile) // throw char * void MappingSurface::ReadSettings_t( CTStream *pFile) // throw char * { (*pFile) >> ms_Name; - pFile->Read_t( &ms_sstShadingType, sizeof(SurfaceShadingType)); - pFile->Read_t( &ms_sttTranslucencyType, sizeof(SurfaceTranslucencyType)); + (*pFile) >> (INDEX&) ms_sstShadingType; + (*pFile) >> (INDEX&) ms_sttTranslucencyType; (*pFile) >> ms_ulRenderingFlags; (*pFile) >> ms_colDiffuse; (*pFile) >> ms_colReflections; @@ -673,20 +676,20 @@ void MappingSurface::Read_t( CTStream *pFile, BOOL bReadPolygonsPerSurface, BOOL bReadSurfaceColors) // throw char * { (*pFile) >> ms_Name; - pFile->Read_t( &ms_vSurface2DOffset, sizeof(FLOAT3D)); - pFile->Read_t( &ms_HPB, sizeof(FLOAT3D)); - pFile->Read_t( &ms_Zoom, sizeof(float)); + (*pFile) >> ms_vSurface2DOffset; + (*pFile) >> ms_HPB; + (*pFile) >> ms_Zoom; if( bReadPolygonsPerSurface) { - pFile->Read_t( &ms_sstShadingType, sizeof(SurfaceShadingType)); + (*pFile) >> (INDEX &) ms_sstShadingType; // WARNING !!! All shading types bigger than matte will be remaped into flat shading // this was done when SHINY and METAL were removed if( ms_sstShadingType > SST_MATTE) { ms_sstShadingType = SST_FLAT; } - pFile->Read_t( &ms_sttTranslucencyType, sizeof(SurfaceTranslucencyType)); + (*pFile) >> (INDEX &) ms_sttTranslucencyType; (*pFile) >> ms_ulRenderingFlags; if( (ms_ulRenderingFlags&SRF_NEW_TEXTURE_FORMAT) == 0) ms_ulRenderingFlags |= SRF_DIFFUSE|SRF_NEW_TEXTURE_FORMAT; @@ -699,19 +702,15 @@ void MappingSurface::Read_t( CTStream *pFile, BOOL bReadPolygonsPerSurface, INDEX ctPolygons; (*pFile) >> ctPolygons; ms_aiPolygons.New( ctPolygons); - if( ctPolygons != 0) - { - pFile->Read_t( &ms_aiPolygons[0], sizeof( INDEX)*ctPolygons); - } + for (INDEX i = 0; i < ctPolygons; i++) + (*pFile) >> ms_aiPolygons[i]; ms_aiTextureVertices.Clear(); INDEX ctTextureVertices; (*pFile) >> ctTextureVertices; ms_aiTextureVertices.New( ctTextureVertices); - if( ctTextureVertices != 0) - { - pFile->Read_t( &ms_aiTextureVertices[0], sizeof( INDEX)*ctTextureVertices); - } + for (INDEX i = 0; i < ctTextureVertices; i++) + (*pFile) >> ms_aiTextureVertices[i]; (*pFile) >> ms_colColor; } @@ -897,6 +896,7 @@ void ModelMipInfo::Read_t(CTStream *pFile, // Load count, allocate array and call Read for array of model polygons pFile->ReadFullChunk_t( CChunkID("IPOL"), &mmpi_PolygonsCt, sizeof(INDEX)); + BYTESWAP(mmpi_PolygonsCt); mmpi_Polygons.New( mmpi_PolygonsCt); {FOREACHINSTATICARRAY(mmpi_Polygons, ModelPolygon, it) { @@ -916,16 +916,16 @@ void ModelMipInfo::Read_t(CTStream *pFile, // if bump normals are saved (new format) if( idChunk == CChunkID("TXV2")) { - pFile->ReadRawChunk_t( &mmpi_TextureVertices[ 0], iMembersCt * - sizeof(struct ModelTextureVertex)); + for (SLONG i = 0; i < iMembersCt; i++) + (*pFile)>>mmpi_TextureVertices[i]; } else { // bump normals are not saved for( INDEX iVertex = 0; iVertexRead_t( &mmpi_TextureVertices[ iVertex].mtv_UVW, sizeof( FLOAT3D)); - pFile->Read_t( &mmpi_TextureVertices[ iVertex].mtv_UV, sizeof( MEX2D)); - pFile->Read_t( &mmpi_TextureVertices[ iVertex].mtv_Done, sizeof( BOOL)); - pFile->Read_t( &mmpi_TextureVertices[ iVertex].mtv_iTransformedVertex, sizeof( INDEX)); + (*pFile)>>mmpi_TextureVertices[ iVertex].mtv_UVW; + (*pFile)>>mmpi_TextureVertices[ iVertex].mtv_UV; + (*pFile)>>mmpi_TextureVertices[ iVertex].mtv_Done; + (*pFile)>>mmpi_TextureVertices[ iVertex].mtv_iTransformedVertex; mmpi_TextureVertices[ iVertex].mtv_vU = FLOAT3D(0,0,0); mmpi_TextureVertices[ iVertex].mtv_vV = FLOAT3D(0,0,0); } @@ -940,9 +940,9 @@ void ModelMipInfo::Read_t(CTStream *pFile, // read models in old format for( INDEX iVertex = 0; iVertexRead_t( &mmpi_TextureVertices[ iVertex].mtv_UVW, sizeof( FLOAT3D)); - pFile->Read_t( &mmpi_TextureVertices[ iVertex].mtv_UV, sizeof( MEX2D)); - pFile->Read_t( &mmpi_TextureVertices[ iVertex].mtv_Done, sizeof( BOOL)); + (*pFile)>>mmpi_TextureVertices[ iVertex].mtv_UVW; + (*pFile)>>mmpi_TextureVertices[ iVertex].mtv_UV; + (*pFile)>>mmpi_TextureVertices[ iVertex].mtv_Done; mmpi_TextureVertices[ iVertex].mtv_iTransformedVertex = 0; mmpi_TextureVertices[ iVertex].mtv_vU = FLOAT3D(0,0,0); mmpi_TextureVertices[ iVertex].mtv_vV = FLOAT3D(0,0,0); @@ -995,6 +995,13 @@ void ModelMipInfo::Read_t(CTStream *pFile, mmpi_aPolygonsPerPatch[iPatch].ppp_iPolygons.New( ctOccupied); pFile->ReadFullChunk_t( CChunkID("OCPL"), &mmpi_aPolygonsPerPatch[iPatch].ppp_iPolygons[ 0], ctOccupied * sizeof(INDEX)); + + #if PLATFORM_BIGENDIAN + for (INDEX i = 0; i < ctOccupied; i++) + { + BYTESWAP(mmpi_aPolygonsPerPatch[iPatch].ppp_iPolygons[i]); + } + #endif } } } @@ -1068,9 +1075,9 @@ CModelCollisionBox::CModelCollisionBox(void) void CModelCollisionBox::Read_t(CTStream *istrFile) { // Read collision box min - istrFile->Read_t( &mcb_vCollisionBoxMin, sizeof(FLOAT3D)); + (*istrFile) >> mcb_vCollisionBoxMin; // Read collision box size - istrFile->Read_t( &mcb_vCollisionBoxMax, sizeof(FLOAT3D)); + (*istrFile) >> mcb_vCollisionBoxMax; // Get "colision box dimensions equality" value if( (mcb_vCollisionBoxMax(2)-mcb_vCollisionBoxMin(2)) == (mcb_vCollisionBoxMax(1)-mcb_vCollisionBoxMin(1)) ) @@ -1090,7 +1097,7 @@ void CModelCollisionBox::Read_t(CTStream *istrFile) else { /* - // Force them to be legal (Lenght = Width) + // Force them to be legal (Length = Width) mcb_vCollisionBoxMax(3) = mcb_vCollisionBoxMin(3) + (mcb_vCollisionBoxMax(1)-mcb_vCollisionBoxMin(1)); */ @@ -1107,11 +1114,11 @@ void CModelCollisionBox::ReadName_t(CTStream *istrFile) void CModelCollisionBox::Write_t(CTStream *ostrFile) { // Write collision box min - ostrFile->Write_t( &mcb_vCollisionBoxMin, sizeof(FLOAT3D)); + (*ostrFile) << mcb_vCollisionBoxMin; // Write collision box size - ostrFile->Write_t( &mcb_vCollisionBoxMax, sizeof(FLOAT3D)); + (*ostrFile) << mcb_vCollisionBoxMax; // write collision box name - (*ostrFile)<WriteID_t( CChunkID( MODEL_VERSION)); // Save flags - pFile->Write_t( &md_Flags, sizeof(ULONG)); + (*pFile) << md_Flags; + + #if PLATFORM_BIGENDIAN + STUBBED("byte order"); + #endif // Save vertices and frames ct pFile->WriteFullChunk_t( CChunkID("IVTX"), &md_VerticesCt, sizeof(INDEX)); @@ -1350,13 +1361,15 @@ void CModelData::Read_t( CTStream *pFile) // throw char * if( bHasSavedFlagsOnStart) { - pFile->Read_t( &md_Flags, sizeof(ULONG)); + (*pFile)>>md_Flags; } // Read vertices and frames ct pFile->ReadFullChunk_t( CChunkID("IVTX"), &md_VerticesCt, sizeof(INDEX)); + BYTESWAP(md_VerticesCt); md_TransformedVertices.New( md_VerticesCt); pFile->ReadFullChunk_t( CChunkID("IFRM"), &md_FramesCt, sizeof(INDEX)); + BYTESWAP(md_FramesCt); // read array of 8-bit or 16-bit compressed vertices if( md_Flags & MF_COMPRESSED_16BIT) @@ -1372,7 +1385,7 @@ void CModelData::Read_t( CTStream *pFile) // throw char * *pFile >> ulDummy; for( INDEX iVtx=0; iVtxReadRawChunk_t( &md_FrameVertices16[iVtx], sizeof(struct ModelFrameVertex16_old)); + (*pFile)>>md_FrameVertices16[iVtx]; // convert 8-bit normal from index into normal defined using heading and pitch INDEX i8BitNormalIndex = md_FrameVertices16[iVtx].mfv_ubNormH; const FLOAT3D &vNormal = avGouraudNormals[i8BitNormalIndex]; @@ -1384,10 +1397,19 @@ void CModelData::Read_t( CTStream *pFile) // throw char * { pFile->ReadFullChunk_t( CChunkID("AV17"), &md_FrameVertices16[ 0], md_VerticesCt * md_FramesCt * sizeof(struct ModelFrameVertex16)); + + #if PLATFORM_BIGENDIAN + for (ULONG i = 0; i < md_VerticesCt * md_FramesCt; i++) + { + BYTESWAP(md_FrameVertices16[i].mfv_SWPoint.vector[0]); + BYTESWAP(md_FrameVertices16[i].mfv_SWPoint.vector[1]); + BYTESWAP(md_FrameVertices16[i].mfv_SWPoint.vector[2]); + } + #endif } else { - ThrowF_t( TRANS("Expecting chunk ID for model frame vertices but found %s"), cidVerticesChunk); + ThrowF_t( TRANS("Expecting chunk ID for model frame vertices but found %s"), (const char *) cidVerticesChunk); } } else @@ -1400,17 +1422,52 @@ void CModelData::Read_t( CTStream *pFile) // throw char * // Allocate and Read frame info array md_FrameInfos.New( md_FramesCt); pFile->ReadFullChunk_t( CChunkID("AFIN"), &md_FrameInfos[0], md_FramesCt * sizeof(struct ModelFrameInfo)); + #if PLATFORM_BIGENDIAN + for (ULONG i = 0; i < md_FramesCt; i++) + { + BYTESWAP(md_FrameInfos[i].mfi_Box.minvect.vector[0]); + BYTESWAP(md_FrameInfos[i].mfi_Box.minvect.vector[1]); + BYTESWAP(md_FrameInfos[i].mfi_Box.minvect.vector[2]); + BYTESWAP(md_FrameInfos[i].mfi_Box.maxvect.vector[0]); + BYTESWAP(md_FrameInfos[i].mfi_Box.maxvect.vector[1]); + BYTESWAP(md_FrameInfos[i].mfi_Box.maxvect.vector[2]); + } + #endif + // Allocate Read frame main mip vertices array md_MainMipVertices.New( md_VerticesCt); pFile->ReadFullChunk_t( CChunkID("AMMV"), &md_MainMipVertices[0], md_VerticesCt * sizeof(FLOAT3D)); + #if PLATFORM_BIGENDIAN + for (ULONG i = 0; i < md_VerticesCt; i++) + { + BYTESWAP(md_MainMipVertices[i].vector[0]); + BYTESWAP(md_MainMipVertices[i].vector[1]); + BYTESWAP(md_MainMipVertices[i].vector[2]); + } + #endif + // Allocate and Read vertex mip-mask array md_VertexMipMask.New( md_VerticesCt); pFile->ReadFullChunk_t( CChunkID("AVMK"), &md_VertexMipMask[0], md_VerticesCt * sizeof(ULONG)); + #if PLATFORM_BIGENDIAN + for (ULONG i = 0; i < md_VerticesCt; i++) + { + BYTESWAP(md_VertexMipMask[i]); + } + #endif // Read mip levels counter pFile->ReadFullChunk_t( CChunkID("IMIP"), &md_MipCt, sizeof(INDEX)); + BYTESWAP(md_MipCt); + // Read mip factors array pFile->ReadFullChunk_t( CChunkID("FMIP"), &md_MipSwitchFactors[0], MAX_MODELMIPS * sizeof(float)); + #if PLATFORM_BIGENDIAN + for (ULONG i = 0; i < MAX_MODELMIPS; i++) + { + BYTESWAP(md_MipSwitchFactors[i]); + } + #endif // Read all model mip infos INDEX ctMipsRejected=0; @@ -1439,6 +1496,7 @@ void CModelData::Read_t( CTStream *pFile) // throw char * { ULONG ulOldExistingPatches; pFile->ReadFullChunk_t( CChunkID("STMK"), &ulOldExistingPatches, sizeof(ULONG)); + BYTESWAP(ulOldExistingPatches); for( INDEX iPatch=0; iPatchReadFullChunk_t( CChunkID("STXW"), &md_Width, sizeof(MEX)); pFile->ReadFullChunk_t( CChunkID("STXH"), &md_Height, sizeof(MEX)); + BYTESWAP(md_Width); + BYTESWAP(md_Height); // in old patch format, now patch postiions are loaded if( cidPatchChunkID == CChunkID("STMK")) @@ -1499,18 +1559,18 @@ void CModelData::Read_t( CTStream *pFile) // throw char * if( !bHasSavedFlagsOnStart) { // Read flags - pFile->Read_t( &md_Flags, sizeof(ULONG)); + (*pFile)>>md_Flags; } // Read value for shading type - pFile->Read_t( &md_ShadowQuality, sizeof(SLONG)); + (*pFile)>>md_ShadowQuality; // Read static stretch value - pFile->Read_t( &md_Stretch, sizeof(FLOAT3D)); + (*pFile)>>md_Stretch; // if this is model with saved center if( bHasSavedCenter) { // read it - pFile->Read_t( &md_vCenter, sizeof(FLOAT3D)); + (*pFile)>>md_vCenter; } // this model has been saved without center point else { // so just reset it @@ -1554,7 +1614,7 @@ void CModelData::Read_t( CTStream *pFile) // throw char * { INDEX ctCollisionBoxes; // get count of collision boxes - pFile->Read_t( &ctCollisionBoxes, sizeof(INDEX)); + (*pFile)>>ctCollisionBoxes; // add needed ammount of members md_acbCollisionBox.New( ctCollisionBoxes); md_acbCollisionBox.Lock(); @@ -1876,9 +1936,9 @@ void CModelObject::Read_t( CTStream *pFile) // throw char * mo_colBlendColor = 0xFFFFFFFF; } - pFile->Read_t( &mo_PatchMask, sizeof(ULONG)); - pFile->Read_t( &mo_Stretch, sizeof(FLOAT3D)); - pFile->Read_t( &mo_ColorMask, sizeof(ULONG)); + (*pFile)>>mo_PatchMask; + (*pFile)>>mo_Stretch; + (*pFile)>>mo_ColorMask; for( INDEX i=0; imd_MipCt; i++) { + INDEX i; + for( i=0; imd_MipCt; i++) { if( fMipFactor < pMD->md_MipSwitchFactors[i]) return i; } return i-1; @@ -2114,7 +2174,7 @@ COLOR CModelObject::GetSurfaceColor( INDEX iCurrentMip, INDEX iCurrentSurface) if( (iCurrentMip>=pMD->md_MipCt) || (iCurrentSurface>=pMD->md_MipInfos[ iCurrentMip].mmpi_MappingSurfaces.Count()) ) { - return -1; + return (COLOR) -1; // !!! FIXME COLOR is unsigned, right? } for( INDEX i=0; imd_MipInfos[ iCurrentMip].mmpi_PolygonsCt; i++) { @@ -2613,7 +2673,7 @@ INDEX CModelObject::PickVertexIndex( CDrawPort *pDP, CProjection3D *pProjection, } } } - return iClosest; + return ((INDEX) iClosest); } /* @@ -2653,7 +2713,7 @@ FLOAT3D CModelObject::GetCollisionBoxMax(INDEX iCollisionBox) return GetData()->GetCollisionBoxMax(iCollisionBox); } -// returns HEIGHT_EQ_WIDTH, LENGHT_EQ_WIDTH or LENGHT_EQ_HEIGHT +// returns HEIGHT_EQ_WIDTH, LENGTH_EQ_WIDTH or LENGTH_EQ_HEIGHT INDEX CModelObject::GetCollisionBoxDimensionEquality(INDEX iCollisionBox) { return GetData()->GetCollisionBoxDimensionEquality(iCollisionBox); diff --git a/Sources/Engine/Models/ModelProfile.cpp b/Sources/Engine/Models/ModelProfile.cpp index 4140f74..5386039 100644 --- a/Sources/Engine/Models/ModelProfile.cpp +++ b/Sources/Engine/Models/ModelProfile.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Models/Model_internal.h b/Sources/Engine/Models/Model_internal.h index 0954f07..e4c60bc 100644 --- a/Sources/Engine/Models/Model_internal.h +++ b/Sources/Engine/Models/Model_internal.h @@ -116,6 +116,22 @@ struct ENGINE_API ModelFrameVertex16 { UBYTE mfv_ubNormH, mfv_ubNormP; }; +static inline CTStream &operator>>(CTStream &strm, ModelFrameVertex16 &mfv) +{ + strm>>mfv.mfv_SWPoint; + strm>>mfv.mfv_ubNormH; + strm>>mfv.mfv_ubNormP; + return strm; +} + +static inline CTStream &operator<<(CTStream &strm, const ModelFrameVertex16 &mfv) +{ + strm<>(CTStream &strm, ModelTextureVertex &mtv) +{ + strm>>mtv.mtv_UVW; + strm>>mtv.mtv_UV; + strm>>mtv.mtv_iSurfaceVx; + strm>>mtv.mtv_iTransformedVertex; + strm>>mtv.mtv_vU; + strm>>mtv.mtv_vV; + return(strm); +} + +static inline CTStream &operator<<(CTStream &strm, const ModelTextureVertex &mtv) +{ + strm< #include -extern FLOAT3D avGouraudNormals[MAX_GOURAUDNORMALS] = { +FLOAT3D avGouraudNormals[MAX_GOURAUDNORMALS] = { FLOAT3D( 1.000000f, 0.000000f, 0.000000f), FLOAT3D( 0.980785f, 0.000000f, 0.195090f), FLOAT3D( 0.980785f, 0.195090f, 0.000000f), diff --git a/Sources/Engine/Models/RenderModel.cpp b/Sources/Engine/Models/RenderModel.cpp index f5fc0ea..3a341ac 100644 --- a/Sources/Engine/Models/RenderModel.cpp +++ b/Sources/Engine/Models/RenderModel.cpp @@ -1,8 +1,8 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" -#include +#include #include #include #include @@ -322,7 +322,7 @@ BOOL CModelObject::CreateAttachment( CRenderModel &rmMain, CAttachmentModelObjec if( fPlaneDistance < -fR) iMirrorPlaneTest = -1; else if( fPlaneDistance > +fR) iMirrorPlaneTest = +1; else { // test box if sphere cut mirror plane - iMirrorPlaneTest = boxEntity.TestAgainstPlane(_aprProjection->pr_plMirrorView); + iMirrorPlaneTest = (INDEX) (boxEntity.TestAgainstPlane(_aprProjection->pr_plMirrorView)); } // mark if attachment is fully inside mirror if( iMirrorPlaneTest>0) rmAttached.rm_ulFlags |= RMF_INMIRROR; diff --git a/Sources/Engine/Models/RenderModel_Mask.cpp b/Sources/Engine/Models/RenderModel_Mask.cpp index 20310a1..e12a3a6 100644 --- a/Sources/Engine/Models/RenderModel_Mask.cpp +++ b/Sources/Engine/Models/RenderModel_Mask.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -347,7 +347,7 @@ void CModelObject::RenderModel_Mask( CRenderModel &rm) CTextureData *ptd = (CTextureData*)mo_toTexture.GetData(); if( ptd!=NULL && ptd->td_ptegEffect!=NULL) { // report to console - CPrintF( TRANS("WARNING: model '%s' cast cluster shadows but has an effect texture.\n"), GetData()->GetName()); + CPrintF( TRANS("WARNING: model '%s' cast cluster shadows but has an effect texture.\n"), (const char *) GetData()->GetName()); return; } diff --git a/Sources/Engine/Models/RenderModel_View.cpp b/Sources/Engine/Models/RenderModel_View.cpp index c6fec77..0055d80 100644 --- a/Sources/Engine/Models/RenderModel_View.cpp +++ b/Sources/Engine/Models/RenderModel_View.cpp @@ -1,8 +1,8 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ - #include "stdh.h" +#include "Engine/StdH.h" -#include +#include #include #include #include @@ -27,7 +27,13 @@ #define W word ptr #define B byte ptr +#if (defined __MSVC_INLINE__) #define ASMOPT 1 +#elif (defined __GNU_INLINE__) +#define ASMOPT 0 // !!! FIXME: rcg10112001 Write GCC inline asm versions... +#else +#define ASMOPT 0 +#endif extern BOOL CVA_bModels; @@ -42,7 +48,6 @@ static GfxAPIType _eAPI; static BOOL _bForceTranslucency; // force translucency of opaque/transparent surfaces (for model fading) static ULONG _ulMipLayerFlags; -static INDEX _icol=0; // mip arrays @@ -87,8 +92,14 @@ static INDEX _ctAllSrfVx = 0; static BOOL _bFlatFill = FALSE; static SLONG _slLR=0, _slLG=0, _slLB=0; static SLONG _slAR=0, _slAG=0, _slAB=0; -static const __int64 mmRounder = 0x007F007F007F007F; -static const __int64 mmF000 = 0x00FF000000000000; + +#if (defined __GNUC__) +static const __int64 mmRounder = 0x007F007F007F007Fll; +static const __int64 mmF000 = 0x00FF000000000000ll; +#else +static const __int64 mmRounder = (__int64) 0x007F007F007F007F; +static const __int64 mmF000 = (__int64) 0x00FF000000000000; +#endif // viewer absolute and object space projection static FLOAT3D _vViewer; @@ -553,7 +564,9 @@ extern void PrepareModelForRendering( CModelData &md) + // strip rendering support +INDEX _icol=0; COLOR _acol[] = { C_BLACK, C_WHITE, C_dGRAY, C_GRAY, C_lGRAY, C_dRED, C_RED, C_lRED, C_dGREEN, C_GREEN, C_lGREEN, C_dBLUE, C_BLUE, C_lBLUE, @@ -672,8 +685,8 @@ static void GetFogMapInVertex( GFXVertex3 &vtx, GFXTexCoord &tex) #else const FLOAT fD = vtx.x*_vFViewerObj(1) + vtx.y*_vFViewerObj(2) + vtx.z*_vFViewerObj(3); const FLOAT fH = vtx.x*_vHDirObj(1) + vtx.y*_vHDirObj(2) + vtx.z*_vHDirObj(3); - tex.s = (fD+_fFogAddZ) * _fog_fMulZ; - tex.t = (fH+_fFogAddH) * _fog_fMulH; + tex.st.s = (fD+_fFogAddZ) * _fog_fMulZ; + tex.st.t = (fH+_fFogAddH) * _fog_fMulH; #endif } @@ -711,14 +724,14 @@ static BOOL IsModelInFog( FLOAT3D &vMin, FLOAT3D &vMax) { GFXTexCoord tex; GFXVertex3 vtx; - vtx.x=vMin(1); vtx.y=vMin(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMin(1); vtx.y=vMin(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMin(1); vtx.y=vMax(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMin(1); vtx.y=vMax(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMax(1); vtx.y=vMin(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMax(1); vtx.y=vMin(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; + vtx.x=vMin(1); vtx.y=vMin(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMin(1); vtx.y=vMin(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMin(1); vtx.y=vMax(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMin(1); vtx.y=vMax(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMax(1); vtx.y=vMin(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMax(1); vtx.y=vMin(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; return FALSE; } @@ -1675,10 +1688,10 @@ colEnd: for( INDEX iMipVx=0; iMipVx<_ctAllMipVx; iMipVx++) { GFXColor &col = pcolMipBase[iMipVx]; const SLONG slShade = Clamp( (SLONG)pswMipCol[iMipVx], 0L, 255L); - col.r = pubClipByte[_slAR + ((_slLR*slShade)>>8)]; - col.g = pubClipByte[_slAG + ((_slLG*slShade)>>8)]; - col.b = pubClipByte[_slAB + ((_slLB*slShade)>>8)]; - col.a = slShade; + col.ub.r = pubClipByte[_slAR + ((_slLR*slShade)>>8)]; + col.ub.g = pubClipByte[_slAG + ((_slLG*slShade)>>8)]; + col.ub.b = pubClipByte[_slAB + ((_slLB*slShade)>>8)]; + col.ub.a = slShade; } #endif @@ -1697,11 +1710,8 @@ void CModelObject::RenderModel_View( CRenderModel &rm) { // cache API _eAPI = _pGfx->gl_eCurrentAPI; -#ifdef SE1_D3D - ASSERT( _eAPI==GAT_OGL || _eAPI==GAT_D3D || _eAPI==GAT_NONE); -#else // SE1_D3D - ASSERT( _eAPI==GAT_OGL || _eAPI==GAT_NONE); -#endif // SE1_D3D + ASSERT( GfxValidApi(_eAPI) ); + if( _eAPI==GAT_NONE) return; // must have API // adjust Truform usage @@ -1973,7 +1983,7 @@ srfVtxLoop: pop ebx } #else - // setup vetrex array + // setup vertex array for( iSrfVx=0; iSrfVx>=1; - colSrfDiffAdj.g >>=1; - colSrfDiffAdj.b >>=1; + colSrfDiffAdj.ub.r >>=1; + colSrfDiffAdj.ub.g >>=1; + colSrfDiffAdj.ub.b >>=1; } // just copy diffuse color for( INDEX iSrfVx=0; iSrfVxmd_colBump, _slTexHueShift, _slTexSaturation); - colMdlBump.abgr = ByteSwap(colB); + colMdlBump.ul.abgr = ByteSwap(colB); // get detail texture corrections fTexCorrU = 1.0f / ptdBump->GetWidth(); fTexCorrV = 1.0f / ptdBump->GetHeight(); @@ -2272,8 +2282,8 @@ diffColLoop: for( INDEX iSrfVx=0; iSrfVxmd_colReflections, _slTexHueShift, _slTexSaturation); - colMdlRefl.abgr = ByteSwap(colR); + colMdlRefl.ul.abgr = ByteSwap(colR); colMdlRefl.AttenuateA( (rm.rm_colBlend&CT_AMASK)>>CT_ASHIFT); // for each reflective surface in current mip model @@ -2599,7 +2609,7 @@ specMipLoop: // for each mip vertex for( INDEX iMipVx=0; iMipVx<_ctAllMipVx; iMipVx++) { // reflect light vector around vertex normal in object space - GFXNormal &nor = pnorMipBase[iMipVx]; + GFXNormal3 &nor = pnorMipBase[iMipVx]; const FLOAT fNL = nor.nx*_vLightObj(1) + nor.ny*_vLightObj(2) + nor.nz*_vLightObj(3); const FLOAT fRx = _vLightObj(1) - 2*nor.nx*fNL; const FLOAT fRy = _vLightObj(2) - 2*nor.ny*fNL; @@ -2610,8 +2620,8 @@ specMipLoop: const FLOAT fRVz = fRx*m(3,1) + fRy*m(3,2) + fRz*m(3,3); // map reflected vector to texture const FLOAT f1oFM = 0.5f / sqrt(2+2*fRVz); // was 2*sqrt(2+2*fRVz) - ptexMipBase[iMipVx].s = fRVx*f1oFM +0.5f; - ptexMipBase[iMipVx].t = fRVy*f1oFM +0.5f; + ptexMipBase[iMipVx].st.s = fRVx*f1oFM +0.5f; + ptexMipBase[iMipVx].st.t = fRVy*f1oFM +0.5f; } #endif _pfModelProfile.StopTimer( CModelProfile::PTI_VIEW_INIT_SPEC_MIP); @@ -2623,11 +2633,11 @@ specMipLoop: // get model specular color and multiply with light color GFXColor colMdlSpec; const COLOR colS = AdjustColor( rm.rm_pmdModelData->md_colSpecular, _slTexHueShift, _slTexSaturation); - colMdlSpec.abgr = ByteSwap(colS); + colMdlSpec.ul.abgr = ByteSwap(colS); colMdlSpec.AttenuateRGB( (rm.rm_colBlend&CT_AMASK)>>CT_ASHIFT); - colMdlSpec.r = ClampUp( (colMdlSpec.r *_slLR)>>8, 255L); - colMdlSpec.g = ClampUp( (colMdlSpec.g *_slLG)>>8, 255L); - colMdlSpec.b = ClampUp( (colMdlSpec.b *_slLB)>>8, 255L); + colMdlSpec.ub.r = ClampUp( (colMdlSpec.ub.r *_slLR)>>8, 255L); + colMdlSpec.ub.g = ClampUp( (colMdlSpec.ub.g *_slLG)>>8, 255L); + colMdlSpec.ub.b = ClampUp( (colMdlSpec.ub.b *_slLB)>>8, 255L); // for each specular surface in current mip model FOREACHINSTATICARRAY( mmi.mmpi_MappingSurfaces, MappingSurface, itms) @@ -2651,10 +2661,10 @@ specMipLoop: const INDEX iMipVx = puwSrfToMip[iSrfVx]; // set specular texture and color ptexSrfBase[iSrfVx] = ptexMipBase[iMipVx]; - const SLONG slShade = pcolMipBase[iMipVx].a; - pcolSrfBase[iSrfVx].abgr = (((colSrfSpec.r)*slShade)>>8) - | (((colSrfSpec.g)*slShade)&0x0000FF00) - | ((((colSrfSpec.b)*slShade)<<8)&0x00FF0000); + const SLONG slShade = pcolMipBase[iMipVx].ub.a; + pcolSrfBase[iSrfVx].ul.abgr = (((colSrfSpec.ub.r)*slShade)>>8) + | (((colSrfSpec.ub.g)*slShade)&0x0000FF00) + | ((((colSrfSpec.ub.b)*slShade)<<8)&0x00FF0000); } // eventually attenuate color in case of fog or haze if( (ms.ms_ulRenderingFlags&SRF_OPAQUE) && !_bForceTranslucency) continue; @@ -2718,8 +2728,8 @@ specMipLoop: // prepare haze vertices for( INDEX iSrfVx=0; iSrfVx #include diff --git a/Sources/Engine/Network/ActionBuffer.cpp b/Sources/Engine/Network/ActionBuffer.cpp index aef0917..9b67c1e 100644 --- a/Sources/Engine/Network/ActionBuffer.cpp +++ b/Sources/Engine/Network/ActionBuffer.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -54,7 +54,7 @@ void CActionBuffer::AddAction(const CPlayerAction &pa) ab_lhActions.AddTail(pae->ae_ln); // sort the list - ab_lhActions.Sort(&qsort_CompareActions, offsetof(CActionEntry, ae_ln)); + ab_lhActions.Sort(&qsort_CompareActions, _offsetof(CActionEntry, ae_ln)); //CPrintF("Buffered: %d (after add)\n", ab_lhActions.Count()); } diff --git a/Sources/Engine/Network/Buffer.cpp b/Sources/Engine/Network/Buffer.cpp index 91caba2..e0ae30a 100644 --- a/Sources/Engine/Network/Buffer.cpp +++ b/Sources/Engine/Network/Buffer.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -86,6 +86,11 @@ void CBuffer::SetAllocationStep(SLONG slStep) bu_slAllocationStep = slStep; } + +#ifndef __min +#define __min(x, y) ((x) < (y) ? (x) : (y)) +#endif + // read bytes from buffer SLONG CBuffer::ReadBytes(void *pv, SLONG slSize) { @@ -327,12 +332,24 @@ void CBlockBuffer::Clear(void) CBuffer::Clear(); } +#ifdef NETSTRUCTS_PACKED + #pragma pack(1) +#endif struct BlockHeader { SLONG bh_slSize; // block size + + #ifdef NETSTRUCTS_PACKED + UBYTE packing[4]; + #endif + CTimerValue bh_tvFinalTime; // block may be read only after this moment in time }; +#ifdef NETSTRUCTS_PACKED + #pragma pack() +#endif + // read one block if possible BOOL CBlockBuffer::ReadBlock(void *pv, SLONG &slSize) { @@ -340,6 +357,14 @@ BOOL CBlockBuffer::ReadBlock(void *pv, SLONG &slSize) ASSERT(bb_slBlockSizeRead==0); // read header of next block in incoming buffer + +// rcg10272001 !!! FIXME: Taking sizeof (bh), with the intention of +// rcg10272001 !!! FIXME: sending that many bytes over the network, +// rcg10272001 !!! FIXME: is really, really risky. DON'T DO IT. +// rcg10272001 !!! FIXME: Instead, send pertinent information field by +// rcg10272001 !!! FIXME: field, and rebuild the structure on the other +// rcg10272001 !!! FIXME: side, swapping byte order as necessary. + struct BlockHeader bh; SLONG slbhSize; slbhSize = ReadBytes(&bh, sizeof(bh)); diff --git a/Sources/Engine/Network/CPacket.cpp b/Sources/Engine/Network/CPacket.cpp index e7acbaf..248163a 100644 --- a/Sources/Engine/Network/CPacket.cpp +++ b/Sources/Engine/Network/CPacket.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -9,7 +9,7 @@ #include #include -#include +#include // should the packet transfers in/out of the buffer be reported to the console extern INDEX net_bReportPackets; @@ -22,7 +22,8 @@ extern FLOAT net_fSendRetryWait; // make the address broadcast void CAddress::MakeBroadcast(void) { - adr_ulAddress = INADDR_BROADCAST; + //adr_ulAddress = INADDR_BROADCAST; +STUBBED("INADDR_BROADCAST?!"); extern INDEX net_iPort; adr_uwPort = net_iPort; adr_uwID = 0; @@ -242,9 +243,10 @@ SLONG CPacket::GetTransferSize() return pa_slTransferSize; }; +#define SLASHSLASH 0x2F2F // looks like "//" in ASCII. BOOL CPacket::IsBroadcast() { - if (pa_adrAddress.adr_uwID == '//' || pa_adrAddress.adr_uwID == 0) { + if (pa_adrAddress.adr_uwID == SLASHSLASH || pa_adrAddress.adr_uwID == 0) { return TRUE; } @@ -606,7 +608,7 @@ BOOL CPacketBuffer::RemoveConnectResponsePackets() { delete litPacketIter; } } - return NULL; + return FALSE; }; diff --git a/Sources/Engine/Network/CPacket.h b/Sources/Engine/Network/CPacket.h index ce4ece8..cc26c45 100644 --- a/Sources/Engine/Network/CPacket.h +++ b/Sources/Engine/Network/CPacket.h @@ -97,7 +97,7 @@ public: void Drop(); // get the size of data transfer unit this packet belongs to - SLONG CPacket::GetTransferSize(); + SLONG GetTransferSize(); // Copy operator void operator=(const CPacket &paOriginal); diff --git a/Sources/Engine/Network/ClientInterface.cpp b/Sources/Engine/Network/ClientInterface.cpp index 977485e..79993c5 100644 --- a/Sources/Engine/Network/ClientInterface.cpp +++ b/Sources/Engine/Network/ClientInterface.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -13,7 +13,7 @@ #include #include -#include +#include // how many acknowledges can fit into one UDP packet #define MAX_ACKS_PER_PACKET (MAX_UDP_BLOCK_SIZE/sizeof(ULONG)) @@ -375,6 +375,7 @@ void CClientInterface::ExchangeBuffers(void) }; +#define SLASHSLASH 0x2F2F // looks like "//" in ASCII. // update interface's input buffer (transfer from input buffer to the reliable buffer...), // for incoming acknowledge packets, remove acknowledged packets from the output buffers, @@ -430,11 +431,11 @@ BOOL CClientInterface::UpdateInputBuffers(void) // generate packet acknowledge // if the packet is from the broadcast address, send the acknowledge for that packet only - if (ppaPacket->pa_adrAddress.adr_uwID == '//' || ppaPacket->pa_adrAddress.adr_uwID == 0) { + if (ppaPacket->pa_adrAddress.adr_uwID == SLASHSLASH || ppaPacket->pa_adrAddress.adr_uwID == 0) { CPacket *ppaAckPacket = new CPacket; ppaAckPacket->pa_adrAddress.adr_ulAddress = ppaPacket->pa_adrAddress.adr_ulAddress; ppaAckPacket->pa_adrAddress.adr_uwPort = ppaPacket->pa_adrAddress.adr_uwPort; - ppaAckPacket->WriteToPacket(&(ppaPacket->pa_ulSequence),sizeof(ULONG),UDP_PACKET_ACKNOWLEDGE,++ci_ulSequence,'//',sizeof(ULONG)); + ppaAckPacket->WriteToPacket(&(ppaPacket->pa_ulSequence),sizeof(ULONG),UDP_PACKET_ACKNOWLEDGE,++ci_ulSequence,SLASHSLASH,sizeof(ULONG)); ci_pbOutputBuffer.AppendPacket(*ppaAckPacket,TRUE); if (net_bReportPackets == TRUE) { CPrintF("Acknowledging broadcast packet sequence %d\n",ppaPacket->pa_ulSequence); @@ -471,7 +472,7 @@ BOOL CClientInterface::UpdateInputBuffers(void) } // a packet can be accepted from the broadcast ID only if it is an acknowledge packet or // if it is a connection confirmation response packet and the client isn't already connected - if (ppaPacket->pa_adrAddress.adr_uwID == '//' || ppaPacket->pa_adrAddress.adr_uwID == 0) { + if (ppaPacket->pa_adrAddress.adr_uwID == SLASHSLASH || ppaPacket->pa_adrAddress.adr_uwID == 0) { if (((!ci_bUsed) && (ppaPacket->pa_ubReliable & UDP_PACKET_CONNECT_RESPONSE)) || (ppaPacket->pa_ubReliable & UDP_PACKET_ACKNOWLEDGE) || ci_bClientLocal) { diff --git a/Sources/Engine/Network/CommunicationInterface.cpp b/Sources/Engine/Network/CommunicationInterface.cpp index c5bddf2..04deb9c 100644 --- a/Sources/Engine/Network/CommunicationInterface.cpp +++ b/Sources/Engine/Network/CommunicationInterface.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -18,8 +18,11 @@ #include - +#ifdef PLATFORM_WIN32 #pragma comment(lib, "wsock32.lib") +#endif + +#define SLASHSLASH 0x2F2F // looks like "//" in ASCII. #define SERVER_LOCAL_CLIENT 0 extern INDEX net_iPort; @@ -31,6 +34,7 @@ extern FLOAT net_tmConnectionTimeout; extern INDEX net_bReportPackets; static struct ErrorCode ErrorCodes[] = { +#ifdef PLATFORM_WIN32 ERRORCODE(WSAEINTR , "WSAEINTR"), ERRORCODE(WSAEBADF , "WSAEBADF"), ERRORCODE(WSAEACCES , "WSAEACCES"), @@ -76,9 +80,63 @@ static struct ErrorCode ErrorCodes[] = { ERRORCODE(WSATRY_AGAIN , "WSATRY_AGAIN"), ERRORCODE(WSANO_RECOVERY , "WSANO_RECOVERY"), ERRORCODE(WSANO_DATA , "WSANO_DATA"), + +#else + + // these were gleaned from the manpages for various BSD socket calls. + // On linux, start with "man ip" for most of these. + + ERRORCODE(EINTR , "EINTR"), + ERRORCODE(EAGAIN , "EAGAIN"), + ERRORCODE(EIO , "EIO"), + ERRORCODE(EISDIR , "EISDIR"), + ERRORCODE(EBADF , "EBADF"), + ERRORCODE(EINVAL , "EINVAL"), + ERRORCODE(EFAULT , "EFAULT"), + ERRORCODE(EPROTONOSUPPORT , "EPROTONOSUPPORT"), + ERRORCODE(ENFILE , "ENFILE"), + ERRORCODE(EACCES , "EACCES"), + ERRORCODE(ENOBUFS , "ENOBUFS"), + ERRORCODE(ENOMEM , "ENOMEM"), + ERRORCODE(ENOTSOCK , "ENOTSOCK"), + ERRORCODE(EOPNOTSUPP , "EOPNOTSUPP"), + ERRORCODE(EPERM , "EPERM"), + ERRORCODE(ECONNABORTED , "ECONNABORTED"), + ERRORCODE(ECONNREFUSED , "ECONNREFUSED"), + ERRORCODE(ENETUNREACH , "ENETUNREACH"), + ERRORCODE(EADDRINUSE , "EADDRINUSE"), + ERRORCODE(EINPROGRESS , "EINPROGRESS"), + ERRORCODE(EALREADY , "EALREADY"), + ERRORCODE(EAGAIN , "EAGAIN"), + ERRORCODE(EAFNOSUPPORT , "EAFNOSUPPORT"), + ERRORCODE(EADDRNOTAVAIL , "EADDRNOTAVAIL"), + ERRORCODE(ETIMEDOUT , "ETIMEDOUT"), + ERRORCODE(ESOCKTNOSUPPORT , "ESOCKTNOSUPPORT"), + ERRORCODE(ENAMETOOLONG , "ENAMETOOLONG"), + ERRORCODE(ENOTDIR , "ENOTDIR"), + ERRORCODE(ELOOP , "ELOOP"), + ERRORCODE(EROFS , "EROFS"), + ERRORCODE(EISCONN , "EISCONN"), + ERRORCODE(EMSGSIZE , "EMSGSIZE"), + ERRORCODE(ENODEV , "ENODEV"), + ERRORCODE(ECONNRESET , "ECONNRESET"), + ERRORCODE(ENOTCONN , "ENOTCONN"), + #if !PLATFORM_MACOSX + ERRORCODE(ENOSR , "ENOSR"), + ERRORCODE(ENOPKG , "ENOPKG"), + #endif +#endif }; static struct ErrorTable SocketErrors = ERRORTABLE(ErrorCodes); +// rcg10122001 +#ifdef PLATFORM_WIN32 +#define isWouldBlockError(x) (x == WSAEWOULDBLOCK) +#else +#define isWouldBlockError(x) ((x == EAGAIN) || (x == EWOULDBLOCK)) +#define WSAECONNRESET ECONNRESET +#endif + //structures used to emulate bandwidth and latency parameters - shared by all client interfaces CPacketBufferStats _pbsSend; @@ -212,6 +270,7 @@ void CCommunicationInterface::Close(void) void CCommunicationInterface::InitWinsock(void) { +#ifdef PLATFORM_WIN32 if (cci_bWinSockOpen) { return; } @@ -227,6 +286,9 @@ void CCommunicationInterface::InitWinsock(void) cci_bWinSockOpen = TRUE; CPrintF(TRANS(" winsock opened ok\n")); } +#else + cci_bWinSockOpen = TRUE; +#endif }; void CCommunicationInterface::EndWinsock(void) @@ -235,8 +297,11 @@ void CCommunicationInterface::EndWinsock(void) return; } +#ifdef PLATFORM_WIN32 int iResult = WSACleanup(); ASSERT(iResult==0); +#endif + cci_bWinSockOpen = FALSE; }; @@ -305,7 +370,7 @@ void CCommunicationInterface::PrepareForUse(BOOL bUseNetwork, BOOL bClient) } } - CPrintF(TRANS(" local addresses: %s (%s)\n"), cm_strName, cm_strAddress); + CPrintF(TRANS(" local addresses: %s (%s)\n"), (const char *) cm_strName, (const char *) cm_strAddress); CPrintF(TRANS(" port: %d\n"), net_iPort); // try to open master UDP socket @@ -415,11 +480,26 @@ void CCommunicationInterface::SetNonBlocking_t(void) return; } +#ifdef PLATFORM_WIN32 ULONG ulArgNonBlocking = 1; if (ioctlsocket(cci_hSocket, FIONBIO, &ulArgNonBlocking) == SOCKET_ERROR) { ThrowF_t(TRANS("Cannot set socket to non-blocking mode. %s"), (const char*)GetSocketError(WSAGetLastError())); } +#else + int flags = fcntl(cci_hSocket, F_GETFL); + int failed = flags; + if (failed != -1) { + flags |= O_NONBLOCK; + failed = fcntl(cci_hSocket, F_SETFL, flags); + } + + if (failed == -1) { + ThrowF_t(TRANS("Cannot set socket to non-blocking mode. %s"), + (const char*)GetSocketError(WSAGetLastError())); + } +#endif + }; @@ -463,12 +543,18 @@ void CCommunicationInterface::GetLocalAddress_t(ULONG &ulHost, ULONG &ulPort) // get socket local port and address sockaddr_in sin; - int iSize = sizeof(sin); + socklen_t iSize = sizeof(sin); if (getsockname(cci_hSocket, (sockaddr*)&sin, &iSize) == SOCKET_ERROR) { ThrowF_t(TRANS("Cannot get local address on socket. %s"), (const char*)GetSocketError(WSAGetLastError())); } + +#ifdef PLATFORM_WIN32 ulHost = ntohl(sin.sin_addr.S_un.S_addr); +#else + ulHost = ntohl(sin.sin_addr.s_addr); +#endif + ulPort = ntohs(sin.sin_port); } @@ -484,12 +570,17 @@ void CCommunicationInterface::GetRemoteAddress_t(ULONG &ulHost, ULONG &ulPort) // get socket local port sockaddr_in sin; - int iSize = sizeof(sin); + socklen_t iSize = sizeof(sin); if (getpeername(cci_hSocket, (sockaddr*)&sin, &iSize) == SOCKET_ERROR) { ThrowF_t(TRANS("Cannot get remote address on socket. %s"), (const char*)GetSocketError(WSAGetLastError())); } + +#ifdef PLATFORM_WIN32 ulHost = ntohl(sin.sin_addr.S_un.S_addr); +#else + ulHost = ntohl(sin.sin_addr.s_addr); +#endif ulPort = ntohs(sin.sin_port); } @@ -549,12 +640,12 @@ void CCommunicationInterface::Broadcast_Update_t() { cm_aciClients[iClient].ci_adrAddress.adr_uwPort = ppaConnectionRequest->pa_adrAddress.adr_uwPort; // generate the ID UWORD uwID = _pTimer->GetHighPrecisionTimer().tv_llValue&0x0FFF; - if (uwID==0 || uwID=='//') { + if (uwID==0 || uwID==SLASHSLASH) { uwID+=1; } cm_aciClients[iClient].ci_adrAddress.adr_uwID = (uwID<<4)+iClient; // form the connection response packet - ppaConnectionRequest->pa_adrAddress.adr_uwID = '//'; + ppaConnectionRequest->pa_adrAddress.adr_uwID = SLASHSLASH; ppaConnectionRequest->pa_ubReliable = UDP_PACKET_RELIABLE | UDP_PACKET_RELIABLE_HEAD | UDP_PACKET_RELIABLE_TAIL | UDP_PACKET_CONNECT_RESPONSE; // return it to the client ppaConnectionRequest->WriteToPacket(&(cm_aciClients[iClient].ci_adrAddress.adr_uwID),sizeof(cm_aciClients[iClient].ci_adrAddress.adr_uwID),ppaConnectionRequest->pa_ubReliable,cm_ciBroadcast.ci_ulSequence++,ppaConnectionRequest->pa_adrAddress.adr_uwID,sizeof(cm_aciClients[iClient].ci_adrAddress.adr_uwID)); @@ -758,7 +849,7 @@ BOOL CCommunicationInterface::Server_Update() } } } else { - CPrintF(TRANS("Unable to deliver data to client '%s', disconnecting.\n"),AddressToString(cm_aciClients[iClient].ci_adrAddress.adr_ulAddress)); + CPrintF(TRANS("Unable to deliver data to client '%s', disconnecting.\n"),(const char *) AddressToString(cm_aciClients[iClient].ci_adrAddress.adr_ulAddress)); Server_ClearClient(iClient); _pNetwork->ga_srvServer.HandleClientDisconected(iClient); @@ -787,7 +878,7 @@ BOOL CCommunicationInterface::Server_Update() BOOL bClientFound; ppaPacket = cci_pbMasterInput.GetFirstPacket(); bClientFound = FALSE; - if (ppaPacket->pa_adrAddress.adr_uwID=='//' || ppaPacket->pa_adrAddress.adr_uwID==0) { + if (ppaPacket->pa_adrAddress.adr_uwID==SLASHSLASH || ppaPacket->pa_adrAddress.adr_uwID==0) { cm_ciBroadcast.ci_pbInputBuffer.AppendPacket(*ppaPacket,FALSE); bClientFound = TRUE; } else { @@ -803,7 +894,7 @@ BOOL CCommunicationInterface::Server_Update() // warn about possible attack extern INDEX net_bReportMiscErrors; if (net_bReportMiscErrors) { - CPrintF(TRANS("WARNING: Invalid message from: %s\n"), AddressToString(ppaPacket->pa_adrAddress.adr_ulAddress)); + CPrintF(TRANS("WARNING: Invalid message from: %s\n"), (const char *) AddressToString(ppaPacket->pa_adrAddress.adr_ulAddress)); } } } @@ -886,7 +977,7 @@ void CCommunicationInterface::Client_Close(void) // dispatch remaining packets (keep trying for half a second - 10 attempts) for(TIME tmWait=0; tmWait<500; - Sleep(NET_WAITMESSAGE_DELAY), tmWait+=NET_WAITMESSAGE_DELAY) { + _pTimer->Sleep(NET_WAITMESSAGE_DELAY), tmWait+=NET_WAITMESSAGE_DELAY) { // if all packets are successfully sent, exit loop if ((cm_ciLocalClient.ci_pbOutputBuffer.pb_ulNumOfPackets == 0) && (cm_ciLocalClient.ci_pbWaitAckBuffer.pb_ulNumOfPackets == 0)) { @@ -933,7 +1024,7 @@ void CCommunicationInterface::Client_OpenNet_t(ULONG ulServerAddress) UBYTE ubReliable; // check for reconnection - static ULONG ulLastServerAddress = -1; + static ULONG ulLastServerAddress = (ULONG) -1; BOOL bReconnecting = ulServerAddress == ulLastServerAddress; ulLastServerAddress = ulServerAddress; @@ -955,7 +1046,7 @@ void CCommunicationInterface::Client_OpenNet_t(ULONG ulServerAddress) ppaInfoPacket->pa_adrAddress.adr_ulAddress = ulServerAddress; ppaInfoPacket->pa_adrAddress.adr_uwPort = net_iPort; ppaInfoPacket->pa_ubRetryNumber = 0; - ppaInfoPacket->WriteToPacket(&ubDummy,1,ubReliable,cm_ciLocalClient.ci_ulSequence++,'//',1); + ppaInfoPacket->WriteToPacket(&ubDummy,1,ubReliable,cm_ciLocalClient.ci_ulSequence++,SLASHSLASH,1); cm_ciLocalClient.ci_pbOutputBuffer.AppendPacket(*ppaInfoPacket,TRUE); @@ -993,7 +1084,7 @@ void CCommunicationInterface::Client_OpenNet_t(ULONG ulServerAddress) } } - Sleep(iRefresh); + _pTimer->Sleep(iRefresh); CallProgressHook_t(FLOAT(iRetry%10)/10); } @@ -1125,13 +1216,13 @@ BOOL CCommunicationInterface::Client_Update(void) bClientFound = FALSE; // if the packet address is broadcast and it's an unreliable transfer, put it in the broadcast buffer - if ((ppaPacket->pa_adrAddress.adr_uwID=='//' || ppaPacket->pa_adrAddress.adr_uwID==0) && + if ((ppaPacket->pa_adrAddress.adr_uwID==SLASHSLASH || ppaPacket->pa_adrAddress.adr_uwID==0) && ppaPacket->pa_ubReliable == UDP_PACKET_UNRELIABLE) { cm_ciBroadcast.ci_pbInputBuffer.AppendPacket(*ppaPacket,FALSE); bClientFound = TRUE; // if the packet is for this client, accept it } else if ((ppaPacket->pa_adrAddress.adr_uwID == cm_ciLocalClient.ci_adrAddress.adr_uwID) || - ppaPacket->pa_adrAddress.adr_uwID=='//' || ppaPacket->pa_adrAddress.adr_uwID==0) { + ppaPacket->pa_adrAddress.adr_uwID==SLASHSLASH || ppaPacket->pa_adrAddress.adr_uwID==0) { cm_ciLocalClient.ci_pbInputBuffer.AppendPacket(*ppaPacket,FALSE); bClientFound = TRUE; } @@ -1139,7 +1230,7 @@ BOOL CCommunicationInterface::Client_Update(void) // warn about possible attack extern INDEX net_bReportMiscErrors; if (net_bReportMiscErrors) { - CPrintF(TRANS("WARNING: Invalid message from: %s\n"), AddressToString(ppaPacket->pa_adrAddress.adr_ulAddress)); + CPrintF(TRANS("WARNING: Invalid message from: %s\n"), (const char *) AddressToString(ppaPacket->pa_adrAddress.adr_ulAddress)); } } } @@ -1161,7 +1252,7 @@ void CCommunicationInterface::UpdateMasterBuffers() UBYTE aub[MAX_PACKET_SIZE]; CAddress adrIncomingAddress; SOCKADDR_IN sa; - int size = sizeof(sa); + socklen_t size = sizeof(sa); SLONG slSizeReceived; SLONG slSizeSent; BOOL bSomethingDone; @@ -1183,7 +1274,7 @@ void CCommunicationInterface::UpdateMasterBuffers() //On error, report it to the console (if error is not a no data to read message) if (slSizeReceived == SOCKET_ERROR) { int iResult = WSAGetLastError(); - if (iResult!=WSAEWOULDBLOCK) { + if (!isWouldBlockError(iResult)) { // report it if (iResult!=WSAECONNRESET || net_bReportICMPErrors) { CPrintF(TRANS("Socket error during UDP receive. %s\n"), @@ -1199,7 +1290,7 @@ void CCommunicationInterface::UpdateMasterBuffers() // the packet is in error extern INDEX net_bReportMiscErrors; if (net_bReportMiscErrors) { - CPrintF(TRANS("WARNING: Bad UDP packet from '%s'\n"), AddressToString(adrIncomingAddress.adr_ulAddress)); + CPrintF(TRANS("WARNING: Bad UDP packet from '%s'\n"), (const char *) AddressToString(adrIncomingAddress.adr_ulAddress)); } // there might be more to do bSomethingDone = TRUE; @@ -1241,7 +1332,7 @@ void CCommunicationInterface::UpdateMasterBuffers() if (slSizeSent == SOCKET_ERROR) { int iResult = WSAGetLastError(); // if output UDP buffer full, stop sending - if (iResult == WSAEWOULDBLOCK) { + if (isWouldBlockError(iResult)) { return; // report it } else if (iResult!=WSAECONNRESET || net_bReportICMPErrors) { @@ -1249,6 +1340,11 @@ void CCommunicationInterface::UpdateMasterBuffers() (const char*)GetSocketError(iResult)); } return; + + } else if (slSizeSent < ppaNewPacket->pa_slSize) { + STUBBED("LOST OUTGOING PACKET DATA!"); + ASSERT(0); + // if all sent ok } else { diff --git a/Sources/Engine/Network/CommunicationInterface.h b/Sources/Engine/Network/CommunicationInterface.h index d95c306..2fd5332 100644 --- a/Sources/Engine/Network/CommunicationInterface.h +++ b/Sources/Engine/Network/CommunicationInterface.h @@ -6,7 +6,7 @@ #pragma once #endif - +#include #define SERVER_CLIENTS 16 diff --git a/Sources/Engine/Network/Compression.cpp b/Sources/Engine/Network/Compression.cpp index 10ba359..8bc2051 100644 --- a/Sources/Engine/Network/Compression.cpp +++ b/Sources/Engine/Network/Compression.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Network/Diff.cpp b/Sources/Engine/Network/Diff.cpp index 3f5bb08..245092c 100644 --- a/Sources/Engine/Network/Diff.cpp +++ b/Sources/Engine/Network/Diff.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -66,6 +66,9 @@ struct EntityBlockInfo { CStaticStackArray _aebiOld; CStaticStackArray _aebiNew; + +#define ENT4 0x34544E45 // looks like "ENT4" in ASCII. + // make array of entity offsets in a block void MakeInfos(CStaticStackArray &aebi, UBYTE *pubBlock, SLONG slSize, UBYTE *pubFirst, UBYTE *&pubEnd) @@ -77,7 +80,7 @@ void MakeInfos(CStaticStackArray &aebi, UBYTE *pub = pubFirst; while (pub +#include //rcg10242001 #include #include #include @@ -35,7 +36,7 @@ public: }; // the thread's local buffer -static _declspec(thread) CMessageBuffer mbReceivedMessage = { 0,0 }; +THREADLOCAL(CMessageBuffer, mbReceivedMessage, CMessageBuffer()); void CMessageBuffer::Allocate(void) { @@ -421,13 +422,15 @@ BOOL CMessageDispatcher::ReceiveFromClientReliable(INDEX iClient, CNetworkMessag return bReceived; } +#define SLASHSLASH 0x2F2F // looks like "//" in ASCII. + /* Send/receive broadcast messages. */ void CMessageDispatcher::SendBroadcast(const CNetworkMessage &nmMessage, ULONG ulAddr, UWORD uwPort) { CAddress adrDestination; adrDestination.adr_ulAddress = ulAddr; adrDestination.adr_uwPort = uwPort; - adrDestination.adr_uwID = '//'; + adrDestination.adr_uwID = SLASHSLASH; // send the message _cmiComm.Broadcast_Send((void*)nmMessage.nm_pubMessage, nmMessage.nm_slSize,adrDestination); diff --git a/Sources/Engine/Network/Network.cpp b/Sources/Engine/Network/Network.cpp index 82effb0..fcd13da 100644 --- a/Sources/Engine/Network/Network.cpp +++ b/Sources/Engine/Network/Network.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include #include #include @@ -23,7 +23,7 @@ #include -#include +#include #include #include #include @@ -58,18 +58,18 @@ #include #include -#include - // pointer to global instance of the only game object in the application CNetworkLibrary *_pNetwork= NULL; extern BOOL _bNeedPretouch; -extern BOOL _bMultiPlayer = FALSE; -extern INDEX _ctEntities = 0; -extern INDEX _ctPredictorEntities = 0; -extern LevelChangePhase _lphCurrent = LCP_NOCHANGE; -extern BOOL _bTempNetwork = FALSE; // set while using temporary second network object + +BOOL _bMultiPlayer = FALSE; +INDEX _ctEntities = 0; +INDEX _ctPredictorEntities = 0; +LevelChangePhase _lphCurrent = LCP_NOCHANGE; +BOOL _bTempNetwork = FALSE; // set while using temporary second network object + extern BOOL con_bCapture; extern CTString con_strCapture; @@ -80,92 +80,92 @@ static FLOAT _bStopDemoRecordingNextTime = FALSE; static INDEX dem_iRecordedNumber = 0; // network control -extern INDEX ser_bReportSyncOK = FALSE; -extern INDEX ser_bReportSyncBad = TRUE; -extern INDEX ser_bReportSyncLate = FALSE; -extern INDEX ser_bReportSyncEarly = FALSE; -extern INDEX ser_bPauseOnSyncBad = FALSE; -extern INDEX ser_iKickOnSyncBad = 10; -extern INDEX ser_bKickOnSyncLate = 1; -extern INDEX ser_iRememberBehind = 3000; -extern INDEX ser_iExtensiveSyncCheck = 0; -extern INDEX ser_bClientsMayPause = TRUE; -extern FLOAT ser_tmSyncCheckFrequency = 1.0f; -extern INDEX ser_iSyncCheckBuffer = 60; -extern INDEX ser_bEnumeration = TRUE; -extern INDEX ser_bPingGameAgent = TRUE; -extern FLOAT ser_tmKeepAlive = 0.1f; -extern FLOAT ser_tmPingUpdate = 3.0f; -extern INDEX ser_bWaitFirstPlayer = 0; -extern INDEX ser_iMaxAllowedBPS = 8000; -extern CTString ser_strIPMask = ""; -extern CTString ser_strNameMask = ""; -extern INDEX ser_bInverseBanning = FALSE; -extern CTString ser_strMOTD = ""; +INDEX ser_bReportSyncOK = FALSE; +INDEX ser_bReportSyncBad = TRUE; +INDEX ser_bReportSyncLate = FALSE; +INDEX ser_bReportSyncEarly = FALSE; +INDEX ser_bPauseOnSyncBad = FALSE; +INDEX ser_iKickOnSyncBad = 10; +INDEX ser_bKickOnSyncLate = 1; +INDEX ser_iRememberBehind = 3000; +INDEX ser_iExtensiveSyncCheck = 0; +INDEX ser_bClientsMayPause = TRUE; +FLOAT ser_tmSyncCheckFrequency = 1.0f; +INDEX ser_iSyncCheckBuffer = 60; +INDEX ser_bEnumeration = TRUE; +INDEX ser_bHeartbeatGameSpy = TRUE; +FLOAT ser_tmKeepAlive = 0.1f; +FLOAT ser_tmPingUpdate = 3.0f; +INDEX ser_bWaitFirstPlayer = 0; +INDEX ser_iMaxAllowedBPS = 8000; +CTString ser_strIPMask = ""; +CTString ser_strNameMask = ""; +INDEX ser_bInverseBanning = FALSE; +CTString ser_strMOTD = ""; -extern INDEX cli_bEmulateDesync = FALSE; -extern INDEX cli_bDumpSync = FALSE; -extern INDEX cli_bDumpSyncEachTick = FALSE; -extern INDEX cli_bAutoAdjustSettings = FALSE; -extern FLOAT cli_tmAutoAdjustThreshold = 2.0f; -extern INDEX cli_bPrediction = FALSE; -extern INDEX cli_iMaxPredictionSteps = 10; -extern INDEX cli_bPredictIfServer = FALSE; -extern INDEX cli_bPredictLocalPlayers = TRUE; -extern INDEX cli_bPredictRemotePlayers = FALSE; -extern FLOAT cli_fPredictEntitiesRange = 20.0f; -extern INDEX cli_bLerpActions = FALSE; -extern INDEX cli_bReportPredicted = FALSE; -extern INDEX cli_iSendBehind = 3; -extern INDEX cli_iPredictionFlushing = 1; +INDEX cli_bEmulateDesync = FALSE; +INDEX cli_bDumpSync = FALSE; +INDEX cli_bDumpSyncEachTick = FALSE; +INDEX cli_bAutoAdjustSettings = FALSE; +FLOAT cli_tmAutoAdjustThreshold = 2.0f; +INDEX cli_bPrediction = FALSE; +INDEX cli_iMaxPredictionSteps = 10; +INDEX cli_bPredictIfServer = FALSE; +INDEX cli_bPredictLocalPlayers = TRUE; +INDEX cli_bPredictRemotePlayers = FALSE; +FLOAT cli_fPredictEntitiesRange = 20.0f; +INDEX cli_bLerpActions = FALSE; +INDEX cli_bReportPredicted = FALSE; +INDEX cli_iSendBehind = 3; +INDEX cli_iPredictionFlushing = 1; -extern INDEX cli_iBufferActions = 1; -extern INDEX cli_iMaxBPS = 4000; -extern INDEX cli_iMinBPS = 0; +INDEX cli_iBufferActions = 1; +INDEX cli_iMaxBPS = 4000; +INDEX cli_iMinBPS = 0; -extern INDEX net_iCompression = 1; -extern INDEX net_bLookupHostNames = FALSE; -extern INDEX net_bReportPackets = FALSE; -extern INDEX net_iMaxSendRetries = 10; -extern FLOAT net_fSendRetryWait = 0.5f; -extern INDEX net_bReportTraffic = FALSE; -extern INDEX net_bReportICMPErrors = FALSE; -extern INDEX net_bReportMiscErrors = FALSE; -extern INDEX net_bLerping = TRUE; -extern INDEX net_iGraphBuffer = 100; -extern INDEX net_iExactTimer = 2; -extern INDEX net_bDumpStreamBlocks = 0; -extern INDEX net_bDumpConnectionInfo = 0; -extern INDEX net_iPort = 25600; -extern CTString net_strLocalHost = ""; -extern CTString net_strLocationCode = ""; -extern CTString net_strConnectPassword = ""; -extern CTString net_strAdminPassword = ""; -extern CTString net_strVIPPassword = ""; -extern CTString net_strObserverPassword = ""; -extern INDEX net_iVIPReserve = 0; -extern INDEX net_iMaxObservers = 16; -extern INDEX net_iMaxClients = 0; -extern FLOAT net_tmConnectionTimeout = 30.0f; -extern FLOAT net_tmProblemsTimeout = 5.0f; -extern FLOAT net_tmDisconnectTimeout = 300.0f; // must be higher for level changing -extern INDEX net_bReportCRC = FALSE; -extern FLOAT net_fDropPackets = 0.0f; -extern FLOAT net_tmLatency = 0.0f; +INDEX net_iCompression = 1; +INDEX net_bLookupHostNames = FALSE; +INDEX net_bReportPackets = FALSE; +INDEX net_iMaxSendRetries = 10; +FLOAT net_fSendRetryWait = 0.5f; +INDEX net_bReportTraffic = FALSE; +INDEX net_bReportICMPErrors = FALSE; +INDEX net_bReportMiscErrors = FALSE; +INDEX net_bLerping = TRUE; +INDEX net_iGraphBuffer = 100; +INDEX net_iExactTimer = 2; +INDEX net_bDumpStreamBlocks = 0; +INDEX net_bDumpConnectionInfo = 0; +INDEX net_iPort = 25600; +CTString net_strLocalHost = ""; +CTString net_strLocationCode = ""; +CTString net_strConnectPassword = ""; +CTString net_strAdminPassword = ""; +CTString net_strVIPPassword = ""; +CTString net_strObserverPassword = ""; +INDEX net_iVIPReserve = 0; +INDEX net_iMaxObservers = 16; +INDEX net_iMaxClients = 0; +FLOAT net_tmConnectionTimeout = 30.0f; +FLOAT net_tmProblemsTimeout = 5.0f; +FLOAT net_tmDisconnectTimeout = 300.0f; // must be higher for level changing +INDEX net_bReportCRC = FALSE; +FLOAT net_fDropPackets = 0.0f; +FLOAT net_tmLatency = 0.0f; -extern INDEX ent_bReportSpawnInWall = FALSE; +INDEX ent_bReportSpawnInWall = FALSE; -extern FLOAT cmd_tmTick = 0.0f; -extern CTString cmd_cmdOnTick = ""; -extern CTString cmd_strChatSender = ""; -extern CTString cmd_strChatMessage = ""; -extern CTString cmd_cmdOnChat = ""; -extern INDEX net_ctChatMessages = 0; // counter for incoming chat messages +FLOAT cmd_tmTick = 0.0f; +CTString cmd_cmdOnTick = ""; +CTString cmd_strChatSender = ""; +CTString cmd_strChatMessage = ""; +CTString cmd_cmdOnChat = ""; +INDEX net_ctChatMessages = 0; // counter for incoming chat messages extern CPacketBufferStats _pbsSend; extern CPacketBufferStats _pbsRecv; -extern BOOL _bPredictionActive = FALSE; +BOOL _bPredictionActive = FALSE; class CGatherCRC { public: @@ -182,43 +182,43 @@ CGatherCRC::~CGatherCRC() { } // precache control -extern INDEX _precache_NONE = PRECACHE_NONE; -extern INDEX _precache_SMART = PRECACHE_SMART; -extern INDEX _precache_ALL = PRECACHE_ALL; -extern INDEX _precache_PARANOIA = PRECACHE_PARANOIA; -extern INDEX gam_iPrecachePolicy = _precache_SMART; -extern INDEX _precache_bNowPrecaching = FALSE; +INDEX _precache_NONE = PRECACHE_NONE; +INDEX _precache_SMART = PRECACHE_SMART; +INDEX _precache_ALL = PRECACHE_ALL; +INDEX _precache_PARANOIA = PRECACHE_PARANOIA; +INDEX gam_iPrecachePolicy = _precache_SMART; +INDEX _precache_bNowPrecaching = FALSE; -extern INDEX dbg_bBreak = FALSE; -extern INDEX gam_bPretouch = FALSE; +INDEX dbg_bBreak = FALSE; +INDEX gam_bPretouch = FALSE; -extern FLOAT phy_fCollisionCacheAhead = 5.0f; -extern FLOAT phy_fCollisionCacheAround = 1.5f; -extern FLOAT cli_fPredictionFilter = 0.5f; +FLOAT phy_fCollisionCacheAhead = 5.0f; +FLOAT phy_fCollisionCacheAround = 1.5f; +FLOAT cli_fPredictionFilter = 0.5f; extern INDEX shd_bCacheAll; // input -extern INDEX inp_iKeyboardReadingMethod = 2; // 0=getasynckey, 1=virtkeytrap, 2=scancodetrap -extern INDEX inp_bAllowMouseAcceleration = TRUE; -extern FLOAT inp_fMouseSensitivity = 1.0f; -extern INDEX inp_bMousePrecision = FALSE; -extern FLOAT inp_fMousePrecisionFactor = 4.0f; -extern FLOAT inp_fMousePrecisionThreshold = 10.0f; -extern FLOAT inp_fMousePrecisionTimeout = 0.25f; -extern FLOAT inp_bInvertMouse = FALSE; -extern INDEX inp_bFilterMouse = FALSE; -extern INDEX inp_bAllowPrescan = TRUE; +INDEX inp_iKeyboardReadingMethod = 2; // 0=getasynckey, 1=virtkeytrap, 2=scancodetrap +INDEX inp_bAllowMouseAcceleration = TRUE; +FLOAT inp_fMouseSensitivity = 1.0f; +INDEX inp_bMousePrecision = FALSE; +FLOAT inp_fMousePrecisionFactor = 4.0f; +FLOAT inp_fMousePrecisionThreshold = 10.0f; +FLOAT inp_fMousePrecisionTimeout = 0.25f; +FLOAT inp_bInvertMouse = FALSE; +INDEX inp_bFilterMouse = FALSE; +INDEX inp_bAllowPrescan = TRUE; -extern INDEX inp_i2ndMousePort = 0; // COM no (0=disable) -extern FLOAT inp_f2ndMouseSensitivity = 1.0f; -extern INDEX inp_b2ndMousePrecision = FALSE; -extern FLOAT inp_f2ndMousePrecisionFactor = 4.0f; -extern FLOAT inp_f2ndMousePrecisionThreshold = 10.0f; -extern FLOAT inp_f2ndMousePrecisionTimeout = 0.25f; -extern INDEX inp_bInvert2ndMouse = FALSE; -extern INDEX inp_bFilter2ndMouse = FALSE; +INDEX inp_i2ndMousePort = 0; // COM no (0=disable) +FLOAT inp_f2ndMouseSensitivity = 1.0f; +INDEX inp_b2ndMousePrecision = FALSE; +FLOAT inp_f2ndMousePrecisionFactor = 4.0f; +FLOAT inp_f2ndMousePrecisionThreshold = 10.0f; +FLOAT inp_f2ndMousePrecisionTimeout = 0.25f; +INDEX inp_bInvert2ndMouse = FALSE; +INDEX inp_bFilter2ndMouse = FALSE; extern INDEX inp_iMButton4Up; extern INDEX inp_iMButton4Dn; @@ -229,8 +229,7 @@ extern INDEX inp_ctJoysticksAllowed; extern INDEX inp_bForceJoystickPolling; extern INDEX inp_bAutoDisableJoysticks; -extern INDEX wed_bUseGenericTextureReplacement = FALSE; - +INDEX wed_bUseGenericTextureReplacement = FALSE; extern void RendererInfo(void); extern void ClearRenderer(void); @@ -319,7 +318,7 @@ static void NetworkInfo(void) CPlayerBuffer &plb = _pNetwork->ga_srvServer.srv_aplbPlayers[iplb]; if (plb.plb_Active) { CPrintF(" %2d(%2d):'%s'@client%2d: (%dact)\n", - iplb, plb.plb_Index, plb.plb_pcCharacter.GetNameForPrinting(), + iplb, plb.plb_Index, (const char *) plb.plb_pcCharacter.GetNameForPrinting(), plb.plb_iClient, plb.plb_abReceived.GetCount()); } } @@ -327,7 +326,7 @@ static void NetworkInfo(void) for(INDEX iSession=0; iSession<_pNetwork->ga_srvServer.srv_assoSessions.Count(); iSession++) { CSessionSocket &sso = _pNetwork->ga_srvServer.srv_assoSessions[iSession]; if (sso.sso_bActive) { - CPrintF(" %2d:'%s'\n", iSession, _cmiComm.Server_GetClientName(iSession)), + CPrintF(" %2d:'%s'\n", iSession, (const char *) _cmiComm.Server_GetClientName(iSession)), CPrintF(" buffer: %dblk=%dk\n", sso.sso_nsBuffer.GetUsedBlocks(), sso.sso_nsBuffer.GetUsedMemory()/1024); @@ -355,7 +354,7 @@ static void NetworkInfo(void) for(INDEX iplt=0; iplt<_pNetwork->ga_sesSessionState.ses_apltPlayers.Count(); iplt++) { CPlayerTarget &plt = _pNetwork->ga_sesSessionState.ses_apltPlayers[iplt]; if (plt.plt_bActive) { - ULONG ulID = -1; + ULONG ulID = (ULONG) -1; if (plt.plt_penPlayerEntity!=NULL) { ulID = plt.plt_penPlayerEntity->en_ulID; } @@ -384,7 +383,7 @@ static void ListPlayers(void) for(INDEX iplb=0; iplb<_pNetwork->ga_srvServer.srv_aplbPlayers.Count(); iplb++) { CPlayerBuffer &plb = _pNetwork->ga_srvServer.srv_aplbPlayers[iplb]; if (plb.plb_Active) { - CPrintF(" %-2d %s\n", plb.plb_iClient, plb.plb_pcCharacter.GetNameForPrinting()); + CPrintF(" %-2d %s\n", plb.plb_iClient, (const char *) plb.plb_pcCharacter.GetNameForPrinting()); } } CPrintF(" ----------------------\n"); @@ -405,7 +404,7 @@ static void KickClient(INDEX iClient, const CTString &strReason) CPrintF(TRANS("Can't kick local client!\n")); return; } - CPrintF( TRANS("Kicking %d with explanation '%s'...\n"), iClient, strReason); + CPrintF( TRANS("Kicking %d with explanation '%s'...\n"), iClient, (const char *) strReason); _pNetwork->ga_srvServer.SendDisconnectMessage(iClient, "Admin: "+strReason); } static void KickClientCfunc(void* pArgs) @@ -476,7 +475,7 @@ static void StockInfo(void) } slUploadMemory += slUploadSize; slShdBytes += slTotalSize + sizeof(CShadowMap); - slSlackMemory += slTotalSize*fSlackRatio; + slSlackMemory += (SLONG) (slTotalSize*fSlackRatio); if( !bIsFlat) { // by size ... if( slStaticSize>128*1024) { ct256++; sl256Memory+=slTotalSize; } @@ -619,7 +618,7 @@ static void StockDump(void) _pSoundStock->DumpMemoryUsage_t(strm); strm.PutLine_t("Classes:"); _pEntityClassStock->DumpMemoryUsage_t(strm); - CPrintF("Dumped to '%s'\n", CTString(fnm)); + CPrintF("Dumped to '%s'\n", (const char *) CTString(fnm)); } catch (char *strError) { CPrintF("Error: %s\n", strError); } @@ -647,10 +646,16 @@ void CNetworkTimerHandler::HandleTimer(void) return; // this can happen during NET_MakeDefaultState_t()! } // enable stream handling during timer +#if (!defined SINGLE_THREADED) CTSTREAM_BEGIN { +#endif + // do the timer loop _pNetwork->TimerLoop(); + +#if (!defined SINGLE_THREADED) } CTSTREAM_END; +#endif } /* @@ -713,169 +718,169 @@ void CNetworkLibrary::Init(const CTString &strGameID) CMessageDispatcher::Init(strGameID); // add shell symbols - _pShell->DeclareSymbol("user INDEX dbg_bBreak;", &dbg_bBreak); - _pShell->DeclareSymbol("persistent user INDEX gam_bPretouch;", &gam_bPretouch); + _pShell->DeclareSymbol("user INDEX dbg_bBreak;", (void *)&dbg_bBreak); + _pShell->DeclareSymbol("persistent user INDEX gam_bPretouch;", (void *)&gam_bPretouch); - _pShell->DeclareSymbol("user INDEX dem_iRecordedNumber;", &dem_iRecordedNumber); - _pShell->DeclareSymbol("user void StartDemoRecording(void);", &StartDemoRecording); - _pShell->DeclareSymbol("user void StopDemoRecording(void);", &StopDemoRecording); - _pShell->DeclareSymbol("user void NetworkInfo(void);", &NetworkInfo); - _pShell->DeclareSymbol("user void StockInfo(void);", &StockInfo); - _pShell->DeclareSymbol("user void StockDump(void);", &StockDump); - _pShell->DeclareSymbol("user void RendererInfo(void);", &RendererInfo); - _pShell->DeclareSymbol("user void ClearRenderer(void);", &ClearRenderer); - _pShell->DeclareSymbol("user void CacheShadows(void);", &CacheShadows); - _pShell->DeclareSymbol("user void KickClient(INDEX, CTString);", &KickClientCfunc); - _pShell->DeclareSymbol("user void KickByName(CTString, CTString);", &KickByNameCfunc); - _pShell->DeclareSymbol("user void ListPlayers(void);", &ListPlayers); - _pShell->DeclareSymbol("user void Admin(CTString);", &Admin); + _pShell->DeclareSymbol("user INDEX dem_iRecordedNumber;", (void *)&dem_iRecordedNumber); + _pShell->DeclareSymbol("user void StartDemoRecording(void);", (void *)&StartDemoRecording); + _pShell->DeclareSymbol("user void StopDemoRecording(void);", (void *)&StopDemoRecording); + _pShell->DeclareSymbol("user void NetworkInfo(void);", (void *)&NetworkInfo); + _pShell->DeclareSymbol("user void StockInfo(void);", (void *)&StockInfo); + _pShell->DeclareSymbol("user void StockDump(void);", (void *)&StockDump); + _pShell->DeclareSymbol("user void RendererInfo(void);", (void *)&RendererInfo); + _pShell->DeclareSymbol("user void ClearRenderer(void);", (void *)&ClearRenderer); + _pShell->DeclareSymbol("user void CacheShadows(void);", (void *)&CacheShadows); + _pShell->DeclareSymbol("user void KickClient(INDEX, CTString);", (void *)&KickClientCfunc); + _pShell->DeclareSymbol("user void KickByName(CTString, CTString);", (void *)&KickByNameCfunc); + _pShell->DeclareSymbol("user void ListPlayers(void);", (void *)&ListPlayers); + _pShell->DeclareSymbol("user void Admin(CTString);", (void *)&Admin); - _pShell->DeclareSymbol("user void AddIPMask(CTString);", &AddIPMask); - _pShell->DeclareSymbol("user void RemIPMask(CTString);", &RemIPMask); - _pShell->DeclareSymbol("user void AddNameMask(CTString);", &AddNameMask); - _pShell->DeclareSymbol("user void RemNameMask(CTString);", &RemNameMask); + _pShell->DeclareSymbol("user void AddIPMask(CTString);", (void *)&AddIPMask); + _pShell->DeclareSymbol("user void RemIPMask(CTString);", (void *)&RemIPMask); + _pShell->DeclareSymbol("user void AddNameMask(CTString);", (void *)&AddNameMask); + _pShell->DeclareSymbol("user void RemNameMask(CTString);", (void *)&RemNameMask); - _pShell->DeclareSymbol("user FLOAT dem_tmTimer;", &ga_fDemoTimer); - _pShell->DeclareSymbol("user FLOAT dem_fSyncRate;", &ga_fDemoSyncRate); - _pShell->DeclareSymbol("user FLOAT dem_fRealTimeFactor;", &ga_fDemoRealTimeFactor); - _pShell->DeclareSymbol("user FLOAT gam_fRealTimeFactor;", &ga_fGameRealTimeFactor); + _pShell->DeclareSymbol("user FLOAT dem_tmTimer;", (void *)&ga_fDemoTimer); + _pShell->DeclareSymbol("user FLOAT dem_fSyncRate;", (void *)&ga_fDemoSyncRate); + _pShell->DeclareSymbol("user FLOAT dem_fRealTimeFactor;", (void *)&ga_fDemoRealTimeFactor); + _pShell->DeclareSymbol("user FLOAT gam_fRealTimeFactor;", (void *)&ga_fGameRealTimeFactor); - _pShell->DeclareSymbol("user const FLOAT net_tmLatency;", &net_tmLatency); - _pShell->DeclareSymbol("user const FLOAT cmd_tmTick;", &cmd_tmTick); - _pShell->DeclareSymbol("persistent user CTString cmd_cmdOnTick;", &cmd_cmdOnTick); - _pShell->DeclareSymbol("user CTString cmd_strChatSender ;", &cmd_strChatSender ); - _pShell->DeclareSymbol("user CTString cmd_strChatMessage;", &cmd_strChatMessage); - _pShell->DeclareSymbol("persistent user CTString cmd_cmdOnChat;", &cmd_cmdOnChat); + _pShell->DeclareSymbol("user const FLOAT net_tmLatency;", (void *)&net_tmLatency); + _pShell->DeclareSymbol("user const FLOAT cmd_tmTick;", (void *)&cmd_tmTick); + _pShell->DeclareSymbol("persistent user CTString cmd_cmdOnTick;", (void *)&cmd_cmdOnTick); + _pShell->DeclareSymbol("user CTString cmd_strChatSender ;", (void *)&cmd_strChatSender ); + _pShell->DeclareSymbol("user CTString cmd_strChatMessage;", (void *)&cmd_strChatMessage); + _pShell->DeclareSymbol("persistent user CTString cmd_cmdOnChat;", (void *)&cmd_cmdOnChat); - _pShell->DeclareSymbol("user INDEX net_ctChatMessages;", &net_ctChatMessages); + _pShell->DeclareSymbol("user INDEX net_ctChatMessages;", (void *)&net_ctChatMessages); - _pShell->DeclareSymbol("persistent user INDEX ent_bReportSpawnInWall;", &ent_bReportSpawnInWall); + _pShell->DeclareSymbol("persistent user INDEX ent_bReportSpawnInWall;", (void *)&ent_bReportSpawnInWall); - _pShell->DeclareSymbol("user INDEX ser_bReportSyncOK;", &ser_bReportSyncOK); - _pShell->DeclareSymbol("user INDEX ser_bReportSyncBad;", &ser_bReportSyncBad); - _pShell->DeclareSymbol("user INDEX ser_bReportSyncLate;", &ser_bReportSyncLate); - _pShell->DeclareSymbol("user INDEX ser_bReportSyncEarly;", &ser_bReportSyncEarly); - _pShell->DeclareSymbol("user INDEX ser_bPauseOnSyncBad;", &ser_bPauseOnSyncBad); - _pShell->DeclareSymbol("user INDEX ser_iKickOnSyncBad;", &ser_iKickOnSyncBad); - _pShell->DeclareSymbol("user INDEX ser_bKickOnSyncLate;", &ser_bKickOnSyncLate); - _pShell->DeclareSymbol("persistent user FLOAT ser_tmSyncCheckFrequency;", &ser_tmSyncCheckFrequency); - _pShell->DeclareSymbol("persistent user INDEX ser_iSyncCheckBuffer;", &ser_iSyncCheckBuffer); - _pShell->DeclareSymbol("persistent user INDEX cli_bLerpActions;", &cli_bLerpActions); - _pShell->DeclareSymbol("persistent user INDEX cli_bReportPredicted;", &cli_bReportPredicted); - _pShell->DeclareSymbol("persistent user INDEX net_iExactTimer;", &net_iExactTimer); - _pShell->DeclareSymbol("user INDEX net_bDumpStreamBlocks;", &net_bDumpStreamBlocks); - _pShell->DeclareSymbol("user INDEX net_bDumpConnectionInfo;", &net_bDumpConnectionInfo); - _pShell->DeclareSymbol("user INDEX net_iPort;", &net_iPort); - _pShell->DeclareSymbol("persistent user CTString net_strLocalHost;", &net_strLocalHost); - _pShell->DeclareSymbol("persistent user CTString net_strLocationCode;", &net_strLocationCode); - _pShell->DeclareSymbol("user CTString net_strVIPPassword;", &net_strVIPPassword); - _pShell->DeclareSymbol("user CTString net_strObserverPassword;", &net_strObserverPassword); - _pShell->DeclareSymbol("user INDEX net_iVIPReserve;", &net_iVIPReserve); - _pShell->DeclareSymbol("user INDEX net_iMaxObservers;", &net_iMaxObservers); - _pShell->DeclareSymbol("user INDEX net_iMaxClients;", &net_iMaxClients); - _pShell->DeclareSymbol("user CTString net_strConnectPassword;", &net_strConnectPassword); - _pShell->DeclareSymbol("user CTString net_strAdminPassword;", &net_strAdminPassword); - _pShell->DeclareSymbol("user FLOAT net_tmConnectionTimeout;", &net_tmConnectionTimeout); - _pShell->DeclareSymbol("user FLOAT net_tmProblemsTimeout;", &net_tmProblemsTimeout); - _pShell->DeclareSymbol("user FLOAT net_tmDisconnectTimeout;", &net_tmDisconnectTimeout); - _pShell->DeclareSymbol("user INDEX net_bReportCRC;", &net_bReportCRC); - _pShell->DeclareSymbol("user INDEX ser_iRememberBehind;", &ser_iRememberBehind); - _pShell->DeclareSymbol("user INDEX cli_bEmulateDesync;", &cli_bEmulateDesync); - _pShell->DeclareSymbol("user INDEX cli_bDumpSync;", &cli_bDumpSync); + _pShell->DeclareSymbol("user INDEX ser_bReportSyncOK;", (void *)&ser_bReportSyncOK); + _pShell->DeclareSymbol("user INDEX ser_bReportSyncBad;", (void *)&ser_bReportSyncBad); + _pShell->DeclareSymbol("user INDEX ser_bReportSyncLate;", (void *)&ser_bReportSyncLate); + _pShell->DeclareSymbol("user INDEX ser_bReportSyncEarly;", (void *)&ser_bReportSyncEarly); + _pShell->DeclareSymbol("user INDEX ser_bPauseOnSyncBad;", (void *)&ser_bPauseOnSyncBad); + _pShell->DeclareSymbol("user INDEX ser_iKickOnSyncBad;", (void *)&ser_iKickOnSyncBad); + _pShell->DeclareSymbol("user INDEX ser_bKickOnSyncLate;", (void *)&ser_bKickOnSyncLate); + _pShell->DeclareSymbol("persistent user FLOAT ser_tmSyncCheckFrequency;", (void *)&ser_tmSyncCheckFrequency); + _pShell->DeclareSymbol("persistent user INDEX ser_iSyncCheckBuffer;", (void *)&ser_iSyncCheckBuffer); + _pShell->DeclareSymbol("persistent user INDEX cli_bLerpActions;", (void *)&cli_bLerpActions); + _pShell->DeclareSymbol("persistent user INDEX cli_bReportPredicted;", (void *)&cli_bReportPredicted); + _pShell->DeclareSymbol("persistent user INDEX net_iExactTimer;", (void *)&net_iExactTimer); + _pShell->DeclareSymbol("user INDEX net_bDumpStreamBlocks;", (void *)&net_bDumpStreamBlocks); + _pShell->DeclareSymbol("user INDEX net_bDumpConnectionInfo;", (void *)&net_bDumpConnectionInfo); + _pShell->DeclareSymbol("user INDEX net_iPort;", (void *)&net_iPort); + _pShell->DeclareSymbol("persistent user CTString net_strLocalHost;", (void *)&net_strLocalHost); + _pShell->DeclareSymbol("persistent user CTString net_strLocationCode;", (void *)&net_strLocationCode); + _pShell->DeclareSymbol("user CTString net_strVIPPassword;", (void *)&net_strVIPPassword); + _pShell->DeclareSymbol("user CTString net_strObserverPassword;", (void *)&net_strObserverPassword); + _pShell->DeclareSymbol("user INDEX net_iVIPReserve;", (void *)&net_iVIPReserve); + _pShell->DeclareSymbol("user INDEX net_iMaxObservers;", (void *)&net_iMaxObservers); + _pShell->DeclareSymbol("user INDEX net_iMaxClients;", (void *)&net_iMaxClients); + _pShell->DeclareSymbol("user CTString net_strConnectPassword;", (void *)&net_strConnectPassword); + _pShell->DeclareSymbol("user CTString net_strAdminPassword;", (void *)&net_strAdminPassword); + _pShell->DeclareSymbol("user FLOAT net_tmConnectionTimeout;", (void *)&net_tmConnectionTimeout); + _pShell->DeclareSymbol("user FLOAT net_tmProblemsTimeout;", (void *)&net_tmProblemsTimeout); + _pShell->DeclareSymbol("user FLOAT net_tmDisconnectTimeout;", (void *)&net_tmDisconnectTimeout); + _pShell->DeclareSymbol("user INDEX net_bReportCRC;", (void *)&net_bReportCRC); + _pShell->DeclareSymbol("user INDEX ser_iRememberBehind;", (void *)&ser_iRememberBehind); + _pShell->DeclareSymbol("user INDEX cli_bEmulateDesync;", (void *)&cli_bEmulateDesync); + _pShell->DeclareSymbol("user INDEX cli_bDumpSync;", (void *)&cli_bDumpSync); _pShell->DeclareSymbol("user INDEX cli_bDumpSyncEachTick;",&cli_bDumpSyncEachTick); - _pShell->DeclareSymbol("persistent user INDEX ser_iExtensiveSyncCheck;", &ser_iExtensiveSyncCheck); - _pShell->DeclareSymbol("persistent user INDEX net_bLookupHostNames;", &net_bLookupHostNames); - _pShell->DeclareSymbol("persistent user INDEX net_iCompression ;", &net_iCompression); - _pShell->DeclareSymbol("persistent user INDEX net_bReportPackets;", &net_bReportPackets); - _pShell->DeclareSymbol("persistent user INDEX net_iMaxSendRetries;", &net_iMaxSendRetries); - _pShell->DeclareSymbol("persistent user FLOAT net_fSendRetryWait;", &net_fSendRetryWait); - _pShell->DeclareSymbol("persistent user INDEX net_bReportTraffic;", &net_bReportTraffic); - _pShell->DeclareSymbol("persistent user INDEX net_bReportICMPErrors;", &net_bReportICMPErrors); - _pShell->DeclareSymbol("persistent user INDEX net_bReportMiscErrors;", &net_bReportMiscErrors); - _pShell->DeclareSymbol("persistent user INDEX net_bLerping;", &net_bLerping); - _pShell->DeclareSymbol("persistent user INDEX ser_bClientsMayPause;", &ser_bClientsMayPause); - _pShell->DeclareSymbol("persistent user INDEX ser_bEnumeration;", &ser_bEnumeration); - _pShell->DeclareSymbol("persistent user INDEX ser_bPingGameAgent;", &ser_bPingGameAgent); - _pShell->DeclareSymbol("persistent user FLOAT ser_tmKeepAlive;", &ser_tmKeepAlive); - _pShell->DeclareSymbol("persistent user FLOAT ser_tmPingUpdate;", &ser_tmPingUpdate); - _pShell->DeclareSymbol("persistent user INDEX ser_bWaitFirstPlayer;", &ser_bWaitFirstPlayer); - _pShell->DeclareSymbol("persistent user INDEX ser_iMaxAllowedBPS;", &ser_iMaxAllowedBPS); - _pShell->DeclareSymbol("persistent user INDEX ser_iMaxAllowedBPS;", &ser_iMaxAllowedBPS); - _pShell->DeclareSymbol("persistent user CTString ser_strIPMask;", &ser_strIPMask); - _pShell->DeclareSymbol("persistent user CTString ser_strNameMask;", &ser_strNameMask); - _pShell->DeclareSymbol("persistent user INDEX ser_bInverseBanning;", &ser_bInverseBanning); - _pShell->DeclareSymbol("persistent user CTString ser_strMOTD;", &ser_strMOTD); + _pShell->DeclareSymbol("persistent user INDEX ser_iExtensiveSyncCheck;", (void *)&ser_iExtensiveSyncCheck); + _pShell->DeclareSymbol("persistent user INDEX net_bLookupHostNames;", (void *)&net_bLookupHostNames); + _pShell->DeclareSymbol("persistent user INDEX net_iCompression ;", (void *)&net_iCompression); + _pShell->DeclareSymbol("persistent user INDEX net_bReportPackets;", (void *)&net_bReportPackets); + _pShell->DeclareSymbol("persistent user INDEX net_iMaxSendRetries;", (void *)&net_iMaxSendRetries); + _pShell->DeclareSymbol("persistent user FLOAT net_fSendRetryWait;", (void *)&net_fSendRetryWait); + _pShell->DeclareSymbol("persistent user INDEX net_bReportTraffic;", (void *)&net_bReportTraffic); + _pShell->DeclareSymbol("persistent user INDEX net_bReportICMPErrors;", (void *)&net_bReportICMPErrors); + _pShell->DeclareSymbol("persistent user INDEX net_bReportMiscErrors;", (void *)&net_bReportMiscErrors); + _pShell->DeclareSymbol("persistent user INDEX net_bLerping;", (void *)&net_bLerping); + _pShell->DeclareSymbol("persistent user INDEX ser_bClientsMayPause;", (void *)&ser_bClientsMayPause); + _pShell->DeclareSymbol("persistent user INDEX ser_bEnumeration;", (void *)&ser_bEnumeration); + _pShell->DeclareSymbol("persistent user INDEX ser_bPingGameAgent;", (void *)&ser_bPingGameAgent); + _pShell->DeclareSymbol("persistent user FLOAT ser_tmKeepAlive;", (void *)&ser_tmKeepAlive); + _pShell->DeclareSymbol("persistent user FLOAT ser_tmPingUpdate;", (void *)&ser_tmPingUpdate); + _pShell->DeclareSymbol("persistent user INDEX ser_bWaitFirstPlayer;", (void *)&ser_bWaitFirstPlayer); + _pShell->DeclareSymbol("persistent user INDEX ser_iMaxAllowedBPS;", (void *)&ser_iMaxAllowedBPS); + _pShell->DeclareSymbol("persistent user INDEX ser_iMaxAllowedBPS;", (void *)&ser_iMaxAllowedBPS); + _pShell->DeclareSymbol("persistent user CTString ser_strIPMask;", (void *)&ser_strIPMask); + _pShell->DeclareSymbol("persistent user CTString ser_strNameMask;", (void *)&ser_strNameMask); + _pShell->DeclareSymbol("persistent user INDEX ser_bInverseBanning;", (void *)&ser_bInverseBanning); + _pShell->DeclareSymbol("persistent user CTString ser_strMOTD;", (void *)&ser_strMOTD); - _pShell->DeclareSymbol("persistent user INDEX cli_bAutoAdjustSettings;", &cli_bAutoAdjustSettings); - _pShell->DeclareSymbol("persistent user FLOAT cli_tmAutoAdjustThreshold;", &cli_tmAutoAdjustThreshold); - _pShell->DeclareSymbol("persistent user INDEX cli_bPrediction;", &cli_bPrediction); - _pShell->DeclareSymbol("persistent user INDEX cli_iMaxPredictionSteps;", &cli_iMaxPredictionSteps); - _pShell->DeclareSymbol("persistent user INDEX cli_bPredictIfServer;", &cli_bPredictIfServer); - _pShell->DeclareSymbol("persistent user INDEX cli_bPredictLocalPlayers;", &cli_bPredictLocalPlayers); - _pShell->DeclareSymbol("persistent user INDEX cli_bPredictRemotePlayers;", &cli_bPredictRemotePlayers); - _pShell->DeclareSymbol("persistent user FLOAT cli_fPredictEntitiesRange;", &cli_fPredictEntitiesRange); - _pShell->DeclareSymbol("persistent user FLOAT cli_fPredictionFilter;", &cli_fPredictionFilter); - _pShell->DeclareSymbol("persistent user INDEX cli_iSendBehind;", &cli_iSendBehind); - _pShell->DeclareSymbol("persistent user INDEX cli_iPredictionFlushing;", &cli_iPredictionFlushing); + _pShell->DeclareSymbol("persistent user INDEX cli_bAutoAdjustSettings;", (void *)&cli_bAutoAdjustSettings); + _pShell->DeclareSymbol("persistent user FLOAT cli_tmAutoAdjustThreshold;", (void *)&cli_tmAutoAdjustThreshold); + _pShell->DeclareSymbol("persistent user INDEX cli_bPrediction;", (void *)&cli_bPrediction); + _pShell->DeclareSymbol("persistent user INDEX cli_iMaxPredictionSteps;", (void *)&cli_iMaxPredictionSteps); + _pShell->DeclareSymbol("persistent user INDEX cli_bPredictIfServer;", (void *)&cli_bPredictIfServer); + _pShell->DeclareSymbol("persistent user INDEX cli_bPredictLocalPlayers;", (void *)&cli_bPredictLocalPlayers); + _pShell->DeclareSymbol("persistent user INDEX cli_bPredictRemotePlayers;", (void *)&cli_bPredictRemotePlayers); + _pShell->DeclareSymbol("persistent user FLOAT cli_fPredictEntitiesRange;", (void *)&cli_fPredictEntitiesRange); + _pShell->DeclareSymbol("persistent user FLOAT cli_fPredictionFilter;", (void *)&cli_fPredictionFilter); + _pShell->DeclareSymbol("persistent user INDEX cli_iSendBehind;", (void *)&cli_iSendBehind); + _pShell->DeclareSymbol("persistent user INDEX cli_iPredictionFlushing;", (void *)&cli_iPredictionFlushing); - _pShell->DeclareSymbol("persistent user INDEX cli_iBufferActions;", &cli_iBufferActions); - _pShell->DeclareSymbol("persistent user INDEX cli_iMaxBPS;", &cli_iMaxBPS); - _pShell->DeclareSymbol("persistent user INDEX cli_iMinBPS;", &cli_iMinBPS); + _pShell->DeclareSymbol("persistent user INDEX cli_iBufferActions;", (void *)&cli_iBufferActions); + _pShell->DeclareSymbol("persistent user INDEX cli_iMaxBPS;", (void *)&cli_iMaxBPS); + _pShell->DeclareSymbol("persistent user INDEX cli_iMinBPS;", (void *)&cli_iMinBPS); - _pShell->DeclareSymbol("user FLOAT net_fLimitLatencySend;", &_pbsSend.pbs_fLatencyLimit); - _pShell->DeclareSymbol("user FLOAT net_fLimitLatencyRecv;", &_pbsRecv.pbs_fLatencyLimit); - _pShell->DeclareSymbol("user FLOAT net_fLatencyVariationSend;", &_pbsSend.pbs_fLatencyVariation); - _pShell->DeclareSymbol("user FLOAT net_fLatencyVariationRecv;", &_pbsRecv.pbs_fLatencyVariation); - _pShell->DeclareSymbol("user FLOAT net_fLimitBandwidthSend;", &_pbsSend.pbs_fBandwidthLimit); - _pShell->DeclareSymbol("user FLOAT net_fLimitBandwidthRecv;", &_pbsRecv.pbs_fBandwidthLimit); - _pShell->DeclareSymbol("user FLOAT net_fDropPackets;", &net_fDropPackets); + _pShell->DeclareSymbol("user FLOAT net_fLimitLatencySend;", (void *)&_pbsSend.pbs_fLatencyLimit); + _pShell->DeclareSymbol("user FLOAT net_fLimitLatencyRecv;", (void *)&_pbsRecv.pbs_fLatencyLimit); + _pShell->DeclareSymbol("user FLOAT net_fLatencyVariationSend;", (void *)&_pbsSend.pbs_fLatencyVariation); + _pShell->DeclareSymbol("user FLOAT net_fLatencyVariationRecv;", (void *)&_pbsRecv.pbs_fLatencyVariation); + _pShell->DeclareSymbol("user FLOAT net_fLimitBandwidthSend;", (void *)&_pbsSend.pbs_fBandwidthLimit); + _pShell->DeclareSymbol("user FLOAT net_fLimitBandwidthRecv;", (void *)&_pbsRecv.pbs_fBandwidthLimit); + _pShell->DeclareSymbol("user FLOAT net_fDropPackets;", (void *)&net_fDropPackets); - _pShell->DeclareSymbol("persistent user INDEX net_iGraphBuffer;", &net_iGraphBuffer); + _pShell->DeclareSymbol("persistent user INDEX net_iGraphBuffer;", (void *)&net_iGraphBuffer); - _pShell->DeclareSymbol("user const INDEX precache_NONE;", &_precache_NONE); - _pShell->DeclareSymbol("user const INDEX precache_SMART;", &_precache_SMART); - _pShell->DeclareSymbol("user const INDEX precache_ALL;", &_precache_ALL); - _pShell->DeclareSymbol("user const INDEX precache_PARANOIA;", &_precache_PARANOIA); - _pShell->DeclareSymbol("persistent user INDEX gam_iPrecachePolicy;", &gam_iPrecachePolicy); + _pShell->DeclareSymbol("user const INDEX precache_NONE;", (void *)&_precache_NONE); + _pShell->DeclareSymbol("user const INDEX precache_SMART;", (void *)&_precache_SMART); + _pShell->DeclareSymbol("user const INDEX precache_ALL;", (void *)&_precache_ALL); + _pShell->DeclareSymbol("user const INDEX precache_PARANOIA;", (void *)&_precache_PARANOIA); + _pShell->DeclareSymbol("persistent user INDEX gam_iPrecachePolicy;", (void *)&gam_iPrecachePolicy); - _pShell->DeclareSymbol("user FLOAT phy_fCollisionCacheAhead;", &phy_fCollisionCacheAhead); - _pShell->DeclareSymbol("user FLOAT phy_fCollisionCacheAround;", &phy_fCollisionCacheAround); + _pShell->DeclareSymbol("user FLOAT phy_fCollisionCacheAhead;", (void *)&phy_fCollisionCacheAhead); + _pShell->DeclareSymbol("user FLOAT phy_fCollisionCacheAround;", (void *)&phy_fCollisionCacheAround); - _pShell->DeclareSymbol("persistent user INDEX inp_iKeyboardReadingMethod;", &inp_iKeyboardReadingMethod); - _pShell->DeclareSymbol("persistent user INDEX inp_bAllowMouseAcceleration;", &inp_bAllowMouseAcceleration); - _pShell->DeclareSymbol("persistent user FLOAT inp_fMouseSensitivity;", &inp_fMouseSensitivity); - _pShell->DeclareSymbol("persistent user INDEX inp_bMousePrecision;", &inp_bMousePrecision); - _pShell->DeclareSymbol("persistent user FLOAT inp_fMousePrecisionFactor;", &inp_fMousePrecisionFactor); - _pShell->DeclareSymbol("persistent user FLOAT inp_fMousePrecisionThreshold;", &inp_fMousePrecisionThreshold); - _pShell->DeclareSymbol("persistent user FLOAT inp_fMousePrecisionTimeout;", &inp_fMousePrecisionTimeout); - _pShell->DeclareSymbol("persistent user INDEX inp_bInvertMouse;", &inp_bInvertMouse); - _pShell->DeclareSymbol("persistent user INDEX inp_bFilterMouse;", &inp_bFilterMouse); - _pShell->DeclareSymbol("persistent user INDEX inp_bAllowPrescan;", &inp_bAllowPrescan); + _pShell->DeclareSymbol("persistent user INDEX inp_iKeyboardReadingMethod;", (void *)&inp_iKeyboardReadingMethod); + _pShell->DeclareSymbol("persistent user INDEX inp_bAllowMouseAcceleration;", (void *)&inp_bAllowMouseAcceleration); + _pShell->DeclareSymbol("persistent user FLOAT inp_fMouseSensitivity;", (void *)&inp_fMouseSensitivity); + _pShell->DeclareSymbol("persistent user INDEX inp_bMousePrecision;", (void *)&inp_bMousePrecision); + _pShell->DeclareSymbol("persistent user FLOAT inp_fMousePrecisionFactor;", (void *)&inp_fMousePrecisionFactor); + _pShell->DeclareSymbol("persistent user FLOAT inp_fMousePrecisionThreshold;", (void *)&inp_fMousePrecisionThreshold); + _pShell->DeclareSymbol("persistent user FLOAT inp_fMousePrecisionTimeout;", (void *)&inp_fMousePrecisionTimeout); + _pShell->DeclareSymbol("persistent user INDEX inp_bInvertMouse;", (void *)&inp_bInvertMouse); + _pShell->DeclareSymbol("persistent user INDEX inp_bFilterMouse;", (void *)&inp_bFilterMouse); + _pShell->DeclareSymbol("persistent user INDEX inp_bAllowPrescan;", (void *)&inp_bAllowPrescan); - _pShell->DeclareSymbol("persistent user INDEX inp_i2ndMousePort;", &inp_i2ndMousePort); - _pShell->DeclareSymbol("persistent user INDEX inp_bInvert2ndMouse;", &inp_bInvert2ndMouse); - _pShell->DeclareSymbol("persistent user INDEX inp_bFilter2ndMouse;", &inp_bFilter2ndMouse); - _pShell->DeclareSymbol("persistent user FLOAT inp_f2ndMouseSensitivity;", &inp_f2ndMouseSensitivity); - _pShell->DeclareSymbol("persistent user INDEX inp_b2ndMousePrecision;", &inp_b2ndMousePrecision); - _pShell->DeclareSymbol("persistent user FLOAT inp_f2ndMousePrecisionFactor;", &inp_f2ndMousePrecisionFactor); - _pShell->DeclareSymbol("persistent user FLOAT inp_f2ndMousePrecisionThreshold;", &inp_f2ndMousePrecisionThreshold); - _pShell->DeclareSymbol("persistent user FLOAT inp_f2ndMousePrecisionTimeout;", &inp_f2ndMousePrecisionTimeout); + _pShell->DeclareSymbol("persistent user INDEX inp_i2ndMousePort;", (void *)&inp_i2ndMousePort); + _pShell->DeclareSymbol("persistent user INDEX inp_bInvert2ndMouse;", (void *)&inp_bInvert2ndMouse); + _pShell->DeclareSymbol("persistent user INDEX inp_bFilter2ndMouse;", (void *)&inp_bFilter2ndMouse); + _pShell->DeclareSymbol("persistent user FLOAT inp_f2ndMouseSensitivity;", (void *)&inp_f2ndMouseSensitivity); + _pShell->DeclareSymbol("persistent user INDEX inp_b2ndMousePrecision;", (void *)&inp_b2ndMousePrecision); + _pShell->DeclareSymbol("persistent user FLOAT inp_f2ndMousePrecisionFactor;", (void *)&inp_f2ndMousePrecisionFactor); + _pShell->DeclareSymbol("persistent user FLOAT inp_f2ndMousePrecisionThreshold;", (void *)&inp_f2ndMousePrecisionThreshold); + _pShell->DeclareSymbol("persistent user FLOAT inp_f2ndMousePrecisionTimeout;", (void *)&inp_f2ndMousePrecisionTimeout); - _pShell->DeclareSymbol("persistent user INDEX inp_bMsgDebugger;", &inp_bMsgDebugger); - _pShell->DeclareSymbol("persistent user INDEX inp_iMButton4Up;", &inp_iMButton4Up); - _pShell->DeclareSymbol("persistent user INDEX inp_iMButton4Dn;", &inp_iMButton4Dn); - _pShell->DeclareSymbol("persistent user INDEX inp_iMButton5Up;", &inp_iMButton5Up); - _pShell->DeclareSymbol("persistent user INDEX inp_iMButton5Dn;", &inp_iMButton5Dn); - _pShell->DeclareSymbol("persistent user INDEX inp_ctJoysticksAllowed;", &inp_ctJoysticksAllowed); - _pShell->DeclareSymbol("persistent user INDEX inp_bForceJoystickPolling;", &inp_bForceJoystickPolling); - _pShell->DeclareSymbol("persistent user INDEX inp_bAutoDisableJoysticks;", &inp_bAutoDisableJoysticks); + _pShell->DeclareSymbol("persistent user INDEX inp_bMsgDebugger;", (void *)&inp_bMsgDebugger); + _pShell->DeclareSymbol("persistent user INDEX inp_iMButton4Up;", (void *)&inp_iMButton4Up); + _pShell->DeclareSymbol("persistent user INDEX inp_iMButton4Dn;", (void *)&inp_iMButton4Dn); + _pShell->DeclareSymbol("persistent user INDEX inp_iMButton5Up;", (void *)&inp_iMButton5Up); + _pShell->DeclareSymbol("persistent user INDEX inp_iMButton5Dn;", (void *)&inp_iMButton5Dn); + _pShell->DeclareSymbol("persistent user INDEX inp_ctJoysticksAllowed;", (void *)&inp_ctJoysticksAllowed); + _pShell->DeclareSymbol("persistent user INDEX inp_bForceJoystickPolling;", (void *)&inp_bForceJoystickPolling); + _pShell->DeclareSymbol("persistent user INDEX inp_bAutoDisableJoysticks;", (void *)&inp_bAutoDisableJoysticks); - _pShell->DeclareSymbol("persistent user INDEX wed_bUseGenericTextureReplacement;", &wed_bUseGenericTextureReplacement); + _pShell->DeclareSymbol("persistent user INDEX wed_bUseGenericTextureReplacement;", (void *)&wed_bUseGenericTextureReplacement); - _pShell->DeclareSymbol("user CTString ga_strServer;", &ga_strServer); + _pShell->DeclareSymbol("user CTString ga_strServer;", (void *)&ga_strServer); - _pShell->DeclareSymbol("INDEX pwoCurrentWorld;", &_pwoCurrentWorld); + _pShell->DeclareSymbol("INDEX pwoCurrentWorld;", (void *)&_pwoCurrentWorld); } /* @@ -966,7 +971,7 @@ void CNetworkLibrary::StartPeerToPeer_t(const CTString &strSessionName, _pSound->Mute(); // go on - CPrintF( TRANS("Starting session: '%s'\n"), strSessionName); + CPrintF( TRANS("Starting session: '%s'\n"), (const char *) strSessionName); CPrintF( TRANS(" level: '%s'\n"), (const char*) fnmWorld); CPrintF( TRANS(" spawnflags: %08x\n"), ulSpawnFlags); CPrintF( TRANS(" max players: %d\n"), ctMaxPlayers); @@ -1218,7 +1223,7 @@ void CNetworkLibrary::JoinSession_t(const CNetworkSession &nsSesssion, INDEX ctL _pSound->Mute(); // report session addres - CPrintF( TRANS("Joining session at: '%s'\n"), nsSesssion.ns_strAddress); + CPrintF( TRANS("Joining session at: '%s'\n"), (const char *) nsSesssion.ns_strAddress); ga_bLocalPause = FALSE; @@ -1706,7 +1711,7 @@ void CNetworkLibrary::ChangeLevel_internal(void) {for( INDEX iClient=0; iClient0) { CNetworkMessage nm(MSG_EXTRA); - nm<SendBroadcast(nm, ulAdr, uwPort); } } @@ -2186,7 +2191,7 @@ CPlayerSource *CNetworkLibrary::AddPlayer_t(CPlayerCharacter &pcCharacter) // t { // synchronize access to network CTSingleLock slNetwork(&ga_csNetwork, TRUE); - CPrintF( TRANS("Adding player: '%s'\n"), pcCharacter.GetNameForPrinting()); + CPrintF( TRANS("Adding player: '%s'\n"), (const char *) pcCharacter.GetNameForPrinting()); // for all local clients on this machine FOREACHINSTATICARRAY(ga_aplsPlayers, CPlayerSource, itcls) { @@ -2262,7 +2267,7 @@ void CNetworkLibrary::CheckVersion_t(CTStream &strm, BOOL bAllowReinit, BOOL &bN if (iCurrent #include @@ -36,7 +36,7 @@ static struct ErrorCode ErrorCodes[] = { ERRORCODE(MSG_GAMESTREAMBLOCKS, "MSG_GAMESTREAMBLOCKS"), ERRORCODE(MSG_REQUESTGAMESTREAMRESEND, "MSG_REQUESTGAMESTREAMRESEND"), }; -extern struct ErrorTable MessageTypes = ERRORTABLE(ErrorCodes); +struct ErrorTable MessageTypes = ERRORTABLE(ErrorCodes); ///////////////////////////////////////////////////////////////////// // CNetworkMessage @@ -847,6 +847,7 @@ void CPlayerAction::Normalize(void) // create a checksum value for sync-check void CPlayerAction::ChecksumForSync(ULONG &ulCRC) { + // !!! FIXME: Bad, bad, bad. --ryan. CRC_AddBlock(ulCRC, (UBYTE*)this, sizeof(this)); } @@ -961,8 +962,8 @@ CNetworkMessage &operator>>(CNetworkMessage &nm, CPlayerAction &pa) } // find number of zero bits for flags - INDEX iZeros=0; - for(; iZeros<6; iZeros++) { + INDEX iZeros; + for(iZeros=0; iZeros<6; iZeros++) { UBYTE ub=0; nm.ReadBits(&ub, 1); if (ub!=0) { @@ -1005,12 +1006,22 @@ CNetworkMessage &operator>>(CNetworkMessage &nm, CPlayerAction &pa) /* Write an object into stream. */ CTStream &operator<<(CTStream &strm, const CPlayerAction &pa) { - strm.Write_t(&pa,sizeof(pa)); + strm<>(CTStream &strm, CPlayerAction &pa) { - strm.Read_t(&pa,sizeof(pa)); + strm>>pa.pa_vTranslation; + strm>>pa.pa_aRotation; + strm>>pa.pa_aViewRotation; + strm>>pa.pa_ulButtons; + strm>>pa.pa_llCreated; return strm; } + + diff --git a/Sources/Engine/Network/NetworkMessage.h b/Sources/Engine/Network/NetworkMessage.h index 71a166d..cc0ec91 100644 --- a/Sources/Engine/Network/NetworkMessage.h +++ b/Sources/Engine/Network/NetworkMessage.h @@ -209,6 +209,15 @@ public: void Write_t(CTStream &strm); // throw char * }; +/* + * !!! FIXME: R_OK is used with the unix access() API... + * !!! FIXME: we're lucky...on Linux, it's a macro, but it could be an + * !!! FIXME: enum just as easily. --ryan. + */ +#ifdef R_OK +#undef R_OK +#endif + /* * Stream of message blocks that can be sent across network. */ @@ -258,6 +267,10 @@ public: void RemoveOlderBlocksBySequence(INDEX iLastSequenceToKeep); }; + +#ifdef NETSTRUCTS_PACKED + #pragma pack(1) +#endif class ENGINE_API CPlayerAction { public: // order is important for compression and normalization - do not reorder! @@ -292,7 +305,10 @@ public: /* Read an object from stream. */ friend CTStream &operator>>(CTStream &strm, CPlayerAction &pa); }; - +#ifdef NETSTRUCTS_PACKED + #pragma pack() +#endif #endif /* include-once check. */ + diff --git a/Sources/Engine/Network/NetworkProfile.cpp b/Sources/Engine/Network/NetworkProfile.cpp index 39bae3d..4ddef27 100644 --- a/Sources/Engine/Network/NetworkProfile.cpp +++ b/Sources/Engine/Network/NetworkProfile.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Network/NetworkProfile.h b/Sources/Engine/Network/NetworkProfile.h index 8fab5ad..61aa25a 100644 --- a/Sources/Engine/Network/NetworkProfile.h +++ b/Sources/Engine/Network/NetworkProfile.h @@ -1,5 +1,11 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ +#ifndef SE_INCL_NETWORKPROFILE_H +#define SE_INCL_NETWORKPROFILE_H +#ifdef PRAGMA_ONCE + #pragma once +#endif + #ifndef __ENGINE_BASE_PROFILING_H__ #include #endif @@ -37,3 +43,7 @@ public: // constructor CNetworkProfile(void); }; + +#endif // include-once blocker. + + diff --git a/Sources/Engine/Network/PlayerBuffer.cpp b/Sources/Engine/Network/PlayerBuffer.cpp index 2ec0290..c03bad2 100644 --- a/Sources/Engine/Network/PlayerBuffer.cpp +++ b/Sources/Engine/Network/PlayerBuffer.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Network/PlayerSource.cpp b/Sources/Engine/Network/PlayerSource.cpp index 6f64295..0cdb058 100644 --- a/Sources/Engine/Network/PlayerSource.cpp +++ b/Sources/Engine/Network/PlayerSource.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -55,7 +55,7 @@ void CPlayerSource::Start_t(CPlayerCharacter &pcCharacter) // throw char * for(TIME tmWait=0; tmWaitSleep(NET_WAITMESSAGE_DELAY), tmWait+=NET_WAITMESSAGE_DELAY) { if (_pNetwork->ga_IsServer) { _pNetwork->TimerLoop(); } @@ -86,7 +86,7 @@ void CPlayerSource::Start_t(CPlayerCharacter &pcCharacter) // throw char * CTString strReason; nmReceived>>strReason; _pNetwork->ga_sesSessionState.ses_strDisconnected = strReason; - ThrowF_t(TRANS("Cannot add player because: %s\n"), strReason); + ThrowF_t(TRANS("Cannot add player because: %s\n"), (const char *) strReason); // otherwise } else { diff --git a/Sources/Engine/Network/PlayerTarget.cpp b/Sources/Engine/Network/PlayerTarget.cpp index f2514a1..440e31a 100644 --- a/Sources/Engine/Network/PlayerTarget.cpp +++ b/Sources/Engine/Network/PlayerTarget.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/Network/Server.cpp b/Sources/Engine/Network/Server.cpp index b75d700..8b76996 100644 --- a/Sources/Engine/Network/Server.cpp +++ b/Sources/Engine/Network/Server.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -219,7 +219,7 @@ void CServer::Stop(void) break; } else { _cmiComm.Server_Update(); - Sleep(100); + _pTimer->Sleep(100); } } @@ -294,7 +294,7 @@ void CServer::SendDisconnectMessage(INDEX iClient, const char *strExplanation, B } // report that it has gone away CPrintF(TRANS("Client '%s' ordered to disconnect: %s\n"), - _cmiComm.Server_GetClientName(iClient), strExplanation); + (const char *) _cmiComm.Server_GetClientName(iClient), strExplanation); // if not disconnected before if (sso.sso_iDisconnectedState==0) { // mark the disconnection @@ -303,7 +303,7 @@ void CServer::SendDisconnectMessage(INDEX iClient, const char *strExplanation, B } else { // force the disconnection CPrintF(TRANS("Forcing client '%s' to disconnect\n"), - _cmiComm.Server_GetClientName(iClient)); + (const char *) _cmiComm.Server_GetClientName(iClient)); sso.sso_iDisconnectedState = 2; } } @@ -379,7 +379,7 @@ void CServer::SendGameStreamBlocks(INDEX iClient) extern INDEX cli_bPredictIfServer; if (iClient==0 && !cli_bPredictIfServer) { ctMinBytes = 0; - ctMaxBytes = 1E6; + ctMaxBytes = (INDEX) 1E6; } // CPrintF("Send%d(%d, %d, %d): ", iClient, iLastSent, ctMinBytes, ctMaxBytes); @@ -515,7 +515,7 @@ void CServer::ResendGameStreamBlocks(INDEX iClient, INDEX iSequence0, INDEX ctSe extern INDEX net_bReportMiscErrors; if (net_bReportMiscErrors) { CPrintF(TRANS("Server: Resending sequences %d-%d(%d) to '%s'..."), - iSequence0, iSequence0+ctSequences-1, ctSequences, _cmiComm.Server_GetClientName(iClient)); + iSequence0, iSequence0+ctSequences-1, ctSequences, (const char *) _cmiComm.Server_GetClientName(iClient)); } // get corresponding session socket @@ -526,8 +526,8 @@ void CServer::ResendGameStreamBlocks(INDEX iClient, INDEX iSequence0, INDEX ctSe CNetworkMessage nmPackedBlocks(MSG_GAMESTREAMBLOCKS); // for each sequence - INDEX iSequence = iSequence0; - for(; iSequence>iTag; - if (iTag=='VTAG') { + #define VTAG 0x56544147 // Looks like 'VTAG' in ASCII. + if (iTag==VTAG) { nm>>iMajor>>iMinor; } else { iMajor = 109; @@ -883,7 +884,7 @@ void CServer::ConnectRemoteSessionState(INDEX iClient, CNetworkMessage &nm) if (_strModName!=strGivenMod) { // disconnect the client // NOTE: DO NOT TRANSLATE THIS STRING! - CTString strMod(0, "MOD:%s\\%s", _strModName, _strModURL); + CTString strMod(0, "MOD:%s\\%s", (const char *) _strModName, (const char *) _strModURL); SendDisconnectMessage(iClient, strMod, /*bStream=*/TRUE); return; } @@ -1083,7 +1084,7 @@ void CServer::HandleAll() INDEX iClient = -1; /* if (_cmiComm.GetLastAccepted(iClient)) { CPrintF(TRANS("Server: Accepted session connection by '%s'\n"), - _cmiComm.Server_GetClientName(iClient)); + (const char *) _cmiComm.Server_GetClientName(iClient)); } */ @@ -1126,7 +1127,7 @@ void CServer::HandleAllForAClient(INDEX iClient) // if the client is disconnected if (!_cmiComm.Server_IsClientUsed(iClient) || sso.sso_iDisconnectedState>1) { - CPrintF(TRANS("Server: Client '%s' disconnected.\n"), _cmiComm.Server_GetClientName(iClient)); + CPrintF(TRANS("Server: Client '%s' disconnected.\n"), (const char *) _cmiComm.Server_GetClientName(iClient)); // clear it _cmiComm.Server_ClearClient(iClient); // free all that data that was allocated for the client @@ -1150,7 +1151,7 @@ void CServer::HandleAllForAClient(INDEX iClient) // if the client has confirmed disconnect in this loop if (!_cmiComm.Server_IsClientUsed(iClient) || sso.sso_iDisconnectedState>1) { - CPrintF(TRANS("Server: Client '%s' disconnected.\n"), _cmiComm.Server_GetClientName(iClient)); + CPrintF(TRANS("Server: Client '%s' disconnected.\n"), (const char *) _cmiComm.Server_GetClientName(iClient)); // clear it _cmiComm.Server_ClearClient(iClient); // free all that data that was allocated for the client @@ -1269,7 +1270,7 @@ void CServer::Handle(INDEX iClient, CNetworkMessage &nmMessage) // send refusal message CTString strMessage; strMessage.PrintF(TRANS("Player character '%s' already exists in this session."), - pcCharacter.GetName()); + (const char *) pcCharacter.GetName()); SendDisconnectMessage(iClient, strMessage); // if the max. number of clients is not reached @@ -1397,7 +1398,7 @@ void CServer::Handle(INDEX iClient, CNetworkMessage &nmMessage) sso.sso_ctBadSyncs++; if( ser_bReportSyncBad) { CPrintF( TRANS("SYNCBAD: Client '%s', Sequence %d Tick %.2f - bad %d\n"), - _cmiComm.Server_GetClientName(iClient), scRemote.sc_iSequence , scRemote.sc_tmTick, sso.sso_ctBadSyncs); + (const char *) _cmiComm.Server_GetClientName(iClient), scRemote.sc_iSequence , scRemote.sc_tmTick, sso.sso_ctBadSyncs); } if (ser_iKickOnSyncBad>0) { if (sso.sso_ctBadSyncs>=ser_iKickOnSyncBad) { @@ -1410,7 +1411,7 @@ void CServer::Handle(INDEX iClient, CNetworkMessage &nmMessage) sso.sso_ctBadSyncs = 0; if (ser_bReportSyncOK) { CPrintF( TRANS("SYNCOK: Client '%s', Tick %.2f\n"), - _cmiComm.Server_GetClientName(iClient), scRemote.sc_tmTick); + (const char *) _cmiComm.Server_GetClientName(iClient), scRemote.sc_tmTick); } } @@ -1424,13 +1425,13 @@ void CServer::Handle(INDEX iClient, CNetworkMessage &nmMessage) // report only if syncs are ok now (so that we don't report a bunch of late syncs on level change if( ser_bReportSyncLate && srv_assoSessions[iClient].sso_tmLastSyncReceived>0) { CPrintF( TRANS("SYNCLATE: Client '%s', Tick %.2f\n"), - _cmiComm.Server_GetClientName(iClient), scRemote.sc_tmTick); + (const char *) _cmiComm.Server_GetClientName(iClient), scRemote.sc_tmTick); } // if too new } else { if( ser_bReportSyncEarly) { CPrintF( TRANS("SYNCEARLY: Client '%s', Tick %.2f\n"), - _cmiComm.Server_GetClientName(iClient), scRemote.sc_tmTick); + (const char *) _cmiComm.Server_GetClientName(iClient), scRemote.sc_tmTick); } // remember that this client has sent sync for that tick // (even though we cannot really check that it is valid) @@ -1488,7 +1489,7 @@ void CServer::Handle(INDEX iClient, CNetworkMessage &nmMessage) // if the source has no players if (ulFrom==0) { // make it public message - ulTo = -1; + ulTo = (ULONG) -1; } // make the outgoing message @@ -1576,7 +1577,7 @@ void CServer::Handle(INDEX iClient, CNetworkMessage &nmMessage) } else { CPrintF(TRANS("Server: Client '%s', Admin cmd: %s\n"), - (const char*)_cmiComm.Server_GetClientName(iClient), strCommand); + (const char*)_cmiComm.Server_GetClientName(iClient), (const char *) strCommand); con_bCapture = TRUE; con_strCapture = ""; diff --git a/Sources/Engine/Network/SessionState.cpp b/Sources/Engine/Network/SessionState.cpp index 4be6556..8f843be 100644 --- a/Sources/Engine/Network/SessionState.cpp +++ b/Sources/Engine/Network/SessionState.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -259,7 +259,7 @@ void CSessionState::Start_AtServer_t(void) // throw char * _pNetwork->SendToServerReliable(nmRegisterMainSessionState); for(TIME tmWait=0; tmWaitSleep(NET_WAITMESSAGE_DELAY), tmWait+=NET_WAITMESSAGE_DELAY) { _pNetwork->TimerLoop(); if (_cmiComm.Client_Update() == FALSE) { break; @@ -302,7 +302,8 @@ void CSessionState::Start_AtClient_t(INDEX ctLocalPlayers) // throw char * // send registration request CNetworkMessage nmRegisterSessionState(MSG_REQ_CONNECTREMOTESESSIONSTATE); - nmRegisterSessionState<Sleep(NET_WAITMESSAGE_DELAY), tmWait+=NET_WAITMESSAGE_DELAY) { // update network connection sockets if (_cmiComm.Client_Update() == FALSE) { break; @@ -478,13 +479,13 @@ void CSessionState::WaitStream_t(CTMemoryStream &strmMessage, const CTString &st ses_strDisconnected = strReason; // no more client/server updates in the progres hook _bRunNetUpdates = FALSE; - ThrowF_t(TRANS("Disconnected: %s\n"), strReason); + ThrowF_t(TRANS("Disconnected: %s\n"), (const char *) strReason); // otherwise } else { // no more client/server updates in the progres hook _bRunNetUpdates = FALSE; // it is invalid message - ThrowF_t(TRANS("Invalid stream while waiting for %s"), strName); + ThrowF_t(TRANS("Invalid stream while waiting for %s"), (const char *) strName); } // if client is disconnected @@ -503,7 +504,7 @@ void CSessionState::WaitStream_t(CTMemoryStream &strmMessage, const CTString &st // _pNetwork->SendToServerReliable(nmConfirmDisconnect); - ThrowF_t(TRANS("Timeout while waiting for %s"), strName); + ThrowF_t(TRANS("Timeout while waiting for %s"), (const char *) strName); } // check if disconnected @@ -1341,7 +1342,7 @@ void CSessionState::ProcessGameStreamBlock(CNetworkMessage &nmMessage) FatalError(TRANS("Cannot load Player class:\n%s"), strError); } if (!_pNetwork->IsPlayerLocal(penNewPlayer)) { - CPrintF(TRANS("%s joined\n"), penNewPlayer->GetPlayerName()); + CPrintF(TRANS("%s joined\n"), (const char *) penNewPlayer->GetPlayerName()); } } else { // attach entity to client data @@ -1350,7 +1351,7 @@ void CSessionState::ProcessGameStreamBlock(CNetworkMessage &nmMessage) penNewPlayer->CharacterChanged(pcCharacter); if (!_pNetwork->IsPlayerLocal(penNewPlayer)) { - CPrintF(TRANS("%s rejoined\n"), penNewPlayer->GetPlayerName()); + CPrintF(TRANS("%s rejoined\n"), (const char *) penNewPlayer->GetPlayerName()); } } @@ -1365,7 +1366,7 @@ void CSessionState::ProcessGameStreamBlock(CNetworkMessage &nmMessage) _pNetwork->ga_World.DeletePredictors(); // inform entity of disconnnection - CPrintF(TRANS("%s left\n"), ses_apltPlayers[iPlayer].plt_penPlayerEntity->GetPlayerName()); + CPrintF(TRANS("%s left\n"), (const char *) ses_apltPlayers[iPlayer].plt_penPlayerEntity->GetPlayerName()); ses_apltPlayers[iPlayer].plt_penPlayerEntity->Disconnect(); // deactivate the player ses_apltPlayers[iPlayer].Deactivate(); @@ -1441,9 +1442,9 @@ void CSessionState::ProcessGameStreamBlock(CNetworkMessage &nmMessage) // report who paused if (ses_bPause!=bPauseBefore) { if (ses_bPause) { - CPrintF(TRANS("Paused by '%s'\n"), strPauser); + CPrintF(TRANS("Paused by '%s'\n"), (const char *) strPauser); } else { - CPrintF(TRANS("Unpaused by '%s'\n"), strPauser); + CPrintF(TRANS("Unpaused by '%s'\n"), (const char *) strPauser); } } } @@ -1631,8 +1632,8 @@ void CSessionState::ReadWorldAndState_t(CTStream *pstr) // throw char * ThrowF_t( TRANS("Cannot play demo because file '%s'\n" "is older than file '%s'!\n"), - CTString(pstr->GetDescription()), - CTString(_pNetwork->ga_fnmWorld)); + (const char *) CTString(pstr->GetDescription()), + (const char *) CTString(_pNetwork->ga_fnmWorld)); } // prepare the world for loading @@ -1857,7 +1858,7 @@ void CSessionState::RestoreOldLevel(const CTString &strFileName) ReadWorldAndState_t(&prlOld->rl_strmSessionState); _pTimer->SetCurrentTick(ses_tmLastProcessedTick); } catch (char *strError) { - FatalError(TRANS("Cannot restore old level '%s':\n%s"), prlOld->rl_strFileName, strError); + FatalError(TRANS("Cannot restore old level '%s':\n%s"), (const char *) prlOld->rl_strFileName, strError); } // delete it delete prlOld; @@ -2030,7 +2031,7 @@ void CSessionState::SessionStateLoop(void) CTString strReason; nmReliable>>strReason; ses_strDisconnected = strReason; - CPrintF(TRANS("Disconnected: %s\n"), strReason); + CPrintF(TRANS("Disconnected: %s\n"), (const char *) strReason); // disconnect _cmiComm.Client_Close(); // if this is recon response @@ -2038,7 +2039,7 @@ void CSessionState::SessionStateLoop(void) // just print it CTString strResponse; nmReliable>>strResponse; - CPrintF("%s", "|"+strResponse+"\n"); + CPrintF("%s", (const char *) ("|"+strResponse+"\n")); // otherwise } else { CPrintF(TRANS("Session state: Unexpected reliable message during game: %s(%d)\n"), @@ -2092,11 +2093,11 @@ void CSessionState::SessionStateLoop(void) DumpSyncToFile_t(strmFile, ses_iExtensiveSyncCheck); } // inform user - CPrintF("Sync data dumped to '%s'\n", strFileName); + CPrintF("Sync data dumped to '%s'\n", (const char *) strFileName); } catch (char *strError) { - CPrintF("Cannot dump sync data: %s\n", strError); + CPrintF("Cannot dump sync data: %s\n", (const char *) strError); } } diff --git a/Sources/Engine/Network/SessionState.h b/Sources/Engine/Network/SessionState.h index 076133d..e7134be 100644 --- a/Sources/Engine/Network/SessionState.h +++ b/Sources/Engine/Network/SessionState.h @@ -26,6 +26,10 @@ void ClearDumpStream(void); #endif +#ifdef NETSTRUCTS_PACKED + #pragma pack(1) +#endif + // checksum of world snapshot at given point in time - used for sync-checking class CSyncCheck { public: @@ -49,6 +53,10 @@ public: void Clear(void) {}; }; +#ifdef NETSTRUCTS_PACKED + #pragma pack() +#endif + /* * Session state, manipulates local copy of the world */ diff --git a/Sources/Engine/Rendering/RenCache.cpp b/Sources/Engine/Rendering/RenCache.cpp index e419d82..73b84c4 100644 --- a/Sources/Engine/Rendering/RenCache.cpp +++ b/Sources/Engine/Rendering/RenCache.cpp @@ -310,7 +310,7 @@ void CRenderer::AddEdgeToAddAndRemoveLists(CScreenEdge &sed) SLONG slIInList; while(plnInList->ln_Succ!=NULL) { slIInList = - ((CAddEdge*)((UBYTE*)plnInList-offsetof(CAddEdge, ade_lnInAdd))) -> ade_xI.slHolder; + ((CAddEdge*)((UBYTE*)plnInList-_offsetof(CAddEdge, ade_lnInAdd))) -> ade_xI.slHolder; // if the edge in list is right of the one to add if (slIInList>slIThis) { // stop searching @@ -796,8 +796,8 @@ void CRenderer::AddPolygonToScene( CScreenPolygon *pspo) // all done sppo.spo_ctVtx = ctVtx; - sppo.spo_piElements = &bpo.bpo_aiTriangleElements[0]; sppo.spo_ctElements = bpo.bpo_aiTriangleElements.Count(); + sppo.spo_piElements = sppo.spo_ctElements ? &bpo.bpo_aiTriangleElements[0] : NULL; _sfStats.IncrementCounter(CStatForm::SCI_SCENE_TRIANGLES, sppo.spo_ctElements/3); } diff --git a/Sources/Engine/Rendering/RendASER.cpp b/Sources/Engine/Rendering/RendASER.cpp index 7e9aff5..e56cf65 100644 --- a/Sources/Engine/Rendering/RendASER.cpp +++ b/Sources/Engine/Rendering/RendASER.cpp @@ -321,7 +321,10 @@ void CRenderer::AddActiveSector(CBrushSector &bscSector) // add it to active sectors list re_lhActiveSectors.AddTail(bscSector.bsc_lnInActiveSectors); +// !!! FIXME : rcg10132001 I'm lazy. +#ifdef PLATFORM_WIN32 ASSERT((_controlfp(0, 0)&_MCW_RC)==_RC_NEAR); +#endif CBrush3D &br = *bscSector.bsc_pbmBrushMip->bm_pbrBrush; // if should render field brush sector diff --git a/Sources/Engine/Rendering/RendMisc.cpp b/Sources/Engine/Rendering/RendMisc.cpp index 425ef9d..fe01f57 100644 --- a/Sources/Engine/Rendering/RendMisc.cpp +++ b/Sources/Engine/Rendering/RendMisc.cpp @@ -89,8 +89,13 @@ CScreenPolygon::~CScreenPolygon(void) { static FLOAT fDiff; static SLONG slTmp; + static inline PIX PIXCoord(FLOAT f) // (f+0.9999f) or (ceil(f)) { + #if (defined USE_PORTABLE_C) + return((PIX) (f+0.9999f)); + + #elif (defined __MSVC_INLINE__) PIX pixRet; __asm { fld dword ptr [f] @@ -104,6 +109,27 @@ static inline PIX PIXCoord(FLOAT f) // (f+0.9999f) or (ceil(f)) mov dword ptr [pixRet],eax } return pixRet; + + #elif (defined __GNU_INLINE__) + PIX pixRet; + __asm__ __volatile__ ( + "flds (%%eax) \n\t" + "fistl (%%edx) \n\t" + "fisubrl (%%edx) \n\t" + "fstps (%%ecx) \n\t" + "movl (%%edx), %%eax \n\t" + "movl (%%ecx), %%edx \n\t" + "addl $0x7FFFFFFF, %%edx \n\t" + "adcl $0, %%eax \n\t" + : "=a" (pixRet) + : "a" (&f), "d" (&slTmp), "c" (&fDiff) + : "cc", "memory" + ); + return pixRet; + + #else + #error Please write inline ASM for your platform. + #endif } @@ -454,6 +480,7 @@ void CRenderer::RenderEntityNames(void) PIX pixH=re_pdpDrawPort->GetHeight(); re_pdpDrawPort->SetFont( _pfdConsoleFont); UBYTE ubAlpha=UBYTE(fPower*255.0f); - re_pdpDrawPort->PutTextC( strName, vProjected(1), pixH-vProjected(2), C_RED|ubAlpha); + re_pdpDrawPort->PutTextC( strName, (PIX) (vProjected(1)), (PIX) (pixH-vProjected(2)), C_RED|ubAlpha); } } + diff --git a/Sources/Engine/Rendering/Render.cpp b/Sources/Engine/Rendering/Render.cpp index f952cae..235ec83 100644 --- a/Sources/Engine/Rendering/Render.cpp +++ b/Sources/Engine/Rendering/Render.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include @@ -77,12 +77,12 @@ extern INDEX gfx_iLensFlareQuality; extern BOOL _bMultiPlayer; // variables for selection on rendering -extern CBrushVertexSelection *_pselbvxtSelectOnRender = NULL; -extern CStaticStackArray *_pavpixSelectLasso = NULL; -extern CEntitySelection *_pselenSelectOnRender = NULL; -extern PIX2D _vpixSelectNearPoint = PIX2D(0,0); -extern BOOL _bSelectAlternative = FALSE; -extern PIX _pixDeltaAroundVertex = 10; +CBrushVertexSelection *_pselbvxtSelectOnRender = NULL; +CStaticStackArray *_pavpixSelectLasso = NULL; +CEntitySelection *_pselenSelectOnRender = NULL; +PIX2D _vpixSelectNearPoint = PIX2D(0,0); +BOOL _bSelectAlternative = FALSE; +PIX _pixDeltaAroundVertex = 10; // shading info for viewer of last rendered view FLOAT3D _vViewerLightDirection; @@ -559,7 +559,7 @@ void CRenderer::DrawToScreen(void) if( re_bBackgroundEnabled) { ChangeStatsMode(CStatForm::STI_PARTICLERENDERING); - RenderParticles(TRUE); // render background particless + RenderParticles(TRUE); // render background particles ChangeStatsMode(CStatForm::STI_WORLDRENDERING); } @@ -994,7 +994,7 @@ ULONG RenderShadows(CWorld &woWorld, CEntity &enViewer, // initialize clipping rectangle around the drawport const FLOATaabbox2D &box = prProjection->ScreenBBoxR(); //re.InitClippingRectangle(box.Min()(1), box.Min()(2), box.Size()(1), box.Size()(2)); - re.InitClippingRectangle(0, 0, box.Size()(1), box.Size()(2)); + re.InitClippingRectangle(0, 0, (PIX) box.Size()(1), (PIX) box.Size()(2)); re.re_bRenderingShadows = TRUE; re.re_bDirectionalShadows = prProjection.IsParallel(); diff --git a/Sources/Engine/Rendering/Render.h b/Sources/Engine/Rendering/Render.h index bc26422..6ecae20 100644 --- a/Sources/Engine/Rendering/Render.h +++ b/Sources/Engine/Rendering/Render.h @@ -2,6 +2,7 @@ #include #include + /* * Preferences for rendering world (another class is used for rendering models). */ diff --git a/Sources/Engine/Rendering/RenderAdding.cpp b/Sources/Engine/Rendering/RenderAdding.cpp index 8f4a099..b63a26e 100644 --- a/Sources/Engine/Rendering/RenderAdding.cpp +++ b/Sources/Engine/Rendering/RenderAdding.cpp @@ -112,7 +112,7 @@ void CRenderer::AddModelEntity(CEntity *penModel) CreateModelOBBox( penModel, vHandle, pprProjection->pr_ViewerRotationMatrix, boxEntity); bModelHasBox = TRUE; } // test it to mirror/warp plane - iMirrorPlaneTest = boxEntity.TestAgainstPlane(pprProjection->pr_plMirrorView); + iMirrorPlaneTest = (INDEX) (boxEntity.TestAgainstPlane(pprProjection->pr_plMirrorView)); } // if not in mirror if( iMirrorPlaneTest<0) { @@ -249,7 +249,7 @@ void CRenderer::AddSkaModelEntity(CEntity *penModel) CreateModelOBBox( penModel, vHandle, pprProjection->pr_ViewerRotationMatrix, boxEntity); bModelHasBox = TRUE; } // test it to mirror/warp plane - iMirrorPlaneTest = boxEntity.TestAgainstPlane(pprProjection->pr_plMirrorView); + iMirrorPlaneTest = (INDEX) boxEntity.TestAgainstPlane(pprProjection->pr_plMirrorView); } // if not in mirror if( iMirrorPlaneTest<0) { diff --git a/Sources/Engine/Rendering/RenderModels.cpp b/Sources/Engine/Rendering/RenderModels.cpp index ca638c4..1b72c52 100644 --- a/Sources/Engine/Rendering/RenderModels.cpp +++ b/Sources/Engine/Rendering/RenderModels.cpp @@ -365,7 +365,7 @@ void CRenderer::RenderOneModel( CEntity &en, CModelObject &moModel, const CPlace if( IsOfClass( &en, "Player Weapons")) rm.rm_ulFlags |= RMF_WEAPON; // set tesselation level of models - rm.rm_iTesselationLevel = en.GetMaxTessellationLevel(); + rm.rm_iTesselationLevel = (INDEX) (en.GetMaxTessellationLevel()); // prepare CRenderModel structure for rendering of one model moModel.SetupModelRendering(rm); @@ -750,10 +750,10 @@ void DeleteLensFlare(CLightSource *pls) /* Render lens flares. */ void CRenderer::RenderLensFlares(void) { - // make sure we're have orthographic projection + // make sure we have orthographic projection re_pdpDrawPort->SetOrtho(); - // if there are no flares of flares are off, do nothing + // if there are no flares or flares are off, do nothing gfx_iLensFlareQuality = Clamp( gfx_iLensFlareQuality, 0L, 3L); if( gfx_iLensFlareQuality==0 || re_alfiLensFlares.Count()==0) return; @@ -768,7 +768,7 @@ void CRenderer::RenderLensFlares(void) if( lfi.lfi_ulDrawPortID!=ulDrawPortID && lfi.lfi_iMirrorLevel==0) continue; // test if it is still visible lfi.lfi_ulFlags &= ~LFF_VISIBLE; - if( re_pdpDrawPort->IsPointVisible( lfi.lfi_fI, lfi.lfi_fJ, lfi.lfi_fOoK, lfi.lfi_iID, lfi.lfi_iMirrorLevel)) { + if( re_pdpDrawPort->IsPointVisible( (PIX) lfi.lfi_fI, (PIX) lfi.lfi_fJ, lfi.lfi_fOoK, lfi.lfi_iID, lfi.lfi_iMirrorLevel)) { lfi.lfi_ulFlags |= LFF_VISIBLE; } }} @@ -855,8 +855,8 @@ void CRenderer::RenderLensFlares(void) if( lfi.lfi_ulFlags&LFF_FOG) { // get fog strength at light position GFXTexCoord tex; - tex.s = -lfi.lfi_vProjected(3)*_fog_fMulZ; - tex.t = (lfi.lfi_vProjected%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; + tex.st.s= -lfi.lfi_vProjected(3)*_fog_fMulZ; + tex.st.t = (lfi.lfi_vProjected%_fog_vHDirView+_fog_fAddH)*_fog_fMulH; FLOAT fFogStrength = NormByteToFloat(GetFogAlpha(tex)); // fade flare with fog fFogHazeFade *= 1-fFogStrength; @@ -903,9 +903,9 @@ void CRenderer::RenderLensFlares(void) FLOAT fThisR = (ubR + (FLOAT(ubI)-ubR)*olf.olf_fLightDesaturation)*fIntensityFactor; FLOAT fThisG = (ubG + (FLOAT(ubI)-ubG)*olf.olf_fLightDesaturation)*fIntensityFactor; FLOAT fThisB = (ubB + (FLOAT(ubI)-ubB)*olf.olf_fLightDesaturation)*fIntensityFactor; - UBYTE ubThisR = Min( fThisR, 255.0f); - UBYTE ubThisG = Min( fThisG, 255.0f); - UBYTE ubThisB = Min( fThisB, 255.0f); + UBYTE ubThisR = (UBYTE) (Min( fThisR, 255.0f)); + UBYTE ubThisG = (UBYTE) (Min( fThisG, 255.0f)); + UBYTE ubThisB = (UBYTE) (Min( fThisB, 255.0f)); COLOR colBlending = RGBToColor( ubThisR,ubThisG,ubThisB); // render the flare @@ -930,7 +930,7 @@ void CRenderer::RenderLensFlares(void) lfi.lfi_fDistance); FLOAT fCenterFactor = (1-fOfCenterFadeFactor); FLOAT fGlare = lft.lft_fGlareIntensity*fIntensity - * (exp(1.0f/(1.0f+fGlearCompression*fCenterFactor*fCenterFactor)) -1.0f) / (exp(1.0f)-1.0f); + * (exp(1/(1+fGlearCompression*fCenterFactor*fCenterFactor)) -1) / (exp(1)-1); ULONG ulGlareA = ClampUp( NormFloatToByte(fGlare), 255UL); // if there is any relevant glare if( ulGlareA>1) { diff --git a/Sources/Engine/Rendering/RenderProfile.cpp b/Sources/Engine/Rendering/RenderProfile.cpp index d2d9913..a2708d3 100644 --- a/Sources/Engine/Rendering/RenderProfile.cpp +++ b/Sources/Engine/Rendering/RenderProfile.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Rendering/Render_internal.h b/Sources/Engine/Rendering/Render_internal.h index 94d0c0b..73b5198 100644 --- a/Sources/Engine/Rendering/Render_internal.h +++ b/Sources/Engine/Rendering/Render_internal.h @@ -479,7 +479,7 @@ public: void RenderOneModel( CEntity &en, CModelObject &moModel, const CPlacement3D &plModel, const FLOAT fDistanceFactor, BOOL bRenderShadow, ULONG ulDMFlags); /* Render a ska model. */ - void CRenderer::RenderOneSkaModel( CEntity &en, const CPlacement3D &plModel, + void RenderOneSkaModel( CEntity &en, const CPlacement3D &plModel, const FLOAT fDistanceFactor, BOOL bRenderShadow, ULONG ulDMFlags); /* Render models that were kept for delayed rendering. */ void RenderModels(BOOL bBackground); diff --git a/Sources/Engine/Rendering/SelectOnRender.cpp b/Sources/Engine/Rendering/SelectOnRender.cpp index 1733784..40e2145 100644 --- a/Sources/Engine/Rendering/SelectOnRender.cpp +++ b/Sources/Engine/Rendering/SelectOnRender.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -182,9 +182,9 @@ BOOL IsVertexInLasso( CProjection3D &prProjection, const FLOAT3D &vtx, FLOATmatr prProjection.ProjectCoordinate( vAbsolute, vtxProjected); PIX2D vpix; - vpix(1) = vtxProjected(1); + vpix(1) = (PIX) vtxProjected(1); // convert coordinate into screen representation - vpix(2) = _pixSizeJ-vtxProjected(2); + vpix(2) = (PIX) (_pixSizeJ-vtxProjected(2)); // if the vertex is out of screen if (vpix(1)<0 || vpix(1)>=_pixSizeI diff --git a/Sources/Engine/Ska/AnimSet.cpp b/Sources/Engine/Ska/AnimSet.cpp index af15cfc..b7c3f9a 100644 --- a/Sources/Engine/Ska/AnimSet.cpp +++ b/Sources/Engine/Ska/AnimSet.cpp @@ -1,12 +1,12 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Engine/StdH.h" #include #include #include #include #include -#include +#include #include #include #include @@ -71,7 +71,7 @@ BOOL RemoveRotFrame(AnimRot &ar1,AnimRot &ar2,AnimRot &ar3,FLOAT fTreshold) // calculate slerp factor for ar2' FLOAT fSlerpFactor = (FLOAT)(ar2.ar_iFrameNum - ar1.ar_iFrameNum)/(FLOAT)(ar3.ar_iFrameNum - ar1.ar_iFrameNum); // calculate ar2' - FLOATquat3D q2i = Slerp(fSlerpFactor,ar1.ar_qRot,ar3.ar_qRot); + FLOATquat3D q2i = Slerp(fSlerpFactor,ar1.ar_qRot,ar3.ar_qRot); // read precalculated values ang1 = aangAngles[ar1.ar_iFrameNum]; ang2 = aangAngles[ar2.ar_iFrameNum]; @@ -163,9 +163,9 @@ void CAnimSet::OptimizeAnimation(Animation &an, FLOAT fTreshold) be.be_arRot[im].ar_qRot.ToMatrix(mat); DecomposeRotationMatrixNoSnap(aangAngles[im],mat); } - // try to remove rotations, steping by 2 - INDEX iloop=0; - for(;iloop>an.an_fTreshold; // read if compresion is used (*istrFile)>>an.an_bCompresed; - // read bool if animstion uses custom speed + // read bool if animation uses custom speed (*istrFile)>>an.an_bCustomSpeed; INDEX ctbe; @@ -484,7 +484,8 @@ void CAnimSet::Read_t(CTStream *istrFile) // read bone envelope ID be.be_iBoneID = ska_GetIDFromStringTable(pstrNameID); // read default pos(matrix12) - istrFile->Read_t(&be.be_mDefaultPos[0],sizeof(FLOAT)*12); + for (int i = 0; i < 12; i++) + (*istrFile) >> be.be_mDefaultPos[i]; INDEX ctp; // read pos array @@ -492,7 +493,7 @@ void CAnimSet::Read_t(CTStream *istrFile) be.be_apPos.New(ctp); for(INDEX ip=0;ipRead_t(&be.be_apPos[ip],sizeof(AnimPos)); + (*istrFile)>>be.be_apPos[ip]; } INDEX ctr; // read rot array count @@ -516,7 +517,7 @@ void CAnimSet::Read_t(CTStream *istrFile) for(INDEX ir=0;irRead_t(&arRot,sizeof(AnimRot)); + (*istrFile) >> arRot; if(!an.an_bCompresed) { be.be_arRot[ir] = arRot; @@ -567,7 +568,8 @@ void CAnimSet::Read_t(CTStream *istrFile) // create morph factors array me.me_aFactors.New(ctmf); // read morph factors - istrFile->Read_t(&me.me_aFactors[0],sizeof(FLOAT)*ctmf); + for (INDEX i = 0; i < ctmf; i++) + (*istrFile) >> me.me_aFactors[i]; } } } diff --git a/Sources/Engine/Ska/AnimSet.h b/Sources/Engine/Ska/AnimSet.h index 09f1059..287a08d 100644 --- a/Sources/Engine/Ska/AnimSet.h +++ b/Sources/Engine/Ska/AnimSet.h @@ -28,6 +28,20 @@ struct AnimPos FLOAT3D ap_vPos; //bone pos }; +static inline CTStream &operator>>(CTStream &strm, AnimPos &ap) +{ + strm>>ap.ap_iFrameNum; + strm>>ap.ap_vPos; + return(strm); +} + +static inline CTStream &operator<<(CTStream &strm, const AnimPos &ap) +{ + strm<>(CTStream &strm, AnimRot &ar) +{ + strm>>ar.ar_iFrameNum; + strm>>ar.ar_qRot; + return(strm); +} + +static inline CTStream &operator<<(CTStream &strm, const AnimRot &ar) +{ + strm< #include "Mesh.h" #define MESH_VERSION 12 @@ -32,7 +32,7 @@ struct SortArray CStaticArray sa_aMorphMapList; }; -CStaticArray _aSortArray; +static CStaticArray _aSortArray; CStaticArray _aiOptimizedIndex; CStaticArray _aiSortedIndex; @@ -99,7 +99,7 @@ void ChangeSurfaceShader_t(MeshSurface &msrf,CTString fnNewShader) msrf.msrf_ShadingParams.sp_afFloats.Expand(ctNewFloats); // set new floats to 0 for(INDEX ifl=ctOldFloats;iflRead_t(&mLod.mlod_aVertices[0],sizeof(MeshVertex)*ctVx); + // read vertices + for (INDEX i = 0; i < ctVx; i++) + (*istrFile)>>mLod.mlod_aVertices[i]; // read normals - istrFile->Read_t(&mLod.mlod_aNormals[0],sizeof(MeshNormal)*ctVx); + for (INDEX i = 0; i < ctVx; i++) + (*istrFile)>>mLod.mlod_aNormals[i]; // read uvmaps count (*istrFile)>>ctUV; @@ -732,7 +734,8 @@ void CMesh::Read_t(CTStream *istrFile) // create array for uvmaps texcordinates mLod.mlod_aUVMaps[iuv].muv_aTexCoords.New(ctVx); // read uvmap texcordinates - istrFile->Read_t(&mLod.mlod_aUVMaps[iuv].muv_aTexCoords[0],sizeof(MeshTexCoord)*ctVx); + for (INDEX i = 0; i < ctVx; i++) + (*istrFile)>>mLod.mlod_aUVMaps[iuv].muv_aTexCoords[i]; } // read surfaces count (*istrFile)>>ctSf; @@ -755,7 +758,8 @@ void CMesh::Read_t(CTStream *istrFile) // create triangles array mLod.mlod_aSurfaces[isf].msrf_aTriangles.New(ctTris); // read triangles - istrFile->Read_t(&mLod.mlod_aSurfaces[isf].msrf_aTriangles[0],sizeof(MeshTriangle)*ctTris); + for (INDEX i = 0; i < ctTris; i++) + (*istrFile)>>mLod.mlod_aSurfaces[isf].msrf_aTriangles[i]; // read bool that this surface has a shader INDEX bShaderExists; @@ -864,7 +868,8 @@ void CMesh::Read_t(CTStream *istrFile) // create wertex weight array mLod.mlod_aWeightMaps[iwm].mwm_aVertexWeight.New(ctWw); // read wertex weights - istrFile->Read_t(&mLod.mlod_aWeightMaps[iwm].mwm_aVertexWeight[0],sizeof(MeshVertexWeight)*ctWw); + for (INDEX i = 0; i < ctWw; i++) + (*istrFile)>>mLod.mlod_aWeightMaps[iwm].mwm_aVertexWeight[i]; } // read morphmap count @@ -885,7 +890,8 @@ void CMesh::Read_t(CTStream *istrFile) // create morps sets array mLod.mlod_aMorphMaps[imm].mmp_aMorphMap.New(ctms); // read morph sets - istrFile->Read_t(&mLod.mlod_aMorphMaps[imm].mmp_aMorphMap[0],sizeof(MeshVertexMorph)*ctms); + for (INDEX i = 0; i < ctms; i++) + (*istrFile)>>mLod.mlod_aMorphMaps[imm].mmp_aMorphMap[i]; } } } diff --git a/Sources/Engine/Ska/Mesh.h b/Sources/Engine/Ska/Mesh.h index 37a0590..4c3bdf1 100644 --- a/Sources/Engine/Ska/Mesh.h +++ b/Sources/Engine/Ska/Mesh.h @@ -18,36 +18,55 @@ #define ML_HALF_FACE_FORWARD (1UL<<0) // half face forward #define ML_FULL_FACE_FORWARD (1UL<<1) // full face forward -struct ENGINE_API MeshLOD -{ - MeshLOD() { - mlod_fMaxDistance = -1; - mlod_ulFlags = 0; - }; - ~MeshLOD() {} - FLOAT mlod_fMaxDistance; - ULONG mlod_ulFlags; - CStaticArray mlod_aVertices; // vertices - CStaticArray mlod_aNormals; // normals - CStaticArray mlod_aUVMaps; // UV maps - CStaticArray mlod_aSurfaces; // surfaces - CStaticArray mlod_aWeightMaps; // weight maps - CStaticArray mlod_aMorphMaps; // morph maps - CTString mlod_fnSourceFile;// file name of ascii am file, used in Ska studio -}; - struct ENGINE_API MeshVertex { FLOAT x, y, z; ULONG dummy; // 16 byte alingment }; +static inline CTStream &operator>>(CTStream &strm, MeshVertex &mv) +{ + strm>>mv.x; + strm>>mv.y; + strm>>mv.z; + strm>>mv.dummy; + return(strm); +} + +static inline CTStream &operator>>(CTStream &strm, const MeshVertex &mv) +{ + strm<>(CTStream &strm, MeshNormal &mn) +{ + strm>>mn.nx; + strm>>mn.ny; + strm>>mn.nz; + strm>>mn.dummy; + return(strm); +} + +static inline CTStream &operator>>(CTStream &strm, const MeshNormal &mn) +{ + strm<>(CTStream &strm, MeshTexCoord &mtc) +{ + strm>>mtc.u; + strm>>mtc.v; + return strm; +} + +static inline CTStream &operator<<(CTStream &strm, const MeshTexCoord &mtc) +{ + strm<>(CTStream &strm, MeshTriangle &mt) +{ + strm>>mt.iVertex[0]; + strm>>mt.iVertex[1]; + strm>>mt.iVertex[2]; + return strm; +} + +static inline CTStream &operator<<(CTStream &strm, const MeshTriangle &mt) +{ + strm<>(CTStream &strm, MeshVertexWeight &mww) +{ + strm>>mww.mww_iVertex; // absolute index of the vertex this weight refers to + strm>>mww.mww_fWeight; // weight for this bone [0.0 - 1.0] + return strm; +} +static inline CTStream &operator<<(CTStream &strm, const MeshVertexWeight &mww) +{ + strm<>(CTStream &strm, MeshVertexMorph &mwm) +{ + strm>>mwm.mwm_iVxIndex; + strm>>mwm.mwm_x; + strm>>mwm.mwm_y; + strm>>mwm.mwm_z; + strm>>mwm.mwm_nx; + strm>>mwm.mwm_ny; + strm>>mwm.mwm_nz; + strm>>mwm.dummy; + return(strm); +} + +static inline CTStream &operator>>(CTStream &strm, const MeshVertexMorph &mwm) +{ + strm< mlod_aVertices; // vertices + CStaticArray mlod_aNormals; // normals + CStaticArray mlod_aUVMaps; // UV maps + CStaticArray mlod_aSurfaces; // surfaces + CStaticArray mlod_aWeightMaps; // weight maps + CStaticArray mlod_aMorphMaps; // morph maps + CTString mlod_fnSourceFile;// file name of ascii am file, used in Ska studio +}; + class ENGINE_API CMesh : public CSerial { public: diff --git a/Sources/Engine/Ska/ModelInstance.cpp b/Sources/Engine/Ska/ModelInstance.cpp index ce83e49..5ec5c2c 100644 --- a/Sources/Engine/Ska/ModelInstance.cpp +++ b/Sources/Engine/Ska/ModelInstance.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include #include @@ -147,7 +147,7 @@ INDEX CModelInstance::GetColisionBoxIndex(INDEX iBoxID) { INDEX ctcb = mi_cbAABox.Count(); // for each existing box - for(INT icb=0;icb=0;ial--) + INDEX ial; + for(ial=ctal-1;ial>=0;ial--) { AnimList &alList = mi_aqAnims.aq_Lists[ial]; // calculate fade factor for this animlist diff --git a/Sources/Engine/Ska/ModelInstance.h b/Sources/Engine/Ska/ModelInstance.h index 544d93d..8a0fc3a 100644 --- a/Sources/Engine/Ska/ModelInstance.h +++ b/Sources/Engine/Ska/ModelInstance.h @@ -37,12 +37,12 @@ struct ColisionBox ColisionBox(FLOAT3D vMin,FLOAT3D vMax) { SetMin(vMin); SetMax(vMax); -// SetName("Default"); + SetName("Default"); }; inline FLOAT3D &Min() {return cb_vMin;} inline FLOAT3D &Max() {return cb_vMax;} - inline void SetMin(FLOAT3D &vMin) {cb_vMin = vMin;} - inline void SetMax(FLOAT3D &vMax) {cb_vMax = vMax;} + inline void SetMin(const FLOAT3D &vMin) {cb_vMin = vMin;} + inline void SetMax(const FLOAT3D &vMax) {cb_vMax = vMax;} inline void SetName(CTString strName) { cb_strName = strName; cb_iBoxID = ska_GetIDFromStringTable(cb_strName); @@ -160,9 +160,9 @@ public: ANGLE3D GetOffsetRot(); // Stretch model instance - void StretchModel(FLOAT3D &vStretch); + void StretchModel(const FLOAT3D &vStretch); // Stretch model instance without attachments - void StretchSingleModel(FLOAT3D &vStretch); + void StretchSingleModel(const FLOAT3D &vStretch); // Add new cloned anim state void NewClonedState(FLOAT fFadeTime); // Add new clear anim state diff --git a/Sources/Engine/Ska/RMRender.cpp b/Sources/Engine/Ska/RMRender.cpp index 7d40325..d64c8a9 100644 --- a/Sources/Engine/Ska/RMRender.cpp +++ b/Sources/Engine/Ska/RMRender.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include #include #include #include @@ -15,9 +15,9 @@ #include #include #include -#include +#include #include -#include +#include static CAnyProjection3D _aprProjection; static CDrawPort *_pdp = NULL; @@ -238,9 +238,9 @@ static void GetFogMapInVertex( GFXVertex4 &vtx, GFXTexCoord &tex) { const FLOAT fD = vtx.x*_vZDirView(1) + vtx.y*_vZDirView(2) + vtx.z*_vZDirView(3); const FLOAT fH = vtx.x*_vHDirView(1) + vtx.y*_vHDirView(2) + vtx.z*_vHDirView(3); - tex.s = (fD+_fFogAddZ) * _fog_fMulZ; -// tex.s = (vtx.z) * _fog_fMulZ; - tex.t = (fH+_fFogAddH) * _fog_fMulH; + tex.st.s = (fD+_fFogAddZ) * _fog_fMulZ; +// tex.st.s = (vtx.z) * _fog_fMulZ; + tex.st.t = (fH+_fFogAddH) * _fog_fMulH; } // check vertex against haze @@ -255,14 +255,14 @@ static BOOL IsModelInFog( FLOAT3D &vMin, FLOAT3D &vMax) { GFXTexCoord tex; GFXVertex4 vtx; - vtx.x=vMin(1); vtx.y=vMin(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMin(1); vtx.y=vMin(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMin(1); vtx.y=vMax(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMin(1); vtx.y=vMax(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMax(1); vtx.y=vMin(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMax(1); vtx.y=vMin(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; - vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.t)) return TRUE; + vtx.x=vMin(1); vtx.y=vMin(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMin(1); vtx.y=vMin(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMin(1); vtx.y=vMax(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMin(1); vtx.y=vMax(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMax(1); vtx.y=vMin(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMax(1); vtx.y=vMin(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMin(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; + vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMax(3); GetFogMapInVertex(vtx,tex); if(InFog(tex.st.t)) return TRUE; return FALSE; } @@ -369,8 +369,8 @@ void RM_DoFogAndHaze(BOOL bOpaqueSurface) // setup haze tex coords and color for( INDEX ivtx=0; ivtxDrawLine3D(vBoneStart,vRingPt[il],col); _pdp->DrawLine3D(vBoneEnd,vRingPt[il],col); } @@ -1030,7 +1030,7 @@ void RM_RenderBone(CModelInstance &mi,INDEX iBoneID) // all vertices by default are not visible ( have alpha set to 0 ) for(INDEX ivx=0;ivxmwm_aVertexWeight[ivw]; INDEX ivx = vw.mww_iVertex; - _aMeshColors[ivx].r = 255; - _aMeshColors[ivx].g = 127; - _aMeshColors[ivx].b = 0; - _aMeshColors[ivx].a += vw.mww_fWeight*255; // _aMeshColors[ivx].a = 255; + _aMeshColors[ivx].ub.r = 255; + _aMeshColors[ivx].ub.g = 127; + _aMeshColors[ivx].ub.b = 0; + _aMeshColors[ivx].ub.a += (UBYTE) (vw.mww_fWeight*255); // _aMeshColors[ivx].ub.a = 255; } } @@ -1109,8 +1109,8 @@ static void RenderActiveBones(RenModel &rm) // find newes animlist that has fully faded in INDEX iFirstAnimList = 0; // loop from newer to older - INDEX ial=ctal-1; - for(;ial>=0;ial--) { + INDEX ial; + for(ial=ctal-1;ial>=0;ial--) { AnimList &alList = pmi->mi_aqAnims.aq_Lists[ial]; // calculate fade factor FLOAT fFadeFactor = CalculateFadeFactor(alList); @@ -1152,7 +1152,7 @@ static void RenderActiveBones(void) gfxSetViewMatrix(NULL); // for each renmodel INDEX ctrm = _aRenModels.Count(); - for(INT irm=0;irm=0;ial--) { + INDEX ial; + for(ial=ctal-1;ial>=0;ial--) { AnimList &alList = rm.rm_pmiModel->mi_aqAnims.aq_Lists[ial]; // calculate fade factor FLOAT fFadeFactor = CalculateFadeFactor(alList); @@ -1977,9 +1977,9 @@ static void MatchAnims(RenModel &rm) } // calculate rotation for bone beetwen current and next frame in animation - qRot = Slerp(fSlerpFactor,*pqRotCurrent,*pqRotNext); + qRot = Slerp(fSlerpFactor,*pqRotCurrent,*pqRotNext); // and currently playing animation - rb.rb_arRot.ar_qRot = Slerp(fFadeFactor*pa.pa_Strength,rb.rb_arRot.ar_qRot,qRot); + rb.rb_arRot.ar_qRot = Slerp(fFadeFactor*pa.pa_Strength,rb.rb_arRot.ar_qRot,qRot); AnimPos *apFirst = &be.be_apPos[0]; INDEX ctfn = be.be_apPos.Count(); diff --git a/Sources/Engine/Ska/RMRenderMask.cpp b/Sources/Engine/Ska/RMRenderMask.cpp index 35b0479..880cd8f 100644 --- a/Sources/Engine/Ska/RMRenderMask.cpp +++ b/Sources/Engine/Ska/RMRenderMask.cpp @@ -1,8 +1,8 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include -#include +#include #include #include #include @@ -84,8 +84,8 @@ extern void InternalShader_Mask(void) // copy view space vertices, project 'em to screen space and mark clipping CStaticStackArray atvd; - INDEX iVtx=0; - for(; iVtx #include "Skeleton.h" #include @@ -13,7 +13,7 @@ #define SKELETON_VERSION 6 #define SKELETON_ID "SKEL" -CStaticArray _aSortArray; +static CStaticArray _aSortArray; INDEX ctSortBones; CSkeleton::CSkeleton() @@ -234,9 +234,10 @@ void CSkeleton::Read_t(CTStream *istrFile) sb.sb_iID = ska_GetIDFromStringTable(strNameID); sb.sb_iParentID = ska_GetIDFromStringTable(strParentID); // read AbsPlacement matrix - istrFile->Read_t(&sb.sb_mAbsPlacement,sizeof(FLOAT)*12); + for (int i = 0; i < 12; i++) + (*istrFile)>>sb.sb_mAbsPlacement[i]; // read RelPlacement Qvect stuct - istrFile->Read_t(&sb.sb_qvRelPlacement,sizeof(QVect)); + (*istrFile)>>sb.sb_qvRelPlacement; // read offset len (*istrFile)>>sb.sb_fOffSetLen; // read bone length diff --git a/Sources/Engine/Ska/Skeleton.h b/Sources/Engine/Ska/Skeleton.h index 22a42f3..7e13f88 100644 --- a/Sources/Engine/Ska/Skeleton.h +++ b/Sources/Engine/Ska/Skeleton.h @@ -22,6 +22,21 @@ struct QVect FLOATquat3D qRot; }; +static inline CTStream &operator>>(CTStream &strm, QVect &qv) +{ + strm>>qv.vPos; + strm>>qv.qRot; + return(strm); +} + +static inline CTStream &operator<<(CTStream &strm, const QVect &qv) +{ + strm< #include #include diff --git a/Sources/Engine/Ska/smcPars.y b/Sources/Engine/Ska/smcPars.y index eb38117..f0110bf 100644 --- a/Sources/Engine/Ska/smcPars.y +++ b/Sources/Engine/Ska/smcPars.y @@ -4,8 +4,12 @@ #include #include #include -#include #include + +// for static linking mojo... +#define yyparse yyparse_engine_ska_smcpars +#define yyerror yyerror_engine_ska_smcpars +#define yylex yylex_engine_ska_smcpars #include "ParsingSmbs.h" extern BOOL bRememberSourceFN; @@ -13,13 +17,19 @@ BOOL bOffsetAllreadySet = FALSE; %} %{ +// turn off over-helpful bit of bison... --ryan. +#ifdef __GNUC__ +#define __attribute__(x) +#endif + #define YYERROR_VERBOSE 0 + // if error occurs in parsing -void syyerror(char *str) +void yyerror(char *str) { - // just report the string - _pShell->ErrorF("%s", str); -}; + //_pShell->ErrorF("%s", str); + _pShell->ErrorF("File '%s'\n %s (line %d)",SMCGetBufferName(), str, SMCGetBufferLineNumber()); +} %} /* BISON Declarations */ diff --git a/Sources/Engine/Ska/smcScan.l b/Sources/Engine/Ska/smcScan.l index 759907c..7bb4f10 100644 --- a/Sources/Engine/Ska/smcScan.l +++ b/Sources/Engine/Ska/smcScan.l @@ -1,16 +1,23 @@ %option prefix="syy" %{ -#include "ParsingSmbs.h" -#include "smcPars.h" - #include #include #include #include #include + +#include "ParsingSmbs.h" +#include "smcPars.h" + extern CTFileName _fnmApplicationPath; +YYSTYPE syylval; + +#ifdef __cplusplus +extern "C" { int syywrap(void); } +#endif + int syywrap(void) { // no more buffers diff --git a/Sources/Engine/Sound/SoundData.cpp b/Sources/Engine/Sound/SoundData.cpp index 2140477..5918e56 100644 --- a/Sources/Engine/Sound/SoundData.cpp +++ b/Sources/Engine/Sound/SoundData.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Sound/SoundDecoder.cpp b/Sources/Engine/Sound/SoundDecoder.cpp index 6037d8b..b233224 100644 --- a/Sources/Engine/Sound/SoundDecoder.cpp +++ b/Sources/Engine/Sound/SoundDecoder.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -10,6 +10,7 @@ #include #include #include +#include // generic function called if a dll function is not found static void FailFunction_t(const char *strName) { @@ -20,8 +21,9 @@ static void FailFunction_t(const char *strName) { // ------------------------------------ AMP11 // amp11lib vars -extern BOOL _bAMP11Enabled = FALSE; -static HINSTANCE _hAmp11lib = NULL; +BOOL _bAMP11Enabled = FALSE; + +static CDynamicLoader *_hAmp11lib = NULL; // amp11lib types typedef signed char ALsint8; @@ -44,12 +46,21 @@ typedef ALsint32 ALhandle; #undef DLLFUNCTION static void AMP11_SetFunctionPointers_t(void) { - const char *strName; // get amp11lib function pointers - #define DLLFUNCTION(dll, output, name, inputs, params, required) \ - strName = "_" #name "@" #params; \ - p##name = (output (__stdcall*) inputs) GetProcAddress( _hAmp11lib, strName); \ - if(p##name == NULL) FailFunction_t(strName); + const char *strName; + + #ifdef PLATFORM_WIN32 + #define DLLFUNCTION(dll, output, name, inputs, params, required) \ + strName = "_" #name "@" #params; \ + p##name = (output (__stdcall*) inputs) _hAmp11lib->FindSymbol(strName); \ + if(p##name == NULL) FailFunction_t(strName); + #else + #define DLLFUNCTION(dll, output, name, inputs, params, required) \ + strName = #name; \ + p##name = (output (__stdcall*) inputs) _hAmp11lib->FindSymbol(strName); \ + if(p##name == NULL) FailFunction_t(strName); + #endif + #include "al_functions.h" #undef DLLFUNCTION } @@ -73,11 +84,11 @@ public: // ------------------------------------ Ogg Vorbis -//#include // we define needed stuff ourselves, and ignore the rest +//#include // we define needed stuff ourselves, and ignore the rest // vorbis vars -extern BOOL _bOVEnabled = FALSE; -static HINSTANCE _hOV = NULL; +BOOL _bOVEnabled = FALSE; +static CDynamicLoader *_hOV = NULL; #define OV_FALSE -1 #define OV_EOF -2 @@ -130,9 +141,10 @@ struct vorbis_info { static void OV_SetFunctionPointers_t(void) { const char *strName; // get vo function pointers + #define DLLFUNCTION(dll, output, name, inputs, params, required) \ strName = #name ; \ - p##name = (output (__cdecl *) inputs) GetProcAddress( _hOV, strName); \ + p##name = (output (__cdecl *) inputs) _hOV->FindSymbol(strName); \ if(p##name == NULL) FailFunction_t(strName); #include "ov_functions.h" #undef DLLFUNCTION @@ -223,35 +235,37 @@ void CSoundDecoder::InitPlugins(void) try { // load vorbis if (_hOV==NULL) { -#ifndef NDEBUG - #define VORBISLIB "vorbisfile_d.dll" -#else - #define VORBISLIB "vorbisfile.dll" -#endif - _hOV = ::LoadLibraryA(VORBISLIB); - } - if( _hOV == NULL) { - ThrowF_t(TRANS("Cannot load vorbisfile.dll.")); + #if ((defined PLATFORM_WIN32) && (defined NDEBUG)) + #define VORBISLIB "vorbisfile_d" + #else + #define VORBISLIB "vorbisfile" + #endif + _hOV = CDynamicLoader::GetInstance(VORBISLIB); + if( _hOV->GetError() != NULL) { + ThrowF_t(TRANS("Cannot load " VORBISLIB " shared library: %s."), _hOV->GetError()); + } } + // prepare function pointers OV_SetFunctionPointers_t(); // if all successful, enable mpx playing _bOVEnabled = TRUE; - CPrintF(TRANS(" vorbisfile.dll loaded, ogg playing enabled\n")); + CPrintF(TRANS(" " VORBISLIB " shared library loaded, ogg playing enabled\n")); - } catch (char *strError) { + } catch (char *strError) { // !!! FIXME: should be const char* ? CPrintF(TRANS("OGG playing disabled: %s\n"), strError); } try { // load amp11lib if (_hAmp11lib==NULL) { - _hAmp11lib = ::LoadLibraryA( "amp11lib.dll"); - } - if( _hAmp11lib == NULL) { - ThrowF_t(TRANS("Cannot load amp11lib.dll.")); + _hAmp11lib = CDynamicLoader::GetInstance("amp11lib"); + if( _hAmp11lib->GetError() != NULL) { + ThrowF_t(TRANS("Cannot load amp11lib shared library: %s"), _hAmp11lib->GetError()); + } } + // prepare function pointers AMP11_SetFunctionPointers_t(); @@ -260,9 +274,9 @@ void CSoundDecoder::InitPlugins(void) // if all successful, enable mpx playing _bAMP11Enabled = TRUE; - CPrintF(TRANS(" amp11lib.dll loaded, mpx playing enabled\n")); + CPrintF(TRANS(" amp11lib shared library loaded, mpx playing enabled\n")); - } catch (char *strError) { + } catch (char *strError) { // !!! FIXME: should be const char* ? CPrintF(TRANS("MPX playing disabled: %s\n"), strError); } } @@ -273,7 +287,7 @@ void CSoundDecoder::EndPlugins(void) if (_bAMP11Enabled) { palEndLibrary(); AMP11_ClearFunctionPointers(); - FreeLibrary(_hAmp11lib); + delete _hAmp11lib; _hAmp11lib = NULL; _bAMP11Enabled = FALSE; } @@ -281,7 +295,7 @@ void CSoundDecoder::EndPlugins(void) // cleanup vorbis when not needed anymore if (_bOVEnabled) { OV_ClearFunctionPointers(); - FreeLibrary(_hOV); + delete _hOV; _hOV = NULL; _bOVEnabled = FALSE; } diff --git a/Sources/Engine/Sound/SoundDecoder.h b/Sources/Engine/Sound/SoundDecoder.h index 4e03790..463062d 100644 --- a/Sources/Engine/Sound/SoundDecoder.h +++ b/Sources/Engine/Sound/SoundDecoder.h @@ -1,6 +1,10 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#pragma once +#ifndef SE_INCL_SOUNDDECODER_H +#define SE_INCL_SOUNDDECODER_H +#ifdef PRAGMA_ONCE + #pragma once +#endif class CSoundDecoder { public: @@ -25,4 +29,7 @@ public: INDEX Decode(void *pvDestBuffer, INDEX ctBytesToDecode); // reset decoder to start of sample void Reset(void); -}; \ No newline at end of file +}; + +#endif /* include-once check. */ + diff --git a/Sources/Engine/Sound/SoundLibrary.cpp b/Sources/Engine/Sound/SoundLibrary.cpp index d003247..6de3104 100644 --- a/Sources/Engine/Sound/SoundLibrary.cpp +++ b/Sources/Engine/Sound/SoundLibrary.cpp @@ -1,8 +1,23 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" -#include "initguid.h" +#include "Engine/StdH.h" + +// !!! FIXME : rcg12162001 This file really needs to be ripped apart and +// !!! FIXME : rcg12162001 into platform/driver specific subdirectories. + + +// !!! FIXME : rcg10132001 what is this file? +#ifdef PLATFORM_WIN32 +#include "initguid.h" +#endif + +// !!! FIXME : Move all the SDL stuff to a different file... +#ifdef PLATFORM_UNIX +#include "SDL.h" +#endif + +#include #include #include @@ -25,18 +40,20 @@ #include #include -template CStaticArray; +template class CStaticArray; +#ifdef _MSC_VER #pragma comment(lib, "winmm.lib") +#endif // pointer to global sound library object CSoundLibrary *_pSound = NULL; // console variables -extern FLOAT snd_tmMixAhead = 0.2f; // mix-ahead in seconds -extern FLOAT snd_fSoundVolume = 1.0f; // master volume for sound playing [0..1] -extern FLOAT snd_fMusicVolume = 1.0f; // master volume for music playing [0..1] +FLOAT snd_tmMixAhead = 0.2f; // mix-ahead in seconds +FLOAT snd_fSoundVolume = 1.0f; // master volume for sound playing [0..1] +FLOAT snd_fMusicVolume = 1.0f; // master volume for music playing [0..1] // NOTES: // - these 3d sound parameters have been set carefully, take extreme if changing ! // - ears distance of 20cm causes phase shift of up to 0.6ms which is very noticable @@ -44,17 +61,17 @@ extern FLOAT snd_fMusicVolume = 1.0f; // master volume for music playing [0..1 // - pan strength needs not to be very strong, since lrfilter has panning-like influence also // - if down filter is too large, it makes too much influence even on small elevation changes // and messes the situation completely -extern FLOAT snd_fDelaySoundSpeed = 1E10; // sound speed used for delay [m/s] -extern FLOAT snd_fDopplerSoundSpeed = 330.0f; // sound speed used for doppler [m/s] -extern FLOAT snd_fEarsDistance = 0.2f; // distance between listener's ears -extern FLOAT snd_fPanStrength = 0.1f; // panning modifier (0=none, 1= full) -extern FLOAT snd_fLRFilter = 3.0f; // filter for left-right -extern FLOAT snd_fBFilter = 5.0f; // filter for back -extern FLOAT snd_fUFilter = 1.0f; // filter for up -extern FLOAT snd_fDFilter = 3.0f; // filter for down +FLOAT snd_fDelaySoundSpeed = 1E10; // sound speed used for delay [m/s] +FLOAT snd_fDopplerSoundSpeed = 330.0f; // sound speed used for doppler [m/s] +FLOAT snd_fEarsDistance = 0.2f; // distance between listener's ears +FLOAT snd_fPanStrength = 0.1f; // panning modifier (0=none, 1= full) +FLOAT snd_fLRFilter = 3.0f; // filter for left-right +FLOAT snd_fBFilter = 5.0f; // filter for back +FLOAT snd_fUFilter = 1.0f; // filter for up +FLOAT snd_fDFilter = 3.0f; // filter for down -ENGINE_API extern INDEX snd_iFormat = 3; -extern INDEX snd_bMono = FALSE; +ENGINE_API INDEX snd_iFormat = 3; +INDEX snd_bMono = FALSE; static INDEX snd_iDevice = -1; static INDEX snd_iInterface = 2; // 0=WaveOut, 1=DirectSound, 2=EAX static INDEX snd_iMaxOpenRetries = 3; @@ -65,9 +82,12 @@ static FLOAT snd_fEAXPanning = 0.0f; static FLOAT snd_fNormalizer = 0.9f; static FLOAT _fLastNormalizeValue = 1; +#ifdef PLATFORM_WIN32 extern HWND _hwndMain; // global handle for application window static HWND _hwndCurrent = NULL; static HINSTANCE _hInstDS = NULL; +#endif + static INDEX _iWriteOffset = 0; static INDEX _iWriteOffset2 = 0; static BOOL _bMuted = FALSE; @@ -93,6 +113,249 @@ static BOOL _bOpened = FALSE; * ---------------------------- **/ +// rcg12162001 Simple Directmedia Layer sound implementation. +#ifdef PLATFORM_UNIX + +static Uint8 sdl_silence = 0; +static volatile SLONG sdl_backbuffer_allocation = 0; +static Uint8 *sdl_backbuffer = NULL; +static volatile SLONG sdl_backbuffer_pos = 0; +static volatile SLONG sdl_backbuffer_remain = 0; + +static void sdl_audio_callback(void *userdata, Uint8 *stream, int len) +{ + ASSERT(!_bDedicatedServer); + ASSERT(sdl_backbuffer != NULL); + ASSERT(sdl_backbuffer_remain <= sdl_backbuffer_allocation); + ASSERT(sdl_backbuffer_remain >= 0); + ASSERT(sdl_backbuffer_pos < sdl_backbuffer_allocation); + ASSERT(sdl_backbuffer_pos >= 0); + + // "avail" is just the byte count before the end of the buffer. + // "cpysize" is how many bytes can actually be copied. + int avail = sdl_backbuffer_allocation - sdl_backbuffer_pos; + int cpysize = (len < sdl_backbuffer_remain) ? len : sdl_backbuffer_remain; + Uint8 *src = sdl_backbuffer + sdl_backbuffer_pos; + + if (avail < cpysize) // Copy would pass end of ring buffer? + cpysize = avail; + + if (cpysize > 0) { + memcpy(stream, src, cpysize); // move first block to SDL stream. + sdl_backbuffer_remain -= cpysize; + ASSERT(sdl_backbuffer_remain >= 0); + len -= cpysize; + ASSERT(len >= 0); + stream += cpysize; + sdl_backbuffer_pos += cpysize; + } // if + + // See if we need to rotate to start of ring buffer... + ASSERT(sdl_backbuffer_pos <= sdl_backbuffer_allocation); + if (sdl_backbuffer_pos == sdl_backbuffer_allocation) { + sdl_backbuffer_pos = 0; + + // we might need to feed SDL more data now... + if (len > 0) { + cpysize = (len < sdl_backbuffer_remain) ? len : sdl_backbuffer_remain; + if (cpysize > 0) { + memcpy(stream, sdl_backbuffer, cpysize); // move 2nd block. + sdl_backbuffer_pos += cpysize; + ASSERT(sdl_backbuffer_pos < sdl_backbuffer_allocation); + sdl_backbuffer_remain -= cpysize; + ASSERT(sdl_backbuffer_remain >= 0); + len -= cpysize; + ASSERT(len >= 0); + stream += cpysize; + } // if + } // if + } // if + + // SDL _still_ needs more data than we've got! Fill with silence. (*shrug*) + if (len > 0) { + ASSERT(sdl_backbuffer_remain == 0); + memset(stream, sdl_silence, len); + } // if +} // sdl_audio_callback + + +// initialize the SDL audio subsystem. + +static BOOL StartUp_SDLaudio( CSoundLibrary &sl, BOOL bReport=TRUE) +{ + bReport=TRUE; // !!! FIXME ...how do you configure this externally? + + // not using DirectSound (obviously) + sl.sl_bUsingDirectSound = FALSE; + sl.sl_bUsingEAX = FALSE; + snd_iDevice = 0; + if( bReport) CPrintF(TRANS("SDL audio initialization ...\n")); + + ASSERT(!_bDedicatedServer); + if (_bDedicatedServer) { + CPrintF("Dedicated server; not initializing audio.\n"); + return FALSE; + } + + SDL_AudioSpec desired; + memset(&desired, '\0', sizeof (SDL_AudioSpec)); + Sint16 bps = sl.sl_SwfeFormat.wBitsPerSample; + if (bps <= 8) + desired.format = AUDIO_U8; + else if (bps <= 16) + desired.format = AUDIO_S16LSB; + else { + CPrintF(TRANS("Unsupported bits-per-sample: %d\n"), bps); + return FALSE; + } + desired.freq = sl.sl_SwfeFormat.nSamplesPerSec; + + // I dunno if this is the best idea, but I'll give it a try... + // should probably check a cvar for this... + if (desired.freq <= 11025) + desired.samples = 512; + else if (desired.freq <= 22050) + desired.samples = 1024; + else if (desired.freq <= 44100) + desired.samples = 2048; + else + desired.samples = 4096; // (*shrug*) + + desired.channels = sl.sl_SwfeFormat.nChannels; + desired.userdata = &sl; + desired.callback = sdl_audio_callback; + + if (SDL_Init(SDL_INIT_AUDIO) == -1) { + CPrintF( TRANS("SDL_Init(SDL_INIT_AUDIO) error: %s\n"), SDL_GetError()); + return FALSE; + } + + // !!! FIXME rcg12162001 We force SDL to convert the audio stream on the + // !!! FIXME rcg12162001 fly to match sl.sl_SwfeFormat, but I'm curious + // !!! FIXME rcg12162001 if the Serious Engine can handle it if we changed + // !!! FIXME rcg12162001 sl.sl_SwfeFormat to match what the audio hardware + // !!! FIXME rcg12162001 can handle. I'll have to check later. + if (SDL_OpenAudio(&desired, NULL) != 0) { + CPrintF( TRANS("SDL_OpenAudio() error: %s\n"), SDL_GetError()); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + return FALSE; + } + + sdl_silence = desired.silence; + sdl_backbuffer_allocation = (desired.size * 2); + sdl_backbuffer = (Uint8 *)AllocMemory(sdl_backbuffer_allocation); + sdl_backbuffer_remain = 0; + sdl_backbuffer_pos = 0; + + // report success + if( bReport) { + char achDriverName[128]; + SDL_AudioDriverName(achDriverName, sizeof (achDriverName)); + CPrintF( TRANS(" opened device: %s\n"), "SDL audio stream"); + CPrintF( TRANS(" %dHz, %dbit, %s\n"), + sl.sl_SwfeFormat.nSamplesPerSec, + sl.sl_SwfeFormat.wBitsPerSample, + achDriverName); + } + + // determine whole mixer buffer size from mixahead console variable + sl.sl_slMixerBufferSize = (SLONG)(ceil(snd_tmMixAhead*sl.sl_SwfeFormat.nSamplesPerSec) * + sl.sl_SwfeFormat.wBitsPerSample/8 * sl.sl_SwfeFormat.nChannels); + // align size to be next multiply of WAVEOUTBLOCKSIZE + sl.sl_slMixerBufferSize += WAVEOUTBLOCKSIZE - (sl.sl_slMixerBufferSize % WAVEOUTBLOCKSIZE); + // decoder buffer always works at 44khz + sl.sl_slDecodeBufferSize = sl.sl_slMixerBufferSize * + ((44100+sl.sl_SwfeFormat.nSamplesPerSec-1)/sl.sl_SwfeFormat.nSamplesPerSec); + if( bReport) { + CPrintF(TRANS(" parameters: %d Hz, %d bit, stereo, mix-ahead: %gs\n"), + sl.sl_SwfeFormat.nSamplesPerSec, sl.sl_SwfeFormat.wBitsPerSample, snd_tmMixAhead); + CPrintF(TRANS(" output buffers: %d x %d bytes\n"), 2, desired.size); + CPrintF(TRANS(" mpx decode: %d bytes\n"), sl.sl_slDecodeBufferSize); + } + + // initialize mixing and decoding buffer + sl.sl_pslMixerBuffer = (SLONG*)AllocMemory( sl.sl_slMixerBufferSize *2); // (*2 because of 32-bit buffer) + sl.sl_pswDecodeBuffer = (SWORD*)AllocMemory( sl.sl_slDecodeBufferSize+4); // (+4 because of linear interpolation of last samples) + + // the audio callback can now safely fill the audio stream with silence + // until there is actual audio data to mix... + SDL_PauseAudio(0); + + // done + return TRUE; +} // StartUp_SDLaudio + + +// SDL audio shutdown procedure +static void ShutDown_SDLaudio( CSoundLibrary &sl) +{ + if (!SDL_WasInit(SDL_INIT_AUDIO)) + return; + + SDL_PauseAudio(1); + + if (sdl_backbuffer != NULL) { + FreeMemory(sdl_backbuffer); + sdl_backbuffer = NULL; + } + + if (sl.sl_pslMixerBuffer != NULL) { + FreeMemory( sl.sl_pslMixerBuffer); + sl.sl_pslMixerBuffer = NULL; + } + + if (sl.sl_pswDecodeBuffer != NULL) { + FreeMemory(sl.sl_pswDecodeBuffer); + sl.sl_pswDecodeBuffer = NULL; + } + + SDL_CloseAudio(); + SDL_QuitSubSystem(SDL_INIT_AUDIO); +} // ShutDown_SDLaudio + + +// SDL_LockAudio() must be in effect when calling this! +// ...and stay in effect until after CopyMixerBuffer_SDLaudio() is called! +static SLONG PrepareSoundBuffer_SDLaudio( CSoundLibrary &sl) +{ + ASSERT(sdl_backbuffer_remain >= 0); + ASSERT(sdl_backbuffer_remain <= sdl_backbuffer_allocation); + return(sdl_backbuffer_allocation - sdl_backbuffer_remain); +} // PrepareSoundBuffer_SDLaudio + + +// SDL_LockAudio() must be in effect when calling this! +// ...and have been in effect since PrepareSoundBuffer_SDLaudio was called! +static void CopyMixerBuffer_SDLaudio( CSoundLibrary &sl, SLONG datasize) +{ + ASSERT((sdl_backbuffer_allocation - sdl_backbuffer_remain) >= datasize); + + SLONG fillpos = sdl_backbuffer_pos + sdl_backbuffer_remain; + if (fillpos > sdl_backbuffer_allocation) + fillpos -= sdl_backbuffer_allocation; + + SLONG cpysize = datasize; + if ( (cpysize + fillpos) > sdl_backbuffer_allocation) + cpysize = sdl_backbuffer_allocation - fillpos; + + Uint8 *src = sdl_backbuffer + fillpos; + CopyMixerBuffer_stereo(0, src, cpysize); + datasize -= cpysize; + sdl_backbuffer_remain += cpysize; + if (datasize > 0) { // rotate to start of ring buffer? + CopyMixerBuffer_stereo(cpysize, sdl_backbuffer, datasize); + sdl_backbuffer_remain += datasize; + } // if + + ASSERT(sdl_backbuffer_remain <= sdl_backbuffer_allocation); +} // CopyMixerBuffer_SDLaudio + + +#endif // defined PLATFORM_UNIX (SDL audio implementation) + + + + /* * Construct uninitialized sound library. */ @@ -113,6 +376,8 @@ CSoundLibrary::CSoundLibrary(void) sl_pslMixerBuffer = NULL; sl_pswDecodeBuffer = NULL; sl_pubBuffersMemory = NULL; + +#ifdef PLATFORM_WIN32 // clear wave out data sl_hwoWaveOut = NULL; @@ -126,6 +391,8 @@ CSoundLibrary::CSoundLibrary(void) sl_pDSListener = NULL; sl_pDSSourceLeft = NULL; sl_pDSSourceRight = NULL; +#endif + sl_bUsingDirectSound = FALSE; sl_bUsingEAX = FALSE; } @@ -178,7 +445,7 @@ static void SndPostFunc(void *pArgs) * some internal functions */ - +#ifdef PLATFORM_WIN32 // DirectSound shutdown procedure static void ShutDown_dsound( CSoundLibrary &sl) { @@ -242,6 +509,7 @@ static void ShutDown_dsound( CSoundLibrary &sl) sl.sl_pswDecodeBuffer = NULL; } } +#endif /* @@ -290,7 +558,7 @@ static void SetLibraryFormat( CSoundLibrary &sl) } - +#ifdef PLATFORM_WIN32 static BOOL DSFail( CSoundLibrary &sl, char *strError) { CPrintF(strError); @@ -667,7 +935,7 @@ static BOOL StartUp_waveout( CSoundLibrary &sl, BOOL bReport=TRUE) // done return TRUE; } - +#endif @@ -701,6 +969,7 @@ static void SetFormat_internal( CSoundLibrary &sl, CSoundLibrary::SoundFormat Es snd_iInterface = Clamp( snd_iInterface, 0L, 2L); BOOL bSoundOK = FALSE; +#ifdef PLATFORM_WIN32 if( snd_iInterface==2) { // if wanted, 1st try to set EAX bSoundOK = StartUp_dsound( sl, bReport); @@ -715,6 +984,9 @@ static void SetFormat_internal( CSoundLibrary &sl, CSoundLibrary::SoundFormat Es bSoundOK = StartUp_waveout( sl, bReport); snd_iInterface = 0; // mark that DirectSound didn't make it } +#else + bSoundOK = StartUp_SDLaudio(sl, bReport); +#endif // if didn't make it by now if( bReport) CPrintF("\n"); @@ -741,29 +1013,37 @@ void CSoundLibrary::Init(void) // synchronize access to sounds CTSingleLock slSounds(&sl_csSound, TRUE); - _pShell->DeclareSymbol( "void SndPostFunc(INDEX);", &SndPostFunc); + _pShell->DeclareSymbol( "void SndPostFunc(INDEX);", (void *) &SndPostFunc); + + _pShell->DeclareSymbol( " user INDEX snd_bMono;", (void *) &snd_bMono); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fEarsDistance;", (void *) &snd_fEarsDistance); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fDelaySoundSpeed;", (void *) &snd_fDelaySoundSpeed); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fDopplerSoundSpeed;", (void *) &snd_fDopplerSoundSpeed); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fPanStrength;", (void *) &snd_fPanStrength); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fLRFilter;", (void *) &snd_fLRFilter); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fBFilter;", (void *) &snd_fBFilter); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fUFilter;", (void *) &snd_fUFilter); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fDFilter;", (void *) &snd_fDFilter); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fSoundVolume;", (void *) &snd_fSoundVolume); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fMusicVolume;", (void *) &snd_fMusicVolume); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fNormalizer;", (void *) &snd_fNormalizer); + _pShell->DeclareSymbol( "persistent user FLOAT snd_tmMixAhead post:SndPostFunc;", (void *) &snd_tmMixAhead); + _pShell->DeclareSymbol( "persistent user INDEX snd_iInterface post:SndPostFunc;", (void *) &snd_iInterface); + _pShell->DeclareSymbol( "persistent user INDEX snd_iDevice post:SndPostFunc;", (void *) &snd_iDevice); + _pShell->DeclareSymbol( "persistent user INDEX snd_iFormat post:SndPostFunc;", (void *) &snd_iFormat); + _pShell->DeclareSymbol( "persistent user INDEX snd_iMaxExtraChannels;", (void *) &snd_iMaxExtraChannels); + _pShell->DeclareSymbol( "persistent user INDEX snd_iMaxOpenRetries;", (void *) &snd_iMaxOpenRetries); + _pShell->DeclareSymbol( "persistent user FLOAT snd_tmOpenFailDelay;", (void *) &snd_tmOpenFailDelay); + _pShell->DeclareSymbol( "persistent user FLOAT snd_fEAXPanning;", (void *) &snd_fEAXPanning); + +// !!! FIXME : rcg12162001 This should probably be done everywhere, honestly. +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) { + CPrintF(TRANS("Dedicated server; not initializing sound.\n")); + return; + } +#endif - _pShell->DeclareSymbol( " user INDEX snd_bMono;", &snd_bMono); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fEarsDistance;", &snd_fEarsDistance); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fDelaySoundSpeed;", &snd_fDelaySoundSpeed); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fDopplerSoundSpeed;", &snd_fDopplerSoundSpeed); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fPanStrength;", &snd_fPanStrength); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fLRFilter;", &snd_fLRFilter); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fBFilter;", &snd_fBFilter); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fUFilter;", &snd_fUFilter); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fDFilter;", &snd_fDFilter); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fSoundVolume;", &snd_fSoundVolume); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fMusicVolume;", &snd_fMusicVolume); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fNormalizer;", &snd_fNormalizer); - _pShell->DeclareSymbol( "persistent user FLOAT snd_tmMixAhead post:SndPostFunc;", &snd_tmMixAhead); - _pShell->DeclareSymbol( "persistent user INDEX snd_iInterface post:SndPostFunc;", &snd_iInterface); - _pShell->DeclareSymbol( "persistent user INDEX snd_iDevice post:SndPostFunc;", &snd_iDevice); - _pShell->DeclareSymbol( "persistent user INDEX snd_iFormat post:SndPostFunc;", &snd_iFormat); - _pShell->DeclareSymbol( "persistent user INDEX snd_iMaxExtraChannels;", &snd_iMaxExtraChannels); - _pShell->DeclareSymbol( "persistent user INDEX snd_iMaxOpenRetries;", &snd_iMaxOpenRetries); - _pShell->DeclareSymbol( "persistent user FLOAT snd_tmOpenFailDelay;", &snd_tmOpenFailDelay); - _pShell->DeclareSymbol( "persistent user FLOAT snd_fEAXPanning;", &snd_fEAXPanning); - // print header CPrintF(TRANS("Initializing sound...\n")); @@ -771,8 +1051,12 @@ void CSoundLibrary::Init(void) SetFormat(SF_NONE); // initialize any installed sound decoders + CSoundDecoder::InitPlugins(); + sl_ctWaveDevices = 0; // rcg11012005 valgrind fix. + +#ifdef PLATFORM_WIN32 // get number of devices INDEX ctDevices = waveOutGetNumDevs(); CPrintF(TRANS(" Detected devices: %d\n"), ctDevices); @@ -792,6 +1076,8 @@ void CSoundLibrary::Init(void) woc.dwFormats, woc.wChannels, woc.dwSupport); } // done +#endif + CPrintF("\n"); } @@ -799,7 +1085,14 @@ void CSoundLibrary::Init(void) /* * Clear Sound Library */ -void CSoundLibrary::Clear(void) { +void CSoundLibrary::Clear(void) +{ +// !!! FIXME : rcg12162001 This should probably be done everywhere, honestly. +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) + return; +#endif + // access to the list of handlers must be locked CTSingleLock slHooks(&_pTimer->tm_csHooks, TRUE); // synchronize access to sounds @@ -822,6 +1115,12 @@ void CSoundLibrary::Clear(void) { /* Clear Library WaveOut */ void CSoundLibrary::ClearLibrary(void) { +// !!! FIXME : rcg12162001 This should probably be done everywhere, honestly. +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) + return; +#endif + // access to the list of handlers must be locked CTSingleLock slHooks(&_pTimer->tm_csHooks, TRUE); @@ -833,6 +1132,10 @@ void CSoundLibrary::ClearLibrary(void) _pTimer->RemHandler(&sl_thTimerHandler); } + sl_bUsingDirectSound = FALSE; + sl_bUsingEAX = FALSE; + +#ifdef PLATFORM_WIN32 // shut down direct sound buffers (if needed) ShutDown_dsound(*this); @@ -864,6 +1167,10 @@ void CSoundLibrary::ClearLibrary(void) // free extra channel handles sl_ahwoExtra.PopAll(); +#else + ShutDown_SDLaudio(*this); +#endif + // free memory if( sl_pslMixerBuffer!=NULL) { FreeMemory( sl_pslMixerBuffer); @@ -884,6 +1191,7 @@ void CSoundLibrary::ClearLibrary(void) BOOL CSoundLibrary::SetEnvironment( INDEX iEnvNo, FLOAT fEnvSize/*=0*/) { if( !sl_bUsingEAX) return FALSE; +#ifdef PLATFORM_WIN32 // trim values if( iEnvNo<0 || iEnvNo>25) iEnvNo=1; if( fEnvSize<1 || fEnvSize>99) fEnvSize=8; @@ -892,6 +1200,7 @@ BOOL CSoundLibrary::SetEnvironment( INDEX iEnvNo, FLOAT fEnvSize/*=0*/) if( hResult != DS_OK) return DSFail( *this, TRANS(" ! EAX error: Cannot set environment.\n")); hResult = sl_pKSProperty->Set( DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE, NULL, 0, &fEnvSize, sizeof(FLOAT)); if( hResult != DS_OK) return DSFail( *this, TRANS(" ! EAX error: Cannot set environment size.\n")); +#endif return TRUE; } @@ -902,6 +1211,13 @@ void CSoundLibrary::Mute(void) // stop all IFeel effects IFeel_StopEffect(NULL); +// !!! FIXME : rcg12162001 This should probably be done everywhere, honestly. +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) + return; +#endif + +#ifdef PLATFORM_WIN32 // erase direct sound buffer (waveout will shut-up by itself), but skip if there's no more sound library if( this==NULL || !sl_bUsingDirectSound) return; @@ -924,6 +1240,14 @@ void CSoundLibrary::Mute(void) memset( lpData, 0, dwSize); sl_pDSSecondary2->Unlock( lpData, dwSize, NULL, 0); } + +#else + SDL_LockAudio(); + _bMuted = TRUE; + sdl_backbuffer_remain = 0; // ditch pending audio data... + sdl_backbuffer_pos = 0; + SDL_UnlockAudio(); +#endif } @@ -935,6 +1259,14 @@ void CSoundLibrary::Mute(void) */ CSoundLibrary::SoundFormat CSoundLibrary::SetFormat( CSoundLibrary::SoundFormat EsfNew, BOOL bReport/*=FALSE*/) { +// !!! FIXME : rcg12162001 Do this for all platforms? +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) { + sl_EsfFormat = SF_NONE; + return(sl_EsfFormat); + } +#endif + // access to the list of handlers must be locked CTSingleLock slHooks(&_pTimer->tm_csHooks, TRUE); // synchronize access to sounds @@ -975,11 +1307,20 @@ CSoundLibrary::SoundFormat CSoundLibrary::SetFormat( CSoundLibrary::SoundFormat /* Update all 3d effects and copy internal data. */ void CSoundLibrary::UpdateSounds(void) { +// !!! FIXME : rcg12162001 This should probably be done everywhere, honestly. +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) + return; +#endif + // see if we have valid handle for direct sound and eventually reinit sound +#ifdef PLATFORM_WIN32 if( sl_bUsingDirectSound && _hwndCurrent!=_hwndMain) { _hwndCurrent = _hwndMain; SetFormat( sl_EsfFormat); } +#endif + _bMuted = FALSE; // enable mixer _sfStats.StartTimer(CStatForm::STI_SOUNDUPDATE); _pfSoundProfile.StartTimer(CSoundProfile::PTI_UPDATESOUNDS); @@ -987,8 +1328,10 @@ void CSoundLibrary::UpdateSounds(void) // synchronize access to sounds CTSingleLock slSounds( &sl_csSound, TRUE); +#ifdef PLATFORM_WIN32 // make sure that the buffers are playing if( sl_bUsingDirectSound) DSPlayBuffers(*this); +#endif // determine number of listeners and get listener INDEX ctListeners=0; @@ -1013,6 +1356,7 @@ void CSoundLibrary::UpdateSounds(void) } // adjust panning if needed +#ifdef PLATFORM_WIN32 snd_fEAXPanning = Clamp( snd_fEAXPanning, -1.0f, +1.0f); if( sl_bUsingEAX && _fLastPanning!=snd_fEAXPanning) { // determine new panning @@ -1028,6 +1372,7 @@ void CSoundLibrary::UpdateSounds(void) hr3 = sl_pDSListener->CommitDeferredSettings(); if( hr1!=DS_OK || hr2!=DS_OK || hr3!=DS_OK) DSFail( *this, TRANS(" ! DirectSound3D error: Cannot set 3D position.\n")); } +#endif // for each sound {FOREACHINLIST( CSoundData, sd_Node, sl_ClhAwareList, itCsdSoundData) { @@ -1073,6 +1418,12 @@ void CSoundLibrary::UpdateSounds(void) */ void CSoundTimerHandler::HandleTimer(void) { +// !!! FIXME : rcg12162001 This should probably be done everywhere, honestly. +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) + return; +#endif + /* memory leak checking routines ASSERT( _CrtCheckMemory()); ASSERT( _CrtIsMemoryBlock( (void*)_pSound->sl_pswDecodeBuffer, @@ -1095,6 +1446,7 @@ void CSoundTimerHandler::HandleTimer(void) static LPVOID _lpData, _lpData2; static DWORD _dwSize, _dwSize2; +#ifdef PLATFORM_WIN32 static void CopyMixerBuffer_dsound( CSoundLibrary &sl, SLONG slMixedSize) { LPVOID lpData; @@ -1233,11 +1585,18 @@ static SLONG PrepareSoundBuffer_waveout( CSoundLibrary &sl) ASSERT( slDataToMix <= sl.sl_slMixerBufferSize); return slDataToMix; } +#endif /* Update Mixer */ void CSoundLibrary::MixSounds(void) { +// !!! FIXME : rcg12162001 This should probably be done everywhere, honestly. +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) + return; +#endif + // synchronize access to sounds CTSingleLock slSounds( &sl_csSound, TRUE); @@ -1250,15 +1609,24 @@ void CSoundLibrary::MixSounds(void) // seek available buffer(s) for next crop of samples SLONG slDataToMix; + +#ifdef PLATFORM_WIN32 if( sl_bUsingDirectSound) { // using direct sound slDataToMix = PrepareSoundBuffer_dsound( *this); } else { // using wave out slDataToMix = PrepareSoundBuffer_waveout(*this); } +#else + SDL_LockAudio(); + slDataToMix = PrepareSoundBuffer_SDLaudio(*this); +#endif // skip mixing if all sound buffers are still busy playing ASSERT( slDataToMix>=0); if( slDataToMix<=0) { + #ifdef PLATFORM_UNIX + SDL_UnlockAudio(); + #endif _pfSoundProfile.StopTimer(CSoundProfile::PTI_MIXSOUNDS); _sfStats.StopTimer(CStatForm::STI_SOUNDMIXING); return; @@ -1299,11 +1667,16 @@ void CSoundLibrary::MixSounds(void) // _bOpened = TRUE; // copy mixer buffer to buffers buffer(s) +#ifdef PLATFORM_WIN32 if( sl_bUsingDirectSound) { // using direct sound CopyMixerBuffer_dsound( *this, slDataToMix); } else { // using wave out CopyMixerBuffer_waveout(*this); } +#else + CopyMixerBuffer_SDLaudio(*this, slDataToMix); + SDL_UnlockAudio(); +#endif // all done _pfSoundProfile.StopTimer(CSoundProfile::PTI_MIXSOUNDS); @@ -1318,7 +1691,14 @@ void CSoundLibrary::MixSounds(void) /* * Add sound in sound aware list */ -void CSoundLibrary::AddSoundAware(CSoundData &CsdAdd) { +void CSoundLibrary::AddSoundAware(CSoundData &CsdAdd) +{ +// !!! FIXME : rcg12162001 This should probably be done everywhere, honestly. +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) + return; +#endif + // add sound to list tail sl_ClhAwareList.AddTail(CsdAdd.sd_Node); }; @@ -1326,7 +1706,14 @@ void CSoundLibrary::AddSoundAware(CSoundData &CsdAdd) { /* * Remove a display mode aware object. */ -void CSoundLibrary::RemoveSoundAware(CSoundData &CsdRemove) { +void CSoundLibrary::RemoveSoundAware(CSoundData &CsdRemove) +{ +// !!! FIXME : rcg12162001 This should probably be done everywhere, honestly. +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) + return; +#endif + // remove it from list CsdRemove.sd_Node.Remove(); }; @@ -1334,6 +1721,12 @@ void CSoundLibrary::RemoveSoundAware(CSoundData &CsdRemove) { // listen from this listener this frame void CSoundLibrary::Listen(CSoundListener &sl) { +// !!! FIXME : rcg12162001 This should probably be done everywhere, honestly. +#ifdef PLATFORM_UNIX + if (_bDedicatedServer) + return; +#endif + // just add it to list if (sl.sli_lnInActiveListeners.IsLinked()) { sl.sli_lnInActiveListeners.Remove(); diff --git a/Sources/Engine/Sound/SoundLibrary.h b/Sources/Engine/Sound/SoundLibrary.h index 08e4043..1217e4d 100644 --- a/Sources/Engine/Sound/SoundLibrary.h +++ b/Sources/Engine/Sound/SoundLibrary.h @@ -26,8 +26,8 @@ // set master volume and resets mixer buffer (wipes it with zeroes and keeps pointers) void ResetMixer( const SLONG *pslBuffer, const SLONG slBufferSize); // copy mixer buffer to the output buffer(s) -void CopyMixerBuffer_stereo( const SLONG slSrcOffset, const void *pDstBuffer, const SLONG slBytes); -void CopyMixerBuffer_mono( const SLONG slSrcOffset, const void *pDstBuffer, const SLONG slBytes); +void CopyMixerBuffer_stereo( const SLONG slSrcOffset, void *pDstBuffer, const SLONG slBytes); +void CopyMixerBuffer_mono( const SLONG slSrcOffset, void *pDstBuffer, const SLONG slBytes); // normalize mixed sounds void NormalizeMixerBuffer( const FLOAT snd_fNormalizer, const SLONG slBytes, FLOAT &_fLastNormalizeValue); // mix in one sound object to mixer buffer @@ -60,12 +60,13 @@ public: public: CTCriticalSection sl_csSound; // sync. access to sounds CSoundTimerHandler sl_thTimerHandler; // handler for mixing sounds in timer + INDEX sl_ctWaveDevices; // number of devices detected /* rcg !!! FIXME: This needs to be abstracted. */ -#ifdef PLATFORM_WIN32 - INDEX sl_ctWaveDevices; // number of devices detected BOOL sl_bUsingDirectSound; BOOL sl_bUsingEAX; +#ifdef PLATFORM_WIN32 + INDEX sl_ctWaveDevices; // number of devices detected HWAVEOUT sl_hwoWaveOut; // wave out handle CStaticStackArray sl_ahwoExtra; // preventively taken channels @@ -78,8 +79,10 @@ public: LPDIRECTSOUND3DBUFFER sl_pDSSourceLeft; LPDIRECTSOUND3DBUFFER sl_pDSSourceRight; - UBYTE *sl_pubBuffersMemory; // memory allocated for the sound buffer(s) output CStaticArray sl_awhWOBuffers; // the waveout buffers +#endif + + UBYTE *sl_pubBuffersMemory; // memory allocated for the sound buffer(s) output SoundFormat sl_EsfFormat; // sound format (external) WAVEFORMATEX sl_SwfeFormat; // primary sound buffer format @@ -91,12 +94,6 @@ public: CListHead sl_ClhAwareList; // list of sound mode aware objects CListHead sl_lhActiveListeners; // active listeners for current frame of listening -#else - - SoundFormat sl_EsfFormat; - -#endif - /* Return library state (active <==> format <> NONE */ inline BOOL IsActive(void) {return sl_EsfFormat != SF_NONE;}; /* Clear Library WaveOut */ diff --git a/Sources/Engine/Sound/SoundMixer.cpp b/Sources/Engine/Sound/SoundMixer.cpp index 88a161f..66f414e 100644 --- a/Sources/Engine/Sound/SoundMixer.cpp +++ b/Sources/Engine/Sound/SoundMixer.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -17,9 +17,6 @@ #define W word ptr #define B byte ptr -#define ASMOPT 1 - - // console variables for volume extern FLOAT snd_fSoundVolume; extern FLOAT snd_fMusicVolume; @@ -29,26 +26,29 @@ extern INDEX snd_bMono; // a bunch of local vars coming up static SLONG slMixerBufferSampleRate; // quality of destination buffer -static SLONG slMixerBufferSize; // size in samples per channel of the destination buffers -static void *pvMixerBuffer; // pointer to the start of the destination buffers - static CSoundData *psd; -static SWORD *pswSrcBuffer; -static SLONG slLeftVolume, slRightVolume, slLeftFilter, slRightFilter; -static SLONG slLastLeftSample, slLastRightSample, slSoundBufferSize; -static FLOAT fSoundSampleRate, fPhase; -static FLOAT fOfsDelta, fStep, fLeftStep, fRightStep, fLeftOfs, fRightOfs; -static __int64 fixLeftOfs, fixRightOfs; // fixed integers 32:32 -static __int64 mmSurroundFactor, mmLeftStep, mmRightStep, mmVolumeGain; -static BOOL bNotLoop, bEndOfSound; -static const FLOAT f65536 = 65536.0f; -static const FLOAT f4G = 4294967296.0f; +// nasm on MacOS X is getting wrong addresses of external globals, so I have +// to define them in the .asm file...lame. +#ifdef __GNU_INLINE__ +#define INASM extern +#else +#define INASM static static __int64 mmInvFactor = 0x00007FFF00007FFF; -static __int64 mmMaskLD = 0x00000000FFFFFFFF; -static __int64 mmUnsign2Sign = 0x8000800080008000; - +static FLOAT f65536 = 65536.0f; +static FLOAT f4G = 4294967296.0f; +#endif +INASM SLONG slMixerBufferSize; // size in samples per channel of the destination buffers +INASM void *pvMixerBuffer; // pointer to the start of the destination buffers +INASM SWORD *pswSrcBuffer; +INASM SLONG slLeftVolume, slRightVolume, slLeftFilter, slRightFilter; +INASM SLONG slLastLeftSample, slLastRightSample, slSoundBufferSize; +INASM FLOAT fSoundSampleRate, fPhase; +INASM FLOAT fOfsDelta, fStep, fLeftStep, fRightStep, fLeftOfs, fRightOfs; +INASM __int64 fixLeftOfs, fixRightOfs; // fixed integers 32:32 +INASM __int64 mmSurroundFactor, mmLeftStep, mmRightStep, mmVolumeGain; +INASM BOOL bNotLoop, bEndOfSound; // reset mixer buffer (wipes it with zeroes and remembers pointers in static mixer variables) void ResetMixer( const SLONG *pslBuffer, const SLONG slBufferSize) @@ -64,6 +64,11 @@ void ResetMixer( const SLONG *pslBuffer, const SLONG slBufferSize) slMixerBufferSampleRate = _pSound->sl_SwfeFormat.nSamplesPerSec; // wipe destination mixer buffer + // (Mac OS X uses this path because Apple's memset() is customized for each CPU they support and way faster than this inline asm. --ryan.) + #if ((defined USE_PORTABLE_C) || (PLATFORM_MACOSX)) + memset(pvMixerBuffer, '\0', slMixerBufferSize * 8); + + #elif (defined __MSVC_INLINE__) __asm { cld xor eax,eax @@ -72,15 +77,33 @@ void ResetMixer( const SLONG *pslBuffer, const SLONG slBufferSize) shl ecx,1 // *2 because of 32-bit src format rep stosd } + #elif (defined __GNU_INLINE__) + // !!! FIXME : rcg12172001 Is this REALLY any faster than memset()? + __asm__ __volatile__ ( + "cld \n\t" + "rep \n\t" + "stosl \n\t" + : // no outputs. + : "a" (0), "D" (pvMixerBuffer), "c" (slMixerBufferSize*2) + : "cc", "memory" + ); + #else + #error please write inline asm for your platform. + #endif } // copy mixer buffer to the output buffer(s) -void CopyMixerBuffer_stereo( const SLONG slSrcOffset, const void *pDstBuffer, const SLONG slBytes) +void CopyMixerBuffer_stereo( const SLONG slSrcOffset, void *pDstBuffer, const SLONG slBytes) { ASSERT( pDstBuffer!=NULL); ASSERT( slBytes%4==0); if( slBytes<4) return; + + #if ((defined USE_PORTABLE_C) || (PLATFORM_MACOSX)) + // (Mac OS X uses this path because Apple's memset() is customized for each CPU they support and way faster than this inline asm. --ryan.) + memcpy(pDstBuffer, ((const char *)pvMixerBuffer) + slSrcOffset, slBytes); + #elif (defined __MSVC_INLINE__) __asm { cld mov esi,D [slSrcOffset] @@ -90,15 +113,43 @@ void CopyMixerBuffer_stereo( const SLONG slSrcOffset, const void *pDstBuffer, co shr ecx,2 // bytes to samples per channel rep movsd } + #elif (defined __GNU_INLINE__) + // !!! FIXME : rcg12172001 Is this REALLY any faster than memcpy()? + __asm__ __volatile__ ( + "cld \n\t" + "rep \n\t" + "movsl \n\t" + : // no outputs. + : "S" (((char *)pvMixerBuffer) + slSrcOffset), + "D" (pDstBuffer), + "c" (slBytes >> 2) + : "cc", "memory" + ); + #else + #error please write inline asm for your platform. + #endif } // copy one channel from mixer buffer to the output buffer(s) -void CopyMixerBuffer_mono( const SLONG slSrcOffset, const void *pDstBuffer, const SLONG slBytes) +void CopyMixerBuffer_mono( const SLONG slSrcOffset, void *pDstBuffer, const SLONG slBytes) { ASSERT( pDstBuffer!=NULL); ASSERT( slBytes%2==0); if( slBytes<4) return; + + #if (defined USE_PORTABLE_C) + // (This is untested, currently. --ryan.) + WORD *dest = (WORD *) pDstBuffer; + DWORD *src = (DWORD *) ( ((char *) pvMixerBuffer) + slSrcOffset ); + SLONG max = slBytes / 4; + for (SLONG i = 0; i < max; i++) { + *dest = *((WORD *) src); + dest++; // move 16 bits. + src++; // move 32 bits. + } + + #elif (defined __MSVC_INLINE__) __asm { mov esi,D [slSrcOffset] add esi,D [pvMixerBuffer] @@ -113,6 +164,26 @@ copyLoop: dec ecx jnz copyLoop } + + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "0: \n\t" // copyLoop + "movzwl (%%esi), %%eax \n\t" + "movw %%ax, (%%edi) \n\t" + "addl $4, %%esi \n\t" + "addl $2, %%edi \n\t" + "decl %%ecx \n\t" + "jnz 0b \n\t" // copyLoop + : // no outputs. + : "S" (((char *)pvMixerBuffer) + slSrcOffset), + "D" (pDstBuffer), + "c" (slBytes >> 2) + : "cc", "memory", "eax" + ); + + #else + #error please write inline asm for your platform. + #endif } @@ -121,6 +192,11 @@ static void ConvertMixerBuffer( const SLONG slBytes) { ASSERT( slBytes%4==0); if( slBytes<4) return; + + #if (defined USE_PORTABLE_C) + STUBBED("ConvertMixerBuffer"); + + #elif (defined __MSVC_INLINE__) __asm { cld mov esi,D [pvMixerBuffer] @@ -137,6 +213,27 @@ copyLoop: jnz copyLoop emms } + + #elif (defined __GNU_INLINE__) + __asm__ __volatile__ ( + "cld \n\t" + "0: \n\t" // copyLoop + "movq (%%esi), %%mm0 \n\t" + "packssdw %%mm0, %%mm0 \n\t" + "movd %%mm0, (%%edi) \n\t" + "addl $8, %%esi \n\t" + "addl $4, %%edi \n\t" + "decl %%ecx \n\t" + "jnz 0b \n\t" // copyLoop + "emms \n\t" + : // no outputs. + : "S" (pvMixerBuffer), "D" (pvMixerBuffer), "c" (slBytes >> 2) + : "cc", "memory" + ); + + #else + #error please write inline asm for your platform. + #endif } @@ -187,14 +284,95 @@ void NormalizeMixerBuffer( const FLOAT fNormStrength, const SLONG slBytes, FLOAT } +#ifdef __GNU_INLINE__ +// These are implemented in an external NASM file. +extern "C" { + void MixStereo_asm(CSoundObject *pso); + void MixMono_asm(CSoundObject *pso); +} +#endif + // mixes one mono 16-bit signed sound to destination buffer inline void MixMono( CSoundObject *pso) { _pfSoundProfile.StartTimer(CSoundProfile::PTI_RAWMIXER); -#if ASMOPT == 1 + #if (defined USE_PORTABLE_C) + // initialize some local vars + SLONG slLeftSample, slRightSample, slNextSample; + SLONG *pslDstBuffer = (SLONG*)pvMixerBuffer; + fixLeftOfs = (__int64)(fLeftOfs * 65536.0); + fixRightOfs = (__int64)(fRightOfs * 65536.0); + __int64 fixLeftStep = (__int64)(fLeftStep * 65536.0); + __int64 fixRightStep = (__int64)(fRightStep * 65536.0); + __int64 fixSoundBufferSize = ((__int64)slSoundBufferSize)<<16; + mmSurroundFactor = (__int64)(SWORD)mmSurroundFactor; + // loop thru source buffer + INDEX iCt = slMixerBufferSize; + FOREVER + { + // if left channel source sample came to end of sample buffer + if( fixLeftOfs >= fixSoundBufferSize) { + fixLeftOfs -= fixSoundBufferSize; + // if has no loop, end it + bEndOfSound = bNotLoop; + } + // if right channel source sample came to end of sample buffer + if( fixRightOfs >= fixSoundBufferSize) { + fixRightOfs -= fixSoundBufferSize; + // if has no loop, end it + bEndOfSound = bNotLoop; + } + // end of buffer? + if( iCt<=0 || bEndOfSound) break; + + // fetch one lineary interpolated sample on left channel + slLeftSample = pswSrcBuffer[(fixLeftOfs>>16)+0]; + slNextSample = pswSrcBuffer[(fixLeftOfs>>16)+1]; + slLeftSample = (slLeftSample*(65535-(fixLeftOfs&65535)) + slNextSample*(fixLeftOfs&65535)) >>16; + // fetch one lineary interpolated sample on right channel + slRightSample = pswSrcBuffer[(fixRightOfs>>16)+0]; + slNextSample = pswSrcBuffer[(fixRightOfs>>16)+1]; + slRightSample = (slRightSample*(65535-(fixRightOfs&65535)) + slNextSample*(fixRightOfs&65535)) >>16; + + // filter samples + slLastLeftSample += ((slLeftSample -slLastLeftSample) *slLeftFilter) >>15; + slLastRightSample += ((slRightSample-slLastRightSample)*slRightFilter)>>15; + + // apply stereo volume to current sample + slLeftSample = (slLastLeftSample * slLeftVolume) >>15; + slRightSample = (slLastRightSample * slRightVolume)>>15; + + slRightSample = slRightSample ^ mmSurroundFactor; + + // mix in current sample + slLeftSample += pslDstBuffer[0]; + slRightSample += pslDstBuffer[1]; + // upper clamp + if( slLeftSample > MAX_SWORD) slLeftSample = MAX_SWORD; + if( slRightSample > MAX_SWORD) slRightSample = MAX_SWORD; + // lower clamp + if( slLeftSample < MIN_SWORD) slLeftSample = MIN_SWORD; + if( slRightSample < MIN_SWORD) slRightSample = MIN_SWORD; + + // store samples (both channels) + pslDstBuffer[0] = slLeftSample; + pslDstBuffer[1] = slRightSample; + + // modify volume ` + slLeftVolume += (SWORD)((mmVolumeGain>> 0)&0xFFFF); + slRightVolume += (SWORD)((mmVolumeGain>>16)&0xFFFF); + + // advance to next sample + fixLeftOfs += fixLeftStep; + fixRightOfs += fixRightStep; + pslDstBuffer += 4; + iCt--; + } + + #elif (defined __MSVC_INLINE__) __asm { // convert from floats to fixints 32:16 fld D [fLeftOfs] @@ -327,82 +505,13 @@ loopEnd: emms } -#else + #elif (defined __GNU_INLINE__) + // This is implemented in an external NASM file. + MixMono_asm(pso); - // initialize some local vars - SLONG slLeftSample, slRightSample, slNextSample; - SLONG *pslDstBuffer = (SLONG*)pvMixerBuffer; - fixLeftOfs = (__int64)(fLeftOfs * 65536.0); - fixRightOfs = (__int64)(fRightOfs * 65536.0); - __int64 fixLeftStep = (__int64)(fLeftStep * 65536.0); - __int64 fixRightStep = (__int64)(fRightStep * 65536.0); - __int64 fixSoundBufferSize = ((__int64)slSoundBufferSize)<<16; - mmSurroundFactor = (__int64)(SWORD)mmSurroundFactor; - - // loop thru source buffer - INDEX iCt = slMixerBufferSize; - FOREVER - { - // if left channel source sample came to end of sample buffer - if( fixLeftOfs >= fixSoundBufferSize) { - fixLeftOfs -= fixSoundBufferSize; - // if has no loop, end it - bEndOfSound = bNotLoop; - } - // if right channel source sample came to end of sample buffer - if( fixRightOfs >= fixSoundBufferSize) { - fixRightOfs -= fixSoundBufferSize; - // if has no loop, end it - bEndOfSound = bNotLoop; - } - // end of buffer? - if( iCt<=0 || bEndOfSound) break; - - // fetch one lineary interpolated sample on left channel - slLeftSample = pswSrcBuffer[(fixLeftOfs>>16)+0]; - slNextSample = pswSrcBuffer[(fixLeftOfs>>16)+1]; - slLeftSample = (slLeftSample*(65535-(fixLeftOfs&65535)) + slNextSample*(fixLeftOfs&65535)) >>16; - // fetch one lineary interpolated sample on right channel - slRightSample = pswSrcBuffer[(fixRightOfs>>16)+0]; - slNextSample = pswSrcBuffer[(fixRightOfs>>16)+1]; - slRightSample = (slRightSample*(65535-(fixRightOfs&65535)) + slNextSample*(fixRightOfs&65535)) >>16; - - // filter samples - slLastLeftSample += ((slLeftSample -slLastLeftSample) *slLeftFilter) >>15; - slLastRightSample += ((slRightSample-slLastRightSample)*slRightFilter)>>15; - - // apply stereo volume to current sample - slLeftSample = (slLastLeftSample * slLeftVolume) >>15; - slRightSample = (slLastRightSample * slRightVolume)>>15; - - slRightSample = slRightSample ^ mmSurroundFactor; - - // mix in current sample - slLeftSample += pslDstBuffer[0]; - slRightSample += pslDstBuffer[1]; - // upper clamp - if( slLeftSample > MAX_SWORD) slLeftSample = MAX_SWORD; - if( slRightSample > MAX_SWORD) slRightSample = MAX_SWORD; - // lower clamp - if( slLeftSample < MIN_SWORD) slLeftSample = MIN_SWORD; - if( slRightSample < MIN_SWORD) slRightSample = MIN_SWORD; - - // store samples (both channels) - pslDstBuffer[0] = slLeftSample; - pslDstBuffer[1] = slRightSample; - - // modify volume ` - slLeftVolume += (SWORD)((mmVolumeGain>> 0)&0xFFFF); - slRightVolume += (SWORD)((mmVolumeGain>>16)&0xFFFF); - - // advance to next sample - fixLeftOfs += fixLeftStep; - fixRightOfs += fixRightStep; - pslDstBuffer += 4; - iCt--; - } - -#endif + #else + #error please write inline asm for your platform. + #endif _pfSoundProfile.StopTimer(CSoundProfile::PTI_RAWMIXER); } @@ -413,8 +522,10 @@ inline void MixStereo( CSoundObject *pso) { _pfSoundProfile.StartTimer(CSoundProfile::PTI_RAWMIXER); -#if ASMOPT == 1 + #if (defined USE_PORTABLE_C) + STUBBED("MixStereo"); + #elif (defined __MSVC_INLINE__) __asm { // convert from floats to fixints 32:16 fld D [fLeftOfs] @@ -549,7 +660,13 @@ loopEnd: emms } -#endif + #elif (defined __GNU_INLINE__) + // This is implemented in an external NASM file. + MixStereo_asm(pso); + + #else + #error please write inline asm for your platform. + #endif _pfSoundProfile.StopTimer(CSoundProfile::PTI_RAWMIXER); } @@ -619,7 +736,7 @@ void MixSound( CSoundObject *pso) pso->so_fRightOffset += fOfsDelta; const FLOAT fMinOfs = Min( pso->so_fLeftOffset, pso->so_fRightOffset); ASSERT( fMinOfs>=0); - if( fMinOfs<0) CPrintF( "BUG: negative offset (%.2g) encountered in sound: '%s' !\n", fMinOfs, (CTString&)psd->GetName()); + if( fMinOfs<0) CPrintF( "BUG: negative offset (%.2g) encountered in sound: '%s' !\n", fMinOfs, (const char *) (CTString&)psd->GetName()); // if looping if (pso->so_slFlags & SOF_LOOP) { // adjust offset ptrs inside sound @@ -745,7 +862,7 @@ void MixSound( CSoundObject *pso) // safety check (needed because of bad-bug!) FLOAT fMinOfs = Min( fLeftOfs, fRightOfs); ASSERT( fMinOfs>=0); - if( fMinOfs<0) CPrintF( "BUG: negative offset (%.2g) encountered in sound: '%s' !\n", fMinOfs, (CTString&)psd->GetName()); + if( fMinOfs<0) CPrintF( "BUG: negative offset (%.2g) encountered in sound: '%s' !\n", fMinOfs, (const char *) (CTString&)psd->GetName()); // adjust offset ptrs inside sound to match those of phase shift while( fLeftOfs < 0) fLeftOfs += slSoundBufferSize; while( fRightOfs < 0) fRightOfs += slSoundBufferSize; diff --git a/Sources/Engine/Sound/SoundMixer386.asm b/Sources/Engine/Sound/SoundMixer386.asm new file mode 100644 index 0000000..9231c0c --- /dev/null +++ b/Sources/Engine/Sound/SoundMixer386.asm @@ -0,0 +1,372 @@ +; /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ +; +; ------- YOU DO NOT NEED THIS FILE UNDER WIN32 AT THE MOMENT. ------- +; +; Chances are, you will need NASM (http://www.octium.net/nasm/) to assemble +; this file. +; +; If we were smart, we'd move all the inline asm to similar files, which +; cleans up the C, and makes the assembly (ahem) more portable. NASM can +; generate Visual C compatible object files as well as Linux ELF and Intel +; Mac Mach-O binaries. +; +; --ryan. + +; asm shortcuts +%define O offset +%define Q qword +%define D dword +%define W word +%define B byte + +%define TRUE 1 +%define FALSE 0 + +; ************************ +; ** Start Data Block ** +; ************************ +SECTION .data + +global slMixerBufferSize +global bEndOfSound +global bNotLoop +global fLeftOfs +global fLeftStep +global fOfsDelta +global fPhase +global fRightOfs +global fRightStep +global fSoundSampleRate +global fStep +global fixLeftOfs +global fixRightOfs +global mmSurroundFactor +global mmVolumeGain +global pswSrcBuffer +global pvMixerBuffer +global slLastLeftSample +global slLastRightSample +global slLeftFilter +global slLeftVolume +global slRightFilter +global slRightVolume +global slSoundBufferSize + +slMixerBufferSize dd 0 +pvMixerBuffer dd 0 +pswSrcBuffer dd 0 +slLeftVolume dd 0 +slRightVolume dd 0 +slLeftFilter dd 0 +slRightFilter dd 0 +slLastLeftSample dd 0 +slLastRightSample dd 0 +slSoundBufferSize dd 0 +fSoundSampleRate dd 0 +fPhase dd 0 +fOfsDelta dd 0 +fStep dd 0 +fLeftStep dd 0 +fRightStep dd 0 +fLeftOfs dd 0 +fRightOfs dd 0 +fixLeftOfs dd 0, 0 +fixRightOfs dd 0, 0 +mmSurroundFactor dd 0, 0 +mmLeftStep dd 0, 0 +mmRightStep dd 0, 0 +mmVolumeGain dd 0, 0 +mmInvFactor dd 0x00007FFF, 0x00007FFF +bNotLoop dd 0 +bEndOfSound dd 0 +f65536 dd 65536.0 +f4G dd 4294967296.0 + + +; ************************ +; ** End Data Block ** +; ************************ + + +; ************************ +; ** Start Code Block ** +; ************************ +SEGMENT .text + +global MixMono_asm +MixMono_asm: + push ebx ; Save GCC register. + ; convert from floats to fixints 32:16 + fld D [fLeftOfs] + fmul D [f65536] + fld D [fRightOfs] + fmul D [f65536] + fld D [fLeftStep] + fmul D [f65536] + fld D [fRightStep] + fmul D [f4G] + fistp Q [mmRightStep] ; fixint 32:32 + fistp Q [mmLeftStep] ; fixint 32:16 + fistp Q [fixRightOfs] ; fixint 32:16 + fistp Q [fixLeftOfs] ; fixint 32:16 + + ; get last played sample (for filtering purposes) + movzx eax,W [slLastRightSample] + movzx edx,W [slLastLeftSample] + shl eax,16 + or eax,edx + movd mm6,eax ; MM6 = 0 | 0 || lastRightSample | lastLeftSample + + ; get volume + movd mm5,D [slRightVolume] + movd mm0,D [slLeftVolume] + psllq mm5,32 + por mm5,mm0 ; MM5 = rightVolume || leftVolume + + ; get filter + mov eax,D [slRightFilter] + mov edx,D [slLeftFilter] + shl eax,16 + or eax,edx + movd mm7,eax ; MM7 = 0 | 0 || rightFilter | leftFilter + + ; get offset of each channel inside sound and loop thru destination buffer + mov W [mmRightStep],0 + movzx eax,W [fixLeftOfs] + movzx edx,W [fixRightOfs] + shl edx,16 + or eax,edx ; EAX = right ofs frac | left ofs frac + mov ebx,D [fixLeftOfs+2] ; EBX = left ofs int + mov edx,D [fixRightOfs+2] ; EDX = right ofs int + mov esi,D [pswSrcBuffer] ; ESI = source sound buffer start ptr + mov edi,D [pvMixerBuffer] ; EDI = mixer buffer ptr + mov ecx,D [slMixerBufferSize] ; ECX = samples counter + +sampleLoop_MixMono: + ; check if source offsets came to the end of source sound buffer + cmp ebx,D [slSoundBufferSize] + jl lNotEnd_MixMono + sub ebx,D [slSoundBufferSize] + push D [bNotLoop] + pop D [bEndOfSound] +lNotEnd_MixMono: + ; same for right channel + cmp edx,D [slSoundBufferSize] + jl rNotEnd_MixMono + sub edx,D [slSoundBufferSize] + push D [bNotLoop] + pop D [bEndOfSound] +rNotEnd_MixMono: + + ; check end of sample + cmp ecx,0 + jle near loopEnd_MixMono + cmp D [bEndOfSound],TRUE + je near loopEnd_MixMono + + ; get sound samples + movd mm1,D [esi+ ebx*2] ; MM1 = 0 | 0 || nextLeftSample | leftSample + movd mm2,D [esi+ edx*2] ; MM2 = 0 | 0 || nextRightSample | RightSample + psllq mm2,32 + por mm1,mm2 ; MM1 = nextRightSample | rightSample || nextLeftSample | leftSample + + ; calc linear interpolation factor (strength) + movd mm3,eax ; MM3 = 0 | 0 || right frac | left frac + punpcklwd mm3,mm3 + psrlw mm3,1 ; MM3 = rightFrac | rightFrac || leftFrac | leftFrac + pxor mm3,Q [mmInvFactor] ; MM3 = rightFrac | 1-rightFrac || leftFrac | 1-leftFrac + ; apply linear interpolation + pmaddwd mm1,mm3 + psrad mm1,15 + packssdw mm1,mm1 ; MM1 = ? | ? || linearRightSample | linearLeftSample + + ; apply filter + psubsw mm1,mm6 + pmulhw mm1,mm7 + psllw mm1,1 + paddsw mm1,mm6 + movq mm6,mm1 + + ; apply volume adjustment + movq mm0,mm5 + psrad mm0,16 + packssdw mm0,mm0 + pmulhw mm1,mm0 + psllw mm1,1 + pxor mm1,Q [mmSurroundFactor] + paddd mm5,Q [mmVolumeGain] ; modify volume + + ; unpack to 32bit and mix it into destination buffer + punpcklwd mm1,mm1 + psrad mm1,16 ; MM1 = finalRightSample || finalLeftSample + paddd mm1,Q [edi] + movq Q [edi],mm1 + + ; advance to next samples in source sound + add eax,D [mmRightStep+0] + adc edx,D [mmRightStep+4] + add ax,W [mmLeftStep +0] + adc ebx,D [mmLeftStep +2] + add edi,8 + dec ecx + jmp sampleLoop_MixMono + +loopEnd_MixMono: + ; store modified asm local vars + mov D [fixLeftOfs +0],eax + shr eax,16 + mov D [fixRightOfs+0],eax + mov D [fixLeftOfs +2],ebx + mov D [fixRightOfs+2],edx + movd eax,mm6 + mov edx,eax + and eax,0x0000FFFF + shr edx,16 + mov D [slLastLeftSample],eax + mov D [slLastRightSample],edx + pop ebx ; Restore GCC register. + emms + ret + + +global MixStereo_asm +MixStereo_asm: + push ebx ; Save GCC register. + ; convert from floats to fixints 32:16 + fld D [fLeftOfs] + fmul D [f65536] + fld D [fRightOfs] + fmul D [f65536] + fld D [fLeftStep] + fmul D [f65536] + fld D [fRightStep] + fmul D [f4G] + fistp Q [mmRightStep] ; fixint 32:32 + fistp Q [mmLeftStep] ; fixint 32:16 + fistp Q [fixRightOfs] ; fixint 32:16 + fistp Q [fixLeftOfs] ; fixint 32:16 + + ; get last played sample (for filtering purposes) + movzx eax,W [slLastRightSample] + movzx edx,W [slLastLeftSample] + shl eax,16 + or eax,edx + movd mm6,eax ; MM6 = 0 | 0 || lastRightSample | lastLeftSample + + ; get volume + movd mm5,D [slRightVolume] + movd mm0,D [slLeftVolume] + psllq mm5,32 + por mm5,mm0 ; MM5 = rightVolume || leftVolume + + ; get filter + mov eax,D [slRightFilter] + mov edx,D [slLeftFilter] + shl eax,16 + or eax,edx + movd mm7,eax ; MM7 = 0 | 0 || rightFilter | leftFilter + + ; get offset of each channel inside sound and loop thru destination buffer + mov W [mmRightStep],0 + movzx eax,W [fixLeftOfs] + movzx edx,W [fixRightOfs] + shl edx,16 + or eax,edx ; EAX = right ofs frac | left ofs frac + mov ebx,D [fixLeftOfs+2] ; EBX = left ofs int + mov edx,D [fixRightOfs+2] ; EDX = right ofs int + mov esi,D [pswSrcBuffer] ; ESI = source sound buffer start ptr + mov edi,D [pvMixerBuffer] ; EDI = mixer buffer ptr + mov ecx,D [slMixerBufferSize] ; ECX = samples counter + +sampleLoop_MixStereo: + ; check if source offsets came to the end of source sound buffer + cmp ebx,D [slSoundBufferSize] + jl lNotEnd_MixStereo + sub ebx,D [slSoundBufferSize] + push D [bNotLoop] + pop D [bEndOfSound] +lNotEnd_MixStereo: + ; same for right channel + cmp edx,D [slSoundBufferSize] + jl rNotEnd_MixStereo + sub edx,D [slSoundBufferSize] + push D [bNotLoop] + pop D [bEndOfSound] +rNotEnd_MixStereo: + + ; check end of sample + cmp ecx,0 + jle near loopEnd_MixStereo + cmp D [bEndOfSound],TRUE + je near loopEnd_MixStereo + + ; get sound samples + movq mm1,Q [esi+ ebx*4] + movq mm2,Q [esi+ edx*4] + pslld mm1,16 + psrad mm1,16 ; MM1 = 0 | nextLeftSample || 0 | leftSample + psrad mm2,16 ; MM2 = 0 | nextRightSample || 0 | rightSample + packssdw mm1,mm2 ; MM1 = nextRightSample | rightSample || nextLeftSample | leftSample + + ; calc linear interpolation factor (strength) + movd mm3,eax ; MM3 = 0 | 0 || right frac | left frac + punpcklwd mm3,mm3 + psrlw mm3,1 ; MM3 = rightFrac | rightFrac || leftFrac | leftFrac + pxor mm3,Q [mmInvFactor] ; MM3 = rightFrac | 1-rightFrac || leftFrac | 1-leftFrac + ; apply linear interpolation + pmaddwd mm1,mm3 + psrad mm1,15 + packssdw mm1,mm1 ; MM1 = ? | ? || linearRightSample | linearLeftSample + + ; apply filter + psubsw mm1,mm6 + pmulhw mm1,mm7 + psllw mm1,1 + paddsw mm1,mm6 + movq mm6,mm1 + + ; apply volume adjustment + movq mm0,mm5 + psrad mm0,16 + packssdw mm0,mm0 + pmulhw mm1,mm0 + psllw mm1,1 + pxor mm1,Q [mmSurroundFactor] + paddd mm5,Q [mmVolumeGain] ; modify volume + + ; unpack to 32bit and mix it into destination buffer + punpcklwd mm1,mm1 + psrad mm1,16 ; MM1 = finalRightSample || finalLeftSample + paddd mm1,Q [edi] + movq Q [edi],mm1 + + ; advance to next samples in source sound + add eax,D [mmRightStep+0] + adc edx,D [mmRightStep+4] + add ax,W [mmLeftStep +0] + adc ebx,D [mmLeftStep +2] + add edi,8 + dec ecx + jmp sampleLoop_MixStereo + +loopEnd_MixStereo: + ; store modified asm local vars + mov D [fixLeftOfs +0],eax + shr eax,16 + mov D [fixRightOfs+0],eax + mov D [fixLeftOfs +2],ebx + mov D [fixRightOfs+2],edx + movd eax,mm6 + mov edx,eax + and eax,0x0000FFFF + shr edx,16 + mov D [slLastLeftSample],eax + mov D [slLastRightSample],edx + emms + pop ebx ; Restore GCC register. + ret + +; ************************ +; ** End Code Block ** +; ************************ + diff --git a/Sources/Engine/Sound/SoundObject.cpp b/Sources/Engine/Sound/SoundObject.cpp index 82d6e2f..e2e53f2 100644 --- a/Sources/Engine/Sound/SoundObject.cpp +++ b/Sources/Engine/Sound/SoundObject.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -51,7 +51,7 @@ static CTString GetPred(CEntity*pen) str1 = "???"; } CTString str; - str.PrintF("%08x-%s", pen, str1); + str.PrintF("%08x-%s", pen, (const char *) str1); return str; } /* ==================================================== @@ -67,7 +67,7 @@ CSoundObject::CSoundObject() so_pCsdLink = NULL; so_psdcDecoder = NULL; so_penEntity = NULL; - so_slFlags = 0; + so_slFlags = SOF_NONE; // clear sound settings so_spNew.sp_fLeftVolume = 1.0f; @@ -94,7 +94,7 @@ CSoundObject::CSoundObject() so_sp3.sp3_fHotSpot = 0.0f; so_sp3.sp3_fMaxVolume = 0.0f; so_sp3.sp3_fPitch = 1.0f; -}; +} /* * Destructor @@ -102,7 +102,7 @@ CSoundObject::CSoundObject() CSoundObject::~CSoundObject() { Stop_internal(); -}; +} // copy from another object of same class void CSoundObject::Copy(CSoundObject &soOther) @@ -143,7 +143,7 @@ void CSoundObject::Set3DParameters( FLOAT fFalloff, FLOAT fHotSpot, pso->so_sp3.sp3_fHotSpot = fHotSpot; pso->so_sp3.sp3_fMaxVolume = fMaxVolume; pso->so_sp3.sp3_fPitch = fPitch; -}; +} /* ==================================================== @@ -308,7 +308,7 @@ void CSoundObject::SetOffset( FLOAT fOffset) // safety check ASSERT( fOffset>=0); if( fOffset<0) { - CPrintF( "BUG: Trying to set negative offset (%.2g) in sound '%s' !\n", fOffset, (CTString&)psoTail->so_pCsdLink->GetName()); + CPrintF( "BUG: Trying to set negative offset (%.2g) in sound '%s' !\n", fOffset, (const char *) (CTString&)psoTail->so_pCsdLink->GetName()); fOffset = 0.0f; } @@ -347,7 +347,7 @@ void CSoundObject::Stop(void) } void CSoundObject::Stop_internal(void) { - // sound is stoped + // sound is stopped so_slFlags &= ~(SOF_PLAY|SOF_PREPARE|SOF_PAUSED); // destroy decoder if exists @@ -365,7 +365,7 @@ void CSoundObject::Stop_internal(void) // clear SoundData link so_pCsdLink = NULL; } -}; +} // Update all 3d effects @@ -446,7 +446,7 @@ void CSoundObject::Update3DEffects(void) ASSERT(fDistanceFactor>=0 && fDistanceFactor<=+1); // calculate volumetric influence - // NOTE: decoded sounds must be threated as volumetric + // NOTE: decoded sounds must be treated as volumetric FLOAT fNonVolumetric = 1.0f; FLOAT fNonVolumetricAdvanced = 1.0f; if( (so_slFlags & SOF_VOLUMETRIC) || so_psdcDecoder!=NULL) { @@ -592,7 +592,7 @@ void CSoundObject::PrepareSound(void) so_fLastLeftVolume *= snd_fSoundVolume; so_fLastRightVolume *= snd_fSoundVolume; } -}; +} // Obtain sound and play it for this object @@ -605,7 +605,7 @@ void CSoundObject::Play_t(const CTFileName &fnmSound, SLONG slFlags) // throw ch // release it (removes one reference) _pSoundStock->Release(ptd); // total reference count +1+1-1 = +1 for new data -1 for old data -}; +} @@ -653,7 +653,7 @@ void CSoundObject::Read_t(CTStream *pistr) // throw char * if ( fnmSound != "" && (so_slFlags&SOF_PLAY)) { Play_t( fnmSound, so_slFlags|SOF_LOADED); } -}; +} void CSoundObject::Write_t(CTStream *pistr) // throw char * { @@ -692,4 +692,5 @@ void CSoundObject::Write_t(CTStream *pistr) // throw char * *pistr << so_sp3.sp3_fHotSpot; *pistr << so_sp3.sp3_fMaxVolume; *pistr << so_sp3.sp3_fPitch; -}; +} + diff --git a/Sources/Engine/Sound/SoundProfile.cpp b/Sources/Engine/Sound/SoundProfile.cpp index a00a2de..efd0c4b 100644 --- a/Sources/Engine/Sound/SoundProfile.cpp +++ b/Sources/Engine/Sound/SoundProfile.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Sound/Wave.cpp b/Sources/Engine/Sound/Wave.cpp index 82dc9e9..7bd4e23 100644 --- a/Sources/Engine/Sound/Wave.cpp +++ b/Sources/Engine/Sound/Wave.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include diff --git a/Sources/Engine/StdH.cpp b/Sources/Engine/StdH.cpp index 95c0896..e975c18 100644 --- a/Sources/Engine/StdH.cpp +++ b/Sources/Engine/StdH.cpp @@ -1,3 +1,4 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ #include "StdH.h" + diff --git a/Sources/Engine/StdH.h b/Sources/Engine/StdH.h index 7a2d829..66dcba0 100644 --- a/Sources/Engine/StdH.h +++ b/Sources/Engine/StdH.h @@ -5,10 +5,8 @@ #define ENGINE_EXPORTS 1 #include -#include #include #include -#include #include #include #include @@ -16,11 +14,17 @@ #include // for qsort #include // for FPU control -#include +#if !PLATFORM_MACOSX +#include +#endif +#ifdef PLATFORM_WIN32 +#include +#include #include #include #include // for timers +#endif #include #include \ No newline at end of file diff --git a/Sources/Engine/Templates/AllocationArray.cpp b/Sources/Engine/Templates/AllocationArray.cpp index 8a100ce..ae98052 100644 --- a/Sources/Engine/Templates/AllocationArray.cpp +++ b/Sources/Engine/Templates/AllocationArray.cpp @@ -77,7 +77,7 @@ inline INDEX CAllocationArray::Allocate(void) // remember old size INDEX ctOldSize = CStaticArray::Count(); // expand the array by the allocation step - Expand(ctOldSize+aa_ctAllocationStep); + this->Expand(ctOldSize+aa_ctAllocationStep); // create new free indices INDEX *piNewFree = aa_aiFreeElements.Push(aa_ctAllocationStep); // fill them up @@ -139,6 +139,10 @@ inline BOOL CAllocationArray::IsAllocated(INDEX i) } /* Random access operator. */ +// rcg10162001 wtf...I had to move this into the class definition itself. +// I think it's an optimization bug; I didn't have this problem when I +// didn't give GCC the "-O2" option. +#if 0 template inline Type &CAllocationArray::operator[](INDEX iObject) { @@ -167,6 +171,8 @@ inline const Type &CAllocationArray::operator[](INDEX iObject) const #endif return CStaticArray::operator[](iObject); } +#endif // 0 + /* Get number of allocated objects in array. */ template INDEX CAllocationArray::Count(void) const @@ -181,7 +187,7 @@ template INDEX CAllocationArray::Index(Type *ptObject) { ASSERT(this!=NULL); - INDEX i = CStaticArray::Index(ptMember); + INDEX i = CStaticArray::Index(this->ptMember); ASSERT(IsAllocated(i)); return i; } diff --git a/Sources/Engine/Templates/AllocationArray.h b/Sources/Engine/Templates/AllocationArray.h index 9a159bd..133b1c1 100644 --- a/Sources/Engine/Templates/AllocationArray.h +++ b/Sources/Engine/Templates/AllocationArray.h @@ -42,8 +42,36 @@ public: inline BOOL IsAllocated(INDEX i); /* Random access operator. */ - inline Type &operator[](INDEX iObject); - inline const Type &operator[](INDEX iObject) const; + inline Type &operator[](INDEX iObject) + { + #ifndef NDEBUG + ASSERT(this!=NULL); + // must be within pool limits + ASSERT(iObject>=0 && iObject::Count()); + // must not be free +// !!! FIXME: rcg10162001 add this back in. +// if (_bAllocationArrayParanoiaCheck) { +// ASSERT(IsAllocated(iObject)); +// } + #endif + return CStaticArray::operator[](iObject); + } + + inline const Type &operator[](INDEX iObject) const + { + #ifndef NDEBUG + ASSERT(this!=NULL); + // must be within pool limits + ASSERT(iObject>=0 && iObject::Count()); + // must not be free +// !!! FIXME: rcg10162001 add this back in. +// if (_bAllocationArrayParanoiaCheck) { +// ASSERT(IsAllocated(iObject)); +// } + #endif + return CStaticArray::operator[](iObject); + } + /* Get number of allocated objects in array. */ INDEX Count(void) const; /* Get index of a object from it's pointer. */ diff --git a/Sources/Engine/Templates/BSP.cpp b/Sources/Engine/Templates/BSP.cpp index 00a618f..5d13d9c 100644 --- a/Sources/Engine/Templates/BSP.cpp +++ b/Sources/Engine/Templates/BSP.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -243,16 +243,6 @@ void BSPVertexContainer::CreateEdges(CDynamicArray -BSPEdge::BSPEdge(const Vector &vVertex0, const Vector &vVertex1, ULONG ulTag) - : bed_vVertex0(vVertex0) - , bed_vVertex1(vVertex1) - , bed_ulEdgeTag(ulTag) -{} - // remove all edges marked for removal template void BSPEdge::RemoveMarkedBSPEdges(CDynamicArray > &abed) @@ -1205,7 +1195,9 @@ void BSPTree::Read_t(CTStream &strm) // throw char * for(INDEX iNode=0; iNode &bn = bt_abnNodes[iNode]; // read it from disk - strm.Read_t(&(Plane&)bn, sizeof(Plane)); + //strm.Read_t(&(Plane&)bn, sizeof(Plane)); + strm >> ((Plane&)bn); + strm>>(INDEX&)bn.bn_bnlLocation; INDEX iFront; @@ -1254,7 +1246,8 @@ void BSPTree::Write_t(CTStream &strm) // throw char * for(INDEX iNode=0; iNode &bn = bt_abnNodes[iNode]; // write it to disk - strm.Write_t(&(Plane&)bn, sizeof(Plane)); + //strm.Write_t(&(Plane&)bn, sizeof(Plane)); + strm << ((Plane&)bn); strm<<(INDEX&)bn.bn_bnlLocation; INDEX iFront; @@ -1283,20 +1276,21 @@ void BSPTree::Write_t(CTStream &strm) // throw char * #pragma warning (disable: 4660) // if already instantiated by some class // remove templates -template DOUBLEbspvertex3D; -template DOUBLEbspvertexcontainer3D; -template DOUBLEbspedge3D; -template DOUBLEbspnode3D; -template DOUBLEbsppolygon3D; -template DOUBLEbsptree3D; -template DOUBLEbspcutter3D; +template class BSPVertex; //DOUBLEbspvertex3D; +template class BSPVertexContainer; +template class BSPEdge; +template class BSPNode; +template class BSPPolygon; +template class BSPTree; +template class BSPCutter; -template FLOATbspvertex3D; -template FLOATbspvertexcontainer3D; -template FLOATbspedge3D; -template FLOATbspnode3D; -template FLOATbsppolygon3D; -template FLOATbsptree3D; -template FLOATbspcutter3D; +template class BSPVertex; +template class BSPVertexContainer; +template class BSPEdge; +template class BSPNode; +template class BSPPolygon; +template class BSPTree; +template class BSPCutter; #pragma warning (default: 4660) + diff --git a/Sources/Engine/Templates/BSP_internal.h b/Sources/Engine/Templates/BSP_internal.h index 36a20bd..4fe5bf1 100644 --- a/Sources/Engine/Templates/BSP_internal.h +++ b/Sources/Engine/Templates/BSP_internal.h @@ -79,7 +79,9 @@ public: /* Default constructor. */ inline BSPEdge(void) {}; /* Constructor with two vectors. */ - inline BSPEdge(const Vector &vVertex0, const Vector &vVertex1, ULONG ulTag); + inline BSPEdge(const Vector &vVertex0, const Vector &vVertex1, ULONG ulTag) + : bed_vVertex0(vVertex0), bed_vVertex1(vVertex1), bed_ulEdgeTag(ulTag) {} + /* Clear the object. */ inline void Clear(void) {}; // remove all edges marked for removal diff --git a/Sources/Engine/Templates/DynamicArray.cpp b/Sources/Engine/Templates/DynamicArray.cpp index 2c18527..84d4ae7 100644 --- a/Sources/Engine/Templates/DynamicArray.cpp +++ b/Sources/Engine/Templates/DynamicArray.cpp @@ -6,6 +6,8 @@ #pragma once #endif +#include + #include #include @@ -100,16 +102,6 @@ void CDynamicArray::Clear(void) { } } -/* Random access operator. */ -template -Type &CDynamicArray::operator[](INDEX iObject) { - return *Pointer(iObject); -}; -template -const Type &CDynamicArray::operator[](INDEX iObject) const { - return *Pointer(iObject); -}; - /* * Grow pointer array by a given number of members. */ diff --git a/Sources/Engine/Templates/DynamicArray.h b/Sources/Engine/Templates/DynamicArray.h index 2b0f106..4a111a1 100644 --- a/Sources/Engine/Templates/DynamicArray.h +++ b/Sources/Engine/Templates/DynamicArray.h @@ -48,8 +48,9 @@ public: Type *Pointer(INDEX iObject); const Type *Pointer(INDEX iObject) const; /* Random access operator. */ - inline Type &operator[](INDEX iObject); - inline const Type &operator[](INDEX iObject) const; + inline Type &operator[](INDEX iObject) { return *Pointer(iObject); } + inline const Type &operator[](INDEX iObject) const { return *Pointer(iObject); } + /* Assignment operator. */ CDynamicArray &operator=(CDynamicArray &arOriginal); /* Move all elements of another array into this one. */ diff --git a/Sources/Engine/Templates/DynamicContainer.cpp b/Sources/Engine/Templates/DynamicContainer.cpp index 3dcd2eb..d035126 100644 --- a/Sources/Engine/Templates/DynamicContainer.cpp +++ b/Sources/Engine/Templates/DynamicContainer.cpp @@ -59,24 +59,7 @@ template void CDynamicContainer::Add(Type *ptNewObject) { // set the new pointer - Push() = ptNewObject; -} - -/* - * Insert a given object to container at specified index. - */ -template -void CDynamicContainer::Insert(Type *ptNewObject, const INDEX iPos/*=0*/) -{ - // get number of member that need moving and add new one - const INDEX ctMovees = CStaticStackArray::Count() - iPos; - CStaticStackArray::Push(); - // move all members after insert position one place up - Type **pptInsertAt = this->sa_Array+iPos; - Type **pptMoveTo = pptInsertAt +1; - memmove( pptMoveTo, pptInsertAt, sizeof(Type*)*ctMovees); - // store pointer to newly inserted member at specified position - *pptInsertAt = ptNewObject; + this->Push() = ptNewObject; } /* @@ -94,8 +77,8 @@ void CDynamicContainer::Remove(Type *ptOldObject) // find its index INDEX iMember=GetIndex(ptOldObject); // move last pointer here - sa_Array[iMember]=sa_Array[Count()-1]; - Pop(); + this->sa_Array[iMember]=this->sa_Array[this->Count()-1]; + this->Pop(); } /* Test if a given object is in the container. */ @@ -105,8 +88,8 @@ BOOL CDynamicContainer::IsMember(Type *ptOldObject) ASSERT(this!=NULL); // slow !!!! // check all members - for (INDEX iMember=0; iMemberCount(); iMember++) { + if(this->sa_Array[iMember]==ptOldObject) { return TRUE; } } @@ -120,23 +103,23 @@ template Type *CDynamicContainer::Pointer(INDEX iMember) { ASSERT(this!=NULL); // check that index is currently valid - ASSERT(iMember>=0 && iMember=0 && iMemberCount()); #if CHECKARRAYLOCKING // check that locked for indices ASSERT(dc_LockCt>0); #endif - return sa_Array[iMember]; + return this->sa_Array[iMember]; } template const Type *CDynamicContainer::Pointer(INDEX iMember) const { ASSERT(this!=NULL); // check that index is currently valid - ASSERT(iMember>=0 && iMember=0 && iMemberCount()); #if CHECKARRAYLOCKING // check that locked for indices ASSERT(dc_LockCt>0); #endif - return sa_Array[iMember]; + return this->sa_Array[iMember]; } /* @@ -185,8 +168,8 @@ INDEX CDynamicContainer::GetIndex(Type *ptMember) { ASSERT(this!=NULL); // slow !!!! // check all members - for (INDEX iMember=0; iMemberCount(); iMember++) { + if(this->sa_Array[iMember]==ptMember) { return iMember; } } @@ -198,8 +181,8 @@ INDEX CDynamicContainer::GetIndex(Type *ptMember) { template Type &CDynamicContainer::GetFirst(void) { - ASSERT(Count()>=1); - return *sa_Array[0]; + ASSERT(this->Count()>=1); + return *this->sa_Array[0]; } /* diff --git a/Sources/Engine/Templates/DynamicContainer.h b/Sources/Engine/Templates/DynamicContainer.h index 9c1defa..e51ac2f 100644 --- a/Sources/Engine/Templates/DynamicContainer.h +++ b/Sources/Engine/Templates/DynamicContainer.h @@ -31,8 +31,6 @@ public: /* Add a given object to container. */ void Add(Type *ptNewObject); - /* Insert a given object to container at specified index. */ - void Insert(Type *ptNewObject, const INDEX iPos=0); /* Remove a given object from container. */ void Remove(Type *ptOldObject); /* Remove all objects, and reset the container to initial (empty) state. */ diff --git a/Sources/Engine/Templates/DynamicStackArray.cpp b/Sources/Engine/Templates/DynamicStackArray.cpp index 65f2367..a58b1f2 100644 --- a/Sources/Engine/Templates/DynamicStackArray.cpp +++ b/Sources/Engine/Templates/DynamicStackArray.cpp @@ -79,8 +79,8 @@ inline Type *CDynamicStackArray::Push(INDEX ct) { template inline void CDynamicStackArray::PopAll(void) { // if there is only one block allocated - if ( da_BlocksList.IsEmpty() - || &da_BlocksList.Head()==&da_BlocksList.Tail()) { + if ( this->da_BlocksList.IsEmpty() + || &this->da_BlocksList.Head()==&this->da_BlocksList.Tail()) { // just clear the counter da_ctUsed = 0; @@ -138,7 +138,7 @@ INDEX CDynamicStackArray::Index(Type *ptMember) { template Type **CDynamicStackArray::GetArrayOfPointers(void) { - return da_Pointers; + return this->da_Pointers; } /* diff --git a/Sources/Engine/Templates/NameTable_CTFileName.cpp b/Sources/Engine/Templates/NameTable_CTFileName.cpp index aa01a1a..282d91d 100644 --- a/Sources/Engine/Templates/NameTable_CTFileName.cpp +++ b/Sources/Engine/Templates/NameTable_CTFileName.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Templates/NameTable_CTranslationPair.cpp b/Sources/Engine/Templates/NameTable_CTranslationPair.cpp index baf5562..b7d4ae0 100644 --- a/Sources/Engine/Templates/NameTable_CTranslationPair.cpp +++ b/Sources/Engine/Templates/NameTable_CTranslationPair.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Templates/Selection.cpp b/Sources/Engine/Templates/Selection.cpp index 597135c..6c8388c 100644 --- a/Sources/Engine/Templates/Selection.cpp +++ b/Sources/Engine/Templates/Selection.cpp @@ -66,10 +66,13 @@ void CSelection::Clear(void) // for all objects in the container FOREACHINDYNAMICCONTAINER(*this, cType, itObject) { // object must be allocated and valid + #ifdef _MSC_VER ASSERT(_CrtIsValidPointer(&*itObject, sizeof(cType), TRUE)); -/* ASSERT(_CrtIsValidHeapPointer(&*itObject)); + /* + ASSERT(_CrtIsValidHeapPointer(&*itObject)); ASSERT(_CrtIsMemoryBlock(&*itObject, sizeof(cType), NULL, NULL, NULL )); */ + #endif // deselect it itObject->Deselect(ulFlag); @@ -81,7 +84,7 @@ void CSelection::Clear(void) template cType *CSelection::GetFirstInSelection(void) { - if( Count() == 0) + if( this->Count() == 0) { return NULL; } diff --git a/Sources/Engine/Templates/StaticArray.cpp b/Sources/Engine/Templates/StaticArray.cpp index ff62e8d..d7792d8 100644 --- a/Sources/Engine/Templates/StaticArray.cpp +++ b/Sources/Engine/Templates/StaticArray.cpp @@ -9,30 +9,8 @@ #define FOREACHINSTATICARRAY(array, type, iter) \ for(CStaticArrayIterator iter(array); !iter.IsPastEnd(); iter.MoveToNext() ) -#include #include -/* - * Default constructor. - */ -template -inline CStaticArray::CStaticArray(void) { - sa_Count=0; - sa_Array=NULL; -} - -/* - * Destructor. - */ -template -inline CStaticArray::~CStaticArray(void) { - // if some objects were allocated - if (sa_Count!=0) { - // destroy them - Delete(); - } -}; - /* Random access operator. */ template inline void CStaticArray::operator=(const CStaticArray &arOriginal) { @@ -56,16 +34,7 @@ inline void CStaticArray::New(INDEX iCount) { // do nothing return; } - //ASSERT(sa_Count==0 && sa_Array==NULL); -#ifndef NDEBUG - if(!(sa_Count==0 && sa_Array==NULL)) { - if(sa_Array == NULL) { - CPrintF("CStaticArray array not set!\n"); - } else { - CPrintF("CStaticArray new(%d) called while already holding %d elements!\n", iCount, sa_Count); - } - } -#endif + ASSERT(sa_Count==0 && sa_Array==NULL); sa_Count = iCount; sa_Array = new Type[iCount+1]; //(+1 for cache-prefetch opt) }; @@ -96,21 +65,13 @@ inline void CStaticArray::Expand(INDEX iNewCount) } } -/* - * Destroy all objects. - */ -template -inline void CStaticArray::Delete(void) { - ASSERT(this!=NULL); - ASSERT(sa_Count!=0 && sa_Array!=NULL); - delete[] sa_Array; - sa_Count = 0; - sa_Array = NULL; -} - /* * Random access operator. */ +// rcg10162001 wtf...I had to move this into the class definition itself. +// I think it's an optimization bug; I didn't have this problem when I +// didn't give GCC the "-O2" option. +#if 0 template inline Type &CStaticArray::operator[](INDEX i) { ASSERT(this!=NULL); @@ -123,6 +84,7 @@ inline const Type &CStaticArray::operator[](INDEX i) const { ASSERT(i>=0 && i &arOriginal); /* Create a given number of objects. */ @@ -26,13 +39,32 @@ public: /* Expand stack size but keep old objects. */ inline void Expand(INDEX iNewCount); /* Destroy all objects. */ - inline void Delete(void); + inline void Delete(void) + { + ASSERT(this!=NULL); + ASSERT(sa_Count!=0 && sa_Array!=NULL); + delete[] sa_Array; + sa_Count = 0; + sa_Array = NULL; + } /* Destroy all objects, and reset the array to initial (empty) state. */ inline void Clear(void); /* Random access operator. */ - inline Type &operator[](INDEX iObject); - inline const Type &operator[](INDEX iObject) const; + inline Type &operator[](INDEX iObject) + { + ASSERT(this!=NULL); + ASSERT(iObject>=0 && iObject=0 && iObjectGetName()), itt->GetUsedCount(), itt->GetDescription()); + slUsedByObject/1024.0f, (const char*)(itt->GetName()), itt->GetUsedCount(), (const char *) itt->GetDescription()); strm.PutLine_t(strLine); }} } diff --git a/Sources/Engine/Templates/Stock_CAnimData.cpp b/Sources/Engine/Templates/Stock_CAnimData.cpp index 4a16e16..41f6b31 100644 --- a/Sources/Engine/Templates/Stock_CAnimData.cpp +++ b/Sources/Engine/Templates/Stock_CAnimData.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Templates/Stock_CAnimSet.cpp b/Sources/Engine/Templates/Stock_CAnimSet.cpp index b415122..e6c2fa9 100644 --- a/Sources/Engine/Templates/Stock_CAnimSet.cpp +++ b/Sources/Engine/Templates/Stock_CAnimSet.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Templates/Stock_CEntityClass.cpp b/Sources/Engine/Templates/Stock_CEntityClass.cpp index 3011b35..bb94d46 100644 --- a/Sources/Engine/Templates/Stock_CEntityClass.cpp +++ b/Sources/Engine/Templates/Stock_CEntityClass.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Templates/Stock_CMesh.cpp b/Sources/Engine/Templates/Stock_CMesh.cpp index 9e9e367..cf38052 100644 --- a/Sources/Engine/Templates/Stock_CMesh.cpp +++ b/Sources/Engine/Templates/Stock_CMesh.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Templates/Stock_CModelData.cpp b/Sources/Engine/Templates/Stock_CModelData.cpp index e26e4ea..058646a 100644 --- a/Sources/Engine/Templates/Stock_CModelData.cpp +++ b/Sources/Engine/Templates/Stock_CModelData.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Templates/Stock_CShader.cpp b/Sources/Engine/Templates/Stock_CShader.cpp index 60eca3a..900d19e 100644 --- a/Sources/Engine/Templates/Stock_CShader.cpp +++ b/Sources/Engine/Templates/Stock_CShader.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Templates/Stock_CSkeleton.cpp b/Sources/Engine/Templates/Stock_CSkeleton.cpp index 3435386..4d0631f 100644 --- a/Sources/Engine/Templates/Stock_CSkeleton.cpp +++ b/Sources/Engine/Templates/Stock_CSkeleton.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Templates/Stock_CSoundData.cpp b/Sources/Engine/Templates/Stock_CSoundData.cpp index 73554b6..7923338 100644 --- a/Sources/Engine/Templates/Stock_CSoundData.cpp +++ b/Sources/Engine/Templates/Stock_CSoundData.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Templates/Stock_CTextureData.cpp b/Sources/Engine/Templates/Stock_CTextureData.cpp index 208a00a..759282e 100644 --- a/Sources/Engine/Templates/Stock_CTextureData.cpp +++ b/Sources/Engine/Templates/Stock_CTextureData.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/Terrain/ArrayHolder.cpp b/Sources/Engine/Terrain/ArrayHolder.cpp index 7e1218d..a391786 100644 --- a/Sources/Engine/Terrain/ArrayHolder.cpp +++ b/Sources/Engine/Terrain/ArrayHolder.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include @@ -55,7 +55,7 @@ INDEX CArrayHolder::GetNewArrays() } // Mark tile arrays as unused -void CArrayHolder::FreeArrays(INT iOldArraysIndex) +void CArrayHolder::FreeArrays(SINT iOldArraysIndex) { // if arrays are valid if(iOldArraysIndex!=-1) { @@ -93,12 +93,12 @@ void CArrayHolder::EmptyArrays(INDEX iArrayIndex) void CArrayHolder::Clear(void) { // for each tile arrays - INT ctta = ah_ataTileArrays.Count(); - for(INT ita=0;ita #include #include #include -#include +#include #include #include #include @@ -496,8 +496,8 @@ void CTerrain::ReAllocateHeightMap(PIX pixWidth, PIX pixHeight) tr_pixHeightMapWidth = pixWidth; tr_pixHeightMapHeight = pixHeight; - ASSERT(_CrtCheckMemory()); + // Update shadow map size cos it depends on size of height map SetShadowMapsSize(tr_iShadowMapSizeAspect,tr_iShadingMapSizeAspect); /* @@ -612,7 +612,7 @@ void CTerrain::SetLodDistanceFactor(FLOAT fLodDistance) } // Get shadow map size -inline PIX CTerrain::GetShadowMapWidth(void) +PIX CTerrain::GetShadowMapWidth(void) { if(tr_iShadowMapSizeAspect<0) { return (tr_pixHeightMapWidth-1)>>-tr_iShadowMapSizeAspect; @@ -620,7 +620,7 @@ inline PIX CTerrain::GetShadowMapWidth(void) return (tr_pixHeightMapWidth-1)<>-tr_iShadowMapSizeAspect; @@ -630,12 +630,12 @@ inline PIX CTerrain::GetShadowMapHeight(void) } // Get shading map size -inline PIX CTerrain::GetShadingMapWidth(void) +PIX CTerrain::GetShadingMapWidth(void) { ASSERT(tr_iShadingMapSizeAspect>=0); return GetShadowMapWidth()>>tr_iShadingMapSizeAspect; } -inline PIX CTerrain::GetShadingMapHeight(void) +PIX CTerrain::GetShadingMapHeight(void) { ASSERT(tr_iShadingMapSizeAspect>=0); return GetShadowMapHeight()>>tr_iShadingMapSizeAspect; @@ -823,10 +823,10 @@ __forceinline void CopyPixel(COLOR *pubSrc,COLOR *pubDst,FLOAT fMaskStrength) { GFXColor *pcolSrc = (GFXColor*)pubSrc; GFXColor *pcolDst = (GFXColor*)pubDst; - pcolSrc->r = Lerp(pcolSrc->r,pcolDst->r,fMaskStrength); - pcolSrc->g = Lerp(pcolSrc->g,pcolDst->g,fMaskStrength); - pcolSrc->b = Lerp(pcolSrc->b,pcolDst->b,fMaskStrength); - pcolSrc->a = 255; + pcolSrc->ub.r = Lerp(pcolSrc->ub.r,pcolDst->ub.r,fMaskStrength); + pcolSrc->ub.g = Lerp(pcolSrc->ub.g,pcolDst->ub.g,fMaskStrength); + pcolSrc->ub.b = Lerp(pcolSrc->ub.b,pcolDst->ub.b,fMaskStrength); + pcolSrc->ub.a = 255; } static INDEX _ctSavedTopMaps=0; @@ -1108,10 +1108,10 @@ void CTerrain::UpdateTopMap(INDEX iTileIndex, Rect *prcDest/*=NULL*/) GFXColor *pcolSrc = (GFXColor*)pulTexDst; GFXColor *pcolDst = (GFXColor*)ulSrc; - pcolSrc->r = (BYTE)( (ULONG)pcolSrc->r + ((((ULONG)pcolDst->r - (ULONG)pcolSrc->r) * xStrength)>>16)); - pcolSrc->g = (BYTE)( (ULONG)pcolSrc->g + ((((ULONG)pcolDst->g - (ULONG)pcolSrc->g) * xStrength)>>16)); - pcolSrc->b = (BYTE)( (ULONG)pcolSrc->b + ((((ULONG)pcolDst->b - (ULONG)pcolSrc->b) * xStrength)>>16)); - pcolSrc->a = pubEdgeMaskRow[iMask]; + pcolSrc->ub.r = (BYTE)( (ULONG)pcolSrc->ub.r + ((((ULONG)pcolDst->ub.r - (ULONG)pcolSrc->ub.r) * xStrength)>>16)); + pcolSrc->ub.g = (BYTE)( (ULONG)pcolSrc->ub.g + ((((ULONG)pcolDst->ub.g - (ULONG)pcolSrc->ub.g) * xStrength)>>16)); + pcolSrc->ub.b = (BYTE)( (ULONG)pcolSrc->ub.b + ((((ULONG)pcolDst->ub.b - (ULONG)pcolSrc->ub.b) * xStrength)>>16)); + pcolSrc->ub.a = pubEdgeMaskRow[iMask]; pulTexDst++; xMaskHPos += xHMaskStep; @@ -1194,8 +1194,8 @@ FLOATplane3D CTerrain::GetPlaneFromPoint(FLOAT3D &vAbsPoint) FLOAT3D vRelPoint = (vAbsPoint-tr_penEntity->en_plPlacement.pl_PositionVector) * !tr_penEntity->en_mRotation; vRelPoint(1) /= tr_vStretch(1); vRelPoint(3) /= tr_vStretch(3); - PIX pixX = floor(vRelPoint(1)); - PIX pixZ = floor(vRelPoint(3)); + PIX pixX = (PIX) floor(vRelPoint(1)); + PIX pixZ = (PIX) floor(vRelPoint(3)); PIX pixWidth = tr_pixHeightMapWidth; FLOAT fXRatio = vRelPoint(1) - pixX; FLOAT fZRatio = vRelPoint(3) - pixZ; @@ -1667,8 +1667,8 @@ void CTerrain::ReGenerate(void) // for each tile that is waiting in regen queue INDEX ctrt = tr_auiRegenList.Count(); - INDEX irt=0; - for(;irt>iShadowMapAspect; (*istrFile)>>iShadingMapAspect; SetShadowMapsSize(iShadowMapAspect,iShadingMapAspect); - INDEX iShadowMapSize = GetShadowMapWidth() * GetShadowMapHeight() * sizeof(ULONG); - INDEX iShadingMapSize = GetShadingMapWidth() * GetShadingMapHeight() * sizeof(UWORD); + INDEX iShadowMapSize = GetShadowMapWidth() * GetShadowMapHeight(); + INDEX iShadingMapSize = GetShadingMapWidth() * GetShadingMapHeight(); // Read shadow map ASSERT(tr_tdShadowMap.td_pulFrames!=NULL); - istrFile->Read_t(&tr_tdShadowMap.td_pulFrames[0],iShadowMapSize); + for (INDEX i = 0; i < iShadowMapSize; i++) + (*istrFile)>>tr_tdShadowMap.td_pulFrames[i]; // Read shading map ASSERT(tr_auwShadingMap!=NULL); - istrFile->Read_t(&tr_auwShadingMap[0],iShadingMapSize); + for (INDEX i = 0; i < iShadingMapSize; i++) + (*istrFile)>>tr_auwShadingMap[i]; } // Create shadow map mipmaps @@ -1883,7 +1885,8 @@ void CTerrain::ReadVersion_t( CTStream *istrFile, INDEX iSavedVersion) (*istrFile).ExpectID_t("TRHM"); // 'Terrain heightmap' // read height map - (*istrFile).Read_t(&tr_auwHeightMap[0],sizeof(UWORD)*tr_pixHeightMapWidth*tr_pixHeightMapHeight); + for (ULONG i = 0; i < tr_pixHeightMapWidth*tr_pixHeightMapHeight; i++) + (*istrFile)>>tr_auwHeightMap[i]; (*istrFile).ExpectID_t("THEN"); // 'Terrain heightmap end' // Terrain will be rebuild in entity.cpp diff --git a/Sources/Engine/Terrain/Terrain.h b/Sources/Engine/Terrain/Terrain.h index 8abe55c..a1c28d2 100644 --- a/Sources/Engine/Terrain/Terrain.h +++ b/Sources/Engine/Terrain/Terrain.h @@ -264,6 +264,6 @@ private: INDEX tr_ctDriverChanges; }; +#endif -#endif \ No newline at end of file diff --git a/Sources/Engine/Terrain/TerrainArchive.cpp b/Sources/Engine/Terrain/TerrainArchive.cpp index 1c924ad..457294e 100644 --- a/Sources/Engine/Terrain/TerrainArchive.cpp +++ b/Sources/Engine/Terrain/TerrainArchive.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -15,7 +15,7 @@ #include #include -template CDynamicArray; +template class CDynamicArray; /* * Read from stream. diff --git a/Sources/Engine/Terrain/TerrainEditing.cpp b/Sources/Engine/Terrain/TerrainEditing.cpp index 0103552..eade411 100644 --- a/Sources/Engine/Terrain/TerrainEditing.cpp +++ b/Sources/Engine/Terrain/TerrainEditing.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include @@ -171,13 +171,13 @@ void ShowSelectionInternal(CTerrain *ptrTerrain, Rect &rcExtract, CTextureData * GFXColor *pacolBrush = (GFXColor*)&ptdBrush->td_pulFrames[iFirst]; // Fill vertex colors for selection preview - SLONG slStrength = Clamp(Abs(fStrenght),0.0f,1.0f) * 256.0f; + SLONG slStrength = (SLONG) (Clamp(Abs(fStrenght),0.0f,1.0f) * 256.0f); // for each row for(INDEX iy=0;iyabgr = colSelection.abgr; - pacolColor->a = (pacolBrush->r*slStrength)>>8; + pacolColor->ul.abgr = colSelection.ul.abgr; + pacolColor->ub.a = (pacolBrush->ub.r*slStrength)>>8; pacolColor++; pacolBrush++; } diff --git a/Sources/Engine/Terrain/TerrainLayer.cpp b/Sources/Engine/Terrain/TerrainLayer.cpp index d50a1f1..740fa2e 100644 --- a/Sources/Engine/Terrain/TerrainLayer.cpp +++ b/Sources/Engine/Terrain/TerrainLayer.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include @@ -50,10 +50,10 @@ CTextureData *CTerrainLayer::GetThumbnail(INDEX iWidth, INDEX iHeight) for(INDEX iy=0;iyr = *paubMask; - pcolTexture->g = *paubMask; - pcolTexture->b = *paubMask; - pcolTexture->a = 0xFF; + pcolTexture->ub.r = *paubMask; + pcolTexture->ub.g = *paubMask; + pcolTexture->ub.b = *paubMask; + pcolTexture->ub.a = 0xFF; pcolTexture++; paubMask+=iStepX; } @@ -172,8 +172,8 @@ void CTerrainLayer::ExportLayerMask_t(CTFileName fnLayerMask) GFXColor *pacolImage = (GFXColor*)&iiHeightMap.ii_Picture[0]; UBYTE *pubMask = &tl_aubColors[0]; for(INDEX ipix=0;ipixabgr = 0x00000000; - pacolImage->r = *pubMask; + pacolImage->ul.abgr = 0x00000000; + pacolImage->ub.r = *pubMask; pacolImage++; pubMask++; } diff --git a/Sources/Engine/Terrain/TerrainMisc.cpp b/Sources/Engine/Terrain/TerrainMisc.cpp index f1d5aa4..92c35f7 100644 --- a/Sources/Engine/Terrain/TerrainMisc.cpp +++ b/Sources/Engine/Terrain/TerrainMisc.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include @@ -28,7 +28,7 @@ CStaticStackArray _aiExtColors; CStaticStackArray _aiHitTiles; static ULONG *_pulSharedTopMap = NULL; // Shared memory used for topmap regeneration -extern SLONG _slSharedTopMapSize = 0; // Size of shared memory allocated for topmap regeneration +SLONG _slSharedTopMapSize = 0; // Size of shared memory allocated for topmap regeneration extern INDEX _ctShadowMapUpdates; #pragma message(">> Create class with destructor to clear shared topmap memory") @@ -338,10 +338,10 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract INDEX *pauiIndices = &_aiExtIndices[0]; // for each row - INDEX iy=0; - for(;iytr_vStretch(1); @@ -367,7 +367,7 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract // for each row for(iy=0;iytr_auwHeightMap[iFirstHeight]; GFXVertex *pavVertices = &_avExtVertices[0]; - INDEX iy=0; - for(;iyx = (FLOAT)(ix+iStartX)*ptrTerrain->tr_vStretch(1); pavVertices->z = (FLOAT)(iy+iStartY)*ptrTerrain->tr_vStretch(3); pavVertices->y = *puwHeight * ptrTerrain->tr_vStretch(2); @@ -534,7 +534,7 @@ UBYTE GetValueFromMask(CTerrain *ptrTerrain, INDEX iLayer, FLOAT3D vHitPoint) vHit(3)=ceil(vHit(3)/ptrTerrain->tr_vStretch(3)); CTerrainLayer &tl = ptrTerrain->GetLayer(iLayer); - INDEX iVtx = vHit(1) + tl.tl_iMaskWidth*vHit(3); + INDEX iVtx = (INDEX) (vHit(1) + tl.tl_iMaskWidth*vHit(3)); if(iVtx<0 || iVtx>=tl.tl_iMaskWidth*tl.tl_iMaskHeight) { ASSERTALWAYS("Invalid hit point"); return 0; @@ -736,17 +736,17 @@ static void CalcPointLight(CPlacement3D &plLight, CLightSource *plsLight, Rect & } ULONG ulIntensity = NormFloatToByte(fIntensity); ulIntensity = (ulIntensity<r = ClampUp(pacolData->r + ((colLight.r*slDot)>>8),255L); - pacolData->g = ClampUp(pacolData->g + ((colLight.g*slDot)>>8),255L); - pacolData->b = ClampUp(pacolData->b + ((colLight.b*slDot)>>8),255L); - pacolData->a = 255; + pacolData->ub.r = ClampUp(pacolData->ub.r + ((colLight.ub.r*slDot)>>8),255L); + pacolData->ub.g = ClampUp(pacolData->ub.g + ((colLight.ub.g*slDot)>>8),255L); + pacolData->ub.b = ClampUp(pacolData->ub.b + ((colLight.ub.b*slDot)>>8),255L); + pacolData->ub.a = 255; pacolData++; } pacolData+=pixStepX; @@ -774,9 +774,9 @@ static void CalcDirectionalLight(CPlacement3D &plLight, CLightSource *plsLight, GFXColor colAmbient = plsLight->GetLightAmbient(); UBYTE ubColShift = 8; - SLONG slar = colAmbient.r; - SLONG slag = colAmbient.g; - SLONG slab = colAmbient.b; + SLONG slar = colAmbient.ub.r; + SLONG slag = colAmbient.ub.g; + SLONG slab = colAmbient.ub.b; extern INDEX mdl_bAllowOverbright; BOOL bOverBrightning = mdl_bAllowOverbright && _pGfx->gl_ctTextureUnits>1; @@ -811,10 +811,10 @@ static void CalcDirectionalLight(CPlacement3D &plLight, CLightSource *plsLight, fDot = Clamp(fDot,0.0f,1.0f); SLONG slDot = NormFloatToByte(fDot); - pacolData->r = ClampUp(pacolData->r + slar + ((colLight.r*slDot)>>ubColShift),255L); - pacolData->g = ClampUp(pacolData->g + slag + ((colLight.g*slDot)>>ubColShift),255L); - pacolData->b = ClampUp(pacolData->b + slab + ((colLight.b*slDot)>>ubColShift),255L); - pacolData->a = 255; + pacolData->ub.r = ClampUp(pacolData->ub.r + slar + ((colLight.ub.r*slDot)>>ubColShift),255L); + pacolData->ub.g = ClampUp(pacolData->ub.g + slag + ((colLight.ub.g*slDot)>>ubColShift),255L); + pacolData->ub.b = ClampUp(pacolData->ub.b + slab + ((colLight.ub.b*slDot)>>ubColShift),255L); + pacolData->ub.a = 255; pacolData++; } pacolData+=pixStepX; @@ -1017,8 +1017,8 @@ Point Calculate2dHitPoint(CTerrain *ptrTerrain, FLOAT3D &vHitPoint) // Unstretch hit point and convert it to 2d Point pt; - pt.pt_iX = ceil(vRelHitPoint(1) / ptrTerrain->tr_vStretch(1) - 0.5f); - pt.pt_iY = ceil(vRelHitPoint(3) / ptrTerrain->tr_vStretch(3) - 0.5f); + pt.pt_iX = (INDEX) (ceil(vRelHitPoint(1) / ptrTerrain->tr_vStretch(1) - 0.5f)); + pt.pt_iY = (INDEX) (ceil(vRelHitPoint(3) / ptrTerrain->tr_vStretch(3) - 0.5f)); return pt; } diff --git a/Sources/Engine/Terrain/TerrainRayCasting.cpp b/Sources/Engine/Terrain/TerrainRayCasting.cpp index c846f74..34ea1bf 100644 --- a/Sources/Engine/Terrain/TerrainRayCasting.cpp +++ b/Sources/Engine/Terrain/TerrainRayCasting.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include @@ -366,16 +366,16 @@ static FLOAT GetExactHitLocation(CTerrain *ptrTerrain, const FLOAT3D &vHitBegin, // Chech quad where ray starts _fMinHeight = vHitBegin(2)-fEpsilonH; _fMaxHeight = vHitBegin(2)+fEpsilonH; - FLOAT fDistanceStart = HitCheckQuad(floor(fX0),floor(fY0)); + FLOAT fDistanceStart = HitCheckQuad((SLONG) floor(fX0),(SLONG) floor(fY0)); if(fDistanceStart +#include #include void ShowRayPath(CDrawPort *pdp) { diff --git a/Sources/Engine/Terrain/TerrainRender.cpp b/Sources/Engine/Terrain/TerrainRender.cpp index a9cd5f8..82127ba 100644 --- a/Sources/Engine/Terrain/TerrainRender.cpp +++ b/Sources/Engine/Terrain/TerrainRender.cpp @@ -1,12 +1,12 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include #include #include #include -#include +#include #include #include #include @@ -146,7 +146,7 @@ void PrepareScene(CAnyProjection3D &apr, CDrawPort *pdp, CTerrain *ptrTerrain) _vViewerObj = _vViewer * !pen->en_mRotation; - CPlacement3D &plTerrain = pen->GetLerpedPlacement(); + const CPlacement3D &plTerrain = pen->GetLerpedPlacement(); _mObjectToView = mViewer * pen->en_mRotation; _vObjectToView = (plTerrain.pl_PositionVector - _aprProjection->pr_vViewerPosition) * mViewer; @@ -846,16 +846,16 @@ static FLOAT _fHazeAdd; static void GetHazeMapInVertex( GFXVertex4 &vtx, GFXTexCoord &txHaze) { const FLOAT fD = vtx.x*_vViewerObj(1) + vtx.y*_vViewerObj(2) + vtx.z*_vViewerObj(3); - txHaze.u = (fD+_fHazeAdd) * _haze_fMul; - txHaze.v = 0.0f; + txHaze.uv.u = (fD+_fHazeAdd) * _haze_fMul; + txHaze.uv.v = 0.0f; } static void GetFogMapInVertex( GFXVertex4 &vtx, GFXTexCoord &tex) { const FLOAT fD = vtx.x*_vFViewerObj(1) + vtx.y*_vFViewerObj(2) + vtx.z*_vFViewerObj(3); const FLOAT fH = vtx.x*_vHDirObj(1) + vtx.y*_vHDirObj(2) + vtx.z*_vHDirObj(3); - tex.u = (fD+_fFogAddZ) * _fog_fMulZ; - tex.v = (fH+_fFogAddH) * _fog_fMulH; + tex.uv.u = (fD+_fFogAddZ) * _fog_fMulZ; + tex.uv.v = (fH+_fFogAddH) * _fog_fMulH; } static CStaticStackArray _atcHaze; @@ -1358,7 +1358,7 @@ void DrawSelectedVertices(GFXVertex *pavVertices, GFXColor *pacolColors, INDEX c GFXVertex &vtx = pavVertices[ivx]; GFXColor &col = pacolColors[ivx]; // draw vertex - _pdp->DrawPoint3D(FLOAT3D(vtx.x,vtx.y,vtx.z),ByteSwap(col.abgr),3); + _pdp->DrawPoint3D(FLOAT3D(vtx.x,vtx.y,vtx.z),ByteSwap(col.ul.abgr),3); } gfxDisableDepthBias(); } diff --git a/Sources/Engine/Terrain/TerrainTile.cpp b/Sources/Engine/Terrain/TerrainTile.cpp index d0bb2b1..f1a68e0 100644 --- a/Sources/Engine/Terrain/TerrainTile.cpp +++ b/Sources/Engine/Terrain/TerrainTile.cpp @@ -1,11 +1,19 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" -#include +#include "Engine/StdH.h" + #include #include #include +// !!! FIXME: This is messing up name mangling. Need to look at this. --ryan. +#if ((defined PLATFORM_UNIX) && (defined __forceinline)) +# undef __forceinline +# define __forceinline +#endif + +#include + extern CTerrain *_ptrTerrain; extern FLOAT3D _vViewerAbs; @@ -158,7 +166,7 @@ inline void CTerrainTile::AddTriangle(INDEX iind1,INDEX iind2,INDEX iind3) continue; // skip it } - COLOR ul = ttl.tl_acColors[iind1].a + ttl.tl_acColors[iind2].a + ttl.tl_acColors[iind3].a; + COLOR ul = ttl.tl_acColors[iind1].ub.a + ttl.tl_acColors[iind2].ub.a + ttl.tl_acColors[iind3].ub.a; if(ul>0) { INDEX *pIndices = ttl.tl_auiIndices.Push(3); pIndices[0] = iind1; @@ -220,7 +228,7 @@ void CTerrainTile::AddVertex(INDEX ic, INDEX ir) GFXVertex4 &vxFinal = GetVertices().Push(); GFXTexCoord &tcShadow = GetShadowMapTC().Push(); - GFXVertex4 &vx = GetVertex(ic,ir,tt_iIndex); + const GFXVertex4 &vx = GetVertex(ic,ir,tt_iIndex); vxFinal.x = vx.x * _ptrTerrain->tr_vStretch(1); vxFinal.y = vx.y * _ptrTerrain->tr_vStretch(2); vxFinal.z = vx.z * _ptrTerrain->tr_vStretch(3); @@ -236,36 +244,36 @@ void CTerrainTile::AddVertex(INDEX ic, INDEX ir) // Set vertex color GFXColor &col = ttl.tl_acColors.Push(); BYTE bAlpha = GetVertexAlpha(ic,ir,tt_iIndex,itl); - col.abgr = 0x00FFFFFF; - col.a = bAlpha; + col.ul.abgr = 0x00FFFFFF; + col.ub.a = bAlpha; // if this is normal layer if(tl.tl_ltType == LT_NORMAL) { // Set its texcoords GFXTexCoord &tc = ttl.tl_atcTexCoords.Push(); - tc.u = (FLOAT)ic; - tc.v = (FLOAT)ir; + tc.uv.u = (FLOAT)ic; + tc.uv.v = (FLOAT)ir; } } GFXTexCoord &tcDetail = GetDetailTC().Push(); - tcDetail.u = ic * 2; - tcDetail.v = ir * 2; + tcDetail.uv.u = ic * 2; + tcDetail.uv.v = ir * 2; // if tile is in lowest lod } else if(tt_iLod==_ptrTerrain->tr_iMaxTileLod) { GFXTexCoord &tc = GetTexCoords().Push(); FLOAT fWidth = (_ptrTerrain->tr_pixHeightMapWidth-1); FLOAT fHeight = (_ptrTerrain->tr_pixHeightMapHeight-1); - tc.u = vx.x / fWidth; - tc.v = vx.z / fHeight; + tc.uv.u = vx.x / fWidth; + tc.uv.v = vx.z / fHeight; // tile is not in highest lod nor in lowest lod } else { GFXTexCoord &tc = GetTexCoords().Push(); - tc.u = ((vx.x - tt_iOffsetX * _ptrTerrain->GetQuadsPerTileRow()) / (_ptrTerrain->GetQuadsPerTileRow())); - tc.v = ((vx.z - tt_iOffsetZ * _ptrTerrain->GetQuadsPerTileRow()) / (_ptrTerrain->GetQuadsPerTileRow())); + tc.uv.u = ((vx.x - tt_iOffsetX * _ptrTerrain->GetQuadsPerTileRow()) / (_ptrTerrain->GetQuadsPerTileRow())); + tc.uv.v = ((vx.z - tt_iOffsetZ * _ptrTerrain->GetQuadsPerTileRow()) / (_ptrTerrain->GetQuadsPerTileRow())); } - tcShadow.u = vx.x / (_ptrTerrain->tr_pixHeightMapWidth-1); - tcShadow.v = vx.z / (_ptrTerrain->tr_pixHeightMapHeight-1); + tcShadow.uv.u = vx.x / (_ptrTerrain->tr_pixHeightMapWidth-1); + tcShadow.uv.v = vx.z / (_ptrTerrain->tr_pixHeightMapHeight-1); } void CTerrainTile::ReGenerateTileLayer(INDEX iTileLayer) @@ -327,18 +335,18 @@ void CTerrainTile::ReGenerateTileLayer(INDEX iTileLayer) ASSERT(iTileY &CTerrainTile::GetVertices() { +__forceinline CStaticStackArray &CTerrainTile::GetVertices() { ASSERT(tt_iArrayIndex!=-1); ASSERT(tt_iLod!=-1); CArrayHolder &ah = _ptrTerrain->tr_aArrayHolders[tt_iLod]; TileArrays &ta = ah.ah_ataTileArrays[tt_iArrayIndex]; return ta.ta_avVertices; } -CStaticStackArray &CTerrainTile::GetTexCoords() { +__forceinline CStaticStackArray &CTerrainTile::GetTexCoords() { ASSERT(tt_iArrayIndex!=-1); ASSERT(tt_iLod!=-1); CArrayHolder &ah = _ptrTerrain->tr_aArrayHolders[tt_iLod]; TileArrays &ta = ah.ah_ataTileArrays[tt_iArrayIndex]; return ta.ta_auvTexCoords; } -CStaticStackArray &CTerrainTile::GetShadowMapTC() { +__forceinline CStaticStackArray &CTerrainTile::GetShadowMapTC() { ASSERT(tt_iArrayIndex!=-1); ASSERT(tt_iLod!=-1); CArrayHolder &ah = _ptrTerrain->tr_aArrayHolders[tt_iLod]; TileArrays &ta = ah.ah_ataTileArrays[tt_iArrayIndex]; return ta.ta_auvShadowMap; } -CStaticStackArray &CTerrainTile::GetDetailTC() { +__forceinline CStaticStackArray &CTerrainTile::GetDetailTC() { ASSERT(tt_iArrayIndex!=-1); ASSERT(tt_iRequestedLod==0 || tt_iLod==0); CArrayHolder &ah = _ptrTerrain->tr_aArrayHolders[tt_iRequestedLod]; TileArrays &ta = ah.ah_ataTileArrays[tt_iArrayIndex]; return ta.ta_auvDetailMap; } -CStaticStackArray &CTerrainTile::GetIndices() { +__forceinline CStaticStackArray &CTerrainTile::GetIndices() { ASSERT(tt_iArrayIndex!=-1); ASSERT(tt_iLod!=-1); CArrayHolder &ah = _ptrTerrain->tr_aArrayHolders[tt_iLod]; TileArrays &ta = ah.ah_ataTileArrays[tt_iArrayIndex]; return ta.ta_auiIndices; } -CStaticStackArray &CTerrainTile::GetTileLayers() { +__forceinline CStaticStackArray &CTerrainTile::GetTileLayers() { ASSERT(tt_iArrayIndex!=-1); ASSERT(tt_iRequestedLod==0 || tt_iLod==0); CArrayHolder &ah = _ptrTerrain->tr_aArrayHolders[tt_iRequestedLod]; TileArrays &ta = ah.ah_ataTileArrays[tt_iArrayIndex]; return ta.ta_atlLayers; } -CTextureData *CTerrainTile::GetTopMap() +__forceinline CTextureData *CTerrainTile::GetTopMap() { ASSERT(tt_iArrayIndex!=-1); ASSERT(tt_iLod!=-1); diff --git a/Sources/Engine/World/PhysicsProfile.cpp b/Sources/Engine/World/PhysicsProfile.cpp index adb34cd..c6e1f96 100644 --- a/Sources/Engine/World/PhysicsProfile.cpp +++ b/Sources/Engine/World/PhysicsProfile.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/World/PhysicsProfile.h b/Sources/Engine/World/PhysicsProfile.h index 10698fe..691f353 100644 --- a/Sources/Engine/World/PhysicsProfile.h +++ b/Sources/Engine/World/PhysicsProfile.h @@ -5,6 +5,12 @@ * Copyright (c) 1997-1998, CroTeam. All rights reserved. */ +#ifndef SE_INCL_PHYSICSPROFILE_H +#define SE_INCL_PHYSICSPROFILE_H +#ifdef PRAGMA_ONCE + #pragma once +#endif + #ifndef __ENGINE_BASE_PROFILING_H__ #include #endif @@ -110,3 +116,7 @@ public: // constructor CPhysicsProfile(void); }; + +#endif /* include-once wrapper. */ + + diff --git a/Sources/Engine/World/World.cpp b/Sources/Engine/World/World.cpp index 00fb6f1..eebf304 100644 --- a/Sources/Engine/World/World.cpp +++ b/Sources/Engine/World/World.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -29,10 +29,10 @@ #include -template CDynamicContainer; -template CBrushPolygonSelection; -template CBrushSectorSelection; -template CEntitySelection; +template class CDynamicContainer; +template class CSelection; +template class CSelection; +template class CSelection; extern BOOL _bPortalSectorLinksPreLoaded; extern BOOL _bEntitySectorLinksPreLoaded; @@ -351,7 +351,7 @@ CPlayerEntity *CWorld::FindEntityWithCharacter(CPlayerCharacter &pcCharacter) */ void CWorld::AddTimer(CRationalEntity *penThinker) { - ASSERT(penThinker->en_timeTimer>_pTimer->CurrentTick()); + ASSERT(penThinker->en_timeTimer>=_pTimer->CurrentTick()); ASSERT(GetFPUPrecision()==FPT_24BIT); // if the entity is already in the list diff --git a/Sources/Engine/World/WorldCSG.cpp b/Sources/Engine/World/WorldCSG.cpp index 46601b1..2912cdf 100644 --- a/Sources/Engine/World/WorldCSG.cpp +++ b/Sources/Engine/World/WorldCSG.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include #include @@ -408,7 +408,8 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT // for all sectors in the selection FOREACHINDYNAMICCONTAINER(selbscSectorsToSplit, CBrushSector, itbsc) { // split the sector using the copy of other object - SplitOneSector(*itbsc, CObject3D(obOther)); + CObject3D obj(obOther); + SplitOneSector(*itbsc, obj); } // update the bounding boxes of this brush diff --git a/Sources/Engine/World/WorldCollision.cpp b/Sources/Engine/World/WorldCollision.cpp index d8475e2..eb9fe3b 100644 --- a/Sources/Engine/World/WorldCollision.cpp +++ b/Sources/Engine/World/WorldCollision.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.H" +#include #include #include diff --git a/Sources/Engine/World/WorldCollisionGrid.cpp b/Sources/Engine/World/WorldCollisionGrid.cpp index d12fd8f..404c9dd 100644 --- a/Sources/Engine/World/WorldCollisionGrid.cpp +++ b/Sources/Engine/World/WorldCollisionGrid.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.H" +#include #include #include diff --git a/Sources/Engine/World/WorldEditingProfile.cpp b/Sources/Engine/World/WorldEditingProfile.cpp index c31f2e3..5f4f1b9 100644 --- a/Sources/Engine/World/WorldEditingProfile.cpp +++ b/Sources/Engine/World/WorldEditingProfile.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "Engine/StdH.h" #include diff --git a/Sources/Engine/World/WorldIO.cpp b/Sources/Engine/World/WorldIO.cpp index f97e53a..66dc769 100644 --- a/Sources/Engine/World/WorldIO.cpp +++ b/Sources/Engine/World/WorldIO.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -21,11 +21,13 @@ #define WORLDSTATEVERSION_MULTITEXTURING 8 #define WORLDSTATEVERSION_SHADOWSPERMIP 7 #define WORLDSTATEVERSION_CURRENT WORLDSTATEVERSION_NOCLASSCONTAINER -extern CWorld *_pwoCurrentLoading = NULL; // world that is currently loading + +CWorld *_pwoCurrentLoading = NULL; // world that is currently loading +BOOL _bReadEntitiesByID = FALSE; + extern BOOL _bPortalSectorLinksPreLoaded; extern BOOL _bEntitySectorLinksPreLoaded; extern BOOL _bFileReplacingApplied; -extern BOOL _bReadEntitiesByID = FALSE; /* * Save entire world (both brushes current state). diff --git a/Sources/Engine/World/WorldRayCasting.cpp b/Sources/Engine/World/WorldRayCasting.cpp index c0787c3..eec9b6c 100644 --- a/Sources/Engine/World/WorldRayCasting.cpp +++ b/Sources/Engine/World/WorldRayCasting.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include #include #include @@ -20,7 +20,7 @@ #include #include -#include +#include #include #define EPSILON (0.1f) diff --git a/Sources/Engine/zlib/adler32.c b/Sources/Engine/zlib/adler32.c index 16cf9a7..73a0af7 100644 --- a/Sources/Engine/zlib/adler32.c +++ b/Sources/Engine/zlib/adler32.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id$ */ +/* @(#) $Id: adler32.c,v 1.2 2002/02/18 06:05:42 icculus Exp $ */ #include "zlib.h" @@ -18,10 +18,7 @@ #define DO16(buf) DO8(buf,0); DO8(buf,8); /* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) { unsigned long s1 = adler & 0xffff; unsigned long s2 = (adler >> 16) & 0xffff; diff --git a/Sources/Engine/zlib/compress.c b/Sources/Engine/zlib/compress.c index 1cee470..020bd76 100644 --- a/Sources/Engine/zlib/compress.c +++ b/Sources/Engine/zlib/compress.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id$ */ +/* @(#) $Id: compress.c,v 1.2 2002/02/18 06:05:42 icculus Exp $ */ #include "zlib.h" @@ -18,12 +18,8 @@ memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ -int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; +int ZEXPORT compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen, int level) { z_stream stream; int err; @@ -58,11 +54,8 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) /* =========================================================================== */ -int ZEXPORT compress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; +int ZEXPORT compress (Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen) { return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); } diff --git a/Sources/Engine/zlib/deflate.c b/Sources/Engine/zlib/deflate.c index 25d5818..8ae6145 100644 --- a/Sources/Engine/zlib/deflate.c +++ b/Sources/Engine/zlib/deflate.c @@ -47,7 +47,7 @@ * */ -/* @(#) $Id$ */ +/* @(#) $Id: deflate.c,v 1.2 2002/02/18 06:05:43 icculus Exp $ */ #include "deflate.h" @@ -187,11 +187,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); /* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; +int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, int stream_size) { return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size); @@ -199,16 +195,9 @@ int ZEXPORT deflateInit_(strm, level, version, stream_size) } /* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; +int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, int strategy, + const char *version, int stream_size) { deflate_state *s; int noheader = 0; @@ -288,10 +277,8 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, } /* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; +int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary, + uInt dictLength) { deflate_state *s; uInt length = dictLength; @@ -329,8 +316,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) } /* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; +int ZEXPORT deflateReset (z_streamp strm) { deflate_state *s; @@ -359,10 +345,7 @@ int ZEXPORT deflateReset (strm) } /* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; +int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { deflate_state *s; compress_func func; @@ -399,9 +382,7 @@ int ZEXPORT deflateParams(strm, level, strategy) * IN assertion: the stream state is correct and there is enough room in * pending_buf. */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; +local void putShortMSB (deflate_state *s, uInt b) { put_byte(s, (Byte)(b >> 8)); put_byte(s, (Byte)(b & 0xff)); @@ -413,8 +394,7 @@ local void putShortMSB (s, b) * to avoid allocating a large strm->next_out buffer and copying into it. * (See also read_buf()). */ -local void flush_pending(strm) - z_streamp strm; +local void flush_pending(z_streamp strm) { unsigned len = strm->state->pending; @@ -433,9 +413,7 @@ local void flush_pending(strm) } /* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; +int ZEXPORT deflate (z_streamp strm, int flush) { int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; @@ -567,8 +545,7 @@ int ZEXPORT deflate (strm, flush) } /* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; +int ZEXPORT deflateEnd (z_streamp strm) { int status; @@ -597,9 +574,7 @@ int ZEXPORT deflateEnd (strm) * To simplify the source, this is not supported for 16-bit MSDOS (which * doesn't have enough memory anyway to duplicate compression states). */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; +int ZEXPORT deflateCopy (z_streamp dest, z_streamp source) { #ifdef MAXSEG_64K return Z_STREAM_ERROR; @@ -659,10 +634,7 @@ int ZEXPORT deflateCopy (dest, source) * allocating a large strm->next_in buffer and copying from it. * (See also flush_pending()). */ -local int read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; +local int read_buf(z_streamp strm, Bytef *buf, unsigned size) { unsigned len = strm->avail_in; @@ -684,8 +656,7 @@ local int read_buf(strm, buf, size) /* =========================================================================== * Initialize the "longest match" routines for a new zlib stream */ -local void lm_init (s) - deflate_state *s; +local void lm_init (deflate_state *s) { s->window_size = (ulg)2L*s->w_size; @@ -723,9 +694,7 @@ local void lm_init (s) * match.S. The code will be functionally equivalent. */ #ifndef FASTEST -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ +local uInt longest_match(deflate_state *s, IPos cur_match) { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Bytef *scan = s->window + s->strstart; /* current string */ @@ -865,9 +834,7 @@ local uInt longest_match(s, cur_match) /* --------------------------------------------------------------------------- * Optimized version for level == 1 only */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ +local uInt longest_match(deflate_state *s, IPos cur_match) { register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ @@ -924,10 +891,7 @@ local uInt longest_match(s, cur_match) /* =========================================================================== * Check that the match at match_start is indeed a match. */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; +local void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ if (zmemcmp(s->window + match, @@ -958,8 +922,7 @@ local void check_match(s, start, match, length) * performed for at least two bytes (required for the zip translate_eol * option -- not supported here). */ -local void fill_window(s) - deflate_state *s; +local void fill_window(deflate_state *s) { register unsigned n, m; register Posf *p; @@ -1078,9 +1041,7 @@ local void fill_window(s) * NOTE: this function should be optimized to avoid extra copying from * window to pending_buf. */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; +local block_state deflate_stored(deflate_state *s, int flush) { /* Stored blocks are limited to 0xffff bytes, pending_buf is limited * to pending_buf_size, and each stored block has a 5 byte header: @@ -1136,9 +1097,7 @@ local block_state deflate_stored(s, flush) * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; +local block_state deflate_fast(deflate_state *s, int flush) { IPos hash_head = NIL; /* head of the hash chain */ int bflush; /* set if current block must be flushed */ @@ -1232,9 +1191,7 @@ local block_state deflate_fast(s, flush) * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; +local block_state deflate_slow(deflate_state *s, int flush) { IPos hash_head = NIL; /* head of hash chain */ int bflush; /* set if current block must be flushed */ diff --git a/Sources/Engine/zlib/deflate.h b/Sources/Engine/zlib/deflate.h index 962676d..4f7d108 100644 --- a/Sources/Engine/zlib/deflate.h +++ b/Sources/Engine/zlib/deflate.h @@ -8,7 +8,7 @@ subject to change. Applications should only use zlib.h. */ -/* @(#) $Id$ */ +/* @(#) $Id: deflate.h,v 1.1 2001/10/04 02:45:08 icculus Exp $ */ #ifndef _DEFLATE_H #define _DEFLATE_H diff --git a/Sources/Engine/zlib/infblock.c b/Sources/Engine/zlib/infblock.c index f4920fa..6dd4e54 100644 --- a/Sources/Engine/zlib/infblock.c +++ b/Sources/Engine/zlib/infblock.c @@ -65,10 +65,7 @@ local const uInt border[] = { /* Order of the bit length code lengths */ */ -void inflate_blocks_reset(s, z, c) -inflate_blocks_statef *s; -z_streamp z; -uLongf *c; +void inflate_blocks_reset(inflate_blocks_statef *s, z_streamp z, uLongf *c) { if (c != Z_NULL) *c = s->check; @@ -86,10 +83,7 @@ uLongf *c; } -inflate_blocks_statef *inflate_blocks_new(z, c, w) -z_streamp z; -check_func c; -uInt w; +inflate_blocks_statef *inflate_blocks_new(z_streamp z, check_func c, uInt w) { inflate_blocks_statef *s; @@ -117,10 +111,7 @@ uInt w; } -int inflate_blocks(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; +int inflate_blocks(inflate_blocks_statef *s, z_streamp z, int r) { uInt t; /* temporary storage */ uLong b; /* bit buffer */ @@ -364,9 +355,7 @@ int r; } -int inflate_blocks_free(s, z) -inflate_blocks_statef *s; -z_streamp z; +int inflate_blocks_free(inflate_blocks_statef *s, z_streamp z) { inflate_blocks_reset(s, z, Z_NULL); ZFREE(z, s->window); @@ -377,10 +366,7 @@ z_streamp z; } -void inflate_set_dictionary(s, d, n) -inflate_blocks_statef *s; -const Bytef *d; -uInt n; +void inflate_set_dictionary(inflate_blocks_statef *s, const Bytef *d, uInt n) { zmemcpy(s->window, d, n); s->read = s->write = s->window + n; @@ -391,8 +377,7 @@ uInt n; * by Z_SYNC_FLUSH or Z_FULL_FLUSH. * IN assertion: s != Z_NULL */ -int inflate_blocks_sync_point(s) -inflate_blocks_statef *s; +int inflate_blocks_sync_point(inflate_blocks_statef *s) { return s->mode == LENS; } diff --git a/Sources/Engine/zlib/infcodes.c b/Sources/Engine/zlib/infcodes.c index d4e5ee9..d3cc8e1 100644 --- a/Sources/Engine/zlib/infcodes.c +++ b/Sources/Engine/zlib/infcodes.c @@ -56,11 +56,7 @@ struct inflate_codes_state { }; -inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) -uInt bl, bd; -inflate_huft *tl; -inflate_huft *td; /* need separate declaration for Borland C++ */ -z_streamp z; +inflate_codes_statef *inflate_codes_new(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, z_streamp z) { inflate_codes_statef *c; @@ -78,10 +74,7 @@ z_streamp z; } -int inflate_codes(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; +int inflate_codes(inflate_blocks_statef *s, z_streamp z, int r) { uInt j; /* temporary storage */ inflate_huft *t; /* temporary pointer */ @@ -248,9 +241,7 @@ int r; } -void inflate_codes_free(c, z) -inflate_codes_statef *c; -z_streamp z; +void inflate_codes_free(inflate_codes_statef *c, z_streamp z) { ZFREE(z, c); Tracev((stderr, "inflate: codes free\n")); diff --git a/Sources/Engine/zlib/inffast.c b/Sources/Engine/zlib/inffast.c index 61a78ee..8501898 100644 --- a/Sources/Engine/zlib/inffast.c +++ b/Sources/Engine/zlib/inffast.c @@ -25,12 +25,8 @@ struct inflate_codes_state {int dummy;}; /* for buggy compilers */ at least ten. The ten bytes are six bytes for the longest length/ distance pair plus four bytes for overloading the bit buffer. */ -int inflate_fast(bl, bd, tl, td, s, z) -uInt bl, bd; -inflate_huft *tl; -inflate_huft *td; /* need separate declaration for Borland C++ */ -inflate_blocks_statef *s; -z_streamp z; +int inflate_fast(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, + inflate_blocks_statef *s, z_streamp z) { inflate_huft *t; /* temporary pointer */ uInt e; /* extra bits or operation */ diff --git a/Sources/Engine/zlib/inflate.c b/Sources/Engine/zlib/inflate.c index 32e9b8d..7ed6ca0 100644 --- a/Sources/Engine/zlib/inflate.c +++ b/Sources/Engine/zlib/inflate.c @@ -50,8 +50,7 @@ struct internal_state { }; -int ZEXPORT inflateReset(z) -z_streamp z; +int ZEXPORT inflateReset(z_streamp z) { if (z == Z_NULL || z->state == Z_NULL) return Z_STREAM_ERROR; @@ -64,8 +63,7 @@ z_streamp z; } -int ZEXPORT inflateEnd(z) -z_streamp z; +int ZEXPORT inflateEnd(z_streamp z) { if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) return Z_STREAM_ERROR; @@ -78,11 +76,7 @@ z_streamp z; } -int ZEXPORT inflateInit2_(z, w, version, stream_size) -z_streamp z; -int w; -const char *version; -int stream_size; +int ZEXPORT inflateInit2_(z_streamp z, int w, const char *version, int stream_size) { if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != sizeof(z_stream)) @@ -135,10 +129,7 @@ int stream_size; } -int ZEXPORT inflateInit_(z, version, stream_size) -z_streamp z; -const char *version; -int stream_size; +int ZEXPORT inflateInit_(z_streamp z, const char *version, int stream_size) { return inflateInit2_(z, DEF_WBITS, version, stream_size); } @@ -147,9 +138,7 @@ int stream_size; #define NEEDBYTE {if(z->avail_in==0)return r;r=f;} #define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) -int ZEXPORT inflate(z, f) -z_streamp z; -int f; +int ZEXPORT inflate(z_streamp z, int f) { int r; uInt b; @@ -275,10 +264,7 @@ int f; } -int ZEXPORT inflateSetDictionary(z, dictionary, dictLength) -z_streamp z; -const Bytef *dictionary; -uInt dictLength; +int ZEXPORT inflateSetDictionary(z_streamp z, const Bytef *dictionary, uInt dictLength) { uInt length = dictLength; @@ -299,8 +285,7 @@ uInt dictLength; } -int ZEXPORT inflateSync(z) -z_streamp z; +int ZEXPORT inflateSync(z_streamp z) { uInt n; /* number of bytes to look at */ Bytef *p; /* pointer to bytes */ @@ -357,8 +342,7 @@ z_streamp z; * decompressing, PPP checks that at the end of input packet, inflate is * waiting for these length bytes. */ -int ZEXPORT inflateSyncPoint(z) -z_streamp z; +int ZEXPORT inflateSyncPoint(z_streamp z) { if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL) return Z_STREAM_ERROR; diff --git a/Sources/Engine/zlib/inftrees.c b/Sources/Engine/zlib/inftrees.c index ef1e0b6..ee2367b 100644 --- a/Sources/Engine/zlib/inftrees.c +++ b/Sources/Engine/zlib/inftrees.c @@ -90,17 +90,9 @@ local const uInt cpdext[30] = { /* Extra bits for distance codes */ /* If BMAX needs to be larger than 16, then h and x[] should be uLong. */ #define BMAX 15 /* maximum bit length of any code */ -local int huft_build(b, n, s, d, e, t, m, hp, hn, v) -uIntf *b; /* code lengths in bits (all assumed <= BMAX) */ -uInt n; /* number of codes (assumed <= 288) */ -uInt s; /* number of simple-valued codes (0..s-1) */ -const uIntf *d; /* list of base values for non-simple codes */ -const uIntf *e; /* list of extra bits for non-simple codes */ -inflate_huft * FAR *t; /* result: starting table */ -uIntf *m; /* maximum lookup bits, returns actual */ -inflate_huft *hp; /* space for trees */ -uInt *hn; /* hufts used in space */ -uIntf *v; /* working area: values in order of bit length */ +local int huft_build(uIntf *b, uInt n, uInt s, const uIntf *d, const uIntf *e, + inflate_huft * FAR *t, uIntf *m, inflate_huft *hp, + uInt *hn, uIntf *v) /* Given a list of code lengths and a maximum table size, make a set of tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR if the given code set is incomplete (the tables are still built in this @@ -291,12 +283,8 @@ uIntf *v; /* working area: values in order of bit length */ } -int inflate_trees_bits(c, bb, tb, hp, z) -uIntf *c; /* 19 code lengths */ -uIntf *bb; /* bits tree desired/actual depth */ -inflate_huft * FAR *tb; /* bits tree result */ -inflate_huft *hp; /* space for trees */ -z_streamp z; /* for messages */ +int inflate_trees_bits(uIntf *c, uIntf *bb, inflate_huft * FAR *tb, + inflate_huft *hp, z_streamp z) { int r; uInt hn = 0; /* hufts used in space */ @@ -318,16 +306,9 @@ z_streamp z; /* for messages */ } -int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp, z) -uInt nl; /* number of literal/length codes */ -uInt nd; /* number of distance codes */ -uIntf *c; /* that many (total) code lengths */ -uIntf *bl; /* literal desired/actual bit depth */ -uIntf *bd; /* distance desired/actual bit depth */ -inflate_huft * FAR *tl; /* literal/length tree result */ -inflate_huft * FAR *td; /* distance tree result */ -inflate_huft *hp; /* space for trees */ -z_streamp z; /* for messages */ +int inflate_trees_dynamic(uInt nl, uInt nd, uIntf *c, uIntf *bl, uIntf *bd, + inflate_huft * FAR *tl, inflate_huft * FAR *td, + inflate_huft *hp, z_streamp z) { int r; uInt hn = 0; /* hufts used in space */ @@ -396,12 +377,8 @@ local inflate_huft *fixed_td; #endif -int inflate_trees_fixed(bl, bd, tl, td, z) -uIntf *bl; /* literal desired/actual bit depth */ -uIntf *bd; /* distance desired/actual bit depth */ -inflate_huft * FAR *tl; /* literal/length tree result */ -inflate_huft * FAR *td; /* distance tree result */ -z_streamp z; /* for memory allocation */ +int inflate_trees_fixed(uIntf *bl, uIntf *bd, inflate_huft * FAR *tl, + inflate_huft * FAR *td, z_streamp z) { #ifdef BUILDFIXED /* build fixed tables if not already */ diff --git a/Sources/Engine/zlib/infutil.c b/Sources/Engine/zlib/infutil.c index 824dab5..ed11348 100644 --- a/Sources/Engine/zlib/infutil.c +++ b/Sources/Engine/zlib/infutil.c @@ -20,10 +20,7 @@ uInt inflate_mask[17] = { /* copy as much as possible from the sliding window to the output area */ -int inflate_flush(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; +int inflate_flush(inflate_blocks_statef *s, z_streamp z, int r) { uInt n; Bytef *p; diff --git a/Sources/Engine/zlib/trees.c b/Sources/Engine/zlib/trees.c index f01fb30..659a463 100644 --- a/Sources/Engine/zlib/trees.c +++ b/Sources/Engine/zlib/trees.c @@ -29,7 +29,7 @@ * Addison-Wesley, 1983. ISBN 0-201-06672-6. */ -/* @(#) $Id$ */ +/* @(#) $Id: trees.c,v 1.2 2002/02/18 06:05:43 icculus Exp $ */ /* #define GEN_TREES_H */ @@ -189,10 +189,7 @@ local void gen_trees_header OF((void)); #ifdef DEBUG local void send_bits OF((deflate_state *s, int value, int length)); -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ +local void send_bits(deflate_state *s, int value, int length) { Tracevv((stderr," l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); @@ -236,7 +233,7 @@ local void send_bits(s, value, length) /* =========================================================================== * Initialize the various 'constant' tables. */ -local void tr_static_init() +local void tr_static_init(void) { #if defined(GEN_TREES_H) || !defined(STDC) static int static_init_done = 0; @@ -328,7 +325,7 @@ local void tr_static_init() ((i) == (last)? "\n};\n\n" : \ ((i) % (width) == (width)-1 ? ",\n" : ", ")) -void gen_trees_header() +void gen_trees_header(void) { FILE *header = fopen("trees.h", "w"); int i; @@ -380,8 +377,7 @@ void gen_trees_header() /* =========================================================================== * Initialize the tree data structures for a new zlib stream. */ -void _tr_init(s) - deflate_state *s; +void _tr_init(deflate_state *s) { tr_static_init(); @@ -409,8 +405,7 @@ void _tr_init(s) /* =========================================================================== * Initialize a new block. */ -local void init_block(s) - deflate_state *s; +local void init_block(deflate_state *s) { int n; /* iterates over tree elements */ @@ -453,10 +448,7 @@ local void init_block(s) * when the heap property is re-established (each father smaller than its * two sons). */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ +local void pqdownheap(deflate_state *s, ct_data *tree, int k) { int v = s->heap[k]; int j = k << 1; /* left son of k */ @@ -488,9 +480,7 @@ local void pqdownheap(s, tree, k) * The length opt_len is updated; static_len is also updated if stree is * not null. */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ +local void gen_bitlen(deflate_state *s, tree_desc *desc) { ct_data *tree = desc->dyn_tree; int max_code = desc->max_code; @@ -575,10 +565,7 @@ local void gen_bitlen(s, desc) * OUT assertion: the field code is set for all tree elements of non * zero code length. */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ +local void gen_codes (ct_data *tree, int max_code, ushf *bl_count) { ush next_code[MAX_BITS+1]; /* next code value for each bit length */ ush code = 0; /* running code value */ @@ -617,9 +604,7 @@ local void gen_codes (tree, max_code, bl_count) * and corresponding code. The length opt_len is updated; static_len is * also updated if stree is not null. The field max_code is set. */ -local void build_tree(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ +local void build_tree(deflate_state *s, tree_desc *desc) { ct_data *tree = desc->dyn_tree; const ct_data *stree = desc->stat_desc->static_tree; @@ -704,10 +689,7 @@ local void build_tree(s, desc) * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ +local void scan_tree (deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ @@ -749,10 +731,7 @@ local void scan_tree (s, tree, max_code) * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ +local void send_tree (deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ @@ -800,8 +779,7 @@ local void send_tree (s, tree, max_code) * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ -local int build_bl_tree(s) - deflate_state *s; +local int build_bl_tree(deflate_state *s) { int max_blindex; /* index of last bit length code of non zero freq */ @@ -835,9 +813,7 @@ local int build_bl_tree(s) * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ +local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes) { int rank; /* index in bl_order */ @@ -864,11 +840,7 @@ local void send_all_trees(s, lcodes, dcodes, blcodes) /* =========================================================================== * Send a stored block */ -void _tr_stored_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ +void _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int eof) { send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ #ifdef DEBUG @@ -889,8 +861,7 @@ void _tr_stored_block(s, buf, stored_len, eof) * To simplify the code, we assume the worst case of last real code encoded * on one bit only. */ -void _tr_align(s) - deflate_state *s; +void _tr_align(deflate_state *s) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); @@ -918,11 +889,7 @@ void _tr_align(s) * Determine the best encoding for the current block: dynamic trees, static * trees or store, and output the encoded block to the zip file. */ -void _tr_flush_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ +void _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len, int eof) { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex = 0; /* index of last bit length code of non zero freq */ @@ -1018,10 +985,7 @@ void _tr_flush_block(s, buf, stored_len, eof) * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ -int _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ +int _tr_tally (deflate_state *s, unsigned int dist, unsigned int lc) { s->d_buf[s->last_lit] = (ush)dist; s->l_buf[s->last_lit++] = (uch)lc; @@ -1068,10 +1032,7 @@ int _tr_tally (s, dist, lc) /* =========================================================================== * Send the block data compressed using the given Huffman trees */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - ct_data *ltree; /* literal tree */ - ct_data *dtree; /* distance tree */ +local void compress_block(deflate_state *s, ct_data *ltree, ct_data *dtree) { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ @@ -1121,8 +1082,7 @@ local void compress_block(s, ltree, dtree) * IN assertion: the fields freq of dyn_ltree are set and the total of all * frequencies does not exceed 64K (to fit in an int on 16 bit machines). */ -local void set_data_type(s) - deflate_state *s; +local void set_data_type(deflate_state *s) { int n = 0; unsigned ascii_freq = 0; @@ -1138,9 +1098,7 @@ local void set_data_type(s) * method would use a table) * IN assertion: 1 <= len <= 15 */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ +local unsigned bi_reverse(unsigned int code, int len) { register unsigned res = 0; do { @@ -1153,8 +1111,7 @@ local unsigned bi_reverse(code, len) /* =========================================================================== * Flush the bit buffer, keeping at most 7 bits in it. */ -local void bi_flush(s) - deflate_state *s; +local void bi_flush(deflate_state *s) { if (s->bi_valid == 16) { put_short(s, s->bi_buf); @@ -1170,8 +1127,7 @@ local void bi_flush(s) /* =========================================================================== * Flush the bit buffer and align the output on a byte boundary */ -local void bi_windup(s) - deflate_state *s; +local void bi_windup(deflate_state *s) { if (s->bi_valid > 8) { put_short(s, s->bi_buf); @@ -1189,11 +1145,7 @@ local void bi_windup(s) * Copy a stored block, storing first the length and its * one's complement if requested. */ -local void copy_block(s, buf, len, header) - deflate_state *s; - charf *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ +local void copy_block(deflate_state *s, charf *buf, unsigned int len, int header) { bi_windup(s); /* align on byte boundary */ s->last_eob_len = 8; /* enough lookahead for inflate */ diff --git a/Sources/Engine/zlib/uncompr.c b/Sources/Engine/zlib/uncompr.c index d103321..61b3431 100644 --- a/Sources/Engine/zlib/uncompr.c +++ b/Sources/Engine/zlib/uncompr.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id$ */ +/* @(#) $Id: uncompr.c,v 1.2 2002/02/18 06:05:43 icculus Exp $ */ #include "zlib.h" @@ -22,11 +22,7 @@ enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted. */ -int ZEXPORT uncompress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; +int ZEXPORT uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) { z_stream stream; int err; diff --git a/Sources/Engine/zlib/zconf.h b/Sources/Engine/zlib/zconf.h index 6d450fc..e758333 100644 --- a/Sources/Engine/zlib/zconf.h +++ b/Sources/Engine/zlib/zconf.h @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id$ */ +/* @(#) $Id: zconf.h,v 1.2 2002/05/01 01:50:13 icculus Exp $ */ #ifndef _ZCONF_H #define _ZCONF_H @@ -51,7 +51,7 @@ #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) # define WIN32 #endif -#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) || defined(__INTEL_COMPILER) # ifndef __32BIT__ # define __32BIT__ # endif diff --git a/Sources/Engine/zlib/zutil.c b/Sources/Engine/zlib/zutil.c index b3de4e8..6b05cd7 100644 --- a/Sources/Engine/zlib/zutil.c +++ b/Sources/Engine/zlib/zutil.c @@ -3,7 +3,7 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -/* @(#) $Id$ */ +/* @(#) $Id: zutil.c,v 1.2 2002/02/18 06:05:43 icculus Exp $ */ #include "zutil.h" @@ -26,7 +26,7 @@ const char *z_errmsg[10] = { ""}; -const char * ZEXPORT zlibVersion() +const char * ZEXPORT zlibVersion(void) { return ZLIB_VERSION; } @@ -38,8 +38,7 @@ const char * ZEXPORT zlibVersion() # endif int z_verbose = verbose; -void z_error (m) - char *m; +void z_error (char *m) { fprintf(stderr, "%s\n", m); exit(1); @@ -49,8 +48,7 @@ void z_error (m) /* exported to allow conversion of error code to string for compress() and * uncompress() */ -const char * ZEXPORT zError(err) - int err; +const char * ZEXPORT zError(int err) { return ERR_MSG(err); } @@ -58,10 +56,7 @@ const char * ZEXPORT zError(err) #ifndef HAVE_MEMCPY -void zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; +void zmemcpy(Bytef* dest, const Bytef* source, uInt len) { if (len == 0) return; do { @@ -69,10 +64,7 @@ void zmemcpy(dest, source, len) } while (--len != 0); } -int zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; +int zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) { uInt j; @@ -82,9 +74,7 @@ int zmemcmp(s1, s2, len) return 0; } -void zmemzero(dest, len) - Bytef* dest; - uInt len; +void zmemzero(Bytef* dest, uInt len) { if (len == 0) return; do { @@ -205,18 +195,13 @@ extern voidp calloc OF((uInt items, uInt size)); extern void free OF((voidpf ptr)); #endif -voidpf zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; +voidpf zcalloc (voidpf opaque, unsigned int items, unsigned int size) { if (opaque) items += size - size; /* make compiler happy */ return (voidpf)calloc(items, size); } -void zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; +void zcfree (voidpf opaque, voidpf ptr) { free(ptr); if (opaque) return; /* make compiler happy */ diff --git a/Sources/Engine/zlib/zutil.h b/Sources/Engine/zlib/zutil.h index 6f2cb97..e939921 100644 --- a/Sources/Engine/zlib/zutil.h +++ b/Sources/Engine/zlib/zutil.h @@ -8,7 +8,7 @@ subject to change. Applications should only use zlib.h. */ -/* @(#) $Id$ */ +/* @(#) $Id: zutil.h,v 1.1 2001/10/04 02:45:08 icculus Exp $ */ #ifndef _Z_UTIL_H #define _Z_UTIL_H diff --git a/Sources/EntitiesMP/AirElemental.es b/Sources/EntitiesMP/AirElemental.es index 8c38102..83f51df 100644 --- a/Sources/EntitiesMP/AirElemental.es +++ b/Sources/EntitiesMP/AirElemental.es @@ -148,7 +148,7 @@ functions: /*BOOL IsTargetValid(SLONG slPropertyOffset, CEntity *penTarget) { - if( slPropertyOffset == offsetof(Classname, propert_var) { + if( slPropertyOffset == _offsetof(Classname, propert_var) { if (IsOfClass(penTarget, "???")) { return TRUE; } else { return FALSE; } return CEntity::IsTargetValid(slPropertyOffset, penTarget); @@ -158,7 +158,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("%s was -*blown away*- by an Air Elemental"), strPlayerName); + str.PrintF(TRANS("%s was -*blown away*- by an Air Elemental"), (const char *) strPlayerName); return str; } virtual const CTFileName &GetComputerMessageName(void) const { @@ -254,7 +254,7 @@ functions: CEntityPointer *penTrigger = &m_penTrigger01; // see if any triggers have to be set - INDEX i=0; + INDEX i; for (i=0; ies_ctCount = 1; - pes->es_ctAmmount = m_fValue; + pes->es_ctAmmount = (INDEX) m_fValue; switch (m_EaitType) { case AIT_SHELLS: pes->es_strName = "Shells"; diff --git a/Sources/EntitiesMP/AmmoPack.es b/Sources/EntitiesMP/AmmoPack.es index 7433a23..b64684c 100644 --- a/Sources/EntitiesMP/AmmoPack.es +++ b/Sources/EntitiesMP/AmmoPack.es @@ -133,15 +133,15 @@ functions: m_fValue = 1.0f; m_fRespawnTime = (m_fCustomRespawnTime>0) ? m_fCustomRespawnTime : 30.0f; - if( m_iShells != 0) {m_strDescription.PrintF("%s: Shells (%d)", m_strDescription, m_iShells);} - if( m_iBullets != 0) {m_strDescription.PrintF("%s: Bullets (%d)", m_strDescription, m_iBullets);} - if( m_iRockets != 0) {m_strDescription.PrintF("%s: Rockets (%d)", m_strDescription, m_iRockets);} - if( m_iGrenades != 0) {m_strDescription.PrintF("%s: Grenades (%d)", m_strDescription, m_iGrenades);} - if( m_iNapalm != 0) {m_strDescription.PrintF("%s: Napalm (%d)", m_strDescription, m_iNapalm);} - if( m_iElectricity != 0) {m_strDescription.PrintF("%s: Electricity (%d)", m_strDescription, m_iElectricity);} - if( m_iIronBalls != 0) {m_strDescription.PrintF("%s: Iron balls (%d)", m_strDescription, m_iIronBalls);} -// if( m_iNukeBalls != 0) {m_strDescription.PrintF("%s: Nuke balls (%d)", m_strDescription, m_iNukeBalls);} - if( m_iSniperBullets != 0) {m_strDescription.PrintF("%s: Sniper bullets (%d)", m_strDescription, m_iSniperBullets);} + if( m_iShells != 0) {m_strDescription.PrintF("%s: Shells (%d)", (const char *) m_strDescription, m_iShells);} + if( m_iBullets != 0) {m_strDescription.PrintF("%s: Bullets (%d)", (const char *) m_strDescription, m_iBullets);} + if( m_iRockets != 0) {m_strDescription.PrintF("%s: Rockets (%d)", (const char *) m_strDescription, m_iRockets);} + if( m_iGrenades != 0) {m_strDescription.PrintF("%s: Grenades (%d)", (const char *) m_strDescription, m_iGrenades);} + if( m_iNapalm != 0) {m_strDescription.PrintF("%s: Napalm (%d)", (const char *) m_strDescription, m_iNapalm);} + if( m_iElectricity != 0) {m_strDescription.PrintF("%s: Electricity (%d)", (const char *) m_strDescription, m_iElectricity);} + if( m_iIronBalls != 0) {m_strDescription.PrintF("%s: Iron balls (%d)", (const char *) m_strDescription, m_iIronBalls);} +// if( m_iNukeBalls != 0) {m_strDescription.PrintF("%s: Nuke balls (%d)", (const char *) m_strDescription, m_iNukeBalls);} + if( m_iSniperBullets != 0) {m_strDescription.PrintF("%s: Sniper bullets (%d)", (const char *) m_strDescription, m_iSniperBullets);} } void AdjustDifficulty(void) diff --git a/Sources/EntitiesMP/AnimationChanger.es b/Sources/EntitiesMP/AnimationChanger.es index c9ce1d1..b8e0e09 100644 --- a/Sources/EntitiesMP/AnimationChanger.es +++ b/Sources/EntitiesMP/AnimationChanger.es @@ -51,7 +51,7 @@ functions: const CTString &GetDescription(void) const { ((CTString&)m_strDescription).PrintF("->"); if (m_penTarget!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penTarget->GetName()); } return m_strDescription; } @@ -76,11 +76,11 @@ functions: // if modelholder if (IsOfClass(penTarget, "ModelHolder2")) { CModelHolder2 *penModel = (CModelHolder2*)&*penTarget; - if (slPropertyOffset==offsetof(CAnimationChanger, m_iModelAnim)) { + if (slPropertyOffset==_offsetof(CAnimationChanger, m_iModelAnim)) { return penModel->GetModelObject()->GetData(); - } else if (slPropertyOffset==offsetof(CAnimationChanger, m_iTextureAnim)) { + } else if (slPropertyOffset==_offsetof(CAnimationChanger, m_iTextureAnim)) { return penModel->GetModelObject()->mo_toTexture.GetData(); - } else if (slPropertyOffset==offsetof(CAnimationChanger, m_iLightAnim)) { + } else if (slPropertyOffset==_offsetof(CAnimationChanger, m_iLightAnim)) { return penModel->m_aoLightAnimation.GetData(); } @@ -88,11 +88,11 @@ functions: } else if (IsOfClass(penTarget, "Light")) { CLight *penLight = (CLight*)&*penTarget; - if (slPropertyOffset==offsetof(CAnimationChanger, m_iLightAnim)) + if (slPropertyOffset==_offsetof(CAnimationChanger, m_iLightAnim)) { return penLight->m_aoLightAnimation.GetData(); } - else if (slPropertyOffset==offsetof(CAnimationChanger, m_iAmbientLightAnim)) + else if (slPropertyOffset==_offsetof(CAnimationChanger, m_iAmbientLightAnim)) { return penLight->m_aoAmbientLightAnimation.GetData(); } diff --git a/Sources/EntitiesMP/AnimationHub.es b/Sources/EntitiesMP/AnimationHub.es index 577976e..868f89f 100644 --- a/Sources/EntitiesMP/AnimationHub.es +++ b/Sources/EntitiesMP/AnimationHub.es @@ -59,7 +59,7 @@ functions: const CTString &GetDescription(void) const { ((CTString&)m_strDescription).PrintF("->"); if (m_penTarget0!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s...", m_penTarget0->GetName()); + ((CTString&)m_strDescription).PrintF("->%s...", (const char *) m_penTarget0->GetName()); } return m_strDescription; } diff --git a/Sources/EntitiesMP/ArmorItem.es b/Sources/EntitiesMP/ArmorItem.es index b0c1db0..0aa3b8a 100644 --- a/Sources/EntitiesMP/ArmorItem.es +++ b/Sources/EntitiesMP/ArmorItem.es @@ -94,7 +94,7 @@ functions: { pes->es_strName = "Armor"; pes->es_ctCount = 1; - pes->es_ctAmmount = m_fValue; + pes->es_ctAmmount = (INDEX) m_fValue; pes->es_fValue = m_fValue*2; pes->es_iScore = 0;//m_iScore; switch (m_EaitType) { diff --git a/Sources/EntitiesMP/BackgroundViewer.es b/Sources/EntitiesMP/BackgroundViewer.es index 7d3b9f5..9d1f436 100644 --- a/Sources/EntitiesMP/BackgroundViewer.es +++ b/Sources/EntitiesMP/BackgroundViewer.es @@ -29,7 +29,7 @@ functions: return FALSE; } // if gradient marker - if( slPropertyOffset==offsetof(CBackgroundViewer, m_penWorldSettingsController)) + if( slPropertyOffset==_offsetof(CBackgroundViewer, m_penWorldSettingsController)) { return IsOfClass(penTarget, "WorldSettingsController"); } diff --git a/Sources/EntitiesMP/Beast.es b/Sources/EntitiesMP/Beast.es index 478afd1..09a630e 100644 --- a/Sources/EntitiesMP/Beast.es +++ b/Sources/EntitiesMP/Beast.es @@ -19,7 +19,7 @@ enum BeastType { }; %{ -static FLOAT _tmLastStandingAnim =0.0f; +static int _tmLastStandingAnim = 0; #define BEAST_STRETCH 2.0f #define BIG_BEAST_STRETCH 12.0f #define HUGE_BEAST_STRETCH 30.0f @@ -76,7 +76,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("A Reptiloid killed %s"), strPlayerName); + str.PrintF(TRANS("A Reptiloid killed %s"), (const char *) strPlayerName); return str; } virtual const CTFileName &GetComputerMessageName(void) const { @@ -221,7 +221,7 @@ functions: // virtual anim functions void StandingAnim(void) { - _tmLastStandingAnim = _pTimer->CurrentTick(); + _tmLastStandingAnim = (int) _pTimer->CurrentTick(); StartModelAnim(BEAST_ANIM_IDLE, AOF_LOOPING|AOF_NORESTART); }; diff --git a/Sources/EntitiesMP/Boneman.es b/Sources/EntitiesMP/Boneman.es index 5379529..2e922c9 100644 --- a/Sources/EntitiesMP/Boneman.es +++ b/Sources/EntitiesMP/Boneman.es @@ -77,9 +77,9 @@ functions: { CTString str; if (eDeath.eLastDamage.dmtType==DMT_CLOSERANGE) { - str.PrintF(TRANS("%s was ripped apart by a Kleer"), strPlayerName); + str.PrintF(TRANS("%s was ripped apart by a Kleer"), (const char *) strPlayerName); } else { - str.PrintF(TRANS("%s was killed by a Kleer"), strPlayerName); + str.PrintF(TRANS("%s was killed by a Kleer"), (const char *) strPlayerName); } return str; } diff --git a/Sources/EntitiesMP/Camera.es b/Sources/EntitiesMP/Camera.es index bf61ea2..6067825 100644 --- a/Sources/EntitiesMP/Camera.es +++ b/Sources/EntitiesMP/Camera.es @@ -5,6 +5,7 @@ #include "StdH.h" %} +uses "EntitiesMP/WorldLink"; uses "EntitiesMP/Player"; uses "EntitiesMP/CameraMarker"; @@ -103,7 +104,7 @@ functions: const CTString &GetDescription(void) const { if (m_penTarget!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penTarget->GetName()); } else { ((CTString&)m_strDescription).PrintF("->"); } @@ -621,7 +622,7 @@ procedures: m_fLastFOV = m_fFOV; if( m_penTarget!=NULL && !IsOfClass( m_penTarget, "Camera Marker")) { - WarningMessage( "Entity '%s' is not of Camera Marker class!", m_penTarget); + WarningMessage( "Entity '%s' is not of Camera Marker class!", (const char *) (m_penTarget->GetName())); m_penTarget = NULL; } diff --git a/Sources/EntitiesMP/CameraMarker.es b/Sources/EntitiesMP/CameraMarker.es index b7ed4dc..ef61e40 100644 --- a/Sources/EntitiesMP/CameraMarker.es +++ b/Sources/EntitiesMP/CameraMarker.es @@ -78,7 +78,7 @@ procedures: SetModelMainTexture(TEXTURE_MARKER); if( m_penTarget!=NULL && !IsOfClass( m_penTarget, "Camera Marker")) { - WarningMessage( "Entity '%s' is not of Camera Marker class!", m_penTarget); + WarningMessage( "Entity '%s' is not of Camera Marker class!", (const char *) (m_penTarget->GetName())); m_penTarget = NULL; } diff --git a/Sources/EntitiesMP/CannonBall.es b/Sources/EntitiesMP/CannonBall.es index 408ce8f..3e54096 100644 --- a/Sources/EntitiesMP/CannonBall.es +++ b/Sources/EntitiesMP/CannonBall.es @@ -3,7 +3,7 @@ 506 %{ #include "StdH.h" -#include "Models/Weapons/Cannon/Projectile/Cannonball.h" +#include "Models/Weapons/Cannon/Projectile/CannonBall.h" #include "EntitiesMP/MovingBrush.h" #include "EntitiesMP/DestroyableArchitecture.h" %} diff --git a/Sources/EntitiesMP/CannonRotating.es b/Sources/EntitiesMP/CannonRotating.es index 04a95e6..918d3fd 100644 --- a/Sources/EntitiesMP/CannonRotating.es +++ b/Sources/EntitiesMP/CannonRotating.es @@ -89,7 +89,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("A Cannon killed %s"), strPlayerName); + str.PrintF(TRANS("A Cannon killed %s"), (const char *) strPlayerName); return str; } @@ -398,7 +398,7 @@ procedures: if (penKiller!=NULL) { // give him score EReceiveScore eScore; - eScore.iPoints = m_iScore; + eScore.iPoints = (INDEX) m_iScore; penKiller->SendEvent(eScore); if( CountAsKill()) { diff --git a/Sources/EntitiesMP/CannonStatic.es b/Sources/EntitiesMP/CannonStatic.es index af71f62..022cf60 100644 --- a/Sources/EntitiesMP/CannonStatic.es +++ b/Sources/EntitiesMP/CannonStatic.es @@ -81,7 +81,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("A Cannon killed %s"), strPlayerName); + str.PrintF(TRANS("A Cannon killed %s"), (const char *) strPlayerName); return str; } @@ -324,7 +324,7 @@ procedures: if (penKiller!=NULL) { // give him score EReceiveScore eScore; - eScore.iPoints = m_iScore; + eScore.iPoints = (INDEX) m_iScore; penKiller->SendEvent(eScore); if( CountAsKill()) { diff --git a/Sources/EntitiesMP/ChainsawFreak.es b/Sources/EntitiesMP/ChainsawFreak.es index e7f2b29..c6de543 100644 --- a/Sources/EntitiesMP/ChainsawFreak.es +++ b/Sources/EntitiesMP/ChainsawFreak.es @@ -61,7 +61,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("Chainsaw freak dismembered %s"), strPlayerName); + str.PrintF(TRANS("Chainsaw freak dismembered %s"), (const char *) strPlayerName); return str; } diff --git a/Sources/EntitiesMP/Common/Common.cpp b/Sources/EntitiesMP/Common/Common.cpp index 9de8dbb..f139cf0 100644 --- a/Sources/EntitiesMP/Common/Common.cpp +++ b/Sources/EntitiesMP/Common/Common.cpp @@ -1,7 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" -#include +#include "EntitiesMP/StdH/StdH.h" #include "EntitiesMP/Reminder.h" #include "EntitiesMP/Flame.h" #include "EntitiesMP/Debris.h" @@ -56,7 +55,7 @@ void CCompMessageID::NewMessage(const CTFileName &fnm) } else if (strName.Matches("*messages\\statistics*")) { cmi_cmtType = CMT_STATISTICS; } else { - CPrintF("Unknown message type: %s\n", (const CTString&) fnm); + CPrintF("Unknown message type: %s\n", (const char *) fnm); cmi_cmtType = CMT_INFORMATION; } // mark as unread @@ -373,8 +372,8 @@ void SpawnHitTypeEffect(CEntity *pen, enum BulletHitType bhtType, BOOL bSound, F { GetNormalComponent( vDistance/fDistance, vHitNormal, ese.vDirection); FLOAT fLength = ese.vDirection.Length(); - fLength = Clamp( fLength*3.0f, 1.0f, 3.0f); - fDistance = Clamp( (FLOAT)log10(fDistance), 0.5f, 2.0f); + fLength = Clamp( fLength*3, 1.0f, 3.0f); + fDistance = Clamp( log10(fDistance), 0.5, 2.0); ese.vStretch = FLOAT3D( fDistance, fLength*fDistance, 1.0f); try { @@ -985,8 +984,8 @@ COLOR _colDebris; // debris spawning void Debris_Begin( EntityInfoBodyType Eeibt, - enum DebrisParticlesType dptParticles, - enum BasicEffectType betStain, + int /*enum DebrisParticlesType*/ _dptParticles, + int /*enum BasicEffectType*/ _betStain, FLOAT fEntitySize, // entity size in meters const FLOAT3D &vSpeed, const FLOAT3D &vSpawnerSpeed, // how fast was the entity moving @@ -995,6 +994,9 @@ void Debris_Begin( const COLOR colDebris /*=C_WHITE*/ // multiply color ) { + enum DebrisParticlesType dptParticles = (enum DebrisParticlesType) _dptParticles; + enum BasicEffectType betStain = (enum BasicEffectType) _betStain; + _Eeibt = Eeibt ; _dptParticles = dptParticles; _betStain = betStain ; @@ -1129,8 +1131,8 @@ CEntityPointer Debris_Spawn_Independent( CEntityPointer Debris_Spawn_Template( EntityInfoBodyType eibt, - enum DebrisParticlesType dptParticles, - enum BasicEffectType betStain, + int /*enum DebrisParticlesType*/ _dptParticles, + int /*enum BasicEffectType*/ _betStain, CModelHolder2 *penmhDestroyed, CEntity *penComponents, CModelHolder2 *penmhTemplate, @@ -1143,6 +1145,9 @@ CEntityPointer Debris_Spawn_Template( FLOAT fDustStretch, COLOR colBurning) { + enum DebrisParticlesType dptParticles = (enum DebrisParticlesType) _dptParticles; + enum BasicEffectType betStain = (enum BasicEffectType) _betStain; + if(penmhTemplate==NULL || penmhTemplate->GetModelObject()==NULL) { return NULL; @@ -1371,7 +1376,7 @@ CPlacement3D LerpPlacementsPrecise(const CPlacement3D &pl0, const CPlacement3D & FLOAT3D v0 = pl0.pl_PositionVector; FLOAT3D v1 = pl1.pl_PositionVector; - FLOATquat3D q = Slerp(fRatio, q0, q1); + FLOATquat3D q = Slerp(fRatio, q0, q1); FLOAT3D v = Lerp(v0, v1, fRatio); pl.pl_PositionVector = v; @@ -1393,7 +1398,7 @@ FLOAT GetGameDamageMultiplier(void) FLOAT fExtraStrengthPerPlayer = GetSP()->sp_fExtraEnemyStrengthPerPlayer; if (fExtraStrengthPerPlayer>0) { INDEX ctPlayers = _pNetwork->ga_sesSessionState.GetPlayersCount(); - fGameDamageMultiplier*=1.0f/(1+fExtraStrengthPerPlayer*ClampDn(ctPlayers-1.0f, 0.0f)); + fGameDamageMultiplier*=1.0f/(1+fExtraStrengthPerPlayer*ClampDn(((FLOAT) ctPlayers)-1.0f, 0.0f)); } if (GetSP()->sp_gdGameDifficulty==CSessionProperties::GD_TOURIST) { fGameDamageMultiplier *= 2.0f; diff --git a/Sources/EntitiesMP/Common/Common.h b/Sources/EntitiesMP/Common/Common.h index 7a1a030..36c5760 100644 --- a/Sources/EntitiesMP/Common/Common.h +++ b/Sources/EntitiesMP/Common/Common.h @@ -2,6 +2,16 @@ // common headers for flesh entity classes +#ifndef SE_INCL_ENTITIESMP_COMMON_H +#define SE_INCL_ENTITIESMP_COMMON_H +#ifdef PRAGMA_ONCE +#pragma once +#endif + +#if 0 +#include /* rcg01202003 need enum definition... */ +#include /* rcg01202003 need enum definition... */ +#endif #define SURFACE_SAND 9 #define SURFACE_WATER 12 @@ -122,6 +132,7 @@ struct EntityStats { INDEX es_ctAmmount; FLOAT es_fValue; INDEX es_iScore; + inline void Clear() { es_strName.Clear(); } }; // statistics data for player stats management @@ -142,6 +153,27 @@ struct DECL_DLL PlayerStats { } }; +static inline CTStream &operator>>(CTStream &strm, PlayerStats &ps) +{ + strm>>ps.ps_iScore; + strm>>ps.ps_iKills; + strm>>ps.ps_iDeaths; + strm>>ps.ps_iSecrets; + strm>>ps.ps_tmTime; + return strm; +} + +static inline CTStream &operator<<(CTStream &strm, const PlayerStats &ps) +{ + strm<>ep_vLastPos; + strm>>ep_vPos; + strm>>ep_fLastRot; + strm>>ep_fRot; + strm>>ep_fRotSpeed; + strm>>ep_vSpeed; + strm>>ep_colLastColor; + strm>>ep_colColor; + strm>>ep_tmEmitted; + strm>>ep_tmLife; + strm>>ep_fStretch; } CEmiter::CEmiter(void) diff --git a/Sources/EntitiesMP/Common/HUD.cpp b/Sources/EntitiesMP/Common/HUD.cpp index ed99c06..3853f09 100644 --- a/Sources/EntitiesMP/Common/HUD.cpp +++ b/Sources/EntitiesMP/Common/HUD.cpp @@ -1,7 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ - -#include "StdH.h" +#include "EntitiesMP/StdH/StdH.h" #include "GameMP/SEColors.h" #include @@ -77,7 +76,7 @@ static TIME _tmLast = -1.0f; static CFontData _fdNumbersFont; // array for pointers of all players -extern CPlayer *_apenPlayers[NET_MAXGAMEPLAYERS] = {0}; +CPlayer *_apenPlayers[NET_MAXGAMEPLAYERS] = {0}; // status bar textures static CTextureObject _toHealth; @@ -307,7 +306,7 @@ static COLOR AddShaker( PIX const pixAmmount, INDEX const iCurrentValue, INDEX & // shake, baby shake! const FLOAT fAmmount = _fResolutionScaling * _fCustomScaling * pixAmmount; const FLOAT fMultiplier = (SHAKE_TIME-tmDelta)/SHAKE_TIME *fAmmount; - const INDEX iRandomizer = (INDEX)(tmNow*511.0f)*fAmmount*iCurrentValue; + const INDEX iRandomizer = (INDEX)((tmNow*511.0f)*fAmmount*iCurrentValue); const FLOAT fNormRnd1 = (FLOAT)((iRandomizer ^ (iRandomizer>>9)) & 1023) * 0.0009775f; // 1/1023 - normalized const FLOAT fNormRnd2 = (FLOAT)((iRandomizer ^ (iRandomizer>>7)) & 1023) * 0.0009775f; // 1/1023 - normalized fMoverX = (fNormRnd1 -0.5f) * fMultiplier; @@ -505,18 +504,18 @@ static void HUD_DrawBar( FLOAT fCenterX, FLOAT fCenterY, PIX pixSizeX, PIX pixSi // determine bar position and inner size switch( eBarOrientation) { case BO_UP: - pixSizeJ *= fNormValue; + pixSizeJ *= (PIX) fNormValue; break; case BO_DOWN: pixUpper = pixUpper + (PIX)ceil(pixSizeJ * (1.0f-fNormValue)); - pixSizeJ *= fNormValue; + pixSizeJ *= (PIX) fNormValue; break; case BO_LEFT: - pixSizeI *= fNormValue; + pixSizeI *= (PIX) fNormValue; break; case BO_RIGHT: pixLeft = pixLeft + (PIX)ceil(pixSizeI * (1.0f-fNormValue)); - pixSizeI *= fNormValue; + pixSizeI *= (PIX) fNormValue; break; } // done @@ -724,13 +723,13 @@ static void HUD_DrawEntityStack() if (DBG_prenStackOutputEntity!=NULL) { pixFontHeight = _pfdConsoleFont->fd_pixCharHeight; - pixTextBottom = _pixDPHeight*0.83; + pixTextBottom = (ULONG) (_pixDPHeight*0.83); _pDP->SetFont( _pfdConsoleFont); _pDP->SetTextScaling( 1.0f); INDEX ctStates = DBG_prenStackOutputEntity->en_stslStateStack.Count(); - strTemp.PrintF("-- stack of '%s'(%s)@%gs\n", DBG_prenStackOutputEntity->GetName(), - DBG_prenStackOutputEntity->en_pecClass->ec_pdecDLLClass->dec_strName, + strTemp.PrintF("-- stack of '%s'(%s)@%gs\n", (const char *) DBG_prenStackOutputEntity->GetName(), + (const char *) DBG_prenStackOutputEntity->en_pecClass->ec_pdecDLLClass->dec_strName, _pTimer->CurrentTick()); _pDP->PutText( strTemp, 1, pixTextBottom-pixFontHeight*(ctStates+1), _colHUD|_ulAlphaHUD); @@ -812,7 +811,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO const PIX pixTopBound = 6; const PIX pixLeftBound = 6; - const PIX pixBottomBound = (480 * _pDP->dp_fWideAdjustment) -pixTopBound; + const PIX pixBottomBound = (PIX) ((480 * _pDP->dp_fWideAdjustment) -pixTopBound); const PIX pixRightBound = 640-pixLeftBound; FLOAT fOneUnit = (32+0) * _fCustomScaling; // unit size FLOAT fAdvUnit = (32+4) * _fCustomScaling; // unit advancer @@ -828,7 +827,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO PrepareColorTransitions( colMax, colTop, colMid, C_RED, 0.5f, 0.25f, FALSE); fRow = pixBottomBound-fHalfUnit; fCol = pixLeftBound+fHalfUnit; - colDefault = AddShaker( 5, fValue, penLast->m_iLastHealth, penLast->m_tmHealthChanged, fMoverX, fMoverY); + colDefault = AddShaker( 5, (INDEX) fValue, penLast->m_iLastHealth, penLast->m_tmHealthChanged, fMoverX, fMoverY); HUD_DrawBorder( fCol+fMoverX, fRow+fMoverY, fOneUnit, fOneUnit, colBorder); fCol += fAdvUnit+fChrUnit*3/2 -fHalfUnit; HUD_DrawBorder( fCol, fRow, fChrUnit*3, fOneUnit, colBorder); @@ -844,7 +843,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO PrepareColorTransitions( colMax, colTop, colMid, C_lGRAY, 0.5f, 0.25f, FALSE); fRow = pixBottomBound- (fNextUnit+fHalfUnit);//*_pDP->dp_fWideAdjustment; fCol = pixLeftBound+ fHalfUnit; - colDefault = AddShaker( 3, fValue, penLast->m_iLastArmor, penLast->m_tmArmorChanged, fMoverX, fMoverY); + colDefault = AddShaker( 3, (INDEX) fValue, penLast->m_iLastArmor, penLast->m_tmArmorChanged, fMoverX, fMoverY); HUD_DrawBorder( fCol+fMoverX, fRow+fMoverY, fOneUnit, fOneUnit, colBorder); fCol += fAdvUnit+fChrUnit*3/2 -fHalfUnit; HUD_DrawBorder( fCol, fRow, fChrUnit*3, fOneUnit, colBorder); @@ -882,7 +881,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO // draw ammo, value and weapon fRow = pixBottomBound-fHalfUnit; fCol = 175 + fHalfUnit; - colDefault = AddShaker( 4, fValue, penLast->m_iLastAmmo, penLast->m_tmAmmoChanged, fMoverX, fMoverY); + colDefault = AddShaker( 4, (INDEX) fValue, penLast->m_iLastAmmo, penLast->m_tmAmmoChanged, fMoverX, fMoverY); HUD_DrawBorder( fCol+fMoverX, fRow+fMoverY, fOneUnit, fOneUnit, colBorder); fCol += fAdvUnit+fChrUnit*3/2 -fHalfUnit; HUD_DrawBorder( fCol, fRow, fChrUnit*3, fOneUnit, colBorder); @@ -944,7 +943,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO } HUD_DrawBorder( fCol, fRow, fOneUnitS, fOneUnitS, colBombBorder); HUD_DrawIcon( fCol, fRow, _toASeriousBomb, colBombIcon, fNormValue, FALSE); - HUD_DrawBar( fCol+fBarPos, fRow, fOneUnitS/5, fOneUnitS-2, BO_DOWN, colBombBar, fNormValue); + HUD_DrawBar( fCol+fBarPos, fRow, (INDEX) (fOneUnitS/5), (INDEX) (fOneUnitS-2), BO_DOWN, colBombBar, fNormValue); // make space for serious bomb fCol -= fAdvUnitS; } @@ -965,7 +964,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO colBar = AddShaker( 4, ai.ai_iAmmoAmmount, ai.ai_iLastAmmoAmmount, ai.ai_tmAmmoChanged, fMoverX, fMoverY); HUD_DrawBorder( fCol, fRow+fMoverY, fOneUnitS, fOneUnitS, colBorder); HUD_DrawIcon( fCol, fRow+fMoverY, *_aaiAmmo[i].ai_ptoAmmo, colIcon, fNormValue, FALSE); - HUD_DrawBar( fCol+fBarPos, fRow+fMoverY, fOneUnitS/5, fOneUnitS-2, BO_DOWN, colBar, fNormValue); + HUD_DrawBar( fCol+fBarPos, fRow+fMoverY, (INDEX) (fOneUnitS/5), (INDEX) (fOneUnitS-2), BO_DOWN, colBar, fNormValue); // advance to next position fCol -= fAdvUnitS; } @@ -986,7 +985,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO // draw icon and a little bar HUD_DrawBorder( fCol, fRow, fOneUnitS, fOneUnitS, colBorder); HUD_DrawIcon( fCol, fRow, _atoPowerups[i], C_WHITE /*_colHUD*/, fNormValue, TRUE); - HUD_DrawBar( fCol+fBarPos, fRow, fOneUnitS/5, fOneUnitS-2, BO_DOWN, NONE, fNormValue); + HUD_DrawBar( fCol+fBarPos, fRow, (INDEX) (fOneUnitS/5), (INDEX) (fOneUnitS-2), BO_DOWN, NONE, fNormValue); // play sound if icon is flashing if(fNormValue<=(_cttHUD.ctt_fLowMedium/2)) { // activate blinking only if value is <= half the low edge @@ -1066,7 +1065,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO fNormValue = ClampDn(fNormValue, 0.0f); HUD_DrawBorder( fCol, fRow, fOneUnit, fOneUnit, colBorder); HUD_DrawBorder( fCol+fAdv, fRow, fOneUnit*4, fOneUnit, colBorder); - HUD_DrawBar( fCol+fAdv, fRow, fOneUnit*4*0.975, fOneUnit*0.9375, BO_LEFT, NONE, fNormValue); + HUD_DrawBar( fCol+fAdv, fRow, (INDEX) (fOneUnit*4*0.975), (INDEX) (fOneUnit*0.9375), BO_LEFT, NONE, fNormValue); HUD_DrawIcon( fCol, fRow, _toOxygen, C_WHITE /*_colHUD*/, fNormValue, TRUE); bOxygenOnScreen = TRUE; } @@ -1100,7 +1099,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO if( bOxygenOnScreen) fRow += fNextUnit; HUD_DrawBorder( fCol, fRow, fOneUnit, fOneUnit, colBorder); HUD_DrawBorder( fCol+fAdv, fRow, fOneUnit*16, fOneUnit, colBorder); - HUD_DrawBar( fCol+fAdv, fRow, fOneUnit*16*0.995, fOneUnit*0.9375, BO_LEFT, NONE, fNormValue); + HUD_DrawBar( fCol+fAdv, fRow, (INDEX) (fOneUnit*16*0.995), (INDEX) (fOneUnit*0.9375), BO_LEFT, NONE, fNormValue); HUD_DrawIcon( fCol, fRow, _toHealth, C_WHITE /*_colHUD*/, fNormValue, FALSE); } } @@ -1194,7 +1193,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO CTString strLimitsInfo=""; if (GetSP()->sp_iTimeLimit>0) { FLOAT fTimeLeft = ClampDn(GetSP()->sp_iTimeLimit*60.0f - _pNetwork->GetGameTime(), 0.0f); - strLimitsInfo.PrintF("%s^cFFFFFF%s: %s\n", strLimitsInfo, TRANS("TIME LEFT"), TimeToString(fTimeLeft)); + strLimitsInfo.PrintF("%s^cFFFFFF%s: %s\n", (const char *) strLimitsInfo, TRANS("TIME LEFT"), (const char *) TimeToString(fTimeLeft)); } extern INDEX SetAllPlayersStats( INDEX iSortKey); // fill players table @@ -1209,11 +1208,11 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO }} if (GetSP()->sp_iFragLimit>0) { INDEX iFragsLeft = ClampDn(GetSP()->sp_iFragLimit-iMaxFrags, INDEX(0)); - strLimitsInfo.PrintF("%s^cFFFFFF%s: %d\n", strLimitsInfo, TRANS("FRAGS LEFT"), iFragsLeft); + strLimitsInfo.PrintF("%s^cFFFFFF%s: %d\n", (const char *) strLimitsInfo, TRANS("FRAGS LEFT"), iFragsLeft); } if (GetSP()->sp_iScoreLimit>0) { INDEX iScoreLeft = ClampDn(GetSP()->sp_iScoreLimit-iMaxScore, INDEX(0)); - strLimitsInfo.PrintF("%s^cFFFFFF%s: %d\n", strLimitsInfo, TRANS("SCORE LEFT"), iScoreLeft); + strLimitsInfo.PrintF("%s^cFFFFFF%s: %d\n", (const char *) strLimitsInfo, TRANS("SCORE LEFT"), iScoreLeft); } _pfdDisplayFont->SetFixedWidth(); _pDP->SetFont( _pfdDisplayFont); @@ -1334,7 +1333,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO // draw cheat modes if( GetSP()->sp_ctMaxPlayers==1) { INDEX iLine=1; - ULONG ulAlpha = sin(_tmNow*16)*96 +128; + ULONG ulAlpha = (ULONG) (sin(_tmNow*16)*96 +128); PIX pixFontHeight = _pfdConsoleFont->fd_pixCharHeight; const COLOR colCheat = _colHUDText; _pDP->SetFont( _pfdConsoleFont); diff --git a/Sources/EntitiesMP/Common/Particles.cpp b/Sources/EntitiesMP/Common/Particles.cpp index 4edbf9d..7324977 100644 --- a/Sources/EntitiesMP/Common/Particles.cpp +++ b/Sources/EntitiesMP/Common/Particles.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "EntitiesMP/StdH/StdH.h" #include "EntitiesMP/BloodSpray.h" #include "EntitiesMP/PlayerWeapons.h" #include "EntitiesMP/WorldSettingsController.h" @@ -1129,8 +1129,8 @@ void Particles_RocketTrail(CEntity *pen, FLOAT fStretch) const FLOAT3D *pvPos2 = &plp->GetPosition(1); INDEX iParticle = 0; INDEX iParticlesLiving = plp->lp_ctUsed*ROCKET_TRAIL_INTERPOSITIONS; - INDEX iPos=2; - for( ; iPoslp_ctUsed; iPos++) + INDEX iPos; + for( iPos=2; iPoslp_ctUsed; iPos++) { pvPos1 = pvPos2; pvPos2 = &plp->GetPosition(iPos); @@ -1206,9 +1206,9 @@ void Particles_ExplosionDebris1(CEntity *pen, FLOAT tmStart, FLOAT3D vStretch, C vRel(3)*=vStretch(3); FLOAT3D vPos=vCenter+vRel; - UBYTE ubR = 255; - UBYTE ubG = 240+afStarsPositions[iRnd][1]*32; - UBYTE ubB = 240+afStarsPositions[iRnd][2]*32; + UBYTE ubR = (UBYTE) (255); + UBYTE ubG = (UBYTE) (240+afStarsPositions[iRnd][1]*32); + UBYTE ubB = (UBYTE) (240+afStarsPositions[iRnd][2]*32); COLOR colAlpha = pTD->GetTexel(PIX(ClampUp(fRatio*1024.0f, 1023.0f)), 0); COLOR col= RGBToColor( ubR, ubG, ubB) | (colAlpha&0x000000FF); col=MulColors(col, colMultiply); @@ -1304,9 +1304,9 @@ void Particles_ExplosionDebris3(CEntity *pen, FLOAT tmStart, FLOAT3D vStretch, C FLOAT3D vOldPos=vCenter+vRelOld; if( (vPos - vOldPos).Length() == 0.0f) {continue;} - UBYTE ubR = 255; - UBYTE ubG = 200+afStarsPositions[iRnd][1]*32; - UBYTE ubB = 150+afStarsPositions[iRnd][2]*32; + UBYTE ubR = (UBYTE) (255); + UBYTE ubG = (UBYTE) (200+afStarsPositions[iRnd][1]*32); + UBYTE ubB = (UBYTE) (150+afStarsPositions[iRnd][2]*32); COLOR colAlpha = pTD->GetTexel(PIX(ClampUp(fRatio*1024.0f, 1023.0f)), 0); COLOR col= RGBToColor( ubR, ubG, ubB) | (colAlpha&0x000000FF); col=MulColors(col, colMultiply); @@ -1525,7 +1525,7 @@ INDEX Particles_FireBreath(CEntity *pen, FLOAT3D vSource, FLOAT3D vTarget, FLOAT afStarsPositions[iFlame][2])*10; FLOAT3D vPos = Lerp( vSource, vFocus+vRnd, fT); FLOAT fSize = 5.0f*fT+5.0f; - UBYTE ub = CalculateRatio( fT, 0.0f, 1.0f, 0.1f, 0.2f)*255; + UBYTE ub = (UBYTE) CalculateRatio( fT, 0.0f, 1.0f, 0.1f, 0.2f)*255; Particle_RenderSquare( vPos, fSize, fT*(1.0f+afStarsPositions[iFlame*3][1])*360.0f, RGBToColor(ub,ub,ub)|0xFF); ctRendered++; } @@ -1576,10 +1576,10 @@ INDEX Particles_Regeneration(CEntity *pen, FLOAT tmStart, FLOAT tmStop, FLOAT fY vPos2 = Lerp( vSource, vDestination, fT2); } - UBYTE ubR = 192+afStarsPositions[iRnd][1]*64; - UBYTE ubG = 192+afStarsPositions[iRnd][2]*64; - UBYTE ubB = 192+afStarsPositions[iRnd][3]*64; - UBYTE ubA = CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f)*255; + UBYTE ubR = (UBYTE) (192+afStarsPositions[iRnd][1]*64); + UBYTE ubG = (UBYTE) (192+afStarsPositions[iRnd][2]*64); + UBYTE ubB = (UBYTE) (192+afStarsPositions[iRnd][3]*64); + UBYTE ubA = (UBYTE) CalculateRatio( fT, 0.0f, 1.0f, 0.4f, 0.01f)*255; COLOR colLine = RGBToColor( ubR, ubG, ubB) | ubA; FLOAT fSize = 1.0f; @@ -1719,7 +1719,7 @@ void Particles_FlameThrowerStart(const CPlacement3D &plPipe, FLOAT fStartTime, F FLOAT fPowerFactor = Clamp((fNow - fStartTime)/2.0f,0.0f,1.0f); fPowerFactor *= Clamp(1+(fStopTime-fNow)/2.0f,0.0f,1.0f); - INDEX ctParticles = FLOAT(CT_FTSPARKS) * fPowerFactor; + INDEX ctParticles = (INDEX) (FLOAT(CT_FTSPARKS) * fPowerFactor); ASSERT( ctParticles<=CT_MAX_PARTICLES_TABLE); FLOAT fHeight = 1.0f*fPowerFactor; INDEX iParticle=0; @@ -1791,12 +1791,12 @@ void Particles_ShooterFlame(const CPlacement3D &plEnd, const CPlacement3D &plSta FLOAT fAngle = fTime*180.0f*afStarsPositions[iRndFact][0]; // transparency UBYTE ub = 255; - if (fTime>1.0f) ub = 0.0f; - else if(fTime>0.6f) ub = (1.0-fTime)*(1.0/0.4)*255; + if (fTime>1.0f) ub = 0; + else if(fTime>0.6f) ub = (UBYTE) ((1.0-fTime)*(1.0/0.4)*255); // color with a bit of red tint before the burnout COLOR col = RGBToColor(192, 192, 192); if (fTime>0.95f) col = RGBToColor(192, 0, 0); - else if (fTime>0.4) col = RGBToColor(192, (1.0-fTime)*(1.0/0.6)*100+92, (1.0-fTime)*(1.0/0.6)*112+80); + else if (fTime>0.4) col = RGBToColor(192, (UBYTE) ((1.0-fTime)*(1.0/0.6)*100+92), (UBYTE) ((1.0-fTime)*(1.0/0.6)*112+80)); vPos(1) += afStarsPositions[iRndFact][0]*fTime; vPos(2) += afStarsPositions[iRndFact][1]*fTime + 0.25*fTime*fTime; @@ -1840,9 +1840,9 @@ void Particles_Stardust( CEntity *pen, FLOAT fSize, FLOAT fHeight, const FLOAT3D vPos = vCenter+FLOAT3D( afStarsPositions[iMemeber][0], afStarsPositions[iMemeber][1], afStarsPositions[iMemeber][2])*fSize; - COLOR colStar = RGBToColor( auStarsColors[iMemeber][0]*fFade, - auStarsColors[iMemeber][1]*fFade, - auStarsColors[iMemeber][2]*fFade); + COLOR colStar = RGBToColor((UBYTE) (auStarsColors[iMemeber][0]*fFade), + (UBYTE) (auStarsColors[iMemeber][1]*fFade), + (UBYTE) (auStarsColors[iMemeber][2]*fFade)); Particle_RenderSquare( vPos, 0.15f, 0, colStar|0xFF); } // all done @@ -1911,7 +1911,7 @@ void Particles_Spiral( CEntity *pen, FLOAT fSize, FLOAT fHeight, if( fMipFactor>7.0f) return; fMipFactor = 2.5f-fMipFactor*0.3f; fMipFactor = Clamp( fMipFactor, 0.0f, 1.0f); - INDEX ctSpiralTrail = fMipFactor*CT_SPIRAL_TRAIL; + INDEX ctSpiralTrail = (INDEX) (fMipFactor*CT_SPIRAL_TRAIL); if( ctSpiralTrail<=0) return; FLOAT fTrailDelta = 0.1f/fMipFactor; @@ -2214,7 +2214,7 @@ void Particles_DustFall(CEntity *pen, FLOAT tmStarted, FLOAT3D vStretch) FLOAT fT = _pTimer->GetLerpedCurrentTick()-tmStarted; FLOAT fStretch=vStretch.Length(); - INDEX ctParticles=4+fSizeRatio*28; + INDEX ctParticles=(INDEX) (4+fSizeRatio*28); for(INDEX iDust=0; iDust<32; iDust++) { INDEX iRnd = (pen->en_ulID*12345+iDust)%CT_MAX_PARTICLES_TABLE; @@ -2326,10 +2326,10 @@ void Particles_ElectricitySparks( CEntity *pen, FLOAT fTimeAppear, FLOAT fSize, FLOAT3D vPosOld = SPARK_CURVE( fTold); FLOAT3D vPosNew = SPARK_CURVE( fT); - UBYTE ubR = 224+(afStarsPositions[iSpark][2]+0.5f)*32; - UBYTE ubG = 224+(afStarsPositions[iSpark][2]+0.5f)*32; - UBYTE ubB = 160; - UBYTE ubA = FloatToInt( 255 * fFade); + UBYTE ubR = (UBYTE) (224+(afStarsPositions[iSpark][2]+0.5f)*32); + UBYTE ubG = (UBYTE) (224+(afStarsPositions[iSpark][2]+0.5f)*32); + UBYTE ubB = (UBYTE) (160); + UBYTE ubA = (UBYTE) (FloatToInt( 255 * fFade)); COLOR colStar = RGBToColor( ubR, ubG, ubB) | ubA; Particle_RenderLine( vPosOld, vPosNew, 0.075f, colStar); } @@ -2376,7 +2376,7 @@ void Particles_Atomic( CEntity *pen, FLOAT fSize, FLOAT fHeight, if( fMipFactor>7.0f) return; fMipFactor = 2.5f-fMipFactor*0.3f; fMipFactor = Clamp(fMipFactor, 0.0f ,1.0f); - INDEX ctAtomicTrail = fMipFactor*CT_ATOMIC_TRAIL; + INDEX ctAtomicTrail = (INDEX) (fMipFactor*CT_ATOMIC_TRAIL); if( ctAtomicTrail<=0) return; FLOAT fTrailDelta = 0.075f/fMipFactor; @@ -2422,7 +2422,7 @@ void Particles_PowerUpIndicator( CEntity *pen, enum ParticleTexture ptTexture, F if( fMipFactor>7.0f) return; fMipFactor = 2.5f-fMipFactor*0.3f; fMipFactor = Clamp(fMipFactor, 0.0f ,1.0f); - INDEX ctAtomicTrail = fMipFactor*iTrailCount; + INDEX ctAtomicTrail = (INDEX) (fMipFactor*iTrailCount); if( ctAtomicTrail<=0) return; FLOAT fTrailDelta = 0.075f/fMipFactor; @@ -2581,7 +2581,7 @@ BOOL UpdateGrowthCache(CEntity *pen, CTextureData *ptdGrowthMap, FLOATaabbox3D & fGridStep = GROWTH_RENDERING_STEP; fXSpan = 1234; - INDEX iGridX1 = GROWTH_RENDERING_RADIUS_FADE/GROWTH_RENDERING_STEP; + INDEX iGridX1 = (INDEX) (GROWTH_RENDERING_RADIUS_FADE/GROWTH_RENDERING_STEP); INDEX iGridX0 = -iGridX1; INDEX iGridY1 = iGridX1; INDEX iGridY0 = -iGridX1; @@ -2638,8 +2638,8 @@ BOOL UpdateGrowthCache(CEntity *pen, CTextureData *ptdGrowthMap, FLOATaabbox3D & } // absolute positions : - INDEX i = iC*GROWTH_RENDERING_STEP + vSnapped(1); - INDEX j = jC*GROWTH_RENDERING_STEP + vSnapped(3); + INDEX i = (INDEX) (iC*GROWTH_RENDERING_STEP + vSnapped(1)); + INDEX j = (INDEX) (jC*GROWTH_RENDERING_STEP + vSnapped(3)); // apply a bit of randomness: @@ -3095,7 +3095,7 @@ void Particles_Rain(CEntity *pen, FLOAT fGridSize, INDEX ctGrids, FLOAT fFactor, fZ+=afStarsPositions[iRnd2][2]; // stretch to falling time FLOAT fY = vPos(2)+RAIN_SOURCE_HEIGHT*(1-fRatio); - UBYTE ubR = 64+afStarsPositions[(INDEX)fT0*CT_MAX_PARTICLES_TABLE][2]*64; + UBYTE ubR = (UBYTE) (64+afStarsPositions[(INDEX)fT0*CT_MAX_PARTICLES_TABLE][2]*64); COLOR colDrop = RGBToColor(ubR, ubR, ubR)|(UBYTE(fFactor*255.0f)); FLOAT3D vRender = FLOAT3D( fX, fY, fZ); FLOAT fSize = 1.75f+afStarsPositions[(INDEX)fT0*CT_MAX_PARTICLES_TABLE][1]; @@ -3252,9 +3252,9 @@ void RenderOneLightningBranch( FLOAT3D vSrc, FLOAT3D vDst, FLOAT fPath, FLOAT3D vRenderDest; BOOL bRenderInProgress = TRUE; FLOAT fPassedTime = fTimeNow-fTimeStart; - INDEX ctBranches=0.0f; - INDEX ctMaxBranches = 3.0f; - INDEX ctKnees=0.0f; + INDEX ctBranches = 0; + INDEX ctMaxBranches = 3; + INDEX ctKnees = 0; FLOAT fTimeKiller = Clamp( (-1.0f/(LIGHTNING_LIFE_TIME-LIGHTNING_DEATH_START)*(fPassedTime-LIGHTNING_DEATH_START)+1), 0.0f, 1.0f); @@ -3353,7 +3353,7 @@ void Particles_SandFlow( CEntity *pen, FLOAT fStretchAll, FLOAT fSize, FLOAT fHe FLOAT fPowerFactor = Clamp((fNow - fStartTime)/2.0f,0.0f,1.0f); fPowerFactor *= Clamp(1+(fStopTime-fNow)/2.0f,0.0f,1.0f); - ctParticles = FLOAT(ctParticles) * fPowerFactor; + ctParticles = (INDEX) (FLOAT(ctParticles) * fPowerFactor); fHeight *= fPowerFactor; for( INDEX iStar=0; iStarGetLerpFactor())*_pTimer->TickQuantum; FLOAT fRatio=fT/(CT_AFTERBURNER_SMOKES*_pTimer->TickQuantum); - INDEX iIndex=fRatio*255; + INDEX iIndex=(INDEX) (fRatio*255); INDEX iRnd=INDEX(pvPos1)%CT_MAX_PARTICLES_TABLE; // smoke @@ -4814,7 +4814,7 @@ void Particles_AfterBurner(CEntity *pen, FLOAT tmSpawn, FLOAT fStretch, INDEX iG { FLOAT fT=(iFlare+_pTimer->GetLerpFactor()+iInter*1.0f/CT_AFTERBURNER_HEAD_INTERPOSITIONS)*_pTimer->TickQuantum; FLOAT fRatio=fT/(ctParticles*_pTimer->TickQuantum); - INDEX iIndex=fRatio*255; + INDEX iIndex=(INDEX) (fRatio*255); FLOAT fSize = (aFlare_sol[iIndex]*2.0f)*fStretch; FLOAT3D vPos = Lerp(*pvPos1, *pvPos2, iInter*1.0f/CT_AFTERBURNER_HEAD_INTERPOSITIONS); FLOAT fAngle = afStarsPositions[iInter][0]*360.0f+fRatio*360.0f; @@ -4883,7 +4883,7 @@ void Particles_RocketMotorBurning(CEntity *pen, FLOAT tmSpawn, FLOAT3D vStretch, FLOAT fSpeed=25.0f+(afStarsPositions[iRnd][0]+0.5f)*10.0f; FLOAT3D vPosS=vCenter+vSpeed*fSpeed*fT; vPosS=vPosS+vY*fPosY; - INDEX iIndex=fT*255; + INDEX iIndex=(INDEX) (fT*255); // smoke Particle_SetTexturePart( 512, 512, 1, 0); FLOAT fAngleS = afStarsPositions[iRnd][2]*360.0f+fT*120.0f*afStarsPositions[iRnd][3]; @@ -4917,7 +4917,7 @@ void Particles_RocketMotorBurning(CEntity *pen, FLOAT tmSpawn, FLOAT3D vStretch, FLOAT fSpeed=25.0f+(afStarsPositions[iRnd][0]+0.5f)*2.0f; FLOAT3D vPosS=vCenter+vSpeed*fSpeed*fT; vPosS=vPosS+vY*fPosY; - INDEX iIndex=fT*255; + INDEX iIndex=(INDEX) (fT*255); // smoke Particle_SetTexturePart( 512, 512, 1, 0); FLOAT fAngleS = afStarsPositions[iRnd][2]*360.0f+fT*120.0f*afStarsPositions[iRnd][3]; @@ -4969,7 +4969,7 @@ void Particles_SummonerProjectileExplode(CEntity *pen, FLOAT fSize, FLOAT fBegin FLOAT fFadeBegin = fDuration*0.7f; if (fElapsed>fFadeBegin) { - ub = 255 - (fElapsed-fFadeBegin)/(fDuration-fFadeBegin)*255; + ub = (UBYTE) (255 - (fElapsed-fFadeBegin)/(fDuration-fFadeBegin)*255); } if (fElapsed>fDuration) ub = 0; @@ -5021,7 +5021,7 @@ void Particles_SummonerExplode(CEntity *pen, FLOAT3D vCenter, FLOAT fArea, FLOAT if (fElapsedGetLerpedPlacement().pl_PositionVector+vY*4.0f; - INDEX ctStars=TM_GROWING_SWIRL_FX_LIFE/TM_SWIRL_SPARK_LAUNCH; + INDEX ctStars=(INDEX)(TM_GROWING_SWIRL_FX_LIFE/TM_SWIRL_SPARK_LAUNCH); for(INDEX i=0; ien_ulID+i)%CT_MAX_PARTICLES_TABLE; @@ -5511,7 +5511,7 @@ void Particles_SummonerStaff(CEmiter &em) if(ep.ep_tmEmitted<0) continue; FLOAT3D vPos=Lerp(ep.ep_vLastPos, ep.ep_vPos, fLerpFactor); FLOAT fRot=Lerp(ep.ep_fLastRot, ep.ep_fRot, fLerpFactor); - INDEX iIndex=Clamp((tmNow-ep.ep_tmEmitted)/(ep.ep_tmLife)*255.0f,0.0f,255.0f); + INDEX iIndex=(INDEX) Clamp((tmNow-ep.ep_tmEmitted)/(ep.ep_tmLife)*255.0f,0.0f,255.0f); COLOR col=ByteSwap(pcol[iIndex]); Particle_RenderSquare( vPos, 1.0f*ep.ep_fStretch, fRot, col); } @@ -5633,7 +5633,7 @@ void Particles_Leaves(CEntity *penTree, FLOATaabbox3D boxSize, FLOAT3D vSource, UBYTE ubH,ubS,ubV; ColorToHSV( colMax, ubH, ubS, ubV); - INDEX ctSprays=128-Clamp(3.0f-fDamagePower,0.0f,3.0f)*32; + INDEX ctSprays=(INDEX) (128-Clamp(3.0f-fDamagePower,0.0f,3.0f)*32); for( INDEX iSpray=0; iSprayGetLerpFactor())*_pTimer->TickQuantum; FLOAT fRatio=fT/(CT_AFTERBURNER_SMOKES*_pTimer->TickQuantum); - INDEX iIndex=fRatio*255; + INDEX iIndex=(INDEX) (fRatio*255); INDEX iRnd=INDEX(pvPos1)%CT_MAX_PARTICLES_TABLE; // smoke @@ -6007,7 +6007,7 @@ void Particles_RunAfterBurner(CEntity *pen, FLOAT tmEnd, FLOAT fStretch, INDEX i { FLOAT fT=(iFlare+_pTimer->GetLerpFactor()+iInter*1.0f/CT_AFTERBURNER_HEAD_INTERPOSITIONS)*_pTimer->TickQuantum; FLOAT fRatio=fT/(ctParticles*_pTimer->TickQuantum); - INDEX iIndex=fRatio*255; + INDEX iIndex=(INDEX) (fRatio*255); FLOAT fSize = (aFlare_sol[iIndex]*2.0f)*fStretch; FLOAT3D vPos = Lerp(*pvPos1, *pvPos2, iInter*1.0f/CT_AFTERBURNER_HEAD_INTERPOSITIONS); FLOAT fAngle = afStarsPositions[iInter][0]*360.0f+fRatio*360.0f; diff --git a/Sources/EntitiesMP/Common/PathFinding.cpp b/Sources/EntitiesMP/Common/PathFinding.cpp index 014e0ef..352bd78 100644 --- a/Sources/EntitiesMP/Common/PathFinding.cpp +++ b/Sources/EntitiesMP/Common/PathFinding.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "EntitiesMP/StdH/StdH.h" #include "EntitiesMP/Common/PathFinding.h" #include "EntitiesMP/NavigationMarker.h" diff --git a/Sources/EntitiesMP/Copier.es b/Sources/EntitiesMP/Copier.es index 938bcc2..49de69f 100644 --- a/Sources/EntitiesMP/Copier.es +++ b/Sources/EntitiesMP/Copier.es @@ -34,7 +34,7 @@ functions: { ((CTString&)m_strDescription).PrintF("->"); if (m_penTarget!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penTarget->GetName()); } return m_strDescription; } diff --git a/Sources/EntitiesMP/CreditsHolder.es b/Sources/EntitiesMP/CreditsHolder.es index 98f6831..997ffdf 100644 --- a/Sources/EntitiesMP/CreditsHolder.es +++ b/Sources/EntitiesMP/CreditsHolder.es @@ -57,7 +57,7 @@ components: functions: const CTString &GetDescription(void) const { - ((CTString&)m_strDescription).PrintF("%s", m_fnmMessage.FileName()); + ((CTString&)m_strDescription).PrintF("%s", (const char *) m_fnmMessage.FileName()); return m_strDescription; } @@ -349,7 +349,7 @@ procedures: if( !Credits_On(m_fnmMessage)) { - CPrintF("Error loading credits file '%s'!\n", m_fnmMessage); + CPrintF("Error loading credits file '%s'!\n", (const char *) m_fnmMessage); Credits_Off(); return; } diff --git a/Sources/EntitiesMP/Debris.es b/Sources/EntitiesMP/Debris.es index 4fc7852..20c2cfc 100644 --- a/Sources/EntitiesMP/Debris.es +++ b/Sources/EntitiesMP/Debris.es @@ -27,7 +27,7 @@ event ESpawnDebris { CTextureData *ptdBump, // bump texture INDEX iModelAnim, // animation for debris model enum DebrisParticlesType dptParticles, // particles type - enum BasicEffectType betStain, // stain left when touching brushes + int /*enum BasicEffectType*/ betStain, // stain left when touching brushes COLOR colDebris, // multiply color for debris BOOL bCustomShading, // if debris uses custom shading ANGLE3D aShadingDirection, // custom shading direction @@ -54,7 +54,7 @@ properties: 4 FLOAT m_fFadeStartTime = 0.0f, // fade start time 5 FLOAT m_fFadeTime = 0.0f, // fade time 6 FLOAT3D m_fLastStainHitPoint = FLOAT3D(0,0,0), // last stain hit point - 7 enum BasicEffectType m_betStain = BET_NONE, // type of stain left + 7 INDEX /*enum BasicEffectType*/ m_betStain = BET_NONE, // type of stain left 8 INDEX m_ctLeftStains = 0, // count of stains already left 9 FLOAT m_tmStarted = 0.0f, // time when spawned 10 FLOAT m_fStretch = 1.0f, // stretch @@ -149,7 +149,7 @@ functions: m_fLastStainHitPoint = vPoint; // stain ese.colMuliplier = C_WHITE|CT_OPAQUE; - ese.betType = m_betStain; + ese.betType = (BasicEffectType) m_betStain; ese.vNormal = FLOAT3D(plPlaneNormal); GetNormalComponent( en_vCurrentTranslationAbsolute, plPlaneNormal, ese.vDirection); FLOAT fLength = ese.vDirection.Length() / 7.5f; diff --git a/Sources/EntitiesMP/Demon.es b/Sources/EntitiesMP/Demon.es index d29f1d2..53738c6 100644 --- a/Sources/EntitiesMP/Demon.es +++ b/Sources/EntitiesMP/Demon.es @@ -16,7 +16,7 @@ uses "EntitiesMP/BasicEffects"; #define CLOSE_ATTACK_RANGE 10.0f #define DEMON_STRETCH 2.5f FLOAT3D vFireballLaunchPos = (FLOAT3D(0.06f, 2.6f, 0.15f)*DEMON_STRETCH); -static FLOAT _tmLastStandingAnim =0.0f; +static int _tmLastStandingAnim = 0; // info structure static EntityInfo eiDemon = { @@ -74,7 +74,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("A Demon executed %s"), strPlayerName); + str.PrintF(TRANS("A Demon executed %s"), (const char *) strPlayerName); return str; } diff --git a/Sources/EntitiesMP/DestroyableArchitecture.es b/Sources/EntitiesMP/DestroyableArchitecture.es index dfabe3a..fe16e9c 100644 --- a/Sources/EntitiesMP/DestroyableArchitecture.es +++ b/Sources/EntitiesMP/DestroyableArchitecture.es @@ -8,7 +8,8 @@ %} uses "EntitiesMP/Devil"; uses "EntitiesMP/Debris"; -uses "EntitiesMP\GradientMarker"; +uses "EntitiesMP/GradientMarker"; +uses "EntitiesMP/Effector"; %{ struct DebrisInfo { @@ -147,7 +148,7 @@ functions: } // if gradient marker - if( slPropertyOffset==offsetof(CDestroyableArchitecture, m_penGradient) ) + if( slPropertyOffset==_offsetof(CDestroyableArchitecture, m_penGradient) ) { return (IsDerivedFromClass(penTarget, "Gradient Marker")); } diff --git a/Sources/EntitiesMP/Devil.es b/Sources/EntitiesMP/Devil.es index b6bef7b..833eb79 100644 --- a/Sources/EntitiesMP/Devil.es +++ b/Sources/EntitiesMP/Devil.es @@ -240,7 +240,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("Ugh Zan killed %s"), strPlayerName); + str.PrintF(TRANS("Ugh Zan killed %s"), (const char *) strPlayerName); return str; } @@ -746,7 +746,7 @@ functions: { m_dsLastDevilState = m_dsDevilState; CTString strDevilState = DevilState_enum.NameForValue(INDEX(m_dsDevilState)); - CPrintF( "New devil state: %s\n", strDevilState); + CPrintF( "New devil state: %s\n", (const char *) strDevilState); } // print fire power state change @@ -754,7 +754,7 @@ functions: { m_dapLastAttackPower = m_dapAttackPower; CTString strAttackPower = DevilAttackPower_enum.NameForValue(INDEX(m_dapAttackPower)); - CPrintF( "New attack power: %s\n", strAttackPower); + CPrintF( "New attack power: %s\n", (const char *) strAttackPower); } // print radius of attack change @@ -801,7 +801,9 @@ functions: strScheduledAnimName = aiScheduled.ai_AnimName; } CPrintF("Time: %-10g %20s, %s\n", - _pTimer->GetLerpedCurrentTick(), strCurrentAnimName, strScheduledAnimName); + _pTimer->GetLerpedCurrentTick(), + (const char *) strCurrentAnimName, + (const char *) strScheduledAnimName); } m_iLastCurrentAnim = iCurrentAnim; m_iLastScheduledAnim = iScheduledAnim; @@ -816,9 +818,9 @@ functions: CPrintF("\n\n"); CTString strAttackPower = DevilAttackPower_enum.NameForValue(INDEX(m_dapAttackPower)); - CPrintF( "Attack power: %s\n", strAttackPower); + CPrintF( "Attack power: %s\n", (const char *) strAttackPower); CTString strDevilState = DevilState_enum.NameForValue(INDEX(m_dsDevilState)); - CPrintF( "Devil state: %s\n", strDevilState); + CPrintF( "Devil state: %s\n", (const char *) strDevilState); CPrintF("m_fFireTime = %g\n", m_fFireTime); CPrintF("m_iFiredProjectiles = %d\n", m_iFiredProjectiles); @@ -845,13 +847,13 @@ functions: CPrintF( "m_ttTarget (type): %d\n", INDEX(m_ttTarget)); - CPrintF( "m_penWatcher %x\n", m_penWatcher); + CPrintF( "m_penWatcher %x\n", (const char *) (m_penWatcher->GetName())); CTString strEnemyName = "Null ptr, no name"; if( m_penEnemy != NULL) { strEnemyName = m_penEnemy->GetName(); } - CPrintF( "m_penEnemy %x, enemy name: %s\n", m_penEnemy, strEnemyName); + CPrintF( "m_penEnemy %x, enemy name: %s\n", (const char *) (m_penEnemy->GetName()), (const char *) strEnemyName); CPrintF( "m_vStartPosition (%g, %g, %g)\n", m_vStartPosition(1), m_vStartPosition(2), m_vStartPosition(3)); CPrintF( "m_vStartDirection (%g, %g, %g)\n", m_vStartDirection(1), m_vStartDirection(2), m_vStartDirection(3)); @@ -879,8 +881,8 @@ functions: CPrintF( "m_vDesiredPosition (%g, %g, %g)\n", m_vDesiredPosition(1), m_vDesiredPosition(2), m_vDesiredPosition(3)); CTString strDestinationType = DestinationType_enum.NameForValue(INDEX(m_dtDestination)); - CPrintF( "m_dtDestination: %s\n", strDestinationType); - CPrintF( "m_penPathMarker %x\n", m_penPathMarker); + CPrintF( "m_dtDestination: %s\n", (const char *) strDestinationType); + CPrintF( "m_penPathMarker %x\n", (const char *) (m_penPathMarker->GetName())); CPrintF( "m_vPlayerSpotted (%g, %g, %g)\n", m_vPlayerSpotted(1), m_vPlayerSpotted(2), m_vPlayerSpotted(3)); CPrintF( "m_fMoveFrequency = %g\n", m_fMoveFrequency); @@ -898,14 +900,14 @@ functions: { strMarkerName = m_penMarker->GetName(); } - CPrintF( "m_penMarker %x, marker name: %s\n", m_penMarker, strMarkerName); + CPrintF( "m_penMarker %x, marker name: %s\n", (const char *) (m_penMarker->GetName()), (const char *) strMarkerName); CTString strMainMusicHolderName = "Null ptr, no name"; if( m_penMainMusicHolder != NULL) { strMainMusicHolderName = m_penMainMusicHolder->GetName(); } - CPrintF( "m_penMainMusicHolder %x, MainMusicHolder name: %s\n", m_penMainMusicHolder, strMainMusicHolderName); + CPrintF( "m_penMainMusicHolder %x, MainMusicHolder name: %s\n", (const char *) (m_penMainMusicHolder->GetName()), (const char *) strMainMusicHolderName); CPrintF( "m_tmLastFussTime = %g\n", m_tmLastFussTime); CPrintF( "m_iScore = %d\n", m_iScore); CPrintF( "m_fMaxHealth = %g\n", m_fMaxHealth); @@ -2341,7 +2343,7 @@ procedures: if( cht_bDebugFinalBoss) { CTString strDevilCommand = DevilCommandType_enum.NameForValue(INDEX(eDevilCommand.dctType)); - CPrintF("Main loop, event: Devil command: %s\n", strDevilCommand); + CPrintF("Main loop, event: Devil command: %s\n", (const char *) strDevilCommand); } if( eDevilCommand.dctType == DC_GRAB_LOWER_WEAPONS) diff --git a/Sources/EntitiesMP/DevilMarker.es b/Sources/EntitiesMP/DevilMarker.es index 5ad4086..7d75369 100644 --- a/Sources/EntitiesMP/DevilMarker.es +++ b/Sources/EntitiesMP/DevilMarker.es @@ -58,10 +58,10 @@ functions: const CTString &GetDescription(void) const { CTString strAction = DevilActionType_enum.NameForValue(INDEX(m_datType)); if (m_penTarget==NULL) { - ((CTString&)m_strDescription).PrintF("%s (%s)->", m_strName, strAction); + ((CTString&)m_strDescription).PrintF("%s (%s)->", (const char *) m_strName, (const char *) strAction); } else { - ((CTString&)m_strDescription).PrintF("%s (%s)->%s", m_strName, strAction, - m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("%s (%s)->%s", (const char *) m_strName, (const char *) strAction, + (const char *) m_penTarget->GetName()); } return m_strDescription; } diff --git a/Sources/EntitiesMP/DoorController.es b/Sources/EntitiesMP/DoorController.es index be33e81..5224d1f 100644 --- a/Sources/EntitiesMP/DoorController.es +++ b/Sources/EntitiesMP/DoorController.es @@ -56,10 +56,10 @@ functions: { if (m_penTarget1!=NULL && m_penTarget2!=NULL) { ((CTString&)m_strDescription).PrintF("->%s,%s", - m_penTarget1->GetName(), m_penTarget2->GetName()); + (const char *) m_penTarget1->GetName(), (const char *) m_penTarget2->GetName()); } else if (m_penTarget1!=NULL) { ((CTString&)m_strDescription).PrintF("->%s", - m_penTarget1->GetName()); + (const char *) m_penTarget1->GetName()); } else { ((CTString&)m_strDescription).PrintF("->"); } diff --git a/Sources/EntitiesMP/Dragonman.es b/Sources/EntitiesMP/Dragonman.es index 14bd415..839cec1 100644 --- a/Sources/EntitiesMP/Dragonman.es +++ b/Sources/EntitiesMP/Dragonman.es @@ -3,7 +3,7 @@ 321 %{ #include "StdH.h" -#include "Models/Enemies/Dragonman/Dragonman.h" +#include "Models/Enemies/DragonMan/DragonMan.h" %} uses "EntitiesMP/EnemyFly"; diff --git a/Sources/EntitiesMP/EffectMarker.es b/Sources/EntitiesMP/EffectMarker.es index 6b117ba..fe58b39 100644 --- a/Sources/EntitiesMP/EffectMarker.es +++ b/Sources/EntitiesMP/EffectMarker.es @@ -85,8 +85,8 @@ functions: return FALSE; } // if should be modelobject - if( slPropertyOffset==offsetof(CEffectMarker, m_penModel) || - slPropertyOffset==offsetof(CEffectMarker, m_penModel2) ) + if( slPropertyOffset==_offsetof(CEffectMarker, m_penModel) || + slPropertyOffset==_offsetof(CEffectMarker, m_penModel2) ) { return IsOfClass(penTarget, "ModelHolder2"); } diff --git a/Sources/EntitiesMP/Elemental.es b/Sources/EntitiesMP/Elemental.es index 83ef834..42bfc3e 100644 --- a/Sources/EntitiesMP/Elemental.es +++ b/Sources/EntitiesMP/Elemental.es @@ -5,7 +5,7 @@ #include "StdH.h" //#include "Models/Enemies/Elementals/AirMan.h" //#include "Models/Enemies/Elementals/IceMan.h" -#include "Models/Enemies/Elementals/StoneMan.h" +#include "Models/Enemies/Elementals/Stoneman.h" //#include "Models/Enemies/Elementals/Twister.h" //#include "Models/Enemies/Elementals/WaterMan.h" //#include "Models/Enemies/Elementals/Projectile/IcePyramid.h" @@ -273,7 +273,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("%s was killed by a Lava Golem"), strPlayerName); + str.PrintF(TRANS("%s was killed by a Lava Golem"), (const char *) strPlayerName); return str; } virtual const CTFileName &GetComputerMessageName(void) const { @@ -1502,7 +1502,7 @@ procedures: // fire count if (m_iFireCount <= 0) { - WarningMessage("Entity: %s - Fire count must be greater than zero", GetName()); + WarningMessage("Entity: %s - Fire count must be greater than zero", (const char *) GetName()); m_iFireCount = 1; } } diff --git a/Sources/EntitiesMP/EnemyBase.es b/Sources/EntitiesMP/EnemyBase.es index f1bfda8..2484d85 100644 --- a/Sources/EntitiesMP/EnemyBase.es +++ b/Sources/EntitiesMP/EnemyBase.es @@ -111,7 +111,7 @@ properties: // attack temporary -> DO NOT USE 60 FLOAT m_fShootTime = 0.0f, // time when entity will try to shoot on enemy 61 FLOAT m_fDamageConfused = 0.0f, // damage amount when entity shoot concentration is spoiled - 62 INDEX m_iChargeHitAnimation = 0.0f, // charge hit (close attack) properties + 62 INDEX m_iChargeHitAnimation = 0, // charge hit (close attack) properties 63 FLOAT m_fChargeHitDamage = 0.0f, 64 FLOAT m_fChargeHitAngle = 0.0f, 65 FLOAT m_fChargeHitSpeed = 0.0f, @@ -231,7 +231,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("%s killed %s"), GetClass()->ec_pdecDLLClass->dec_strName, strPlayerName); + str.PrintF(TRANS("%s killed %s"), (const char *) GetClass()->ec_pdecDLLClass->dec_strName, (const char *) strPlayerName); return str; } @@ -544,7 +544,7 @@ functions: const CTString &GetDescription(void) const { ((CTString&)m_strDescription).PrintF("->"); if (m_penMarker!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penMarker->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penMarker->GetName()); } return m_strDescription; } @@ -608,7 +608,7 @@ functions: } pes->es_ctAmmount = 1; pes->es_fValue = GetHealth(); - pes->es_iScore = m_iScore; + pes->es_iScore = (INDEX) m_iScore; return TRUE; } @@ -648,7 +648,7 @@ functions: UBYTE ubR, ubG, ubB, ubA; FLOAT fColorFactor=fNewDamage/m_fMaxHealth*255.0f; ColorToRGBA(m_colBurning, ubR, ubG, ubB, ubA); - ubR=ClampDn(ubR-fColorFactor, 32.0f); + ubR=(UBYTE)ClampDn(ubR-fColorFactor, 32.0f); m_colBurning=RGBAToColor(ubR, ubR, ubR, ubA); } @@ -1573,8 +1573,8 @@ functions: }; // prepare propelled projectile - void PreparePropelledProjectile(CPlacement3D &plProjectile, FLOAT3D vShootTarget, - FLOAT3D &vOffset, ANGLE3D &aOffset) + void PreparePropelledProjectile(CPlacement3D &plProjectile, const FLOAT3D vShootTarget, + const FLOAT3D &vOffset, const ANGLE3D &aOffset) { FLOAT3D vDiff = (vShootTarget - (GetPlacement().pl_PositionVector + vOffset*GetRotationMatrix())).SafeNormalize(); @@ -1597,8 +1597,8 @@ functions: }; // prepare free flying projectile - void PrepareFreeFlyingProjectile(CPlacement3D &plProjectile, FLOAT3D vShootTarget, - FLOAT3D &vOffset, ANGLE3D &aOffset) + void PrepareFreeFlyingProjectile(CPlacement3D &plProjectile, const FLOAT3D vShootTarget, + const FLOAT3D &vOffset, const ANGLE3D &aOffset) { FLOAT3D vDiff = (vShootTarget - (GetPlacement().pl_PositionVector + vOffset*GetRotationMatrix())).SafeNormalize(); @@ -1621,7 +1621,7 @@ functions: }; // shoot projectile on enemy - CEntity *ShootProjectile(enum ProjectileType pt, FLOAT3D &vOffset, ANGLE3D &aOffset) { + CEntity *ShootProjectile(enum ProjectileType pt, const FLOAT3D &vOffset, const ANGLE3D &aOffset) { ASSERT(m_penEnemy != NULL); // target enemy body @@ -1643,7 +1643,7 @@ functions: }; // shoot projectile at an exact spot - CEntity *ShootProjectileAt(FLOAT3D vShootTarget, enum ProjectileType pt, FLOAT3D &vOffset, ANGLE3D &aOffset) { + CEntity *ShootProjectileAt(FLOAT3D vShootTarget, enum ProjectileType pt, const FLOAT3D &vOffset, const ANGLE3D &aOffset) { // launch CPlacement3D pl; @@ -1658,7 +1658,7 @@ functions: }; // shoot projectile on enemy - CEntity *ShootPredictedProjectile(enum ProjectileType pt, FLOAT3D vPredictedPos, FLOAT3D &vOffset, ANGLE3D &aOffset) { + CEntity *ShootPredictedProjectile(enum ProjectileType pt, const FLOAT3D vPredictedPos, const FLOAT3D &vOffset, const ANGLE3D &aOffset) { ASSERT(m_penEnemy != NULL); // target enemy body (predicted) @@ -2766,7 +2766,7 @@ procedures: if (penKiller!=NULL) { // give him score EReceiveScore eScore; - eScore.iPoints = m_iScore; + eScore.iPoints = (INDEX) m_iScore; penKiller->SendEvent(eScore); if( CountAsKill()) { diff --git a/Sources/EntitiesMP/EnemyMarker.es b/Sources/EntitiesMP/EnemyMarker.es index 81ed961..cdc3a50 100644 --- a/Sources/EntitiesMP/EnemyMarker.es +++ b/Sources/EntitiesMP/EnemyMarker.es @@ -45,7 +45,7 @@ functions: BOOL IsTargetValid(SLONG slPropertyOffset, CEntity *penTarget) { - if( slPropertyOffset == offsetof(CMarker, m_penTarget)) + if( slPropertyOffset == _offsetof(CMarker, m_penTarget)) { if (IsOfClass(penTarget, "Enemy Marker")) { return TRUE; } else { return FALSE; } diff --git a/Sources/EntitiesMP/EnemySpawner.es b/Sources/EntitiesMP/EnemySpawner.es index 7c2dd3a..326591b 100644 --- a/Sources/EntitiesMP/EnemySpawner.es +++ b/Sources/EntitiesMP/EnemySpawner.es @@ -75,10 +75,10 @@ functions: { ((CTString&)m_strDescription).PrintF("->"); if (m_penTarget!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penTarget->GetName()); if (m_penSeriousTarget!=NULL) { ((CTString&)m_strDescription).PrintF("->%s, %s", - m_penTarget->GetName(), m_penSeriousTarget->GetName()); + (const char *) m_penTarget->GetName(), (const char *) m_penSeriousTarget->GetName()); } } ((CTString&)m_strDescription) = EnemySpawnerType_enum.NameForValue(INDEX(m_estType)) @@ -102,19 +102,19 @@ functions: BOOL IsTargetValid(SLONG slPropertyOffset, CEntity *penTarget) { - if( slPropertyOffset == offsetof(CEnemySpawner, m_penTarget)) + if( slPropertyOffset == _offsetof(CEnemySpawner, m_penTarget)) { return CheckTemplateValid(penTarget); } - else if( slPropertyOffset == offsetof(CEnemySpawner, m_penPatrol)) + else if( slPropertyOffset == _offsetof(CEnemySpawner, m_penPatrol)) { return (penTarget!=NULL && IsDerivedFromClass(penTarget, "Enemy Marker")); } - else if( slPropertyOffset == offsetof(CEnemySpawner, m_penSeriousTarget)) + else if( slPropertyOffset == _offsetof(CEnemySpawner, m_penSeriousTarget)) { return CheckTemplateValid(penTarget); } - else if( slPropertyOffset == offsetof(CEnemySpawner, m_penTacticsHolder)) + else if( slPropertyOffset == _offsetof(CEnemySpawner, m_penTacticsHolder)) { if (IsOfClass(penTarget, "TacticsHolder")) { return TRUE; } else { return FALSE; } @@ -174,7 +174,14 @@ functions: // calculate new position FLOAT fR = fInnerCircle + FRnd()*(fOuterCircle-fInnerCircle); FLOAT fA = FRnd()*360.0f; - CPlacement3D pl(FLOAT3D(CosFast(fA)*fR, 0.05f, SinFast(fA)*fR), ANGLE3D(0, 0, 0)); + + // This line needs to be split up, since it triggers a bug in gcc 2.95.3. --ryan. + //CPlacement3D pl(FLOAT3D(CosFast(fA)*fR, 0.05f, SinFast(fA)*fR), ANGLE3D(0, 0, 0)); + + FLOAT3D f3d(CosFast(fA)*fR, 0.05f, SinFast(fA)*fR); + ANGLE3D a3d(0, 0, 0); + CPlacement3D pl(f3d, a3d); + pl.RelativeToAbsolute(GetPlacement()); // teleport back @@ -449,13 +456,13 @@ procedures: // check target if (m_penTarget!=NULL) { if (!IsDerivedFromClass(m_penTarget, "Enemy Base")) { - WarningMessage("Target '%s' is of wrong class!", m_penTarget->GetName()); + WarningMessage("Target '%s' is of wrong class!", (const char *) m_penTarget->GetName()); m_penTarget = NULL; } } if (m_penSeriousTarget!=NULL) { if (!IsDerivedFromClass(m_penSeriousTarget, "Enemy Base")) { - WarningMessage("Target '%s' is of wrong class!", m_penSeriousTarget->GetName()); + WarningMessage("Target '%s' is of wrong class!", (const char *) m_penSeriousTarget->GetName()); m_penSeriousTarget = NULL; } } diff --git a/Sources/EntitiesMP/EnvironmentBase.es b/Sources/EntitiesMP/EnvironmentBase.es index 97add26..9f4d21e 100644 --- a/Sources/EntitiesMP/EnvironmentBase.es +++ b/Sources/EntitiesMP/EnvironmentBase.es @@ -68,26 +68,26 @@ functions: const CTString &GetDescription(void) const { ((CTString&)m_strDescription).PrintF("->"); if (m_penTarget!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penTarget->GetName()); } return m_strDescription; }; /* Get anim data for given animation property - return NULL for none. */ CAnimData *GetAnimData(SLONG slPropertyOffset) { - if(slPropertyOffset==offsetof(CEnvironmentBase, m_iAnim)) { + if(slPropertyOffset==_offsetof(CEnvironmentBase, m_iAnim)) { return GetModelObject()->GetData(); - } else if(slPropertyOffset==offsetof(CEnvironmentBase, m_iAtt1Anim)) { + } else if(slPropertyOffset==_offsetof(CEnvironmentBase, m_iAtt1Anim)) { CAttachmentModelObject *pamo = GetModelObject()->GetAttachmentModel(m_iAtt1Position); if( pamo != NULL) { return pamo->amo_moModelObject.GetData(); } return CEntity::GetAnimData(slPropertyOffset); - } else if(slPropertyOffset==offsetof(CEnvironmentBase, m_iAtt2Anim)) { + } else if(slPropertyOffset==_offsetof(CEnvironmentBase, m_iAtt2Anim)) { CAttachmentModelObject *pamo = GetModelObject()->GetAttachmentModel(m_iAtt2Position); if( pamo != NULL) { return pamo->amo_moModelObject.GetData(); } return CEntity::GetAnimData(slPropertyOffset); - } else if(slPropertyOffset==offsetof(CEnvironmentBase, m_iAtt3Anim)) { + } else if(slPropertyOffset==_offsetof(CEnvironmentBase, m_iAtt3Anim)) { CAttachmentModelObject *pamo = GetModelObject()->GetAttachmentModel(m_iAtt3Position); if( pamo != NULL) { return pamo->amo_moModelObject.GetData(); } return CEntity::GetAnimData(slPropertyOffset); @@ -110,7 +110,7 @@ functions: // assure valid target if (m_penTarget!=NULL && !IsOfClass(m_penTarget, "Environment Marker")) { - WarningMessage("Target '%s' is not of Environment Marker class!", m_penTarget->GetName()); + WarningMessage("Target '%s' is not of Environment Marker class!", (const char *) m_penTarget->GetName()); m_penTarget = NULL; return FALSE; } @@ -249,7 +249,7 @@ functions: // assure valid target if (m_penTarget!=NULL && !IsOfClass(m_penTarget, "Environment Marker")) { - WarningMessage("Target '%s' is not of Environment Marker class!", m_penTarget->GetName()); + WarningMessage("Target '%s' is not of Environment Marker class!", (const char *) m_penTarget->GetName()); m_penTarget = NULL; } }; diff --git a/Sources/EntitiesMP/EnvironmentMarker.es b/Sources/EntitiesMP/EnvironmentMarker.es index 70f17b5..4912063 100644 --- a/Sources/EntitiesMP/EnvironmentMarker.es +++ b/Sources/EntitiesMP/EnvironmentMarker.es @@ -43,7 +43,7 @@ functions: }; /* Get anim data for given animation property - return NULL for none. */ CAnimData *GetAnimData(SLONG slPropertyOffset) { - if(slPropertyOffset==offsetof(CEnvironmentMarker, m_iAnim)) { + if(slPropertyOffset==_offsetof(CEnvironmentMarker, m_iAnim)) { return m_moAnimData.GetData(); } else { @@ -69,7 +69,7 @@ functions: // if failed } catch(char *strErrorDefault) { FatalError(TRANS("Cannot load default model '%s':\n%s"), - (CTString&)fnmDefault, strErrorDefault); + (const char *) (CTString&)fnmDefault, (const char *) strErrorDefault); } } }; diff --git a/Sources/EntitiesMP/EnvironmentParticlesHolder.es b/Sources/EntitiesMP/EnvironmentParticlesHolder.es index a884511..da56304 100644 --- a/Sources/EntitiesMP/EnvironmentParticlesHolder.es +++ b/Sources/EntitiesMP/EnvironmentParticlesHolder.es @@ -78,7 +78,7 @@ functions: BOOL IsTargetValid(SLONG slPropertyOffset, CEntity *penTarget) { - if( slPropertyOffset == offsetof(CEnvironmentParticlesHolder, m_penNextHolder)) + if( slPropertyOffset == _offsetof(CEnvironmentParticlesHolder, m_penNextHolder)) { if (IsOfClass(penTarget, "EnvironmentParticlesHolder")) { return TRUE; } else { return FALSE; } diff --git a/Sources/EntitiesMP/ExotechLarva.es b/Sources/EntitiesMP/ExotechLarva.es index 336aa47..70af945 100644 --- a/Sources/EntitiesMP/ExotechLarva.es +++ b/Sources/EntitiesMP/ExotechLarva.es @@ -191,12 +191,12 @@ functions: BOOL IsTargetValid(SLONG slPropertyOffset, CEntity *penTarget) { - if( slPropertyOffset == offsetof(CExotechLarva, m_penMarkerNew)) + if( slPropertyOffset == _offsetof(CExotechLarva, m_penMarkerNew)) { if (IsOfClass(penTarget, "NavigationMarker")) { return TRUE; } else { return FALSE; } } - if( slPropertyOffset == offsetof(CExotechLarva, m_penRecharger)) + if( slPropertyOffset == _offsetof(CExotechLarva, m_penRecharger)) { if (IsOfClass(penTarget, "ExotechLarvaCharger")) { return TRUE; } else { return FALSE; } @@ -499,7 +499,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("Exotech larva reduced %s to pulp."), strPlayerName); + str.PrintF(TRANS("Exotech larva reduced %s to pulp."), (const char *) strPlayerName); return str; } diff --git a/Sources/EntitiesMP/ExotechLarvaCharger.es b/Sources/EntitiesMP/ExotechLarvaCharger.es index 3a0f3de..dcc8c5d 100644 --- a/Sources/EntitiesMP/ExotechLarvaCharger.es +++ b/Sources/EntitiesMP/ExotechLarvaCharger.es @@ -62,12 +62,12 @@ functions: BOOL IsTargetValid(SLONG slPropertyOffset, CEntity *penTarget) { - if( slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery01) || - slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery02) || - slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery03) || - slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery04) || - slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery05) || - slPropertyOffset == offsetof(CExotechLarvaCharger, m_penBattery06)) + if( slPropertyOffset == _offsetof(CExotechLarvaCharger, m_penBattery01) || + slPropertyOffset == _offsetof(CExotechLarvaCharger, m_penBattery02) || + slPropertyOffset == _offsetof(CExotechLarvaCharger, m_penBattery03) || + slPropertyOffset == _offsetof(CExotechLarvaCharger, m_penBattery04) || + slPropertyOffset == _offsetof(CExotechLarvaCharger, m_penBattery05) || + slPropertyOffset == _offsetof(CExotechLarvaCharger, m_penBattery06)) { if (IsOfClass(penTarget, "ExotechLarvaBattery")) { return TRUE; } else { return FALSE; } diff --git a/Sources/EntitiesMP/Eyeman.es b/Sources/EntitiesMP/Eyeman.es index 3c7cca4..553aa76 100644 --- a/Sources/EntitiesMP/Eyeman.es +++ b/Sources/EntitiesMP/Eyeman.es @@ -77,9 +77,9 @@ functions: { CTString str; if (m_bInAir) { - str.PrintF(TRANS("A Gnaar bit %s to death"), strPlayerName); + str.PrintF(TRANS("A Gnaar bit %s to death"), (const char *) strPlayerName); } else { - str.PrintF(TRANS("%s was beaten up by a Gnaar"), strPlayerName); + str.PrintF(TRANS("%s was beaten up by a Gnaar"), (const char *) strPlayerName); } return str; } diff --git a/Sources/EntitiesMP/Fireworks.es b/Sources/EntitiesMP/Fireworks.es index 877ccf0..d172029 100644 --- a/Sources/EntitiesMP/Fireworks.es +++ b/Sources/EntitiesMP/Fireworks.es @@ -99,7 +99,7 @@ procedures: FLOAT3D vPos=GetPlacement().pl_PositionVector+vRndPos; m_emEmiter.em_vG=FLOAT3D(0,0,0); - m_emEmiter.em_iGlobal=FRnd()*16; + m_emEmiter.em_iGlobal=(INDEX) (FRnd()*16); UBYTE ubRndH = UBYTE( FRnd()*255); UBYTE ubRndS = UBYTE( 255); diff --git a/Sources/EntitiesMP/Fish.es b/Sources/EntitiesMP/Fish.es index 8500336..cfc18f8 100644 --- a/Sources/EntitiesMP/Fish.es +++ b/Sources/EntitiesMP/Fish.es @@ -48,7 +48,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("%s was electrocuted by a fish"), strPlayerName); + str.PrintF(TRANS("%s was electrocuted by a fish"), (const char *) strPlayerName); return str; } virtual const CTFileName &GetComputerMessageName(void) const { @@ -205,7 +205,7 @@ functions: FLOAT fR = 0.7f+0.1f*(FLOAT(rand())/RAND_MAX); FLOAT fG = 0.7f+0.2f*(FLOAT(rand())/RAND_MAX); FLOAT fB = 0.7f+0.3f*(FLOAT(rand())/RAND_MAX); - colAmbient = RGBToColor( fR*128*fDieFactor, fG*128*fDieFactor, fB*128*fDieFactor); + colAmbient = RGBToColor( (UBYTE) (fR*128*fDieFactor), (UBYTE) (fG*128*fDieFactor), (UBYTE) (fB*128*fDieFactor)); colLight = C_WHITE; return CEnemyBase::AdjustShadingParameters(vLightDirection, colLight, colAmbient); } diff --git a/Sources/EntitiesMP/Gizmo.es b/Sources/EntitiesMP/Gizmo.es index 2c6be11..d4f9cfa 100644 --- a/Sources/EntitiesMP/Gizmo.es +++ b/Sources/EntitiesMP/Gizmo.es @@ -47,7 +47,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("%s ate a marsh hopper"), strPlayerName); + str.PrintF(TRANS("%s ate a marsh hopper"), (const char *) strPlayerName); return str; } virtual const CTFileName &GetComputerMessageName(void) const { diff --git a/Sources/EntitiesMP/GravityRouter.es b/Sources/EntitiesMP/GravityRouter.es index 5794885..d00f833 100644 --- a/Sources/EntitiesMP/GravityRouter.es +++ b/Sources/EntitiesMP/GravityRouter.es @@ -75,7 +75,7 @@ procedures: } if( m_penTarget!=NULL && !IsOfClass( m_penTarget, "Gravity Marker")) { - WarningMessage( "Entity '%s' is not of Gravity Marker class!", m_penTarget); + WarningMessage( "Entity '%s' is not of Gravity Marker class!", (const char *) m_penTarget->GetName()); m_penTarget = NULL; } diff --git a/Sources/EntitiesMP/Grunt.es b/Sources/EntitiesMP/Grunt.es index 16a1c28..2d767a0 100644 --- a/Sources/EntitiesMP/Grunt.es +++ b/Sources/EntitiesMP/Grunt.es @@ -75,7 +75,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("A Grunt sent %s into the halls of Valhalla"), strPlayerName); + str.PrintF(TRANS("A Grunt sent %s into the halls of Valhalla"), (const char *) strPlayerName); return str; } diff --git a/Sources/EntitiesMP/GruntSka.es b/Sources/EntitiesMP/GruntSka.es index ec2a1c7..688e4fb 100644 --- a/Sources/EntitiesMP/GruntSka.es +++ b/Sources/EntitiesMP/GruntSka.es @@ -256,7 +256,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("A Grunt sent %s into the halls of Valhalla"), strPlayerName); + str.PrintF(TRANS("A Grunt sent %s into the halls of Valhalla"), (const char *) strPlayerName); return str; } diff --git a/Sources/EntitiesMP/Guffy.es b/Sources/EntitiesMP/Guffy.es index aeb4f36..e1b99ba 100644 --- a/Sources/EntitiesMP/Guffy.es +++ b/Sources/EntitiesMP/Guffy.es @@ -65,7 +65,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("Guffy gunned %s down"), strPlayerName); + str.PrintF(TRANS("Guffy gunned %s down"), (const char *) strPlayerName); return str; } @@ -240,7 +240,7 @@ procedures: FLOAT3D fLookRight = FLOAT3D(1.0f, 0.0f, 0.0f); MakeRotationMatrixFast(m, GetPlacement().pl_OrientationAngle); fLookRight = fLookRight * m; - BOOL bEnemyRight = fLookRight % (m_penEnemy->GetPlacement().pl_PositionVector - GetPlacement().pl_PositionVector); + BOOL bEnemyRight = (BOOL) (fLookRight % (m_penEnemy->GetPlacement().pl_PositionVector - GetPlacement().pl_PositionVector)); if (bEnemyRight>=0) { // enemy is to the right of guffy ShootProjectile(PRT_GUFFY_PROJECTILE, FIRE_LEFT_ARM*m_fSize, ANGLE3D(0, 0, 0)); diff --git a/Sources/EntitiesMP/Headman.es b/Sources/EntitiesMP/Headman.es index d2458c1..904c73c 100644 --- a/Sources/EntitiesMP/Headman.es +++ b/Sources/EntitiesMP/Headman.es @@ -3,7 +3,7 @@ 303 %{ #include "StdH.h" -#include "Models/Enemies/Headman/Headman.h" +#include "Models/Enemies/Headman/headman.h" %} uses "EntitiesMP/EnemyBase"; @@ -88,14 +88,14 @@ functions: CTString str; if (eDeath.eLastDamage.dmtType==DMT_EXPLOSION) { if (m_hdtType==HDT_BOMBERMAN) { - str.PrintF(TRANS("%s was bombed by a Bomberman"), strPlayerName); + str.PrintF(TRANS("%s was bombed by a Bomberman"), (const char *) strPlayerName); } else { - str.PrintF(TRANS("%s fell victim of a Kamikaze"), strPlayerName); + str.PrintF(TRANS("%s fell victim of a Kamikaze"), (const char *) strPlayerName); } } else if (m_hdtType==HDT_ROCKETMAN) { - str.PrintF(TRANS("A Rocketeer tickled %s to death"), strPlayerName); + str.PrintF(TRANS("A Rocketeer tickled %s to death"), (const char *) strPlayerName); } else if (m_hdtType==HDT_FIRECRACKER) { - str.PrintF(TRANS("A Firecracker tickled %s to death"), strPlayerName); + str.PrintF(TRANS("A Firecracker tickled %s to death"), (const char *) strPlayerName); } return str; } diff --git a/Sources/EntitiesMP/HealthItem.es b/Sources/EntitiesMP/HealthItem.es index 4b89186..92ae5bc 100644 --- a/Sources/EntitiesMP/HealthItem.es +++ b/Sources/EntitiesMP/HealthItem.es @@ -87,7 +87,7 @@ functions: { pes->es_strName = "Health"; pes->es_ctCount = 1; - pes->es_ctAmmount = m_fValue; + pes->es_ctAmmount = (INDEX) m_fValue; pes->es_fValue = m_fValue; pes->es_iScore = 0;//m_iScore; diff --git a/Sources/EntitiesMP/HudPicHolder.es b/Sources/EntitiesMP/HudPicHolder.es index bda91e1..63a9669 100644 --- a/Sources/EntitiesMP/HudPicHolder.es +++ b/Sources/EntitiesMP/HudPicHolder.es @@ -39,7 +39,7 @@ components: functions: const CTString &GetDescription(void) const { - ((CTString&)m_strDescription).PrintF("%s", m_fnmPicture.FileName()); + ((CTString&)m_strDescription).PrintF("%s", (const char *) m_fnmPicture.FileName()); return m_strDescription; } @@ -127,8 +127,8 @@ functions: fPicRatioW = 1.0f; fPicRatioH = mexTexH/mexTexW; } - PIX picW = 128*m_fPictureStretch*fResScale*fPicRatioW; - PIX picH = 128*m_fPictureStretch*fResScale*fPicRatioH; + PIX picW = (PIX) (128*m_fPictureStretch*fResScale*fPicRatioW); + PIX picH = (PIX) (128*m_fPictureStretch*fResScale*fPicRatioH); FLOAT fXCenter = m_fXRatio * pdpCurr->GetWidth(); FLOAT fYCenter = m_fYRatio * pdpCurr->GetHeight(); diff --git a/Sources/EntitiesMP/KeyItem.es b/Sources/EntitiesMP/KeyItem.es index 636e9bf..377f70b 100644 --- a/Sources/EntitiesMP/KeyItem.es +++ b/Sources/EntitiesMP/KeyItem.es @@ -35,8 +35,10 @@ event EKey { %{ -const char *GetKeyName(enum KeyItemType kit) +const char *GetKeyName(int /*enum KeyItemType*/ _kit) { + enum KeyItemType kit = (KeyItemType) _kit; + switch(kit) { case KIT_BOOKOFWISDOM : return TRANS("Book of wisdom"); break; case KIT_CROSSWOODEN : return TRANS("Wooden cross"); break; diff --git a/Sources/EntitiesMP/LarvaOffspring.es b/Sources/EntitiesMP/LarvaOffspring.es index 38d35bf..1a5d479 100644 --- a/Sources/EntitiesMP/LarvaOffspring.es +++ b/Sources/EntitiesMP/LarvaOffspring.es @@ -279,7 +279,7 @@ procedures: FLOAT fRNDHeading = (FRnd()-0.5f)*180*fDistanceFactor; // if we are looking near direction of target - if( Abs( aWantedHeading) < 30.0f) + if( Abs(aWantedHeading) < 30.0f) { // adjust heading and pich SetDesiredRotation(ANGLE3D(aHeading+fRNDHeading,0,0)); diff --git a/Sources/EntitiesMP/Light.es b/Sources/EntitiesMP/Light.es index 2872526..0b5a50a 100644 --- a/Sources/EntitiesMP/Light.es +++ b/Sources/EntitiesMP/Light.es @@ -95,11 +95,11 @@ functions: /* Get anim data for given animation property - return NULL for none. */ CAnimData *GetAnimData(SLONG slPropertyOffset) { - if (slPropertyOffset==offsetof(CLight, m_iLightAnimation)) + if (slPropertyOffset==_offsetof(CLight, m_iLightAnimation)) { return m_aoLightAnimation.GetData(); } - else if (slPropertyOffset==offsetof(CLight, m_iAmbientLightAnimation)) + else if (slPropertyOffset==_offsetof(CLight, m_iAmbientLightAnimation)) { return m_aoAmbientLightAnimation.GetData(); } @@ -423,7 +423,7 @@ procedures: try { m_aoLightAnimation.SetData_t(m_fnmLightAnimation); } catch (char *strError) { - WarningMessage(TRANS("Cannot load '%s': %s"), (CTString&)m_fnmLightAnimation, strError); + WarningMessage(TRANS("Cannot load '%s': %s"), (const char *) (CTString&)m_fnmLightAnimation, strError); m_fnmLightAnimation = ""; } if (m_aoLightAnimation.GetData()!=NULL) { @@ -435,7 +435,7 @@ procedures: try { m_aoAmbientLightAnimation.SetData_t(m_fnmAmbientLightAnimation); } catch (char *strError) { - WarningMessage(TRANS("Cannot load '%s': %s"), (CTString&)m_fnmAmbientLightAnimation, strError); + WarningMessage(TRANS("Cannot load '%s': %s"), (const char *) (CTString&)m_fnmAmbientLightAnimation, strError); m_fnmAmbientLightAnimation = ""; } if (m_aoAmbientLightAnimation.GetData()!=NULL) { @@ -464,7 +464,7 @@ procedures: } m_strDescription.PrintF("%s:%g-%g", - strType, m_rHotSpotRange, m_rFallOffRange); + (const char *) strType, m_rHotSpotRange, m_rFallOffRange); return; }; diff --git a/Sources/EntitiesMP/Lightning.es b/Sources/EntitiesMP/Lightning.es index 31287c0..894e858 100644 --- a/Sources/EntitiesMP/Lightning.es +++ b/Sources/EntitiesMP/Lightning.es @@ -69,14 +69,14 @@ functions: { CLight *penLight = (CLight*)&*m_penLight; - if (slPropertyOffset==offsetof(CLightning, m_iLightAnim)) + if (slPropertyOffset==_offsetof(CLightning, m_iLightAnim)) { return penLight->m_aoLightAnimation.GetData(); } } else { - WarningMessage("Target '%s' is not of light class!", m_penLight->GetName()); + WarningMessage("Target '%s' is not of light class!", (const char *) m_penLight->GetName()); } return NULL; }; @@ -212,7 +212,7 @@ procedures: { if( m_penTarget != NULL) { - WarningMessage("Target '%s' is not of Marker class!", m_penTarget->GetName()); + WarningMessage("Target '%s' is not of Marker class!", (const char *) m_penTarget->GetName()); } // don't do anything return; diff --git a/Sources/EntitiesMP/Marker.es b/Sources/EntitiesMP/Marker.es index bcc7cfc..5a1c374 100644 --- a/Sources/EntitiesMP/Marker.es +++ b/Sources/EntitiesMP/Marker.es @@ -29,7 +29,7 @@ functions: { ((CTString&)m_strDescription).PrintF("->"); if (m_penTarget!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penTarget->GetName()); } return m_strDescription; } diff --git a/Sources/EntitiesMP/MessageHolder.es b/Sources/EntitiesMP/MessageHolder.es index 29ce68c..feff54c 100644 --- a/Sources/EntitiesMP/MessageHolder.es +++ b/Sources/EntitiesMP/MessageHolder.es @@ -25,7 +25,7 @@ components: functions: const CTString &GetDescription(void) const { - ((CTString&)m_strDescription).PrintF("%s", m_fnmMessage.FileName()); + ((CTString&)m_strDescription).PrintF("%s", (const char *) m_fnmMessage.FileName()); return m_strDescription; } diff --git a/Sources/EntitiesMP/ModelDestruction.es b/Sources/EntitiesMP/ModelDestruction.es index baea38c..1144d5f 100644 --- a/Sources/EntitiesMP/ModelDestruction.es +++ b/Sources/EntitiesMP/ModelDestruction.es @@ -5,9 +5,9 @@ #include "StdH.h" %} +uses "EntitiesMP/Debris"; uses "EntitiesMP/ModelHolder2"; uses "EntitiesMP/BasicEffects"; -uses "EntitiesMP/Debris"; uses "EntitiesMP/BloodSpray"; uses "EntitiesMP/SoundHolder"; @@ -48,8 +48,8 @@ properties: 27 FLOAT m_fParticleSize "Particle Size" 'Z' = 1.0f, // size of particles 28 BOOL m_bRequireExplosion "Requires Explosion" = FALSE, 29 FLOAT m_fDebrisLaunchPower "CC: Debris Launch Power" 'L' = 1.0f, // launch power of debris - 30 enum DebrisParticlesType m_dptParticles "CC: Trail particles" = DPT_NONE, - 31 enum BasicEffectType m_betStain "CC: Leave stain" = BET_NONE, + 30 INDEX /*enum DebrisParticlesType*/ m_dptParticles "CC: Trail particles" = DPT_NONE, + 31 INDEX /*enum BasicEffectType*/ m_betStain "CC: Leave stain" = BET_NONE, 32 FLOAT m_fLaunchCone "CC: Launch cone" = 45.0f, 33 FLOAT m_fRndRotH "CC: Rotation heading" = 720.0f, 34 FLOAT m_fRndRotP "CC: Rotation pitch" = 720.0f, @@ -105,7 +105,7 @@ functions: /* Get anim data for given animation property - return NULL for none. */ CAnimData *GetAnimData(SLONG slPropertyOffset) { - if(slPropertyOffset==offsetof(CModelDestruction, m_iStartAnim)) + if(slPropertyOffset==_offsetof(CModelDestruction, m_iStartAnim)) { CModelHolder2 *pmh=GetModel(0); if(pmh!=NULL) @@ -121,9 +121,9 @@ functions: if(ct==0) { ((CTString&)m_strDescription).PrintF("(%g): no more", m_fHealth); } else if(ct==1) { - ((CTString&)m_strDescription).PrintF("(%g): %s", m_fHealth, m_penModel0->GetName()); + ((CTString&)m_strDescription).PrintF("(%g): %s", m_fHealth, (const char *) m_penModel0->GetName()); } else if (TRUE) { - ((CTString&)m_strDescription).PrintF("(%g): %s,...(%d)", m_fHealth, m_penModel0->GetName(), ct); + ((CTString&)m_strDescription).PrintF("(%g): %s,...(%d)", m_fHealth, (const char *) m_penModel0->GetName(), ct); } return m_strDescription; } @@ -132,7 +132,7 @@ functions: void CheckOneModelTarget(CEntityPointer &pen) { if (pen!=NULL && !IsOfClass(pen, "ModelHolder2")) { - WarningMessage("Model '%s' is not ModelHolder2!", pen->GetName()); + WarningMessage("Model '%s' is not ModelHolder2!", (const char *) pen->GetName()); pen=NULL; } } diff --git a/Sources/EntitiesMP/ModelHolder.es b/Sources/EntitiesMP/ModelHolder.es index 7288954..111fe59 100644 --- a/Sources/EntitiesMP/ModelHolder.es +++ b/Sources/EntitiesMP/ModelHolder.es @@ -43,11 +43,11 @@ functions: /* Get anim data for given animation property - return NULL for none. */ CAnimData *GetAnimData(SLONG slPropertyOffset) { - if (slPropertyOffset==offsetof(CModelHolder, m_iModelAnimation)) { + if (slPropertyOffset==_offsetof(CModelHolder, m_iModelAnimation)) { return GetModelObject()->GetData(); - } else if (slPropertyOffset==offsetof(CModelHolder, m_iTextureAnimation)) { + } else if (slPropertyOffset==_offsetof(CModelHolder, m_iTextureAnimation)) { return GetModelObject()->mo_toTexture.GetData(); - } else if (slPropertyOffset==offsetof(CModelHolder, m_iLightAnimation)) { + } else if (slPropertyOffset==_offsetof(CModelHolder, m_iLightAnimation)) { return m_aoLightAnimation.GetData(); } else { return CEntity::GetAnimData(slPropertyOffset); @@ -78,8 +78,8 @@ functions: UBYTE ubAmbientR, ubAmbientG, ubAmbientB; ColorToRGB( m_colLight, ubLightR, ubLightG, ubLightB); ColorToRGB( m_colAmbient, ubAmbientR, ubAmbientG, ubAmbientB); - colLight = RGBToColor( ubLightR *fAnimR, ubLightG *fAnimG, ubLightB *fAnimB); - colAmbient = RGBToColor( ubAmbientR*fAnimR, ubAmbientG*fAnimG, ubAmbientB*fAnimB); + colLight = RGBToColor( (UBYTE) (ubLightR *fAnimR), (UBYTE) (ubLightG *fAnimG), (UBYTE) (ubLightB *fAnimB)); + colAmbient = RGBToColor( (UBYTE) (ubAmbientR*fAnimR), (UBYTE) (ubAmbientG*fAnimG), (UBYTE) (ubAmbientB*fAnimB)); // if there is no color animation } else { @@ -157,14 +157,14 @@ functions: try { m_aoLightAnimation.SetData_t(m_fnmLightAnimation); } catch (char *strError) { - WarningMessage(TRANS("Cannot load '%s': %s"), (CTString&)m_fnmLightAnimation, strError); + WarningMessage(TRANS("Cannot load '%s': %s"), (const char *) (CTString&)m_fnmLightAnimation, strError); m_fnmLightAnimation = ""; } if (m_aoLightAnimation.GetData()!=NULL) { m_aoLightAnimation.PlayAnim(m_iLightAnimation, AOF_LOOPING); } - m_strDescription.PrintF("%s,%s", (CTString&)m_fnModel.FileName(), (CTString&)m_fnTexture.FileName()); + m_strDescription.PrintF("%s,%s", (const char *) m_fnModel.FileName(), (const char *) m_fnTexture.FileName()); return; }; diff --git a/Sources/EntitiesMP/ModelHolder2.es b/Sources/EntitiesMP/ModelHolder2.es index d85ef3b..6aea4da 100644 --- a/Sources/EntitiesMP/ModelHolder2.es +++ b/Sources/EntitiesMP/ModelHolder2.es @@ -308,11 +308,11 @@ functions: /* Get anim data for given animation property - return NULL for none. */ CAnimData *GetAnimData(SLONG slPropertyOffset) { - if (slPropertyOffset==offsetof(CModelHolder2, m_iModelAnimation)) { + if (slPropertyOffset==_offsetof(CModelHolder2, m_iModelAnimation)) { return GetModelObject()->GetData(); - } else if (slPropertyOffset==offsetof(CModelHolder2, m_iTextureAnimation)) { + } else if (slPropertyOffset==_offsetof(CModelHolder2, m_iTextureAnimation)) { return GetModelObject()->mo_toTexture.GetData(); - } else if (slPropertyOffset==offsetof(CModelHolder2, m_iLightAnimation)) { + } else if (slPropertyOffset==_offsetof(CModelHolder2, m_iLightAnimation)) { return m_aoLightAnimation.GetData(); } else { return CEntity::GetAnimData(slPropertyOffset); @@ -387,8 +387,8 @@ functions: UBYTE ubAmbientR, ubAmbientG, ubAmbientB; ColorToRGB( m_colLight, ubLightR, ubLightG, ubLightB); ColorToRGB( m_colAmbient, ubAmbientR, ubAmbientG, ubAmbientB); - colLight = RGBToColor( ubLightR *fAnimR, ubLightG *fAnimG, ubLightB *fAnimB); - colAmbient = RGBToColor( ubAmbientR*fAnimR, ubAmbientG*fAnimG, ubAmbientB*fAnimB); + colLight = RGBToColor( (UBYTE) (ubLightR *fAnimR), (UBYTE) (ubLightG *fAnimG), (UBYTE) (ubLightB *fAnimB)); + colAmbient = RGBToColor( (UBYTE) (ubAmbientR*fAnimR), (UBYTE) (ubAmbientG*fAnimG), (UBYTE) (ubAmbientB*fAnimB)); // if there is no color animation } else { @@ -602,7 +602,7 @@ functions: try { m_aoLightAnimation.SetData_t(m_fnmLightAnimation); } catch (char *strError) { - WarningMessage(TRANS("Cannot load '%s': %s"), (CTString&)m_fnmLightAnimation, strError); + WarningMessage(TRANS("Cannot load '%s': %s"), (const char *) (CTString&)m_fnmLightAnimation, strError); m_fnmLightAnimation = ""; } if (m_aoLightAnimation.GetData()!=NULL) { @@ -610,10 +610,10 @@ functions: } if (m_penDestruction==NULL) { - m_strDescription.PrintF("%s,%s undestroyable", (CTString&)m_fnModel.FileName(), (CTString&)m_fnTexture.FileName()); + m_strDescription.PrintF("%s,%s undestroyable", (const char *) m_fnModel.FileName(), (const char *) m_fnTexture.FileName()); } else { - m_strDescription.PrintF("%s,%s -> %s", (CTString&)m_fnModel.FileName(), (CTString&)m_fnTexture.FileName(), - m_penDestruction->GetName()); + m_strDescription.PrintF("%s,%s -> %s", (const char *) m_fnModel.FileName(), (const char *) m_fnTexture.FileName(), + (const char *) m_penDestruction->GetName()); } return; @@ -746,7 +746,7 @@ procedures: // check your destruction pointer if (m_penDestruction!=NULL && !IsOfClass(m_penDestruction, "ModelDestruction")) { - WarningMessage("Destruction '%s' is wrong class!", m_penDestruction->GetName()); + WarningMessage("Destruction '%s' is wrong class!", (const char *) m_penDestruction->GetName()); m_penDestruction=NULL; } diff --git a/Sources/EntitiesMP/ModelHolder3.es b/Sources/EntitiesMP/ModelHolder3.es index 56ca2ed..27b145c 100644 --- a/Sources/EntitiesMP/ModelHolder3.es +++ b/Sources/EntitiesMP/ModelHolder3.es @@ -322,11 +322,11 @@ functions: /* Get anim data for given animation property - return NULL for none. */ /* CAnimData *GetAnimData(SLONG slPropertyOffset) { - if (slPropertyOffset==offsetof(CModelHolder3, m_iModelAnimation)) { + if (slPropertyOffset==_offsetof(CModelHolder3, m_iModelAnimation)) { return GetModelObject()->GetData(); - } else if (slPropertyOffset==offsetof(CModelHolder3, m_iTextureAnimation)) { + } else if (slPropertyOffset==_offsetof(CModelHolder3, m_iTextureAnimation)) { return GetModelObject()->mo_toTexture.GetData(); - } else if (slPropertyOffset==offsetof(CModelHolder3, m_iLightAnimation)) { + } else if (slPropertyOffset==_offsetof(CModelHolder3, m_iLightAnimation)) { return m_aoLightAnimation.GetData(); } else { return CEntity::GetAnimData(slPropertyOffset); @@ -516,7 +516,7 @@ functions: SetSkaModel_t(m_fnModel); // if failed } catch(char *strError) { - WarningMessage(TRANS("Cannot load ska model '%s':\n%s"), (CTString&)m_fnModel, strError); + WarningMessage(TRANS("Cannot load ska model '%s':\n%s"), (const char *) m_fnModel, strError); bLoadOK = FALSE; // set colision info for default model //SetSkaColisionInfo(); @@ -596,7 +596,7 @@ functions: m_fFadeEndWait = ClampDn(m_fFadeEndWait, 0.05f); m_fFadeSpeed = ClampDn(m_fFadeSpeed, 0.05f);*/ - m_strDescription.PrintF("%s", (CTString&)m_fnModel.FileName()); + m_strDescription.PrintF("%s", (const char *) m_fnModel.FileName()); return; }; diff --git a/Sources/EntitiesMP/MovingBrush.es b/Sources/EntitiesMP/MovingBrush.es index fc13eff..0a4b3f9 100644 --- a/Sources/EntitiesMP/MovingBrush.es +++ b/Sources/EntitiesMP/MovingBrush.es @@ -7,7 +7,7 @@ uses "EntitiesMP/MovingBrushMarker"; uses "EntitiesMP/SoundHolder"; -uses "EntitiesMP\MirrorMarker"; +uses "EntitiesMP/MirrorMarker"; uses "EntitiesMP/Debris"; event EHit { @@ -188,7 +188,7 @@ functions: // if impact by bull if( dmtType == DMT_IMPACT && IsOfClass(penInflictor, "Werebull")) { - // receive the damage so large to blowup + // recieve the damage so large to blowup CMovableBrushEntity::ReceiveDamage(penInflictor, dmtType, m_fHealth*2, vHitPoint, vDirection); // kill the bull in place, but make sure it doesn't blow up ((CLiveEntity*)penInflictor)->SetHealth(0.0f); @@ -238,7 +238,7 @@ functions: const CTString &GetDescription(void) const { ((CTString&)m_strDescription).PrintF("->"); if (m_penTarget!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penTarget->GetName()); } return m_strDescription; } @@ -395,7 +395,7 @@ functions: } if (!IsOfClass(m_penTarget, "Moving Brush Marker")) { - WarningMessage("Entity '%s' is not of Moving Brush Marker class!", m_penTarget->GetName()); + WarningMessage("Entity '%s' is not of Moving Brush Marker class!", (const char *) m_penTarget->GetName()); return FALSE; } diff --git a/Sources/EntitiesMP/MusicChanger.es b/Sources/EntitiesMP/MusicChanger.es index 7a80fd4..7c52d16 100644 --- a/Sources/EntitiesMP/MusicChanger.es +++ b/Sources/EntitiesMP/MusicChanger.es @@ -42,8 +42,8 @@ procedures: SetModelMainTexture(TEXTURE_MARKER); m_strDescription.PrintF("%s: %s (%g)", - MusicType_enum.NameForValue((INDEX)m_mtType), - (CTString&)m_fnMusic.FileName(), + (const char *) MusicType_enum.NameForValue((INDEX)m_mtType), + (const char *) m_fnMusic.FileName(), m_fVolume); // wait for game to start diff --git a/Sources/EntitiesMP/MusicHolder.es b/Sources/EntitiesMP/MusicHolder.es index aabf5eb..0bb266f 100644 --- a/Sources/EntitiesMP/MusicHolder.es +++ b/Sources/EntitiesMP/MusicHolder.es @@ -187,7 +187,7 @@ functions: INDEX iScore = 0; {FOREACHINDYNAMICCONTAINER(m_cenFussMakers, CEntity, itenFussMaker) { CEnemyBase &enFussMaker = (CEnemyBase&)*itenFussMaker; - iScore += enFussMaker.m_iScore; + iScore += (INDEX) enFussMaker.m_iScore; }} return iScore; } diff --git a/Sources/EntitiesMP/Player.es b/Sources/EntitiesMP/Player.es index 7707532..f3285c2 100644 --- a/Sources/EntitiesMP/Player.es +++ b/Sources/EntitiesMP/Player.es @@ -53,6 +53,8 @@ extern void JumpFromBouncer(CEntity *penToBounce, CEntity *penBouncer); %} +uses "EntitiesMP/WorldLink"; + enum PlayerViewType { 0 PVT_PLAYEREYES "", 1 PVT_PLAYERAUTOVIEW "", @@ -100,7 +102,7 @@ extern void EndHUD(void); static CTimerValue _tvProbingLast; // used to render certain entities only for certain players (like picked items, etc.) -extern ULONG _ulPlayerRenderingMask = 0; +ULONG _ulPlayerRenderingMask = 0; // temporary BOOL used to discard calculating of 3rd view when calculating absolute view placement BOOL _bDiscard3rdView=FALSE; @@ -156,7 +158,7 @@ static CTString MakeEmptyString(INDEX ctLen, char ch=' ') } // take a two line string and align into one line of minimum given length -static INDEX _ctAlignWidth = 20; +static int _ctAlignWidth = 20; static CTString AlignString(const CTString &strOrg) { // split into two lines @@ -325,42 +327,42 @@ static INDEX cht_bGiveAll = FALSE; static INDEX cht_bOpen = FALSE; static INDEX cht_bAllMessages= FALSE; static INDEX cht_bRefresh = FALSE; -extern INDEX cht_bGod = FALSE; -extern INDEX cht_bFly = FALSE; -extern INDEX cht_bGhost = FALSE; -extern INDEX cht_bInvisible = FALSE; -extern FLOAT cht_fTranslationMultiplier = 1.0f; -extern INDEX cht_bEnable = 0; +INDEX cht_bGod = FALSE; +INDEX cht_bFly = FALSE; +INDEX cht_bGhost = FALSE; +INDEX cht_bInvisible = FALSE; +FLOAT cht_fTranslationMultiplier = 1.0f; +INDEX cht_bEnable = 0; // interface control static INDEX hud_bShowAll = TRUE; // used internaly in menu/console -extern INDEX hud_bShowWeapon = TRUE; -extern INDEX hud_bShowMessages = TRUE; -extern INDEX hud_bShowInfo = TRUE; -extern INDEX hud_bShowLatency = FALSE; -extern INDEX hud_iShowPlayers = -1; // auto -extern INDEX hud_iSortPlayers = -1; // auto -extern FLOAT hud_fOpacity = 0.9f; -extern FLOAT hud_fScaling = 1.0f; -extern FLOAT hud_tmWeaponsOnScreen = 3.0f; -extern FLOAT hud_tmLatencySnapshot = 1.0f; -extern INDEX hud_bShowMatchInfo = TRUE; +INDEX hud_bShowWeapon = TRUE; +INDEX hud_bShowMessages = TRUE; +INDEX hud_bShowInfo = TRUE; +INDEX hud_bShowLatency = FALSE; +INDEX hud_iShowPlayers = -1; // auto +INDEX hud_iSortPlayers = -1; // auto +FLOAT hud_fOpacity = 0.9f; +FLOAT hud_fScaling = 1.0f; +FLOAT hud_tmWeaponsOnScreen = 3.0f; +FLOAT hud_tmLatencySnapshot = 1.0f; +INDEX hud_bShowMatchInfo = TRUE; -extern FLOAT plr_fBreathingStrength = 0.0f; +FLOAT plr_fBreathingStrength = 0.0f; extern FLOAT plr_tmSnoopingTime; -extern INDEX cht_bKillFinalBoss = FALSE; +INDEX cht_bKillFinalBoss = FALSE; INDEX cht_bDebugFinalBoss = FALSE; INDEX cht_bDumpFinalBossData = FALSE; INDEX cht_bDebugFinalBossAnimations = FALSE; INDEX cht_bDumpPlayerShading = FALSE; -extern FLOAT wpn_fRecoilSpeed[17] = {0}; -extern FLOAT wpn_fRecoilLimit[17] = {0}; -extern FLOAT wpn_fRecoilDampUp[17] = {0}; -extern FLOAT wpn_fRecoilDampDn[17] = {0}; -extern FLOAT wpn_fRecoilOffset[17] = {0}; -extern FLOAT wpn_fRecoilFactorP[17] = {0}; -extern FLOAT wpn_fRecoilFactorZ[17] = {0}; +FLOAT wpn_fRecoilSpeed[17] = {0}; +FLOAT wpn_fRecoilLimit[17] = {0}; +FLOAT wpn_fRecoilDampUp[17] = {0}; +FLOAT wpn_fRecoilDampDn[17] = {0}; +FLOAT wpn_fRecoilOffset[17] = {0}; +FLOAT wpn_fRecoilFactorP[17] = {0}; +FLOAT wpn_fRecoilFactorZ[17] = {0}; // misc static FLOAT plr_fAcceleration = 100.0f; @@ -373,30 +375,30 @@ static FLOAT plr_fViewHeightStand = 1.9f; static FLOAT plr_fViewHeightCrouch = 0.7f; static FLOAT plr_fViewHeightSwim = 0.4f; static FLOAT plr_fViewHeightDive = 0.0f; -extern FLOAT plr_fViewDampFactor = 0.4f; -extern FLOAT plr_fViewDampLimitGroundUp = 0.1f; -extern FLOAT plr_fViewDampLimitGroundDn = 0.4f; -extern FLOAT plr_fViewDampLimitWater = 0.1f; +FLOAT plr_fViewDampFactor = 0.4f; +FLOAT plr_fViewDampLimitGroundUp = 0.1f; +FLOAT plr_fViewDampLimitGroundDn = 0.4f; +FLOAT plr_fViewDampLimitWater = 0.1f; static FLOAT plr_fFrontClipDistance = 0.25f; static FLOAT plr_fFOV = 90.0f; static FLOAT net_tmLatencyAvg; -extern INDEX plr_bRenderPicked = FALSE; -extern INDEX plr_bRenderPickedParticles = FALSE; -extern INDEX plr_bOnlySam = FALSE; -extern INDEX ent_bReportBrokenChains = FALSE; -extern FLOAT ent_tmMentalIn = 0.5f; -extern FLOAT ent_tmMentalOut = 0.75f; -extern FLOAT ent_tmMentalFade = 0.5f; +INDEX plr_bRenderPicked = FALSE; +INDEX plr_bRenderPickedParticles = FALSE; +INDEX plr_bOnlySam = FALSE; +INDEX ent_bReportBrokenChains = FALSE; +FLOAT ent_tmMentalIn = 0.5f; +FLOAT ent_tmMentalOut = 0.75f; +FLOAT ent_tmMentalFade = 0.5f; -extern FLOAT gfx_fEnvParticlesDensity = 1.0f; -extern FLOAT gfx_fEnvParticlesRange = 1.0f; +FLOAT gfx_fEnvParticlesDensity = 1.0f; +FLOAT gfx_fEnvParticlesRange = 1.0f; // prediction control vars -extern FLOAT cli_fPredictPlayersRange = 0.0f; -extern FLOAT cli_fPredictItemsRange = 3.0f; -extern FLOAT cli_tmPredictFoe = 10.0f; -extern FLOAT cli_tmPredictAlly = 10.0f; -extern FLOAT cli_tmPredictEnemy = 10.0f; +FLOAT cli_fPredictPlayersRange = 0.0f; +FLOAT cli_fPredictItemsRange = 3.0f; +FLOAT cli_tmPredictFoe = 10.0f; +FLOAT cli_tmPredictAlly = 10.0f; +FLOAT cli_tmPredictEnemy = 10.0f; static FLOAT plr_fSwimSoundDelay = 0.8f; static FLOAT plr_fDiveSoundDelay = 1.6f; @@ -414,20 +416,20 @@ static FLOAT ctl_fButtonRotationSpeedB = 150.0f; static FLOAT ctl_fAxisStrafingModifier = 1.0f; // !=NULL if some player wants to call computer -DECL_DLL extern class CPlayer *cmp_ppenPlayer = NULL; +DECL_DLL class CPlayer *cmp_ppenPlayer = NULL; // !=NULL for rendering computer on secondary display in dualhead -DECL_DLL extern class CPlayer *cmp_ppenDHPlayer = NULL; +DECL_DLL class CPlayer *cmp_ppenDHPlayer = NULL; // set to update current message in background mode (for dualhead) -DECL_DLL extern BOOL cmp_bUpdateInBackground = FALSE; +DECL_DLL BOOL cmp_bUpdateInBackground = FALSE; // set for initial calling computer without rendering game -DECL_DLL extern BOOL cmp_bInitialStart = FALSE; +DECL_DLL BOOL cmp_bInitialStart = FALSE; // game sets this for player hud and statistics and hiscore sound playing -DECL_DLL extern INDEX plr_iHiScore = 0.0f; +DECL_DLL INDEX plr_iHiScore = 0; // these define address and size of player controls structure -DECL_DLL extern void *ctl_pvPlayerControls = &pctlCurrent; -DECL_DLL extern const SLONG ctl_slPlayerControlsSize = sizeof(pctlCurrent); +DECL_DLL void *ctl_pvPlayerControls = &pctlCurrent; +DECL_DLL const SLONG ctl_slPlayerControlsSize = sizeof(pctlCurrent); // called to compose action packet from current controls DECL_DLL void ctl_ComposeActionPacket(const CPlayerCharacter &pc, CPlayerAction &paAction, BOOL bPreScan) @@ -681,134 +683,134 @@ void CPlayer_OnInitClass(void) // clear current player controls memset(&pctlCurrent, 0, sizeof(pctlCurrent)); // declare player control variables - _pShell->DeclareSymbol("user INDEX ctl_bMoveForward;", &pctlCurrent.bMoveForward); - _pShell->DeclareSymbol("user INDEX ctl_bMoveBackward;", &pctlCurrent.bMoveBackward); - _pShell->DeclareSymbol("user INDEX ctl_bMoveLeft;", &pctlCurrent.bMoveLeft); - _pShell->DeclareSymbol("user INDEX ctl_bMoveRight;", &pctlCurrent.bMoveRight); - _pShell->DeclareSymbol("user INDEX ctl_bMoveUp;", &pctlCurrent.bMoveUp); - _pShell->DeclareSymbol("user INDEX ctl_bMoveDown;", &pctlCurrent.bMoveDown); - _pShell->DeclareSymbol("user INDEX ctl_bTurnLeft;", &pctlCurrent.bTurnLeft); - _pShell->DeclareSymbol("user INDEX ctl_bTurnRight;", &pctlCurrent.bTurnRight); - _pShell->DeclareSymbol("user INDEX ctl_bTurnUp;", &pctlCurrent.bTurnUp); - _pShell->DeclareSymbol("user INDEX ctl_bTurnDown;", &pctlCurrent.bTurnDown); - _pShell->DeclareSymbol("user INDEX ctl_bTurnBankingLeft;", &pctlCurrent.bTurnBankingLeft); - _pShell->DeclareSymbol("user INDEX ctl_bTurnBankingRight;", &pctlCurrent.bTurnBankingRight); - _pShell->DeclareSymbol("user INDEX ctl_bCenterView;", &pctlCurrent.bCenterView); - _pShell->DeclareSymbol("user INDEX ctl_bLookLeft;", &pctlCurrent.bLookLeft); - _pShell->DeclareSymbol("user INDEX ctl_bLookRight;", &pctlCurrent.bLookRight); - _pShell->DeclareSymbol("user INDEX ctl_bLookUp;", &pctlCurrent.bLookUp); - _pShell->DeclareSymbol("user INDEX ctl_bLookDown;", &pctlCurrent.bLookDown); - _pShell->DeclareSymbol("user INDEX ctl_bLookBankingLeft;", &pctlCurrent.bLookBankingLeft); - _pShell->DeclareSymbol("user INDEX ctl_bLookBankingRight;", &pctlCurrent.bLookBankingRight ); - _pShell->DeclareSymbol("user INDEX ctl_bWalk;", &pctlCurrent.bWalk); - _pShell->DeclareSymbol("user INDEX ctl_bStrafe;", &pctlCurrent.bStrafe); - _pShell->DeclareSymbol("user INDEX ctl_bFire;", &pctlCurrent.bFire); - _pShell->DeclareSymbol("user INDEX ctl_bReload;", &pctlCurrent.bReload); - _pShell->DeclareSymbol("user INDEX ctl_bUse;", &pctlCurrent.bUse); - _pShell->DeclareSymbol("user INDEX ctl_bComputer;", &pctlCurrent.bComputer); - _pShell->DeclareSymbol("user INDEX ctl_bUseOrComputer;", &pctlCurrent.bUseOrComputer); - _pShell->DeclareSymbol("user INDEX ctl_b3rdPersonView;", &pctlCurrent.b3rdPersonView); - _pShell->DeclareSymbol("user INDEX ctl_bWeaponNext;", &pctlCurrent.bWeaponNext); - _pShell->DeclareSymbol("user INDEX ctl_bWeaponPrev;", &pctlCurrent.bWeaponPrev); - _pShell->DeclareSymbol("user INDEX ctl_bWeaponFlip;", &pctlCurrent.bWeaponFlip); - _pShell->DeclareSymbol("user INDEX ctl_bSelectWeapon[30+1];", &pctlCurrent.bSelectWeapon); - _pShell->DeclareSymbol("persistent user FLOAT ctl_tmComputerDoubleClick;", &ctl_tmComputerDoubleClick); - _pShell->DeclareSymbol("persistent user FLOAT ctl_fButtonRotationSpeedH;", &ctl_fButtonRotationSpeedH); - _pShell->DeclareSymbol("persistent user FLOAT ctl_fButtonRotationSpeedP;", &ctl_fButtonRotationSpeedP); - _pShell->DeclareSymbol("persistent user FLOAT ctl_fButtonRotationSpeedB;", &ctl_fButtonRotationSpeedB); - _pShell->DeclareSymbol("persistent user FLOAT ctl_fAxisStrafingModifier;", &ctl_fAxisStrafingModifier); + _pShell->DeclareSymbol("user INDEX ctl_bMoveForward;", (void *) &pctlCurrent.bMoveForward); + _pShell->DeclareSymbol("user INDEX ctl_bMoveBackward;", (void *) &pctlCurrent.bMoveBackward); + _pShell->DeclareSymbol("user INDEX ctl_bMoveLeft;", (void *) &pctlCurrent.bMoveLeft); + _pShell->DeclareSymbol("user INDEX ctl_bMoveRight;", (void *) &pctlCurrent.bMoveRight); + _pShell->DeclareSymbol("user INDEX ctl_bMoveUp;", (void *) &pctlCurrent.bMoveUp); + _pShell->DeclareSymbol("user INDEX ctl_bMoveDown;", (void *) &pctlCurrent.bMoveDown); + _pShell->DeclareSymbol("user INDEX ctl_bTurnLeft;", (void *) &pctlCurrent.bTurnLeft); + _pShell->DeclareSymbol("user INDEX ctl_bTurnRight;", (void *) &pctlCurrent.bTurnRight); + _pShell->DeclareSymbol("user INDEX ctl_bTurnUp;", (void *) &pctlCurrent.bTurnUp); + _pShell->DeclareSymbol("user INDEX ctl_bTurnDown;", (void *) &pctlCurrent.bTurnDown); + _pShell->DeclareSymbol("user INDEX ctl_bTurnBankingLeft;", (void *) &pctlCurrent.bTurnBankingLeft); + _pShell->DeclareSymbol("user INDEX ctl_bTurnBankingRight;", (void *) &pctlCurrent.bTurnBankingRight); + _pShell->DeclareSymbol("user INDEX ctl_bCenterView;", (void *) &pctlCurrent.bCenterView); + _pShell->DeclareSymbol("user INDEX ctl_bLookLeft;", (void *) &pctlCurrent.bLookLeft); + _pShell->DeclareSymbol("user INDEX ctl_bLookRight;", (void *) &pctlCurrent.bLookRight); + _pShell->DeclareSymbol("user INDEX ctl_bLookUp;", (void *) &pctlCurrent.bLookUp); + _pShell->DeclareSymbol("user INDEX ctl_bLookDown;", (void *) &pctlCurrent.bLookDown); + _pShell->DeclareSymbol("user INDEX ctl_bLookBankingLeft;", (void *) &pctlCurrent.bLookBankingLeft); + _pShell->DeclareSymbol("user INDEX ctl_bLookBankingRight;", (void *) &pctlCurrent.bLookBankingRight ); + _pShell->DeclareSymbol("user INDEX ctl_bWalk;", (void *) &pctlCurrent.bWalk); + _pShell->DeclareSymbol("user INDEX ctl_bStrafe;", (void *) &pctlCurrent.bStrafe); + _pShell->DeclareSymbol("user INDEX ctl_bFire;", (void *) &pctlCurrent.bFire); + _pShell->DeclareSymbol("user INDEX ctl_bReload;", (void *) &pctlCurrent.bReload); + _pShell->DeclareSymbol("user INDEX ctl_bUse;", (void *) &pctlCurrent.bUse); + _pShell->DeclareSymbol("user INDEX ctl_bComputer;", (void *) &pctlCurrent.bComputer); + _pShell->DeclareSymbol("user INDEX ctl_bUseOrComputer;", (void *) &pctlCurrent.bUseOrComputer); + _pShell->DeclareSymbol("user INDEX ctl_b3rdPersonView;", (void *) &pctlCurrent.b3rdPersonView); + _pShell->DeclareSymbol("user INDEX ctl_bWeaponNext;", (void *) &pctlCurrent.bWeaponNext); + _pShell->DeclareSymbol("user INDEX ctl_bWeaponPrev;", (void *) &pctlCurrent.bWeaponPrev); + _pShell->DeclareSymbol("user INDEX ctl_bWeaponFlip;", (void *) &pctlCurrent.bWeaponFlip); + _pShell->DeclareSymbol("user INDEX ctl_bSelectWeapon[30+1];", (void *) &pctlCurrent.bSelectWeapon); + _pShell->DeclareSymbol("persistent user FLOAT ctl_tmComputerDoubleClick;", (void *) &ctl_tmComputerDoubleClick); + _pShell->DeclareSymbol("persistent user FLOAT ctl_fButtonRotationSpeedH;", (void *) &ctl_fButtonRotationSpeedH); + _pShell->DeclareSymbol("persistent user FLOAT ctl_fButtonRotationSpeedP;", (void *) &ctl_fButtonRotationSpeedP); + _pShell->DeclareSymbol("persistent user FLOAT ctl_fButtonRotationSpeedB;", (void *) &ctl_fButtonRotationSpeedB); + _pShell->DeclareSymbol("persistent user FLOAT ctl_fAxisStrafingModifier;", (void *) &ctl_fAxisStrafingModifier); //new - _pShell->DeclareSymbol("user INDEX ctl_bSniperZoomIn;", &pctlCurrent.bSniperZoomIn); - _pShell->DeclareSymbol("user INDEX ctl_bSniperZoomOut;", &pctlCurrent.bSniperZoomOut); - _pShell->DeclareSymbol("user INDEX ctl_bFireBomb;", &pctlCurrent.bFireBomb); + _pShell->DeclareSymbol("user INDEX ctl_bSniperZoomIn;", (void *) &pctlCurrent.bSniperZoomIn); + _pShell->DeclareSymbol("user INDEX ctl_bSniperZoomOut;", (void *) &pctlCurrent.bSniperZoomOut); + _pShell->DeclareSymbol("user INDEX ctl_bFireBomb;", (void *) &pctlCurrent.bFireBomb); - _pShell->DeclareSymbol("user FLOAT plr_fSwimSoundDelay;", &plr_fSwimSoundDelay); - _pShell->DeclareSymbol("user FLOAT plr_fDiveSoundDelay;", &plr_fDiveSoundDelay); - _pShell->DeclareSymbol("user FLOAT plr_fWalkSoundDelay;", &plr_fWalkSoundDelay); - _pShell->DeclareSymbol("user FLOAT plr_fRunSoundDelay;", &plr_fRunSoundDelay); + _pShell->DeclareSymbol("user FLOAT plr_fSwimSoundDelay;", (void *) &plr_fSwimSoundDelay); + _pShell->DeclareSymbol("user FLOAT plr_fDiveSoundDelay;", (void *) &plr_fDiveSoundDelay); + _pShell->DeclareSymbol("user FLOAT plr_fWalkSoundDelay;", (void *) &plr_fWalkSoundDelay); + _pShell->DeclareSymbol("user FLOAT plr_fRunSoundDelay;", (void *) &plr_fRunSoundDelay); - _pShell->DeclareSymbol("persistent user FLOAT cli_fPredictPlayersRange;",&cli_fPredictPlayersRange); - _pShell->DeclareSymbol("persistent user FLOAT cli_fPredictItemsRange;", &cli_fPredictItemsRange ); - _pShell->DeclareSymbol("persistent user FLOAT cli_tmPredictFoe;", &cli_tmPredictFoe ); - _pShell->DeclareSymbol("persistent user FLOAT cli_tmPredictAlly;", &cli_tmPredictAlly ); - _pShell->DeclareSymbol("persistent user FLOAT cli_tmPredictEnemy;", &cli_tmPredictEnemy ); + _pShell->DeclareSymbol("persistent user FLOAT cli_fPredictPlayersRange;",(void *) &cli_fPredictPlayersRange); + _pShell->DeclareSymbol("persistent user FLOAT cli_fPredictItemsRange;", (void *) &cli_fPredictItemsRange ); + _pShell->DeclareSymbol("persistent user FLOAT cli_tmPredictFoe;", (void *) &cli_tmPredictFoe ); + _pShell->DeclareSymbol("persistent user FLOAT cli_tmPredictAlly;", (void *) &cli_tmPredictAlly ); + _pShell->DeclareSymbol("persistent user FLOAT cli_tmPredictEnemy;", (void *) &cli_tmPredictEnemy ); - _pShell->DeclareSymbol(" INDEX hud_bShowAll;", &hud_bShowAll); - _pShell->DeclareSymbol("user INDEX hud_bShowInfo;", &hud_bShowInfo); - _pShell->DeclareSymbol("user const FLOAT net_tmLatencyAvg;", &net_tmLatencyAvg); - _pShell->DeclareSymbol("persistent user INDEX hud_bShowLatency;", &hud_bShowLatency); - _pShell->DeclareSymbol("persistent user INDEX hud_iShowPlayers;", &hud_iShowPlayers); - _pShell->DeclareSymbol("persistent user INDEX hud_iSortPlayers;", &hud_iSortPlayers); - _pShell->DeclareSymbol("persistent user INDEX hud_bShowWeapon;", &hud_bShowWeapon); - _pShell->DeclareSymbol("persistent user INDEX hud_bShowMessages;",&hud_bShowMessages); - _pShell->DeclareSymbol("persistent user FLOAT hud_fScaling;", &hud_fScaling); - _pShell->DeclareSymbol("persistent user FLOAT hud_fOpacity;", &hud_fOpacity); - _pShell->DeclareSymbol("persistent user FLOAT hud_tmWeaponsOnScreen;", &hud_tmWeaponsOnScreen); - _pShell->DeclareSymbol("persistent user FLOAT hud_tmLatencySnapshot;", &hud_tmLatencySnapshot); - _pShell->DeclareSymbol("persistent user FLOAT plr_fBreathingStrength;", &plr_fBreathingStrength); - _pShell->DeclareSymbol("INDEX cht_bKillFinalBoss;", &cht_bKillFinalBoss); - _pShell->DeclareSymbol("INDEX cht_bDebugFinalBoss;", &cht_bDebugFinalBoss); - _pShell->DeclareSymbol("INDEX cht_bDumpFinalBossData;", &cht_bDumpFinalBossData); - _pShell->DeclareSymbol("INDEX cht_bDebugFinalBossAnimations;", &cht_bDebugFinalBossAnimations); - _pShell->DeclareSymbol("INDEX cht_bDumpPlayerShading;", &cht_bDumpPlayerShading); - _pShell->DeclareSymbol("persistent user INDEX hud_bShowMatchInfo;", &hud_bShowMatchInfo); + _pShell->DeclareSymbol(" INDEX hud_bShowAll;", (void *) &hud_bShowAll); + _pShell->DeclareSymbol("user INDEX hud_bShowInfo;", (void *) &hud_bShowInfo); + _pShell->DeclareSymbol("user const FLOAT net_tmLatencyAvg;", (void *) &net_tmLatencyAvg); + _pShell->DeclareSymbol("persistent user INDEX hud_bShowLatency;", (void *) &hud_bShowLatency); + _pShell->DeclareSymbol("persistent user INDEX hud_iShowPlayers;", (void *) &hud_iShowPlayers); + _pShell->DeclareSymbol("persistent user INDEX hud_iSortPlayers;", (void *) &hud_iSortPlayers); + _pShell->DeclareSymbol("persistent user INDEX hud_bShowWeapon;", (void *) &hud_bShowWeapon); + _pShell->DeclareSymbol("persistent user INDEX hud_bShowMessages;",(void *) &hud_bShowMessages); + _pShell->DeclareSymbol("persistent user FLOAT hud_fScaling;", (void *) &hud_fScaling); + _pShell->DeclareSymbol("persistent user FLOAT hud_fOpacity;", (void *) &hud_fOpacity); + _pShell->DeclareSymbol("persistent user FLOAT hud_tmWeaponsOnScreen;", (void *) &hud_tmWeaponsOnScreen); + _pShell->DeclareSymbol("persistent user FLOAT hud_tmLatencySnapshot;", (void *) &hud_tmLatencySnapshot); + _pShell->DeclareSymbol("persistent user FLOAT plr_fBreathingStrength;", (void *) &plr_fBreathingStrength); + _pShell->DeclareSymbol("INDEX cht_bKillFinalBoss;", (void *) &cht_bKillFinalBoss); + _pShell->DeclareSymbol("INDEX cht_bDebugFinalBoss;", (void *) &cht_bDebugFinalBoss); + _pShell->DeclareSymbol("INDEX cht_bDumpFinalBossData;", (void *) &cht_bDumpFinalBossData); + _pShell->DeclareSymbol("INDEX cht_bDebugFinalBossAnimations;", (void *) &cht_bDebugFinalBossAnimations); + _pShell->DeclareSymbol("INDEX cht_bDumpPlayerShading;", (void *) &cht_bDumpPlayerShading); + _pShell->DeclareSymbol("persistent user INDEX hud_bShowMatchInfo;", (void *) &hud_bShowMatchInfo); - _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilSpeed[17];", &wpn_fRecoilSpeed); - _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilLimit[17];", &wpn_fRecoilLimit); - _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilDampUp[17];", &wpn_fRecoilDampUp); - _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilDampDn[17];", &wpn_fRecoilDampDn); - _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilOffset[17];", &wpn_fRecoilOffset); - _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilFactorP[17];", &wpn_fRecoilFactorP); - _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilFactorZ[17];", &wpn_fRecoilFactorZ); + _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilSpeed[17];", (void *) &wpn_fRecoilSpeed); + _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilLimit[17];", (void *) &wpn_fRecoilLimit); + _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilDampUp[17];", (void *) &wpn_fRecoilDampUp); + _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilDampDn[17];", (void *) &wpn_fRecoilDampDn); + _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilOffset[17];", (void *) &wpn_fRecoilOffset); + _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilFactorP[17];", (void *) &wpn_fRecoilFactorP); + _pShell->DeclareSymbol("persistent user FLOAT wpn_fRecoilFactorZ[17];", (void *) &wpn_fRecoilFactorZ); // cheats - _pShell->DeclareSymbol("user INDEX cht_bGod;", &cht_bGod); - _pShell->DeclareSymbol("user INDEX cht_bFly;", &cht_bFly); - _pShell->DeclareSymbol("user INDEX cht_bGhost;", &cht_bGhost); - _pShell->DeclareSymbol("user INDEX cht_bInvisible;", &cht_bInvisible); - _pShell->DeclareSymbol("user INDEX cht_bGiveAll;", &cht_bGiveAll); - _pShell->DeclareSymbol("user INDEX cht_bKillAll;", &cht_bKillAll); - _pShell->DeclareSymbol("user INDEX cht_bOpen;", &cht_bOpen); - _pShell->DeclareSymbol("user INDEX cht_bAllMessages;", &cht_bAllMessages); - _pShell->DeclareSymbol("user FLOAT cht_fTranslationMultiplier ;", &cht_fTranslationMultiplier); - _pShell->DeclareSymbol("user INDEX cht_bRefresh;", &cht_bRefresh); + _pShell->DeclareSymbol("user INDEX cht_bGod;", (void *) &cht_bGod); + _pShell->DeclareSymbol("user INDEX cht_bFly;", (void *) &cht_bFly); + _pShell->DeclareSymbol("user INDEX cht_bGhost;", (void *) &cht_bGhost); + _pShell->DeclareSymbol("user INDEX cht_bInvisible;", (void *) &cht_bInvisible); + _pShell->DeclareSymbol("user INDEX cht_bGiveAll;", (void *) &cht_bGiveAll); + _pShell->DeclareSymbol("user INDEX cht_bKillAll;", (void *) &cht_bKillAll); + _pShell->DeclareSymbol("user INDEX cht_bOpen;", (void *) &cht_bOpen); + _pShell->DeclareSymbol("user INDEX cht_bAllMessages;", (void *) &cht_bAllMessages); + _pShell->DeclareSymbol("user FLOAT cht_fTranslationMultiplier ;", (void *) &cht_fTranslationMultiplier); + _pShell->DeclareSymbol("user INDEX cht_bRefresh;", (void *) &cht_bRefresh); // this one is masqueraded cheat enable variable - _pShell->DeclareSymbol("INDEX cht_bEnable;", &cht_bEnable); + _pShell->DeclareSymbol("INDEX cht_bEnable;", (void *) &cht_bEnable); // this cheat is always enabled - _pShell->DeclareSymbol("user INDEX cht_iGoToMarker;", &cht_iGoToMarker); + _pShell->DeclareSymbol("user INDEX cht_iGoToMarker;", (void *) &cht_iGoToMarker); // player speed and view parameters, not declared except in internal build #if 0 - _pShell->DeclareSymbol("user FLOAT plr_fViewHeightStand;", &plr_fViewHeightStand); - _pShell->DeclareSymbol("user FLOAT plr_fViewHeightCrouch;",&plr_fViewHeightCrouch); - _pShell->DeclareSymbol("user FLOAT plr_fViewHeightSwim;", &plr_fViewHeightSwim); - _pShell->DeclareSymbol("user FLOAT plr_fViewHeightDive;", &plr_fViewHeightDive); - _pShell->DeclareSymbol("user FLOAT plr_fViewDampFactor;", &plr_fViewDampFactor); - _pShell->DeclareSymbol("user FLOAT plr_fViewDampLimitGroundUp;", &plr_fViewDampLimitGroundUp); - _pShell->DeclareSymbol("user FLOAT plr_fViewDampLimitGroundDn;", &plr_fViewDampLimitGroundDn); - _pShell->DeclareSymbol("user FLOAT plr_fViewDampLimitWater;", &plr_fViewDampLimitWater); - _pShell->DeclareSymbol("user FLOAT plr_fAcceleration;", &plr_fAcceleration); - _pShell->DeclareSymbol("user FLOAT plr_fDeceleration;", &plr_fDeceleration); - _pShell->DeclareSymbol("user FLOAT plr_fSpeedForward;", &plr_fSpeedForward); - _pShell->DeclareSymbol("user FLOAT plr_fSpeedBackward;", &plr_fSpeedBackward); - _pShell->DeclareSymbol("user FLOAT plr_fSpeedSide;", &plr_fSpeedSide); - _pShell->DeclareSymbol("user FLOAT plr_fSpeedUp;", &plr_fSpeedUp); + _pShell->DeclareSymbol("user FLOAT plr_fViewHeightStand;", (void *) &plr_fViewHeightStand); + _pShell->DeclareSymbol("user FLOAT plr_fViewHeightCrouch;",(void *) &plr_fViewHeightCrouch); + _pShell->DeclareSymbol("user FLOAT plr_fViewHeightSwim;", (void *) &plr_fViewHeightSwim); + _pShell->DeclareSymbol("user FLOAT plr_fViewHeightDive;", (void *) &plr_fViewHeightDive); + _pShell->DeclareSymbol("user FLOAT plr_fViewDampFactor;", (void *) &plr_fViewDampFactor); + _pShell->DeclareSymbol("user FLOAT plr_fViewDampLimitGroundUp;", (void *) &plr_fViewDampLimitGroundUp); + _pShell->DeclareSymbol("user FLOAT plr_fViewDampLimitGroundDn;", (void *) &plr_fViewDampLimitGroundDn); + _pShell->DeclareSymbol("user FLOAT plr_fViewDampLimitWater;", (void *) &plr_fViewDampLimitWater); + _pShell->DeclareSymbol("user FLOAT plr_fAcceleration;", (void *) &plr_fAcceleration); + _pShell->DeclareSymbol("user FLOAT plr_fDeceleration;", (void *) &plr_fDeceleration); + _pShell->DeclareSymbol("user FLOAT plr_fSpeedForward;", (void *) &plr_fSpeedForward); + _pShell->DeclareSymbol("user FLOAT plr_fSpeedBackward;", (void *) &plr_fSpeedBackward); + _pShell->DeclareSymbol("user FLOAT plr_fSpeedSide;", (void *) &plr_fSpeedSide); + _pShell->DeclareSymbol("user FLOAT plr_fSpeedUp;", (void *) &plr_fSpeedUp); #endif - _pShell->DeclareSymbol("persistent user FLOAT plr_fFOV;", &plr_fFOV); - _pShell->DeclareSymbol("persistent user FLOAT plr_fFrontClipDistance;", &plr_fFrontClipDistance); - _pShell->DeclareSymbol("persistent user INDEX plr_bRenderPicked;", &plr_bRenderPicked); - _pShell->DeclareSymbol("persistent user INDEX plr_bRenderPickedParticles;", &plr_bRenderPickedParticles); - _pShell->DeclareSymbol("persistent user INDEX plr_bOnlySam;", &plr_bOnlySam); - _pShell->DeclareSymbol("persistent user INDEX ent_bReportBrokenChains;", &ent_bReportBrokenChains); - _pShell->DeclareSymbol("persistent user FLOAT ent_tmMentalIn ;", &ent_tmMentalIn ); - _pShell->DeclareSymbol("persistent user FLOAT ent_tmMentalOut ;", &ent_tmMentalOut ); - _pShell->DeclareSymbol("persistent user FLOAT ent_tmMentalFade;", &ent_tmMentalFade); - _pShell->DeclareSymbol("persistent user FLOAT gfx_fEnvParticlesDensity;", &gfx_fEnvParticlesDensity); - _pShell->DeclareSymbol("persistent user FLOAT gfx_fEnvParticlesRange;", &gfx_fEnvParticlesRange); + _pShell->DeclareSymbol("persistent user FLOAT plr_fFOV;", (void *) &plr_fFOV); + _pShell->DeclareSymbol("persistent user FLOAT plr_fFrontClipDistance;", (void *) &plr_fFrontClipDistance); + _pShell->DeclareSymbol("persistent user INDEX plr_bRenderPicked;", (void *) &plr_bRenderPicked); + _pShell->DeclareSymbol("persistent user INDEX plr_bRenderPickedParticles;", (void *) &plr_bRenderPickedParticles); + _pShell->DeclareSymbol("persistent user INDEX plr_bOnlySam;", (void *) &plr_bOnlySam); + _pShell->DeclareSymbol("persistent user INDEX ent_bReportBrokenChains;", (void *) &ent_bReportBrokenChains); + _pShell->DeclareSymbol("persistent user FLOAT ent_tmMentalIn ;", (void *) &ent_tmMentalIn ); + _pShell->DeclareSymbol("persistent user FLOAT ent_tmMentalOut ;", (void *) &ent_tmMentalOut ); + _pShell->DeclareSymbol("persistent user FLOAT ent_tmMentalFade;", (void *) &ent_tmMentalFade); + _pShell->DeclareSymbol("persistent user FLOAT gfx_fEnvParticlesDensity;", (void *) &gfx_fEnvParticlesDensity); + _pShell->DeclareSymbol("persistent user FLOAT gfx_fEnvParticlesRange;", (void *) &gfx_fEnvParticlesRange); // player appearance interface - _pShell->DeclareSymbol("INDEX SetPlayerAppearance(INDEX, INDEX, INDEX, INDEX);", &SetPlayerAppearance); + _pShell->DeclareSymbol("INDEX SetPlayerAppearance(INDEX, INDEX, INDEX, INDEX);", (void *) &SetPlayerAppearance); // call player weapons persistant variable initialization extern void CPlayerWeapons_Init(void); @@ -926,41 +928,41 @@ void PrintPlayerDeathMessage(CPlayer *ppl, const EDeath &eDeath) CTString strKillerName = ((CPlayer*)penKiller)->GetPlayerName(); if(eDeath.eLastDamage.dmtType==DMT_TELEPORT) { - CPrintF(TRANS("%s telefragged %s\n"), strKillerName, strMyName); + CPrintF(TRANS("%s telefragged %s\n"), (const char *) strKillerName, (const char *) strMyName); } else if(eDeath.eLastDamage.dmtType==DMT_CLOSERANGE) { - CPrintF(TRANS("%s cut %s into pieces\n"), strKillerName, strMyName); + CPrintF(TRANS("%s cut %s into pieces\n"), (const char *) strKillerName, (const char *) strMyName); } else if(eDeath.eLastDamage.dmtType==DMT_CHAINSAW) { - CPrintF(TRANS("%s cut %s into pieces\n"), strKillerName, strMyName); + CPrintF(TRANS("%s cut %s into pieces\n"), (const char *) strKillerName, (const char *) strMyName); } else if(eDeath.eLastDamage.dmtType==DMT_BULLET) { - CPrintF(TRANS("%s poured lead into %s\n"), strKillerName, strMyName); + CPrintF(TRANS("%s poured lead into %s\n"), (const char *) strKillerName, (const char *) strMyName); } else if(eDeath.eLastDamage.dmtType==DMT_PROJECTILE || eDeath.eLastDamage.dmtType==DMT_EXPLOSION) { - CPrintF(TRANS("%s blew %s away\n"), strKillerName, strMyName); + CPrintF(TRANS("%s blew %s away\n"), (const char *) strKillerName, (const char *) strMyName); } else if(eDeath.eLastDamage.dmtType==DMT_CANNONBALL) { - CPrintF(TRANS("%s smashed %s with a cannon\n"), strKillerName, strMyName); + CPrintF(TRANS("%s smashed %s with a cannon\n"), (const char *) strKillerName, (const char *) strMyName); } else if(eDeath.eLastDamage.dmtType==DMT_CANNONBALL_EXPLOSION) { - CPrintF(TRANS("%s nuked %s\n"), strKillerName, strMyName); + CPrintF(TRANS("%s nuked %s\n"), (const char *) strKillerName, (const char *) strMyName); } else { - CPrintF(TRANS("%s killed %s\n"), strKillerName, strMyName); + CPrintF(TRANS("%s killed %s\n"), (const char *) strKillerName, (const char *) strMyName); } } else { // make message from damage type switch(eDeath.eLastDamage.dmtType) { - case DMT_DROWNING: CPrintF(TRANS("%s drowned\n"), strMyName); break; - case DMT_BURNING: CPrintF(TRANS("%s burst into flames\n"), strMyName); break; - case DMT_SPIKESTAB: CPrintF(TRANS("%s fell into a spike-hole\n"), strMyName); break; - case DMT_FREEZING: CPrintF(TRANS("%s has frozen\n"), strMyName); break; - case DMT_ACID: CPrintF(TRANS("%s dissolved\n"), strMyName); break; + case DMT_DROWNING: CPrintF(TRANS("%s drowned\n"), (const char *) strMyName); break; + case DMT_BURNING: CPrintF(TRANS("%s burst into flames\n"), (const char *) strMyName); break; + case DMT_SPIKESTAB: CPrintF(TRANS("%s fell into a spike-hole\n"), (const char *) strMyName); break; + case DMT_FREEZING: CPrintF(TRANS("%s has frozen\n"), (const char *) strMyName); break; + case DMT_ACID: CPrintF(TRANS("%s dissolved\n"), (const char *) strMyName); break; case DMT_PROJECTILE: case DMT_EXPLOSION: - CPrintF(TRANS("%s blew himself away\n"), strMyName); break; - default: CPrintF(TRANS("%s has committed suicide\n"), strMyName); + CPrintF(TRANS("%s blew himself away\n"), (const char *) strMyName); break; + default: CPrintF(TRANS("%s has committed suicide\n"), (const char *) strMyName); } } // if killed by an enemy } else if (IsDerivedFromClass(penKiller, "Enemy Base")) { // check for telefrag first if(eDeath.eLastDamage.dmtType==DMT_TELEPORT) { - CPrintF(TRANS("%s was telefragged\n"), strMyName); + CPrintF(TRANS("%s was telefragged\n"), (const char *) strMyName); return; } // describe how this enemy killed player @@ -970,17 +972,17 @@ void PrintPlayerDeathMessage(CPlayer *ppl, const EDeath &eDeath) } else { // make message from damage type switch(eDeath.eLastDamage.dmtType) { - case DMT_SPIKESTAB: CPrintF(TRANS("%s was pierced\n"), strMyName); break; - case DMT_BRUSH: CPrintF(TRANS("%s was squashed\n"), strMyName); break; - case DMT_ABYSS: CPrintF(TRANS("%s went over the edge\n"), strMyName); break; - case DMT_IMPACT: CPrintF(TRANS("%s swashed\n"), strMyName); break; - case DMT_HEAT: CPrintF(TRANS("%s stood in the sun for too long\n"), strMyName); break; - default: CPrintF(TRANS("%s passed away\n"), strMyName); + case DMT_SPIKESTAB: CPrintF(TRANS("%s was pierced\n"), (const char *) strMyName); break; + case DMT_BRUSH: CPrintF(TRANS("%s was squashed\n"), (const char *) strMyName); break; + case DMT_ABYSS: CPrintF(TRANS("%s went over the edge\n"), (const char *) strMyName); break; + case DMT_IMPACT: CPrintF(TRANS("%s swashed\n"), (const char *) strMyName); break; + case DMT_HEAT: CPrintF(TRANS("%s stood in the sun for too long\n"), (const char *) strMyName); break; + default: CPrintF(TRANS("%s passed away\n"), (const char *) strMyName); } } // if no entity pointer (shouldn't happen) } else { - CPrintF(TRANS("%s is missing in action\n"), strMyName); + CPrintF(TRANS("%s is missing in action\n"), (const char *) strMyName); } } @@ -1316,7 +1318,7 @@ functions: bsld.bsld_vPos = vPos; bsld.bsld_vG = en_vGravityDir; bsld.bsld_eptType=eptType; - bsld.bsld_iRndBase=FRnd()*123456; + bsld.bsld_iRndBase=(INDEX) (FRnd()*123456); bsld.bsld_tmLaunch = _pTimer->CurrentTick(); bsld.bsld_vStretch=vStretch; // move to bullet spray position @@ -1544,10 +1546,10 @@ functions: } } - istr->Read_t(&m_psLevelStats, sizeof(m_psLevelStats)); - istr->Read_t(&m_psLevelTotal, sizeof(m_psLevelTotal)); - istr->Read_t(&m_psGameStats , sizeof(m_psGameStats )); - istr->Read_t(&m_psGameTotal , sizeof(m_psGameTotal )); + (*istr) >> m_psLevelStats; + (*istr) >> m_psLevelTotal; + (*istr) >> m_psGameStats; + (*istr) >> m_psGameTotal; // set your real appearance if possible ValidateCharacter(); @@ -1628,7 +1630,7 @@ functions: CTString GetStatsRealWorldStarted(void) { struct tm *newtime; - newtime = localtime((const time_t*)&m_iStartTime); + newtime = localtime(&m_iStartTime); setlocale(LC_ALL, ""); CTString strTimeline; @@ -1668,7 +1670,7 @@ functions: void GetShortStats(CTString &strStats) { strStats.PrintF( TRANS("%s %s Score: %d Kills: %d/%d"), - GetDifficultyString(), TimeToString(GetStatsInGameTimeLevel()), + (const char *) GetDifficultyString(), (const char *) TimeToString(GetStatsInGameTimeLevel()), m_psLevelStats.ps_iScore, m_psLevelStats.ps_iKills, m_psLevelTotal.ps_iKills); } @@ -1684,7 +1686,7 @@ functions: const INDEX ctPlayers = SetAllPlayersStats(bFragMatch?5:3); // sort by frags or by score // get time elapsed since the game start - strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%s", TRANS("TIME"), TimeToString(_pNetwork->GetGameTime()))); + strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%s", (const char *) TRANS("TIME"), (const char *) TimeToString(_pNetwork->GetGameTime()))); strStats+="\n"; // find maximum frags/score that one player has @@ -1700,7 +1702,7 @@ functions: const CSessionProperties &sp = *GetSP(); if (sp.sp_iTimeLimit>0) { FLOAT fTimeLeft = ClampDn(sp.sp_iTimeLimit*60.0f - _pNetwork->GetGameTime(), 0.0f); - strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%s", TRANS("TIME LEFT"), TimeToString(fTimeLeft))); + strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%s", (const char *) TRANS("TIME LEFT"), (const char *) TimeToString(fTimeLeft))); strStats+="\n"; } if (bFragMatch && sp.sp_iFragLimit>0) { @@ -1735,7 +1737,7 @@ functions: {for(INDEX iPlayer=0; iPlayeren_tmPing*1000.0f); + INDEX iPing = (INDEX) (ceil(penPlayer->en_tmPing*1000.0f)); INDEX iScore = bFragMatch ? penPlayer->m_psLevelStats.ps_iKills : penPlayer->m_psLevelStats.ps_iScore; CTString strName = penPlayer->GetPlayerName(); @@ -1840,13 +1842,13 @@ functions: if (iCoopType<=1) { // report total score info - strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%d", TRANS("TOTAL SCORE"), m_psGameStats.ps_iScore)); + strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%d", (const char *) TRANS("TOTAL SCORE"), m_psGameStats.ps_iScore)); strStats+="\n"; - strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%s", TRANS("DIFFICULTY"), GetDifficultyString())); + strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%s", (const char *) TRANS("DIFFICULTY"), (const char *) GetDifficultyString())); strStats+="\n"; - strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%s", TRANS("STARTED"), GetStatsRealWorldStarted())); + strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%s", (const char *) TRANS("STARTED"), (const char *) GetStatsRealWorldStarted())); strStats+="\n"; - strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%s", TRANS("PLAYING TIME"), TimeToString(GetStatsRealWorldTime()))); + strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%s", (const char *) TRANS("PLAYING TIME"), (const char *) TimeToString(GetStatsRealWorldTime()))); strStats+="\n"; if( m_psGameStats.ps_iScore<=plr_iHiScore) { strStats+=AlignString(CTString(0, "^cFFFFFF%s:^r\n%d", TRANS("HI-SCORE"), plr_iHiScore)); @@ -1861,9 +1863,9 @@ functions: strStats+="\n"; if (iCoopType<=1) { if( m_bEndOfLevel) { - strStats+=AlignString(CTString(0, " %s:\n%s", TRANS("ESTIMATED TIME"), TimeToString(m_tmEstTime))); + strStats+=AlignString(CTString(0, " %s:\n%s", (const char *) TRANS("ESTIMATED TIME"), (const char *) TimeToString(m_tmEstTime))); strStats+="\n"; - strStats+=AlignString(CTString(0, " %s:\n%d", TRANS("TIME BONUS"), m_iTimeScore)); + strStats+=AlignString(CTString(0, " %s:\n%d", (const char *) TRANS("TIME BONUS"), m_iTimeScore)); strStats+="\n"; strStats+="\n"; } @@ -1881,7 +1883,7 @@ functions: strStats+=AlignString(CTString(0, " %s:\n%d/%d", TRANS("SECRETS"), m_psLevelStats.ps_iSecrets, m_psLevelTotal.ps_iSecrets)); strStats+="\n"; if (iCoopType<=1) { - strStats+=AlignString(CTString(0, " %s:\n%s", TRANS("TIME"), TimeToString(GetStatsInGameTimeLevel()))); + strStats+=AlignString(CTString(0, " %s:\n%s", TRANS("TIME"), (const char *) TimeToString(GetStatsInGameTimeLevel()))); strStats+="\n"; } strStats+="\n"; @@ -1900,7 +1902,7 @@ functions: strStats+=AlignString(CTString(0, " %s:\n%d/%d", TRANS("SECRETS"), m_psGameStats.ps_iSecrets, m_psGameTotal.ps_iSecrets)); strStats+="\n"; if (iCoopType<=1) { - strStats+=AlignString(CTString(0, " %s:\n%s", TRANS("GAME TIME"), TimeToString(GetStatsInGameTimeGame()))); + strStats+=AlignString(CTString(0, " %s:\n%s", TRANS("GAME TIME"), (const char *) TimeToString(GetStatsInGameTimeGame()))); strStats+="\n"; } strStats+="\n"; @@ -1995,7 +1997,7 @@ functions: { // list the directory CDynamicStackArray afnmDir; - MakeDirList(afnmDir, strDir, "*.txt", DLI_RECURSIVE); + MakeDirList(afnmDir, strDir, CTFileName(CTString("*.txt")), DLI_RECURSIVE); // for each file in the directory for (INDEX i=0; iSetTextScaling( fScale); pdp->SetTextAspect( 1.0f); CTString strMsg; - strMsg.PrintF(TRANS("%s connected"), GetPlayerName()); + strMsg.PrintF(TRANS("%s connected"), (const char *) GetPlayerName()); pdp->PutTextCXY( strMsg, pixDPWidth*0.5f, pixDPHeight*0.5f, SE_COL_BLUE_NEUTRAL_LT|CT_OPAQUE); } } @@ -2528,7 +2530,7 @@ functions: if (m_fPickedAmmount==0) { strPicked = m_strPickedName; } else { - strPicked.PrintF("%s +%d", m_strPickedName, int(m_fPickedAmmount)); + strPicked.PrintF("%s +%d", (const char *) m_strPickedName, int(m_fPickedAmmount)); } pdp->PutTextCXY( strPicked, pixDPWidth*0.5f, pixDPHeight*0.82f, C_WHITE|0xDD); if (!GetSP()->sp_bCooperative && !GetSP()->sp_bUseFrags && m_fPickedMana>=1) { @@ -2746,7 +2748,7 @@ functions: m_fManaFraction += ClampDn( 1.0f-en_vCurrentTranslationAbsolute.Length()/20.0f, 0.0f) * 20.0f * _pTimer->TickQuantum; - INDEX iNewMana = m_fManaFraction; + INDEX iNewMana = (INDEX) m_fManaFraction; m_iMana += iNewMana; m_fManaFraction -= iNewMana; } @@ -3371,7 +3373,7 @@ functions: ItemPicked(strKey, 0); // if in cooperative if (GetSP()->sp_bCooperative && !GetSP()->sp_bSinglePlayer) { - CPrintF(TRANS("^cFFFFFF%s - %s^r\n"), GetPlayerName(), strKey); + CPrintF(TRANS("^cFFFFFF%s - %s^r\n"), (const char *) GetPlayerName(), (const char *) strKey); } return TRUE; } @@ -3771,14 +3773,14 @@ functions: if (pcOrg.GetName()!=pcNew.GetName()) { // report that CPrintF(TRANS("%s is now known as %s\n"), - pcOrg.GetNameForPrinting(), pcNew.GetNameForPrinting()); + (const char *) pcOrg.GetNameForPrinting(), (const char *) pcNew.GetNameForPrinting()); } // if the team has changed if (pcOrg.GetTeam()!=pcNew.GetTeam()) { // report that CPrintF(TRANS("%s switched to team %s\n"), - pcNew.GetNameForPrinting(), pcNew.GetTeamForPrinting()); + (const char *) pcNew.GetNameForPrinting(), (const char *) pcNew.GetTeamForPrinting()); } // if appearance changed @@ -3793,12 +3795,12 @@ functions: ParseGender(strNewLook); // report that CPrintF(TRANS("%s now appears as %s\n"), - pcNew.GetNameForPrinting(), strNewLook); + (const char *) pcNew.GetNameForPrinting(), (const char *) strNewLook); // if failed } else { // report that CPrintF(TRANS("Cannot change appearance for %s: setting '%s' is unavailable\n"), - pcNew.GetNameForPrinting(), (const char*)ppsNew->GetModelFilename()); + (const char *) pcNew.GetNameForPrinting(), (const char*)ppsNew->GetModelFilename()); } // attach weapon to new appearance GetPlayerAnimator()->SyncWeapon(); @@ -4431,7 +4433,7 @@ functions: } // initiate respawn - CPrintF(TRANS("%s is riding the gun again\n"), GetPlayerName()); + CPrintF(TRANS("%s is riding the gun again\n"), (const char *) GetPlayerName()); SendEvent(EEnd()); // report number of credits left @@ -4445,7 +4447,7 @@ functions: // if no more credits left } else { // report that you cannot respawn - CPrintF(TRANS("%s rests in peace - out of credits\n"), GetPlayerName()); + CPrintF(TRANS("%s rests in peace - out of credits\n"), (const char *) GetPlayerName()); } } } @@ -4847,7 +4849,7 @@ functions: CPlayer *pen = (CPlayer*)GetPredictionTail(); // do screen blending ULONG ulR=255, ulG=0, ulB=0; // red for wounding - ULONG ulA = pen->m_fDamageAmmount*5.0f; + ULONG ulA = (ULONG) (pen->m_fDamageAmmount*5.0f); // if less than few seconds elapsed since last damage FLOAT tmSinceWounding = _pTimer->CurrentTick() - pen->m_tmWoundedTime; @@ -5152,7 +5154,7 @@ functions: if (pen==NULL) { // try to find normal start marker CTString strPlayerStart; - strPlayerStart.PrintF("Player Start - %s", m_strGroup); + strPlayerStart.PrintF("Player Start - %s", (const char *) m_strGroup); pen = _pNetwork->GetEntityWithName(strPlayerStart, 0); if (m_strGroup=="") { bSetHealth = TRUE; @@ -5338,20 +5340,20 @@ functions: m_iMayRespawn = 0; m_bEndOfLevel = TRUE; // remember end time - time((time_t*)&m_iEndTime); + time(&m_iEndTime); // add time score TIME tmLevelTime = _pTimer->CurrentTick()-m_tmLevelStarted; m_psLevelStats.ps_tmTime = tmLevelTime; m_psGameStats.ps_tmTime += tmLevelTime; - FLOAT fTimeDelta = ClampDn((FLOAT)(floor(m_tmEstTime)-floor(tmLevelTime)), 0.0f); - m_iTimeScore = floor(fTimeDelta*100.0f); + FLOAT fTimeDelta = ClampDn(floor(m_tmEstTime)-floor(tmLevelTime), 0.0); + m_iTimeScore = (INDEX) floor(fTimeDelta*100.0f); m_psLevelStats.ps_iScore+=m_iTimeScore; m_psGameStats.ps_iScore+=m_iTimeScore; // record stats for this level and add to global table CTString strStats; strStats.PrintF(TRANS("%s\n Time: %s\n Score: %9d\n Kills: %03d/%03d\n Secrets: %02d/%02d\n"), - TranslateConst(en_pwoWorld->GetName(), 0), TimeToString(tmLevelTime), + TranslateConst(en_pwoWorld->GetName(), 0), (const char *) TimeToString(tmLevelTime), m_psLevelStats.ps_iScore, m_psLevelStats.ps_iKills, m_psLevelTotal.ps_iKills, m_psLevelStats.ps_iSecrets, m_psLevelTotal.ps_iSecrets); @@ -5636,11 +5638,11 @@ procedures: // if killed by a player if (pplKillerPlayer!=NULL) { // print how much that player gained - CPrintF(TRANS(" %s: +%d points\n"), pplKillerPlayer->GetPlayerName(), m_iMana); + CPrintF(TRANS(" %s: +%d points\n"), (const char *) pplKillerPlayer->GetPlayerName(), m_iMana); // if it was a suicide, or an accident } else { // print how much you lost - CPrintF(TRANS(" %s: -%d points\n"), GetPlayerName(), m_iMana); + CPrintF(TRANS(" %s: -%d points\n"), (const char *) GetPlayerName(), m_iMana); } } @@ -6520,7 +6522,7 @@ procedures: Main(EVoid evoid) { // remember start time - time((time_t*)&m_iStartTime); + time(&m_iStartTime); m_ctUnreadMessages = 0; SetFlags(GetFlags()|ENF_CROSSESLEVELS|ENF_NOTIFYLEVELCHANGE); @@ -6673,7 +6675,7 @@ procedures: on (EReceiveScore eScore) : { m_psLevelStats.ps_iScore += eScore.iPoints; m_psGameStats.ps_iScore += eScore.iPoints; - m_iMana += eScore.iPoints*GetSP()->sp_fManaTransferFactor; + m_iMana += (INDEX) (eScore.iPoints*GetSP()->sp_fManaTransferFactor); CheckHighScore(); resume; } diff --git a/Sources/EntitiesMP/PlayerActionMarker.es b/Sources/EntitiesMP/PlayerActionMarker.es index ea1c960..20b5ca2 100644 --- a/Sources/EntitiesMP/PlayerActionMarker.es +++ b/Sources/EntitiesMP/PlayerActionMarker.es @@ -59,10 +59,10 @@ functions: const CTString &GetDescription(void) const { CTString strAction = PlayerAutoAction_enum.NameForValue(INDEX(m_paaAction)); if (m_penTarget==NULL) { - ((CTString&)m_strDescription).PrintF("%s (%s)->", m_strName, strAction); + ((CTString&)m_strDescription).PrintF("%s (%s)->", (const char *) m_strName, (const char *) strAction); } else { - ((CTString&)m_strDescription).PrintF("%s (%s)->%s", m_strName, strAction, - m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("%s (%s)->%s", (const char *) m_strName, (const char *) strAction, + (const char *) m_penTarget->GetName()); } return m_strDescription; } diff --git a/Sources/EntitiesMP/PlayerAnimator.es b/Sources/EntitiesMP/PlayerAnimator.es index 4088626..fbe7145 100644 --- a/Sources/EntitiesMP/PlayerAnimator.es +++ b/Sources/EntitiesMP/PlayerAnimator.es @@ -26,10 +26,10 @@ //#include "Models/Weapons/Pipebomb/StickItem.h" #include "ModelsMP/Weapons/Flamer/FlamerItem.h" #include "ModelsMP/Weapons/Flamer/Body.h" -//#include "ModelsMP/Weapons/Chainsaw/ChainsawItem.h" -#include "ModelsMP/Weapons/Chainsaw/ChainsawForPlayer.h" -#include "ModelsMP/Weapons/Chainsaw/BladeForPlayer.h" -#include "ModelsMP/Weapons/Chainsaw/Body.h" +//#include "ModelsMP/Weapons/ChainSaw/ChainsawItem.h" +#include "ModelsMP/Weapons/ChainSaw/ChainsawForPlayer.h" +#include "ModelsMP/Weapons/ChainSaw/BladeForPlayer.h" +#include "ModelsMP/Weapons/ChainSaw/Body.h" #include "Models/Weapons/Laser/LaserItem.h" //#include "Models/Weapons/GhostBuster/GhostBusterItem.h" //#include "Models/Weapons/GhostBuster/Effect01.h" @@ -1159,7 +1159,7 @@ functions: // moving view change // translating -> change banking - if (m_bReference != NULL && vDesiredTranslation.Length()>1.0f && vCurrentTranslation.Length()>1.0f) { + if (m_bReference && vDesiredTranslation.Length()>1.0f && vCurrentTranslation.Length()>1.0f) { m_bMoving = TRUE; // sidestep banking FLOAT vSidestepSpeedDesired = vDesiredTranslation(1); diff --git a/Sources/EntitiesMP/PlayerMarker.es b/Sources/EntitiesMP/PlayerMarker.es index 18defb0..dd3ed6f 100644 --- a/Sources/EntitiesMP/PlayerMarker.es +++ b/Sources/EntitiesMP/PlayerMarker.es @@ -84,7 +84,7 @@ procedures: if (m_bQuickStart) { m_strName.PrintF("Player Quick Start"); } else { - m_strName.PrintF("Player Start - %s", m_strGroup); + m_strName.PrintF("Player Start - %s", (const char *) m_strGroup); } return; diff --git a/Sources/EntitiesMP/PlayerWeapons.es b/Sources/EntitiesMP/PlayerWeapons.es index 9de5b2b..d00faa6 100644 --- a/Sources/EntitiesMP/PlayerWeapons.es +++ b/Sources/EntitiesMP/PlayerWeapons.es @@ -11,16 +11,16 @@ #include "EntitiesMP/Bullet.h" #include "Models/Weapons/Knife/Knife.h" #include "Models/Weapons/Knife/KnifeItem.h" -#include "Models/Weapons/Colt/Colt.h" +#include "Models/Weapons/Colt/colt.h" #include "Models/Weapons/Colt/ColtMain.h" -#include "Models/Weapons/SingleShotgun/SingleShotgun.h" +#include "Models/Weapons/SingleShotgun/SingleShotGun.h" #include "Models/Weapons/SingleShotgun/Barrels.h" #include "Models/Weapons/DoubleShotgun/DoubleShotgun.h" #include "Models/Weapons/DoubleShotgun/Dshotgunbarrels.h" #include "Models/Weapons/DoubleShotgun/HandWithAmmo.h" #include "Models/Weapons/TommyGun/TommyGun.h" #include "Models/Weapons/TommyGun/Body.h" -#include "Models/Weapons/MiniGun/MiniGun.h" +#include "Models/Weapons/MiniGun/minigun.h" #include "Models/Weapons/MiniGun/Body.h" #include "Models/Weapons/GrenadeLauncher/GrenadeLauncher.h" #include "Models/Weapons/RocketLauncher/RocketLauncher.h" @@ -35,11 +35,11 @@ #include "ModelsMP/Weapons/Flamer/Body.h" #include "ModelsMP/Weapons/Flamer/FuelReservoir.h" #include "ModelsMP/Weapons/Flamer/Flame.h" -#include "ModelsMP/Weapons/Chainsaw/Chainsaw.h" -#include "ModelsMP/Weapons/Chainsaw/ChainSawForPlayer.h" -#include "ModelsMP/Weapons/Chainsaw/Body.h" -#include "ModelsMP/Weapons/Chainsaw/Blade.h" -#include "ModelsMP/Weapons/Chainsaw/Teeth.h" +#include "ModelsMP/Weapons/ChainSaw/ChainSaw.h" +#include "ModelsMP/Weapons/ChainSaw/ChainsawForPlayer.h" +#include "ModelsMP/Weapons/ChainSaw/Body.h" +#include "ModelsMP/Weapons/ChainSaw/Blade.h" +#include "ModelsMP/Weapons/ChainSaw/Teeth.h" // Mission Pack player body instead of the old one #include "ModelsMP/Player/SeriousSam/Body.h" @@ -223,7 +223,7 @@ static FLOAT hud_fCrosshairRatio = 0.5f; // max distance size ratio static INDEX hud_bShowPlayerName = TRUE; static INDEX hud_bShowCoords = FALSE; static FLOAT plr_tmSnoopingDelay = 1.0f; // seconds -extern FLOAT plr_tmSnoopingTime = 1.0f; // seconds +FLOAT plr_tmSnoopingTime = 1.0f; // seconds // some static vars static INDEX _iLastCrosshairType=-1; @@ -966,9 +966,18 @@ functions: prMirror.FrontClipDistanceL() = wpn_fClip[iWeaponData]; prMirror.DepthBufferNearL() = 0.0f; prMirror.DepthBufferFarL() = 0.1f; - CPlacement3D plWeaponMirror( FLOAT3D(wpn_fX[iWeaponData], wpn_fY[iWeaponData], wpn_fZ[iWeaponData]), - ANGLE3D(AngleDeg(wpn_fH[iWeaponData]), AngleDeg(wpn_fP[iWeaponData]), - AngleDeg(wpn_fB[iWeaponData]))); + + // This line confuses gcc 2.95.3 unless split up. --ryan. + //CPlacement3D plWeaponMirror( FLOAT3D(wpn_fX[iWeaponData], wpn_fY[iWeaponData], wpn_fZ[iWeaponData]), + // ANGLE3D(AngleDeg(wpn_fH[iWeaponData]), AngleDeg(wpn_fP[iWeaponData]), + // AngleDeg(wpn_fB[iWeaponData]))); + + + FLOAT3D f3d(wpn_fX[iWeaponData], wpn_fY[iWeaponData], wpn_fZ[iWeaponData]); + ANGLE3D a3d(AngleDeg(wpn_fH[iWeaponData]), AngleDeg(wpn_fP[iWeaponData]), + AngleDeg(wpn_fB[iWeaponData])); + CPlacement3D plWeaponMirror(f3d, a3d); + if( iWeaponData==WEAPON_DOUBLECOLT /*|| iWeaponData==WEAPON_PIPEBOMB*/) { FLOATmatrix3D mRotation; MakeRotationMatrixFast(mRotation, plView.pl_OrientationAngle); @@ -1197,7 +1206,7 @@ functions: } // keep player name, mana and health for eventual printout or coloring m_fEnemyHealth = ((CPlayer*)pen)->GetHealth() / ((CPlayer*)pen)->m_fMaxHealth; - m_strLastTarget.PrintF( "%s", ((CPlayer*)pen)->GetPlayerName()); + m_strLastTarget.PrintF( "%s", (const char *) ((CPlayer*)pen)->GetPlayerName()); if( GetSP()->sp_gmGameMode==CSessionProperties::GM_SCOREMATCH) { // add mana to player name CTString strMana=""; @@ -1377,7 +1386,7 @@ functions: pdp->SetTextScaling( fScaling); pdp->SetTextAspect( 1.0f); // do faded printout - ULONG ulA = (FLOAT)ulAlpha * Clamp( 2*tmDelta, 0.0f, 1.0f); + ULONG ulA = (ULONG) ((FLOAT)ulAlpha * Clamp( 2*tmDelta, 0.0f, 1.0f)); pdp->PutTextC( m_strLastTarget, slDPWidth*0.5f, slDPHeight*0.75f, SE_COL_BLUE_NEUTRAL|ulA); } @@ -2576,88 +2585,88 @@ functions: break; // shells case WEAPON_SINGLESHOTGUN: - iAmmoPicked = Max(10.0f, m_iMaxShells*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(10.0f, m_iMaxShells*fMaxAmmoRatio); m_iShells += iAmmoPicked; AddManaToPlayer(iAmmoPicked*70.0f*MANA_AMMO); break; case WEAPON_DOUBLESHOTGUN: - iAmmoPicked = Max(20.0f, m_iMaxShells*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(20.0f, m_iMaxShells*fMaxAmmoRatio); m_iShells += iAmmoPicked; AddManaToPlayer(iAmmoPicked*70.0f*MANA_AMMO); break; // bullets case WEAPON_TOMMYGUN: - iAmmoPicked = Max(50.0f, m_iMaxBullets*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(50.0f, m_iMaxBullets*fMaxAmmoRatio); m_iBullets += iAmmoPicked; AddManaToPlayer( iAmmoPicked*10.0f*MANA_AMMO); break; case WEAPON_SNIPER: - iAmmoPicked = Max(15.0f, m_iMaxSniperBullets*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(15.0f, m_iMaxSniperBullets*fMaxAmmoRatio); m_iSniperBullets += iAmmoPicked; AddManaToPlayer( iAmmoPicked*10.0f*MANA_AMMO); break; case WEAPON_MINIGUN: - iAmmoPicked = Max(100.0f, m_iMaxBullets*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(100.0f, m_iMaxBullets*fMaxAmmoRatio); m_iBullets += iAmmoPicked; AddManaToPlayer( iAmmoPicked*10.0f*MANA_AMMO); break; // rockets case WEAPON_ROCKETLAUNCHER: - iAmmoPicked = Max(5.0f, m_iMaxRockets*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(5.0f, m_iMaxRockets*fMaxAmmoRatio); m_iRockets += iAmmoPicked; AddManaToPlayer( iAmmoPicked*150.0f*MANA_AMMO); break; // grenades case WEAPON_GRENADELAUNCHER: - iAmmoPicked = Max(5.0f, m_iMaxGrenades*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(5.0f, m_iMaxGrenades*fMaxAmmoRatio); m_iGrenades += iAmmoPicked; AddManaToPlayer( iAmmoPicked*100.0f*MANA_AMMO); break; /* case WEAPON_PIPEBOMB: - iAmmoPicked = Max(5.0f, m_iMaxGrenades*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(5.0f, m_iMaxGrenades*fMaxAmmoRatio); m_iGrenades += iAmmoPicked; AddManaToPlayer( iAmmoPicked*100.0f*MANA_AMMO); break; case WEAPON_GHOSTBUSTER: - iAmmoPicked = Max(100.0f, m_iMaxElectricity*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(100.0f, m_iMaxElectricity*fMaxAmmoRatio); m_iElectricity += iAmmoPicked; AddManaToPlayer( iAmmoPicked*15.0f*MANA_AMMO); break; */ // electricity case WEAPON_LASER: - iAmmoPicked = Max(50.0f, m_iMaxElectricity*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(50.0f, m_iMaxElectricity*fMaxAmmoRatio); m_iElectricity += iAmmoPicked; AddManaToPlayer( iAmmoPicked*15.0f*MANA_AMMO); break; // cannon balls case WEAPON_IRONCANNON: // for iron ball - iAmmoPicked = Max(1.0f, m_iMaxIronBalls*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(1.0f, m_iMaxIronBalls*fMaxAmmoRatio); m_iIronBalls += iAmmoPicked; AddManaToPlayer( iAmmoPicked*700.0f*MANA_AMMO); break; /* // for nuke ball case WEAPON_NUKECANNON: - iAmmoPicked = Max(1.0f, m_iMaxNukeBalls*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(1.0f, m_iMaxNukeBalls*fMaxAmmoRatio); m_iNukeBalls += iAmmoPicked; AddManaToPlayer( iAmmoPicked*1000.0f*MANA_AMMO); break;*/ // flamer // !!!! how much mana exactly? case WEAPON_FLAMER: - iAmmoPicked = Max(50.0f, m_iMaxNapalm*fMaxAmmoRatio); + iAmmoPicked = (INDEX) Max(50.0f, m_iMaxNapalm*fMaxAmmoRatio); m_iNapalm += iAmmoPicked; AddManaToPlayer( iAmmoPicked*15.0f*MANA_AMMO); break; case WEAPON_CHAINSAW: - /*iAmmoPicked = Max(50.0f, m_iMaxNapalm*fMaxAmmoRatio); + /*iAmmoPicked = (INDEX) Max(50.0f, m_iMaxNapalm*fMaxAmmoRatio); m_iNapalm += iAmmoPicked; AddManaToPlayer( iAmmoPicked*15.0f*MANA_AMMO);*/ break; // error default: - ASSERTALWAYS("Uknown weapon type"); + ASSERTALWAYS("Unknown weapon type"); break; } @@ -2909,20 +2918,20 @@ functions: AddManaToPlayer(Eai.iQuantity*AV_NAPALM*MANA_AMMO); break; case AIT_BACKPACK: - m_iShells += 20*GetSP()->sp_fAmmoQuantity; - m_iBullets += 200*GetSP()->sp_fAmmoQuantity; - m_iRockets += 5*GetSP()->sp_fAmmoQuantity; + m_iShells += (INDEX) (20*GetSP()->sp_fAmmoQuantity); + m_iBullets += (INDEX) (200*GetSP()->sp_fAmmoQuantity); + m_iRockets += (INDEX) (5*GetSP()->sp_fAmmoQuantity); ((CPlayer&)*m_penPlayer).ItemPicked(TRANS("Ammo pack"), 0); AddManaToPlayer(100000000.0f *MANA_AMMO); // adjust mana value!!!! break; case AIT_SERIOUSPACK: - m_iShells += MAX_SHELLS*GetSP()->sp_fAmmoQuantity; - m_iBullets += MAX_BULLETS*GetSP()->sp_fAmmoQuantity; - m_iGrenades += MAX_GRENADES*GetSP()->sp_fAmmoQuantity; - m_iRockets += MAX_ROCKETS*GetSP()->sp_fAmmoQuantity; - m_iElectricity += MAX_ELECTRICITY*GetSP()->sp_fAmmoQuantity; - m_iIronBalls += MAX_IRONBALLS*GetSP()->sp_fAmmoQuantity; -// m_iNukeBalls += MAX_NUKEBALLS*GetSP()->sp_fAmmoQuantity; + m_iShells += (INDEX) (MAX_SHELLS*GetSP()->sp_fAmmoQuantity); + m_iBullets += (INDEX) (MAX_BULLETS*GetSP()->sp_fAmmoQuantity); + m_iGrenades += (INDEX) (MAX_GRENADES*GetSP()->sp_fAmmoQuantity); + m_iRockets += (INDEX) (MAX_ROCKETS*GetSP()->sp_fAmmoQuantity); + m_iElectricity += (INDEX) (MAX_ELECTRICITY*GetSP()->sp_fAmmoQuantity); + m_iIronBalls += (INDEX) (MAX_IRONBALLS*GetSP()->sp_fAmmoQuantity); +// m_iNukeBalls += (INDEX) (MAX_NUKEBALLS*GetSP()->sp_fAmmoQuantity); case AIT_SNIPERBULLETS: if (m_iSniperBullets>=m_iMaxSniperBullets) { m_iSniperBullets = m_iMaxSniperBullets; return FALSE; } m_iSniperBullets+= Eai.iQuantity; @@ -2980,14 +2989,14 @@ functions: // preapare message string and count different types of ammo INDEX iAmmoTypes = 0; CTString strMessage; - if( eapi.iShells != 0) { strMessage.PrintF("%s %d %s,", strMessage, eapi.iShells, TRANS("Shells")); iAmmoTypes++; } - if( eapi.iBullets != 0) { strMessage.PrintF("%s %d %s,", strMessage, eapi.iBullets, TRANS("Bullets")); iAmmoTypes++; } - if( eapi.iRockets != 0) { strMessage.PrintF("%s %d %s,", strMessage, eapi.iRockets, TRANS("Rockets")); iAmmoTypes++; } - if( eapi.iGrenades != 0) { strMessage.PrintF("%s %d %s,", strMessage, eapi.iGrenades, TRANS("Grenades")); iAmmoTypes++; } - if( eapi.iNapalm != 0) { strMessage.PrintF("%s %d %s,", strMessage, eapi.iNapalm, TRANS("Napalm")); iAmmoTypes++; } - if( eapi.iElectricity != 0) { strMessage.PrintF("%s %d %s,", strMessage, eapi.iElectricity, TRANS("Cells")); iAmmoTypes++; } - if( eapi.iIronBalls != 0) { strMessage.PrintF("%s %d %s,", strMessage, eapi.iIronBalls, TRANS("Cannonballs")); iAmmoTypes++; } - if( eapi.iSniperBullets != 0) { strMessage.PrintF("%s %d %s,", strMessage, eapi.iSniperBullets, TRANS("Sniper bullets")); iAmmoTypes++; } + if( eapi.iShells != 0) { strMessage.PrintF("%s %d %s,", (const char *) strMessage, eapi.iShells, TRANS("Shells")); iAmmoTypes++; } + if( eapi.iBullets != 0) { strMessage.PrintF("%s %d %s,", (const char *) strMessage, eapi.iBullets, TRANS("Bullets")); iAmmoTypes++; } + if( eapi.iRockets != 0) { strMessage.PrintF("%s %d %s,", (const char *) strMessage, eapi.iRockets, TRANS("Rockets")); iAmmoTypes++; } + if( eapi.iGrenades != 0) { strMessage.PrintF("%s %d %s,", (const char *) strMessage, eapi.iGrenades, TRANS("Grenades")); iAmmoTypes++; } + if( eapi.iNapalm != 0) { strMessage.PrintF("%s %d %s,", (const char *) strMessage, eapi.iNapalm, TRANS("Napalm")); iAmmoTypes++; } + if( eapi.iElectricity != 0) { strMessage.PrintF("%s %d %s,", (const char *) strMessage, eapi.iElectricity, TRANS("Cells")); iAmmoTypes++; } + if( eapi.iIronBalls != 0) { strMessage.PrintF("%s %d %s,", (const char *) strMessage, eapi.iIronBalls, TRANS("Cannonballs")); iAmmoTypes++; } + if( eapi.iSniperBullets != 0) { strMessage.PrintF("%s %d %s,", (const char *) strMessage, eapi.iSniperBullets, TRANS("Sniper bullets")); iAmmoTypes++; } INDEX iLen = strlen(strMessage); if( iLen>0 && strMessage[iLen-1]==',') diff --git a/Sources/EntitiesMP/Projectile.es b/Sources/EntitiesMP/Projectile.es index 45dfecf..acd1641 100644 --- a/Sources/EntitiesMP/Projectile.es +++ b/Sources/EntitiesMP/Projectile.es @@ -10,7 +10,7 @@ #include "Models/Enemies/ElementalLava/Projectile/LavaStone.h" #include "Models/Enemies/ElementalLava/Projectile/LavaBomb.h" #include "Models/Enemies/Headman/Projectile/Blade.h" -#include "Models/Enemies/Huanman/Projectile/Projectile.h" +#include "Models/Enemies/HuanMan/Projectile/Projectile.h" #include "Models/Enemies/Cyborg/Projectile/LaserProjectile.h" #include "ModelsMP/Enemies/Grunt/Projectile/GruntProjectile.h" @@ -628,7 +628,7 @@ functions: if (m_penLauncher!=NULL) { strm.FPrintF_t("id:%05d '%s'(%s) (%g, %g, %g)\n", m_penLauncher->en_ulID, - m_penLauncher->GetName(), m_penLauncher->GetClass()->ec_pdecDLLClass->dec_strName, + (const char *) m_penLauncher->GetName(), (const char *) m_penLauncher->GetClass()->ec_pdecDLLClass->dec_strName, m_penLauncher->GetPlacement().pl_PositionVector(1), m_penLauncher->GetPlacement().pl_PositionVector(2), m_penLauncher->GetPlacement().pl_PositionVector(3)); diff --git a/Sources/EntitiesMP/PyramidSpaceShip.es b/Sources/EntitiesMP/PyramidSpaceShip.es index 79834a3..d0c29d3 100644 --- a/Sources/EntitiesMP/PyramidSpaceShip.es +++ b/Sources/EntitiesMP/PyramidSpaceShip.es @@ -149,8 +149,8 @@ functions: { return FALSE; } - if( slPropertyOffset==offsetof(CPyramidSpaceShip, m_penTarget) || - slPropertyOffset==offsetof(CPyramidSpaceShip, m_penFlyAwayTarget)) + if( slPropertyOffset==_offsetof(CPyramidSpaceShip, m_penTarget) || + slPropertyOffset==_offsetof(CPyramidSpaceShip, m_penFlyAwayTarget)) { return( IsDerivedFromClass(penTarget, "Pyramid Space Ship Marker")); } @@ -176,7 +176,7 @@ functions: const CTString &GetDescription(void) const { if (m_penTarget!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penTarget->GetName()); } else { ((CTString&)m_strDescription).PrintF("->"); } diff --git a/Sources/EntitiesMP/PyramidSpaceShipMarker.es b/Sources/EntitiesMP/PyramidSpaceShipMarker.es index 032abb3..bb4ba76 100644 --- a/Sources/EntitiesMP/PyramidSpaceShipMarker.es +++ b/Sources/EntitiesMP/PyramidSpaceShipMarker.es @@ -37,7 +37,7 @@ functions: { return FALSE; } - if(slPropertyOffset == offsetof(CPyramidSpaceShipMarker, m_penTarget)) + if(slPropertyOffset == _offsetof(CPyramidSpaceShipMarker, m_penTarget)) { return( IsDerivedFromClass(penTarget, "Pyramid Space Ship Marker") || IsDerivedFromClass(penTarget, "PyramidSpaceShip") ); @@ -91,7 +91,7 @@ procedures: ModelChangeNotify(); if( m_penTarget!=NULL && !IsOfClass( m_penTarget, "Pyramid Space Ship Marker")) { - WarningMessage( "Entity '%s' is not of Pyramid Space Ship Marker class!", m_penTarget); + WarningMessage( "Entity '%s' is not of Pyramid Space Ship Marker class!", (const char *) m_penTarget->GetName()); m_penTarget = NULL; } diff --git a/Sources/EntitiesMP/Scorpman.es b/Sources/EntitiesMP/Scorpman.es index b0ec978..2d3b99e 100644 --- a/Sources/EntitiesMP/Scorpman.es +++ b/Sources/EntitiesMP/Scorpman.es @@ -3,8 +3,8 @@ 306 %{ #include "StdH.h" -#include "Models/Enemies/Scorpman/Scorpman.h" -#include "Models/Enemies/Scorpman/Gun.h" +#include "Models/Enemies/SCORPMAN/scorpman.h" +#include "Models/Enemies/SCORPMAN/Gun.h" %} uses "EntitiesMP/EnemyBase"; @@ -91,9 +91,9 @@ functions: { CTString str; if (eDeath.eLastDamage.dmtType==DMT_CLOSERANGE) { - str.PrintF(TRANS("%s was stabbed by an Arachnoid"), strPlayerName); + str.PrintF(TRANS("%s was stabbed by an Arachnoid"), (const char *) strPlayerName); } else { - str.PrintF(TRANS("An Arachnoid poured lead into %s"), strPlayerName); + str.PrintF(TRANS("An Arachnoid poured lead into %s"), (const char *) strPlayerName); } return str; } diff --git a/Sources/EntitiesMP/ScrollHolder.es b/Sources/EntitiesMP/ScrollHolder.es index e2fe72e..6dbeed7 100644 --- a/Sources/EntitiesMP/ScrollHolder.es +++ b/Sources/EntitiesMP/ScrollHolder.es @@ -40,7 +40,7 @@ components: functions: const CTString &GetDescription(void) const { - ((CTString&)m_strDescription).PrintF("%s", m_fnmMessage.FileName()); + ((CTString&)m_strDescription).PrintF("%s", (const char *) m_fnmMessage.FileName()); return m_strDescription; } @@ -142,14 +142,14 @@ functions: pixH = pdpCurr->GetHeight(); fResolutionScaling = (FLOAT)pixH / 360.0f; pdpCurr->SetFont( _pfdDisplayFont); - pixLineHeight = floor(20*fResolutionScaling); + pixLineHeight = (PIX) floor(20*fResolutionScaling); const FLOAT fLinesPerSecond = penThis->m_fSpeed; FLOAT fOffset = fTime*fLinesPerSecond; INDEX ctLinesOnScreen = pixH/pixLineHeight; - INDEX iLine1 = fOffset; + INDEX iLine1 = (INDEX) fOffset; - pixJ = iLine1*pixLineHeight-fOffset*pixLineHeight; + pixJ = (PIX) (iLine1*pixLineHeight-fOffset*pixLineHeight); iLine1-=ctLinesOnScreen; INDEX ctLines = _astrCredits.Count(); diff --git a/Sources/EntitiesMP/Ship.es b/Sources/EntitiesMP/Ship.es index e49b0b0..0b96667 100644 --- a/Sources/EntitiesMP/Ship.es +++ b/Sources/EntitiesMP/Ship.es @@ -70,17 +70,17 @@ functions: const CTString &GetDescription(void) const { ((CTString&)m_strDescription).PrintF("->"); if (m_penTarget!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penTarget->GetName()); } return m_strDescription; } /* Get anim data for given animation property - return NULL for none. */ CAnimData *GetAnimData(SLONG slPropertyOffset) { - if((slPropertyOffset==offsetof(CShip, m_iSailUpAnim) - ||slPropertyOffset==offsetof(CShip, m_iSailDownAnim) - ||slPropertyOffset==offsetof(CShip, m_iSailSailAnim) - ||slPropertyOffset==offsetof(CShip, m_iSailWaveingAnim)) + if((slPropertyOffset==_offsetof(CShip, m_iSailUpAnim) + ||slPropertyOffset==_offsetof(CShip, m_iSailDownAnim) + ||slPropertyOffset==_offsetof(CShip, m_iSailSailAnim) + ||slPropertyOffset==_offsetof(CShip, m_iSailWaveingAnim)) &&m_penSail!=NULL) { return m_penSail->GetModelObject()->GetData(); } else { @@ -300,12 +300,12 @@ procedures: // assure valid target if (m_penTarget!=NULL && !IsOfClass(m_penTarget, "Ship Marker")) { - WarningMessage("Target '%s' is not of ShipMarker class!", m_penTarget->GetName()); + WarningMessage("Target '%s' is not of ShipMarker class!", (const char *) m_penTarget->GetName()); m_penTarget = NULL; } // assure valid sail if (m_penSail!=NULL && m_penSail->GetRenderType()!=RT_MODEL) { - WarningMessage("Sail '%s' is not a model!", m_penSail->GetName()); + WarningMessage("Sail '%s' is not a model!", (const char *) m_penSail->GetName()); m_penSail = NULL; } diff --git a/Sources/EntitiesMP/Shooter.es b/Sources/EntitiesMP/Shooter.es index ba1e8cc..6f4c74e 100644 --- a/Sources/EntitiesMP/Shooter.es +++ b/Sources/EntitiesMP/Shooter.es @@ -131,11 +131,11 @@ functions: /* Get anim data for given animation property - return NULL for none. */ CAnimData *GetAnimData(SLONG slPropertyOffset) { - if (slPropertyOffset==offsetof(CShooter, m_iModelPreFireAnimation) || - slPropertyOffset==offsetof(CShooter, m_iModelPostFireAnimation)) { + if (slPropertyOffset==_offsetof(CShooter, m_iModelPreFireAnimation) || + slPropertyOffset==_offsetof(CShooter, m_iModelPostFireAnimation)) { return GetModelObject()->GetData(); - } else if (slPropertyOffset==offsetof(CShooter, m_iTexturePreFireAnimation) || - slPropertyOffset==offsetof(CShooter, m_iTexturePostFireAnimation)) { + } else if (slPropertyOffset==_offsetof(CShooter, m_iTexturePreFireAnimation) || + slPropertyOffset==_offsetof(CShooter, m_iTexturePostFireAnimation)) { return GetModelObject()->mo_toTexture.GetData(); } else { return CModelHolder2::GetAnimData(slPropertyOffset); @@ -143,7 +143,7 @@ functions: } // shoot projectile on enemy - CEntity *ShootProjectile(enum ProjectileType pt, FLOAT3D &vOffset, ANGLE3D &aOffset) { + CEntity *ShootProjectile(enum ProjectileType pt, const FLOAT3D &vOffset, const ANGLE3D &aOffset) { // launch CPlacement3D pl; pl = GetPlacement(); @@ -343,11 +343,11 @@ procedures: ClampDn(m_fCannonBallPower, 0.0f); if (m_penSoundLaunch!=NULL && !IsOfClass(m_penSoundLaunch, "SoundHolder")) { - WarningMessage( "Entity '%s' is not of class SoundHolder!", m_penSoundLaunch); + WarningMessage( "Entity '%s' is not of class SoundHolder!", (const char *) m_penSoundLaunch->GetName()); m_penSoundLaunch=NULL; } if (m_penDestruction!=NULL && !IsOfClass(m_penDestruction, "ModelDestruction")) { - WarningMessage( "Entity '%s' is not of class ModelDestruction!", m_penDestruction); + WarningMessage( "Entity '%s' is not of class ModelDestruction!", (const char *) m_penDestruction->GetName()); m_penDestruction=NULL; } diff --git a/Sources/EntitiesMP/SoundHolder.es b/Sources/EntitiesMP/SoundHolder.es index f9a2545..a3d2658 100644 --- a/Sources/EntitiesMP/SoundHolder.es +++ b/Sources/EntitiesMP/SoundHolder.es @@ -109,7 +109,7 @@ procedures: SetModel(MODEL_MARKER); SetModelMainTexture(TEXTURE_MARKER); - m_strDescription.PrintF("%s", (CTString&)m_fnSound.FileName()); + m_strDescription.PrintF("%s", (const char *) m_fnSound.FileName()); // wait for a while to play sound -> Sound Can Be Spawned if( _pTimer->CurrentTick()<=0.1f) diff --git a/Sources/EntitiesMP/StdH/StdH.cpp b/Sources/EntitiesMP/StdH/StdH.cpp index 95c0896..e975c18 100644 --- a/Sources/EntitiesMP/StdH/StdH.cpp +++ b/Sources/EntitiesMP/StdH/StdH.cpp @@ -1,3 +1,4 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ #include "StdH.h" + diff --git a/Sources/EntitiesMP/StdH/StdH.h b/Sources/EntitiesMP/StdH/StdH.h index 9eabb5b..76086d9 100644 --- a/Sources/EntitiesMP/StdH/StdH.h +++ b/Sources/EntitiesMP/StdH/StdH.h @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include +#include #include #include @@ -13,9 +13,10 @@ #define DECL_DLL #endif -#include "..\Global.h" -#include "..\Common\Flags.h" -#include "..\Common\Common.h" -#include "..\Common\Particles.h" -#include "..\Common\EmanatingParticles.h" -#include "..\Common\GameInterface.h" +#include "../Global.h" +#include "../Common/Flags.h" +#include "../Common/Common.h" +#include "../Common/Particles.h" +#include "../Common/EmanatingParticles.h" +#include "../Common/GameInterface.h" + diff --git a/Sources/EntitiesMP/StormController.es b/Sources/EntitiesMP/StormController.es index 08f53e0..410c86d 100644 --- a/Sources/EntitiesMP/StormController.es +++ b/Sources/EntitiesMP/StormController.es @@ -62,7 +62,7 @@ functions: { if (pen!=NULL && !IsOfClass(pen, "Lightning")) { - WarningMessage("Target '%s' is not of class Lightning!", pen->GetName()); + WarningMessage("Target '%s' is not of class Lightning!", (const char *) pen->GetName()); pen=NULL; } } diff --git a/Sources/EntitiesMP/Summoner.es b/Sources/EntitiesMP/Summoner.es index 5273e76..1fdbdef 100644 --- a/Sources/EntitiesMP/Summoner.es +++ b/Sources/EntitiesMP/Summoner.es @@ -194,8 +194,8 @@ functions: BOOL IsTargetValid(SLONG slPropertyOffset, CEntity *penTarget) { - if ( slPropertyOffset >= offsetof(CSummoner, m_penGroup01Template01) && - slPropertyOffset <= offsetof(CSummoner, m_penGroup03Template06)) + if ( slPropertyOffset >= _offsetof(CSummoner, m_penGroup01Template01) && + slPropertyOffset <= _offsetof(CSummoner, m_penGroup03Template06)) { if (IsDerivedFromClass(penTarget, "Enemy Base")) { if (((CEnemyBase &)*penTarget).m_bTemplate) { @@ -207,7 +207,7 @@ functions: return FALSE; } } - if( slPropertyOffset == offsetof(CSummoner, m_penControlArea)) + if( slPropertyOffset == _offsetof(CSummoner, m_penControlArea)) { if (IsDerivedFromClass(penTarget, "AreaMarker")) { return TRUE; @@ -215,7 +215,7 @@ functions: return FALSE; } } - if( slPropertyOffset == offsetof(CSummoner, m_penSpawnMarker)) + if( slPropertyOffset == _offsetof(CSummoner, m_penSpawnMarker)) { if (IsDerivedFromClass(penTarget, "Enemy Marker")) { return TRUE; @@ -223,8 +223,8 @@ functions: return FALSE; } } - if( slPropertyOffset == offsetof(CSummoner, m_penTeleportMarker) || - slPropertyOffset == offsetof(CSummoner, m_penDeathMarker)) + if( slPropertyOffset == _offsetof(CSummoner, m_penTeleportMarker) || + slPropertyOffset == _offsetof(CSummoner, m_penDeathMarker)) { if (IsDerivedFromClass(penTarget, "SummonerMarker")) { return TRUE; @@ -266,7 +266,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("The Summoner unsummoned %s"), strPlayerName); + str.PrintF(TRANS("The Summoner unsummoned %s"), (const char *) strPlayerName); return str; } @@ -913,7 +913,7 @@ procedures: } else { fToSpawn = 1.0f; } - INDEX iToSpawn = ceilf(fToSpawn); + INDEX iToSpawn = (INDEX) ceilf(fToSpawn); CMusicHolder *penMusicHolder = GetMusicHolder(); //CPrintF("spawning %d from %d group\n", iToSpawn, iScheme); diff --git a/Sources/EntitiesMP/SummonerMarker.es b/Sources/EntitiesMP/SummonerMarker.es index 6ff1d50..71f5a20 100644 --- a/Sources/EntitiesMP/SummonerMarker.es +++ b/Sources/EntitiesMP/SummonerMarker.es @@ -38,7 +38,7 @@ functions: BOOL IsTargetValid(SLONG slPropertyOffset, CEntity *penTarget) { - if( slPropertyOffset == offsetof(CSummonerMarker, m_penTarget)) + if( slPropertyOffset == _offsetof(CSummonerMarker, m_penTarget)) { if (IsOfClass(penTarget, "SummonerMarker")) { return TRUE; } else { return FALSE; } diff --git a/Sources/EntitiesMP/Switch.es b/Sources/EntitiesMP/Switch.es index 2a68f5d..e13e660 100644 --- a/Sources/EntitiesMP/Switch.es +++ b/Sources/EntitiesMP/Switch.es @@ -48,11 +48,11 @@ functions: /* Get anim data for given animation property - return NULL for none. */ CAnimData *GetAnimData(SLONG slPropertyOffset) { - if (slPropertyOffset==offsetof(CSwitch, m_iModelONAnimation) || - slPropertyOffset==offsetof(CSwitch, m_iModelOFFAnimation)) { + if (slPropertyOffset==_offsetof(CSwitch, m_iModelONAnimation) || + slPropertyOffset==_offsetof(CSwitch, m_iModelOFFAnimation)) { return GetModelObject()->GetData(); - } else if (slPropertyOffset==offsetof(CSwitch, m_iTextureONAnimation) || - slPropertyOffset==offsetof(CSwitch, m_iTextureOFFAnimation)) { + } else if (slPropertyOffset==_offsetof(CSwitch, m_iTextureONAnimation) || + slPropertyOffset==_offsetof(CSwitch, m_iTextureOFFAnimation)) { return GetModelObject()->mo_toTexture.GetData(); } else { return CModelHolder2::GetAnimData(slPropertyOffset); diff --git a/Sources/EntitiesMP/Teleport.es b/Sources/EntitiesMP/Teleport.es index 39f7219..accaff2 100644 --- a/Sources/EntitiesMP/Teleport.es +++ b/Sources/EntitiesMP/Teleport.es @@ -37,7 +37,7 @@ functions: const CTString &GetDescription(void) const { ((CTString&)m_strDescription).PrintF("->"); if (m_penTarget!=NULL) { - ((CTString&)m_strDescription).PrintF("->%s", m_penTarget->GetName()); + ((CTString&)m_strDescription).PrintF("->%s", (const char *) m_penTarget->GetName()); } return m_strDescription; } diff --git a/Sources/EntitiesMP/TextFXHolder.es b/Sources/EntitiesMP/TextFXHolder.es index 70debaa..3c4be77 100644 --- a/Sources/EntitiesMP/TextFXHolder.es +++ b/Sources/EntitiesMP/TextFXHolder.es @@ -39,7 +39,7 @@ components: functions: const CTString &GetDescription(void) const { - ((CTString&)m_strDescription).PrintF("%s", m_fnmMessage.FileName()); + ((CTString&)m_strDescription).PrintF("%s", (const char *) m_fnmMessage.FileName()); return m_strDescription; } @@ -142,7 +142,7 @@ functions: pixH = pdpCurr->GetHeight(); fResolutionScaling = (FLOAT)pixH / 360.0f; pdpCurr->SetFont( _pfdDisplayFont); - pixLineHeight = floor(20*fResolutionScaling); + pixLineHeight = (PIX) floor(20*fResolutionScaling); INDEX ctMaxLinesOnScreen = pixH/pixLineHeight; INDEX ctLines=ClampUp(_astrLines.Count(), ctMaxLinesOnScreen); diff --git a/Sources/EntitiesMP/Trigger.es b/Sources/EntitiesMP/Trigger.es index 69dce4c..ad0eef6 100644 --- a/Sources/EntitiesMP/Trigger.es +++ b/Sources/EntitiesMP/Trigger.es @@ -123,7 +123,7 @@ procedures: if (penCaused!=NULL) { // send the score EReceiveScore eScore; - eScore.iPoints = m_fScore; + eScore.iPoints = (INDEX) m_fScore; penCaused->SendEvent(eScore); penCaused->SendEvent(ESecretFound()); } diff --git a/Sources/EntitiesMP/VoiceHolder.es b/Sources/EntitiesMP/VoiceHolder.es index 8845661..d90a5a5 100644 --- a/Sources/EntitiesMP/VoiceHolder.es +++ b/Sources/EntitiesMP/VoiceHolder.es @@ -31,7 +31,7 @@ functions: m_aps.Precache(m_fnmMessage); } const CTString &GetDescription(void) const { - ((CTString&)m_strDescription).PrintF("%s", m_fnmMessage.FileName()); + ((CTString&)m_strDescription).PrintF("%s", (const char *) m_fnmMessage.FileName()); return m_strDescription; } diff --git a/Sources/EntitiesMP/Walker.es b/Sources/EntitiesMP/Walker.es index c31c94d..80cabe7 100644 --- a/Sources/EntitiesMP/Walker.es +++ b/Sources/EntitiesMP/Walker.es @@ -87,7 +87,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("A Biomech blew %s away"), strPlayerName); + str.PrintF(TRANS("A Biomech blew %s away"), (const char *) strPlayerName); return str; } @@ -235,7 +235,7 @@ functions: } // fire death rocket - void FireDeathRocket(FLOAT3D &vPos) { + void FireDeathRocket(const FLOAT3D &vPos) { CPlacement3D plRocket; plRocket.pl_PositionVector = vPos; plRocket.pl_OrientationAngle = ANGLE3D(0, -5.0f-FRnd()*10.0f, 0); @@ -247,7 +247,7 @@ functions: penProjectile->Initialize(eLaunch); }; // fire death laser - void FireDeathLaser(FLOAT3D &vPos) { + void FireDeathLaser(const FLOAT3D &vPos) { CPlacement3D plLaser; plLaser.pl_PositionVector = vPos; plLaser.pl_OrientationAngle = ANGLE3D(0, -5.0f-FRnd()*10.0f, 0); diff --git a/Sources/EntitiesMP/WeaponItem.es b/Sources/EntitiesMP/WeaponItem.es index 21aba69..fed4758 100644 --- a/Sources/EntitiesMP/WeaponItem.es +++ b/Sources/EntitiesMP/WeaponItem.es @@ -14,8 +14,8 @@ #include "ModelsMP/Weapons/Sniper/SniperItem.h" #include "ModelsMP/Weapons/Sniper/Body.h" #include "ModelsMP/Weapons/Flamer/FlamerItem.h" -#include "ModelsMP/Weapons/Chainsaw/ChainsawItem.h" -#include "ModelsMP/Weapons/Chainsaw/BladeForPlayer.h" +#include "ModelsMP/Weapons/ChainSaw/ChainsawItem.h" +#include "ModelsMP/Weapons/ChainSaw/BladeForPlayer.h" #include "Models/Weapons/Laser/LaserItem.h" #include "Models/Weapons/Cannon/Cannon.h" diff --git a/Sources/EntitiesMP/Werebull.es b/Sources/EntitiesMP/Werebull.es index ad764cf..68a6676 100644 --- a/Sources/EntitiesMP/Werebull.es +++ b/Sources/EntitiesMP/Werebull.es @@ -3,7 +3,7 @@ 307 %{ #include "StdH.h" -#include "Models/Enemies/Werebull/Werebull.h" +#include "Models/Enemies/WereBull/WereBull.h" %} uses "EntitiesMP/EnemyBase"; @@ -57,7 +57,7 @@ functions: virtual CTString GetPlayerKillDescription(const CTString &strPlayerName, const EDeath &eDeath) { CTString str; - str.PrintF(TRANS("Sirian werebull sent %s flying"), strPlayerName); + str.PrintF(TRANS("Sirian werebull sent %s flying"), (const char *) strPlayerName); return str; } diff --git a/Sources/EntitiesMP/Woman.es b/Sources/EntitiesMP/Woman.es index 26221ca..b283eba 100644 --- a/Sources/EntitiesMP/Woman.es +++ b/Sources/EntitiesMP/Woman.es @@ -4,7 +4,7 @@ %{ #include "StdH.h" #include "ModelsMP/Enemies/Woman/Woman.h" -#include "Models/Enemies/Headman/Headman.h" +#include "Models/Enemies/Headman/headman.h" #include "EntitiesMP/Headman.h" %} @@ -64,9 +64,9 @@ functions: { CTString str; if (eDeath.eLastDamage.dmtType==DMT_CLOSERANGE) { - str.PrintF(TRANS("%s was beaten by a Scythian Harpy"), strPlayerName); + str.PrintF(TRANS("%s was beaten by a Scythian Harpy"), (const char *) strPlayerName); } else { - str.PrintF(TRANS("A Scythian Harpy got %s spellbound"), strPlayerName); + str.PrintF(TRANS("A Scythian Harpy got %s spellbound"), (const char *) strPlayerName); } return str; } diff --git a/Sources/EntitiesMP/WorldBase.es b/Sources/EntitiesMP/WorldBase.es index 5bc20d1..8423f47 100644 --- a/Sources/EntitiesMP/WorldBase.es +++ b/Sources/EntitiesMP/WorldBase.es @@ -7,12 +7,29 @@ #include "EntitiesMP/WorldSettingsController.h" // for error checking: #include "EntitiesMP/SoundHolder.h" + +// !!! rcg01202003 do something with this. +#ifdef PLATFORM_UNIX +#define EAX_ENVIRONMENT_LIVINGROOM 0 +#define EAX_ENVIRONMENT_STONEROOM 0 +#define EAX_ENVIRONMENT_AUDITORIUM 0 +#define EAX_ENVIRONMENT_HALLWAY 0 +#define EAX_ENVIRONMENT_ARENA 0 +#define EAX_ENVIRONMENT_STONECORRIDOR 0 +#define EAX_ENVIRONMENT_QUARRY 0 +#define EAX_ENVIRONMENT_MOUNTAINS 0 +#define EAX_ENVIRONMENT_PLAIN 0 +#define EAX_ENVIRONMENT_CAVE 0 +#define EAX_ENVIRONMENT_SEWERPIPE 0 +#define EAX_ENVIRONMENT_UNDERWATER 0 +#endif + %} -uses "EntitiesMP\FogMarker"; -uses "EntitiesMP\HazeMarker"; -uses "EntitiesMP\MirrorMarker"; -uses "EntitiesMP\GradientMarker"; +uses "EntitiesMP/FogMarker"; +uses "EntitiesMP/HazeMarker"; +uses "EntitiesMP/MirrorMarker"; +uses "EntitiesMP/GradientMarker"; %{ @@ -86,10 +103,10 @@ static void MakeWorldStatistics(void) EntityStats &es = *ites; CTString strLine; strLine.PrintF("%-40s: %8d %8d %10g %10d", - es.es_strName, es.es_ctCount, es.es_ctAmmount, es.es_fValue, es.es_iScore); + (const char *) es.es_strName, es.es_ctCount, es.es_ctAmmount, es.es_fValue, es.es_iScore); strm.PutLine_t(strLine); }} - CPrintF("Dumped to '%s'\n", CTString(fnm)); + CPrintF("Dumped to '%s'\n", (const char *) fnm); } catch (char *strError) { CPrintF("Error: %s\n", strError); } @@ -141,7 +158,7 @@ static void DoLevelSafetyChecks() CModelHolder2 *mh = (CModelHolder2*)&*iten; FLOAT3D vPos = mh->GetPlacement().pl_PositionVector; if (mh->m_penDestruction == NULL) { - CPrintF(" model holder '%s' at (%2.2f, %2.2f, %2.2f) has no destruction\n", mh->m_strName, vPos(1), vPos(2), vPos(3)); + CPrintF(" model holder '%s' at (%2.2f, %2.2f, %2.2f) has no destruction\n", (const char *) mh->m_strName, vPos(1), vPos(2), vPos(3)); } } }} @@ -153,7 +170,7 @@ static void DoLevelSafetyChecks() CSoundHolder *sh = (CSoundHolder *)&*iten; FLOAT3D vPos = sh->GetPlacement().pl_PositionVector; if (sh->m_fnSound == CTFILENAME("Sounds\\Default.wav")) { - CPrintF(" sound holder '%s' at (%2.2f, %2.2f, %2.2f) has default sound!\n", sh->m_strName, vPos(1), vPos(2), vPos(3)); + CPrintF(" sound holder '%s' at (%2.2f, %2.2f, %2.2f) has default sound!\n", (const char *) sh->m_strName, vPos(1), vPos(2), vPos(3)); } } }} @@ -682,9 +699,9 @@ void CWorldBase_OnWorldInit(CWorld *pwo) pwo->wo_aetEnvironmentTypes[13].et_fSize = 1.8f; // declare console variables - _pShell->DeclareSymbol("user void MakeWorldStatistics(void);", &MakeWorldStatistics); - _pShell->DeclareSymbol("user void ReoptimizeAllBrushes(void);", &ReoptimizeAllBrushes); - _pShell->DeclareSymbol("user void DoLevelSafetyChecks(void);", &DoLevelSafetyChecks); + _pShell->DeclareSymbol("user void MakeWorldStatistics(void);", (void *) &MakeWorldStatistics); + _pShell->DeclareSymbol("user void ReoptimizeAllBrushes(void);", (void *) &ReoptimizeAllBrushes); + _pShell->DeclareSymbol("user void DoLevelSafetyChecks(void);", (void *) &DoLevelSafetyChecks); } void CWorldBase_OnWorldRender(CWorld *pwo) @@ -778,9 +795,9 @@ void CWorldBase_OnWorldRender(CWorld *pwo) pwo->wo_attTextureTransformations[35].tt_mdTransformation.FromUI(mdui); // blendings FLOAT f = Abs(Sin(tmNow*AngleDeg(180.0f))); - pwo->wo_atbTextureBlendings[4].tb_colMultiply = RGBAToColor(f*255, f*255, f*255, 255); + pwo->wo_atbTextureBlendings[4].tb_colMultiply = RGBAToColor((UBYTE) (f*255), (UBYTE) (f*255), (UBYTE) (f*255), (UBYTE) (255)); pwo->wo_atbTextureBlendings[5].tb_colMultiply = C_WHITE|UBYTE(255*f); - pwo->wo_atbTextureBlendings[6].tb_colMultiply = RGBAToColor(f*255, f*255, f*255, 255); + pwo->wo_atbTextureBlendings[6].tb_colMultiply = RGBAToColor((UBYTE) (f*255), (UBYTE) (f*255), (UBYTE) (f*255), (UBYTE) (255)); pwo->wo_atbTextureBlendings[7].tb_colMultiply = C_WHITE|UBYTE(255*Lerp(0.5f, 1.0f, f)); pwo->wo_attTextureTransformations[11].tt_mdTransformation.md_fUOffset=Sin( tmNow*22)/30; @@ -1017,16 +1034,16 @@ functions: CTString strClass; // if gradient marker - ulFirst = offsetof(CWorldBase, m_penGradient0); - ulLast = offsetof(CWorldBase, m_penGradient19); + ulFirst = _offsetof(CWorldBase, m_penGradient0); + ulLast = _offsetof(CWorldBase, m_penGradient19); strClass = "Gradient Marker"; if( (slPropertyOffset>=ulFirst) && (slPropertyOffset<=ulLast) ) { return (IsDerivedFromClass(penTarget, strClass)); } // if gravity marker - ulFirst = offsetof(CWorldBase, m_penGravity0); - ulLast = offsetof(CWorldBase, m_penGravity9); + ulFirst = _offsetof(CWorldBase, m_penGravity0); + ulLast = _offsetof(CWorldBase, m_penGravity9); if( (slPropertyOffset>=ulFirst) && (slPropertyOffset<=ulLast) ) { return IsDerivedFromClass(penTarget, "Gravity Marker")|| @@ -1034,24 +1051,24 @@ functions: } // if mirror marker - ulFirst = offsetof(CWorldBase, m_penMirror0); - ulLast = offsetof(CWorldBase, m_penMirror4); + ulFirst = _offsetof(CWorldBase, m_penMirror0); + ulLast = _offsetof(CWorldBase, m_penMirror4); strClass = "Mirror Marker"; if( (slPropertyOffset>=ulFirst) && (slPropertyOffset<=ulLast) ) { return (IsDerivedFromClass(penTarget, strClass)); } // if fog marker - ulFirst = offsetof(CWorldBase, m_penFog0); - ulLast = offsetof(CWorldBase, m_penFog9); + ulFirst = _offsetof(CWorldBase, m_penFog0); + ulLast = _offsetof(CWorldBase, m_penFog9); strClass = "Fog Marker"; if( (slPropertyOffset>=ulFirst) && (slPropertyOffset<=ulLast) ) { return (IsDerivedFromClass(penTarget, strClass)); } // if haze marker - ulFirst = offsetof(CWorldBase, m_penHaze0); - ulLast = offsetof(CWorldBase, m_penHaze4); + ulFirst = _offsetof(CWorldBase, m_penHaze0); + ulLast = _offsetof(CWorldBase, m_penHaze4); strClass = "Haze Marker"; if( (slPropertyOffset>=ulFirst) && (slPropertyOffset<=ulLast) ) { return (IsDerivedFromClass(penTarget, strClass)); diff --git a/Sources/EntitiesMP/WorldLink.es b/Sources/EntitiesMP/WorldLink.es index d0ca120..df5c736 100644 --- a/Sources/EntitiesMP/WorldLink.es +++ b/Sources/EntitiesMP/WorldLink.es @@ -59,7 +59,7 @@ procedures: SetModelMainTexture(TEXTURE_WORLDLINK); // set name - m_strName.PrintF("World link - %s", m_strGroup); + m_strName.PrintF("World link - %s", (const char *) m_strGroup); return; } diff --git a/Sources/EntitiesMP/WorldSettingsController.es b/Sources/EntitiesMP/WorldSettingsController.es index deceb30..ada6699 100644 --- a/Sources/EntitiesMP/WorldSettingsController.es +++ b/Sources/EntitiesMP/WorldSettingsController.es @@ -76,7 +76,7 @@ functions: BOOL IsTargetValid(SLONG slPropertyOffset, CEntity *penTarget) { - if( slPropertyOffset == offsetof(CWorldSettingsController, m_penEnvPartHolder)) + if( slPropertyOffset == _offsetof(CWorldSettingsController, m_penEnvPartHolder)) { if (IsOfClass(penTarget, "EnvironmentParticlesHolder")) { return TRUE; } else { return FALSE; } diff --git a/Sources/External/SDL12/SDL.h b/Sources/External/SDL12/SDL.h new file mode 100644 index 0000000..60ac26c --- /dev/null +++ b/Sources/External/SDL12/SDL.h @@ -0,0 +1,94 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Main include header for the SDL library */ + +#ifndef _SDL_H +#define _SDL_H + +#include "SDL_main.h" +#include "SDL_stdinc.h" +#include "SDL_audio.h" +#include "SDL_cdrom.h" +#include "SDL_cpuinfo.h" +#include "SDL_endian.h" +#include "SDL_error.h" +#include "SDL_events.h" +#include "SDL_loadso.h" +#include "SDL_mutex.h" +#include "SDL_rwops.h" +#include "SDL_thread.h" +#include "SDL_timer.h" +#include "SDL_video.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* As of version 0.5, SDL is loaded dynamically into the application */ + +/* These are the flags which may be passed to SDL_Init() -- you should + specify the subsystems which you will be using in your application. +*/ +#define SDL_INIT_TIMER 0x00000001 +#define SDL_INIT_AUDIO 0x00000010 +#define SDL_INIT_VIDEO 0x00000020 +#define SDL_INIT_CDROM 0x00000100 +#define SDL_INIT_JOYSTICK 0x00000200 +#define SDL_INIT_NOPARACHUTE 0x00100000 /* Don't catch fatal signals */ +#define SDL_INIT_EVENTTHREAD 0x01000000 /* Not supported on all OS's */ +#define SDL_INIT_EVERYTHING 0x0000FFFF + +/* This function loads the SDL dynamically linked library and initializes + * the subsystems specified by 'flags' (and those satisfying dependencies) + * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup + * signal handlers for some commonly ignored fatal signals (like SIGSEGV) + */ +extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); + +/* This function initializes specific SDL subsystems */ +extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); + +/* This function cleans up specific SDL subsystems */ +extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); + +/* This function returns mask of the specified subsystems which have + been initialized. + If 'flags' is 0, it returns a mask of all initialized subsystems. +*/ +extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); + +/* This function cleans up all initialized subsystems and unloads the + * dynamically linked library. You should call it upon all exit conditions. + */ +extern DECLSPEC void SDLCALL SDL_Quit(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_H */ diff --git a/Sources/External/SDL12/SDL_active.h b/Sources/External/SDL12/SDL_active.h new file mode 100644 index 0000000..2cf474c --- /dev/null +++ b/Sources/External/SDL12/SDL_active.h @@ -0,0 +1,58 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Include file for SDL application focus event handling */ + +#ifndef _SDL_active_h +#define _SDL_active_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The available application states */ +#define SDL_APPMOUSEFOCUS 0x01 /* The app has mouse coverage */ +#define SDL_APPINPUTFOCUS 0x02 /* The app has input focus */ +#define SDL_APPACTIVE 0x04 /* The application is active */ + +/* Function prototypes */ +/* + * This function returns the current state of the application, which is a + * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and + * SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to + * see your application, otherwise it has been iconified or disabled. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_active_h */ diff --git a/Sources/External/SDL12/SDL_audio.h b/Sources/External/SDL12/SDL_audio.h new file mode 100644 index 0000000..68ec475 --- /dev/null +++ b/Sources/External/SDL12/SDL_audio.h @@ -0,0 +1,253 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Access to the raw audio mixing buffer for the SDL library */ + +#ifndef _SDL_audio_h +#define _SDL_audio_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_endian.h" +#include "SDL_mutex.h" +#include "SDL_thread.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The calculated values in this structure are calculated by SDL_OpenAudio() */ +typedef struct SDL_AudioSpec { + int freq; /* DSP frequency -- samples per second */ + Uint16 format; /* Audio data format */ + Uint8 channels; /* Number of channels: 1 mono, 2 stereo */ + Uint8 silence; /* Audio buffer silence value (calculated) */ + Uint16 samples; /* Audio buffer size in samples (power of 2) */ + Uint16 padding; /* Necessary for some compile environments */ + Uint32 size; /* Audio buffer size in bytes (calculated) */ + /* This function is called when the audio device needs more data. + 'stream' is a pointer to the audio data buffer + 'len' is the length of that buffer in bytes. + Once the callback returns, the buffer will no longer be valid. + Stereo samples are stored in a LRLRLR ordering. + */ + void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len); + void *userdata; +} SDL_AudioSpec; + +/* Audio format flags (defaults to LSB byte order) */ +#define AUDIO_U8 0x0008 /* Unsigned 8-bit samples */ +#define AUDIO_S8 0x8008 /* Signed 8-bit samples */ +#define AUDIO_U16LSB 0x0010 /* Unsigned 16-bit samples */ +#define AUDIO_S16LSB 0x8010 /* Signed 16-bit samples */ +#define AUDIO_U16MSB 0x1010 /* As above, but big-endian byte order */ +#define AUDIO_S16MSB 0x9010 /* As above, but big-endian byte order */ +#define AUDIO_U16 AUDIO_U16LSB +#define AUDIO_S16 AUDIO_S16LSB + +/* Native audio byte ordering */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define AUDIO_U16SYS AUDIO_U16LSB +#define AUDIO_S16SYS AUDIO_S16LSB +#else +#define AUDIO_U16SYS AUDIO_U16MSB +#define AUDIO_S16SYS AUDIO_S16MSB +#endif + + +/* A structure to hold a set of audio conversion filters and buffers */ +typedef struct SDL_AudioCVT { + int needed; /* Set to 1 if conversion possible */ + Uint16 src_format; /* Source audio format */ + Uint16 dst_format; /* Target audio format */ + double rate_incr; /* Rate conversion increment */ + Uint8 *buf; /* Buffer to hold entire audio data */ + int len; /* Length of original audio buffer */ + int len_cvt; /* Length of converted audio buffer */ + int len_mult; /* buffer must be len*len_mult big */ + double len_ratio; /* Given len, final size is len*len_ratio */ + void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format); + int filter_index; /* Current audio conversion function */ +} SDL_AudioCVT; + + +/* Function prototypes */ + +/* These functions are used internally, and should not be used unless you + * have a specific need to specify the audio driver you want to use. + * You should normally use SDL_Init() or SDL_InitSubSystem(). + */ +extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); +extern DECLSPEC void SDLCALL SDL_AudioQuit(void); + +/* This function fills the given character buffer with the name of the + * current audio driver, and returns a pointer to it if the audio driver has + * been initialized. It returns NULL if no driver has been initialized. + */ +extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen); + +/* + * This function opens the audio device with the desired parameters, and + * returns 0 if successful, placing the actual hardware parameters in the + * structure pointed to by 'obtained'. If 'obtained' is NULL, the audio + * data passed to the callback function will be guaranteed to be in the + * requested format, and will be automatically converted to the hardware + * audio format if necessary. This function returns -1 if it failed + * to open the audio device, or couldn't set up the audio thread. + * + * When filling in the desired audio spec structure, + * 'desired->freq' should be the desired audio frequency in samples-per-second. + * 'desired->format' should be the desired audio format. + * 'desired->samples' is the desired size of the audio buffer, in samples. + * This number should be a power of two, and may be adjusted by the audio + * driver to a value more suitable for the hardware. Good values seem to + * range between 512 and 8096 inclusive, depending on the application and + * CPU speed. Smaller values yield faster response time, but can lead + * to underflow if the application is doing heavy processing and cannot + * fill the audio buffer in time. A stereo sample consists of both right + * and left channels in LR ordering. + * Note that the number of samples is directly related to time by the + * following formula: ms = (samples*1000)/freq + * 'desired->size' is the size in bytes of the audio buffer, and is + * calculated by SDL_OpenAudio(). + * 'desired->silence' is the value used to set the buffer to silence, + * and is calculated by SDL_OpenAudio(). + * 'desired->callback' should be set to a function that will be called + * when the audio device is ready for more data. It is passed a pointer + * to the audio buffer, and the length in bytes of the audio buffer. + * This function usually runs in a separate thread, and so you should + * protect data structures that it accesses by calling SDL_LockAudio() + * and SDL_UnlockAudio() in your code. + * 'desired->userdata' is passed as the first parameter to your callback + * function. + * + * The audio device starts out playing silence when it's opened, and should + * be enabled for playing by calling SDL_PauseAudio(0) when you are ready + * for your audio callback function to be called. Since the audio driver + * may modify the requested size of the audio buffer, you should allocate + * any local mixing buffers after you open the audio device. + */ +extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained); + +/* + * Get the current audio state: + */ +typedef enum { + SDL_AUDIO_STOPPED = 0, + SDL_AUDIO_PLAYING, + SDL_AUDIO_PAUSED +} SDL_audiostatus; +extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void); + +/* + * This function pauses and unpauses the audio callback processing. + * It should be called with a parameter of 0 after opening the audio + * device to start playing sound. This is so you can safely initialize + * data for your callback function after opening the audio device. + * Silence will be written to the audio device during the pause. + */ +extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); + +/* + * This function loads a WAVE from the data source, automatically freeing + * that source if 'freesrc' is non-zero. For example, to load a WAVE file, + * you could do: + * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); + * + * If this function succeeds, it returns the given SDL_AudioSpec, + * filled with the audio data format of the wave data, and sets + * 'audio_buf' to a malloc()'d buffer containing the audio data, + * and sets 'audio_len' to the length of that audio buffer, in bytes. + * You need to free the audio buffer with SDL_FreeWAV() when you are + * done with it. + * + * This function returns NULL and sets the SDL error message if the + * wave file cannot be opened, uses an unknown data format, or is + * corrupt. Currently raw and MS-ADPCM WAVE files are supported. + */ +extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); + +/* Compatibility convenience function -- loads a WAV from a file */ +#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ + SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) + +/* + * This function frees data previously allocated with SDL_LoadWAV_RW() + */ +extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf); + +/* + * This function takes a source format and rate and a destination format + * and rate, and initializes the 'cvt' structure with information needed + * by SDL_ConvertAudio() to convert a buffer of audio data from one format + * to the other. + * This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt, + Uint16 src_format, Uint8 src_channels, int src_rate, + Uint16 dst_format, Uint8 dst_channels, int dst_rate); + +/* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), + * created an audio buffer cvt->buf, and filled it with cvt->len bytes of + * audio data in the source format, this function will convert it in-place + * to the desired format. + * The data conversion may expand the size of the audio data, so the buffer + * cvt->buf should be allocated after the cvt structure is initialized by + * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. + */ +extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt); + +/* + * This takes two audio buffers of the playing audio format and mixes + * them, performing addition, volume adjustment, and overflow clipping. + * The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME + * for full audio volume. Note this does not change hardware volume. + * This is provided for convenience -- you can mix your own audio data. + */ +#define SDL_MIX_MAXVOLUME 128 +extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume); + +/* + * The lock manipulated by these functions protects the callback function. + * During a LockAudio/UnlockAudio pair, you can be guaranteed that the + * callback function is not running. Do not call these from the callback + * function or you will cause deadlock. + */ +extern DECLSPEC void SDLCALL SDL_LockAudio(void); +extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); + +/* + * This function shuts down audio processing and closes the audio device. + */ +extern DECLSPEC void SDLCALL SDL_CloseAudio(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_audio_h */ diff --git a/Sources/External/SDL12/SDL_byteorder.h b/Sources/External/SDL12/SDL_byteorder.h new file mode 100644 index 0000000..3871cfe --- /dev/null +++ b/Sources/External/SDL12/SDL_byteorder.h @@ -0,0 +1,24 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* DEPRECATED */ +#include "SDL_endian.h" diff --git a/Sources/External/SDL12/SDL_cdrom.h b/Sources/External/SDL12/SDL_cdrom.h new file mode 100644 index 0000000..5f8f0c6 --- /dev/null +++ b/Sources/External/SDL12/SDL_cdrom.h @@ -0,0 +1,171 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* This is the CD-audio control API for Simple DirectMedia Layer */ + +#ifndef _SDL_cdrom_h +#define _SDL_cdrom_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* In order to use these functions, SDL_Init() must have been called + with the SDL_INIT_CDROM flag. This causes SDL to scan the system + for CD-ROM drives, and load appropriate drivers. +*/ + +/* The maximum number of CD-ROM tracks on a disk */ +#define SDL_MAX_TRACKS 99 + +/* The types of CD-ROM track possible */ +#define SDL_AUDIO_TRACK 0x00 +#define SDL_DATA_TRACK 0x04 + +/* The possible states which a CD-ROM drive can be in. */ +typedef enum { + CD_TRAYEMPTY, + CD_STOPPED, + CD_PLAYING, + CD_PAUSED, + CD_ERROR = -1 +} CDstatus; + +/* Given a status, returns true if there's a disk in the drive */ +#define CD_INDRIVE(status) ((int)(status) > 0) + +typedef struct SDL_CDtrack { + Uint8 id; /* Track number */ + Uint8 type; /* Data or audio track */ + Uint16 unused; + Uint32 length; /* Length, in frames, of this track */ + Uint32 offset; /* Offset, in frames, from start of disk */ +} SDL_CDtrack; + +/* This structure is only current as of the last call to SDL_CDStatus() */ +typedef struct SDL_CD { + int id; /* Private drive identifier */ + CDstatus status; /* Current drive status */ + + /* The rest of this structure is only valid if there's a CD in drive */ + int numtracks; /* Number of tracks on disk */ + int cur_track; /* Current track position */ + int cur_frame; /* Current frame offset within current track */ + SDL_CDtrack track[SDL_MAX_TRACKS+1]; +} SDL_CD; + +/* Conversion functions from frames to Minute/Second/Frames and vice versa */ +#define CD_FPS 75 +#define FRAMES_TO_MSF(f, M,S,F) { \ + int value = f; \ + *(F) = value%CD_FPS; \ + value /= CD_FPS; \ + *(S) = value%60; \ + value /= 60; \ + *(M) = value; \ +} +#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F)) + +/* CD-audio API functions: */ + +/* Returns the number of CD-ROM drives on the system, or -1 if + SDL_Init() has not been called with the SDL_INIT_CDROM flag. + */ +extern DECLSPEC int SDLCALL SDL_CDNumDrives(void); + +/* Returns a human-readable, system-dependent identifier for the CD-ROM. + Example: + "/dev/cdrom" + "E:" + "/dev/disk/ide/1/master" +*/ +extern DECLSPEC const char * SDLCALL SDL_CDName(int drive); + +/* Opens a CD-ROM drive for access. It returns a drive handle on success, + or NULL if the drive was invalid or busy. This newly opened CD-ROM + becomes the default CD used when other CD functions are passed a NULL + CD-ROM handle. + Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. +*/ +extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive); + +/* This function returns the current status of the given drive. + If the drive has a CD in it, the table of contents of the CD and current + play position of the CD will be stored in the SDL_CD structure. +*/ +extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom); + +/* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' + tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play + until the end of the CD. This function will skip data tracks. + This function should only be called after calling SDL_CDStatus() to + get track information about the CD. + For example: + // Play entire CD: + if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) + SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); + // Play last track: + if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) { + SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0); + } + // Play first and second track and 10 seconds of third track: + if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) + SDL_CDPlayTracks(cdrom, 0, 0, 2, 10); + + This function returns 0, or -1 if there was an error. +*/ +extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom, + int start_track, int start_frame, int ntracks, int nframes); + +/* Play the given CD starting at 'start' frame for 'length' frames. + It returns 0, or -1 if there was an error. +*/ +extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length); + +/* Pause play -- returns 0, or -1 on error */ +extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom); + +/* Resume play -- returns 0, or -1 on error */ +extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom); + +/* Stop play -- returns 0, or -1 on error */ +extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom); + +/* Eject CD-ROM -- returns 0, or -1 on error */ +extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom); + +/* Closes the handle for the CD-ROM drive */ +extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ diff --git a/Sources/External/SDL12/SDL_config.h b/Sources/External/SDL12/SDL_config.h new file mode 100644 index 0000000..a508101 --- /dev/null +++ b/Sources/External/SDL12/SDL_config.h @@ -0,0 +1,45 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_h +#define _SDL_config_h + +#include "SDL_platform.h" + +/* Add any platform that doesn't build using the configure system */ +#if defined(__DREAMCAST__) +#include "SDL_config_dreamcast.h" +#elif defined(__MACOS__) +#include "SDL_config_macos.h" +#elif defined(__MACOSX__) +#include "SDL_config_macosx.h" +#elif defined(__SYMBIAN32__) +#include "SDL_config_symbian.h" /* must be before win32! */ +#elif defined(__WIN32__) +#include "SDL_config_win32.h" +#elif defined(__OS2__) +#include "SDL_config_os2.h" +#else +#include "SDL_config_minimal.h" +#endif /* platform config */ + +#endif /* _SDL_config_h */ diff --git a/Sources/External/SDL12/SDL_config_dreamcast.h b/Sources/External/SDL12/SDL_config_dreamcast.h new file mode 100644 index 0000000..9cbeea3 --- /dev/null +++ b/Sources/External/SDL12/SDL_config_dreamcast.h @@ -0,0 +1,106 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_dreamcast_h +#define _SDL_config_dreamcast_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +typedef unsigned long uintptr_t; +#define SDL_HAS_64BIT_TYPE 1 + +/* Useful headers */ +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRDUP 1 +#define HAVE_INDEX 1 +#define HAVE_RINDEX 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRICMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_DC 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#define SDL_CDROM_DC 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_DC 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_DUMMY 1 + +/* Enable various threading systems */ +#define SDL_THREAD_DC 1 + +/* Enable various timer systems */ +#define SDL_TIMER_DC 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DC 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +#endif /* _SDL_config_dreamcast_h */ diff --git a/Sources/External/SDL12/SDL_config_macos.h b/Sources/External/SDL12/SDL_config_macos.h new file mode 100644 index 0000000..c4a1c59 --- /dev/null +++ b/Sources/External/SDL12/SDL_config_macos.h @@ -0,0 +1,112 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_macos_h +#define _SDL_config_macos_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#include + +typedef SInt8 int8_t; +typedef UInt8 uint8_t; +typedef SInt16 int16_t; +typedef UInt16 uint16_t; +typedef SInt32 int32_t; +typedef UInt32 uint32_t; +typedef SInt64 int64_t; +typedef UInt64 uint64_t; +typedef unsigned long uintptr_t; + +#define SDL_HAS_64BIT_TYPE 1 + +/* Useful headers */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_SSCANF 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_SNDMGR 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#if TARGET_API_MAC_CARBON +#define SDL_CDROM_DUMMY 1 +#else +#define SDL_CDROM_MACOS 1 +#endif + +/* Enable various input drivers */ +#if TARGET_API_MAC_CARBON +#define SDL_JOYSTICK_DUMMY 1 +#else +#define SDL_JOYSTICK_MACOS 1 +#endif + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_MACOS 1 + +/* Enable various threading systems */ +#define SDL_THREADS_DISABLED 1 + +/* Enable various timer systems */ +#define SDL_TIMER_MACOS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_DRAWSPROCKET 1 +#define SDL_VIDEO_DRIVER_TOOLBOX 1 + +/* Enable OpenGL support */ +#define SDL_VIDEO_OPENGL 1 + +#endif /* _SDL_config_macos_h */ diff --git a/Sources/External/SDL12/SDL_config_macosx.h b/Sources/External/SDL12/SDL_config_macosx.h new file mode 100644 index 0000000..481c22e --- /dev/null +++ b/Sources/External/SDL12/SDL_config_macosx.h @@ -0,0 +1,135 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_macosx_h +#define _SDL_config_macosx_h + +#include "SDL_platform.h" + +/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ +#include + +/* This is a set of defines to configure the SDL features */ + +#define SDL_HAS_64BIT_TYPE 1 + +/* Useful headers */ +/* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */ +#if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) ) +#define HAVE_ALLOCA_H 1 +#endif +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_COREAUDIO 1 +#define SDL_AUDIO_DRIVER_SNDMGR 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#define SDL_CDROM_MACOSX 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_IOKIT 1 + +/* Enable various shared object loading systems */ +#ifdef __ppc__ +/* For Mac OS X 10.2 compatibility */ +#define SDL_LOADSO_DLCOMPAT 1 +#else +#define SDL_LOADSO_DLOPEN 1 +#endif + +/* Enable various threading systems */ +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 + +/* Enable various timer systems */ +#define SDL_TIMER_UNIX 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#if ((defined TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON)) +#define SDL_VIDEO_DRIVER_TOOLBOX 1 +#else +#define SDL_VIDEO_DRIVER_QUARTZ 1 +#endif + +/* Enable OpenGL support */ +#define SDL_VIDEO_OPENGL 1 + +/* Enable assembly routines */ +#define SDL_ASSEMBLY_ROUTINES 1 +#ifdef __ppc__ +#define SDL_ALTIVEC_BLITTERS 1 +#endif + +#endif /* _SDL_config_macosx_h */ diff --git a/Sources/External/SDL12/SDL_config_minimal.h b/Sources/External/SDL12/SDL_config_minimal.h new file mode 100644 index 0000000..5bb804a --- /dev/null +++ b/Sources/External/SDL12/SDL_config_minimal.h @@ -0,0 +1,79 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_minimal_h +#define _SDL_config_minimal_h + +#include "SDL_platform.h" + +/* This is the minimal configuration that can be used to build SDL */ + +#include + +// @Braid: added this block. --ryan. +#include +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_ICONV_H 1 +// @Braid: end + + +#ifndef _STDINT_H +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef unsigned int size_t; +typedef unsigned long uintptr_t; +#endif + +/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ +#define SDL_CDROM_DISABLED 1 + +/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ +#define SDL_JOYSTICK_DISABLED 1 + +/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + +/* Enable the stub thread support (src/thread/generic/\*.c) */ +#define SDL_THREADS_DISABLED 1 + +/* Enable the stub timer support (src/timer/dummy/\*.c) */ +#define SDL_TIMERS_DISABLED 1 + +/* Enable the dummy video driver (src/video/dummy/\*.c) */ +#define SDL_VIDEO_DRIVER_DUMMY 1 + +#endif /* _SDL_config_minimal_h */ diff --git a/Sources/External/SDL12/SDL_config_nds.h b/Sources/External/SDL12/SDL_config_nds.h new file mode 100644 index 0000000..20b789c --- /dev/null +++ b/Sources/External/SDL12/SDL_config_nds.h @@ -0,0 +1,115 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_nds_h +#define _SDL_config_nds_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +/* C datatypes */ +#define SDL_HAS_64BIT_TYPE 1 + +/* Endianness */ +#define SDL_BYTEORDER 1234 + +/* Useful headers */ +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_ICONV_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_SETJMP 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_NDS 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ +#define SDL_CDROM_DISABLED 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_NDS 1 + +/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + +/* Enable the stub thread support (src/thread/generic/\*.c) */ +#define SDL_THREADS_DISABLED 1 + +/* Enable various timer systems */ +#define SDL_TIMER_NDS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_NDS 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +#endif /* _SDL_config_nds_h */ diff --git a/Sources/External/SDL12/SDL_config_os2.h b/Sources/External/SDL12/SDL_config_os2.h new file mode 100644 index 0000000..8cdea9f --- /dev/null +++ b/Sources/External/SDL12/SDL_config_os2.h @@ -0,0 +1,141 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_os2_h +#define _SDL_config_os2_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef unsigned int size_t; +typedef unsigned long uintptr_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; + +#define SDL_HAS_64BIT_TYPE 1 + +/* Use Watcom's LIBC */ +#define HAVE_LIBC 1 + +/* Useful headers */ +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_INDEX 1 +#define HAVE_RINDEX 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE__LTOA 1 +#define HAVE__UITOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE__I64TOA 1 +#define HAVE__UI64TOA 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRICMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_SETJMP 1 +#define HAVE_CLOCK_GETTIME 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_DART 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#define SDL_CDROM_OS2 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_OS2 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_OS2 1 + +/* Enable various threading systems */ +#define SDL_THREAD_OS2 1 + +/* Enable various timer systems */ +#define SDL_TIMER_OS2 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_OS2FS 1 + +/* Enable OpenGL support */ +/* Nothing here yet for OS/2... :( */ + +/* Enable assembly routines where available */ +#define SDL_ASSEMBLY_ROUTINES 1 + +#endif /* _SDL_config_os2_h */ diff --git a/Sources/External/SDL12/SDL_config_symbian.h b/Sources/External/SDL12/SDL_config_symbian.h new file mode 100644 index 0000000..607c37a --- /dev/null +++ b/Sources/External/SDL12/SDL_config_symbian.h @@ -0,0 +1,146 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* + +Symbian version Markus Mertama + +*/ + + +#ifndef _SDL_CONFIG_SYMBIAN_H +#define _SDL_CONFIG_SYMBIAN_H + +#include "SDL_platform.h" + +/* This is the minimal configuration that can be used to build SDL */ + + +#include +#include + + +#ifdef __GCCE__ +#define SYMBIAN32_GCCE +#endif + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#endif + +#ifndef _INTPTR_T_DECLARED +typedef unsigned int uintptr_t; +#endif + +#ifndef _INT8_T_DECLARED +typedef signed char int8_t; +#endif + +#ifndef _UINT8_T_DECLARED +typedef unsigned char uint8_t; +#endif + +#ifndef _INT16_T_DECLARED +typedef signed short int16_t; +#endif + +#ifndef _UINT16_T_DECLARED +typedef unsigned short uint16_t; +#endif + +#ifndef _INT32_T_DECLARED +typedef signed int int32_t; +#endif + +#ifndef _UINT32_T_DECLARED +typedef unsigned int uint32_t; +#endif + +#ifndef _INT64_T_DECLARED +typedef signed long long int64_t; +#endif + +#ifndef _UINT64_T_DECLARED +typedef unsigned long long uint64_t; +#endif + +#define SDL_AUDIO_DRIVER_EPOCAUDIO 1 + + +/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ +#define SDL_CDROM_DISABLED 1 + +/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ +#define SDL_JOYSTICK_DISABLED 1 + +/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + +#define SDL_THREAD_SYMBIAN 1 + +#define SDL_VIDEO_DRIVER_EPOC 1 + +#define SDL_VIDEO_OPENGL 0 + +#define SDL_HAS_64BIT_TYPE 1 + +#define HAVE_LIBC 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 + +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +/*#define HAVE_ALLOCA 1*/ +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRUPR 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +/*#define HAVE__STRICMP 1*/ +#define HAVE__STRNICMP 1 +#define HAVE_SSCANF 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 + + + +#endif /* _SDL_CONFIG_SYMBIAN_H */ diff --git a/Sources/External/SDL12/SDL_config_win32.h b/Sources/External/SDL12/SDL_config_win32.h new file mode 100644 index 0000000..cfb44d2 --- /dev/null +++ b/Sources/External/SDL12/SDL_config_win32.h @@ -0,0 +1,180 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_win32_h +#define _SDL_config_win32_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#if defined(__GNUC__) || defined(__DMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#define SDL_HAS_64BIT_TYPE 1 + +/* Enabled for SDL 1.2 (binary compatibility) */ +#define HAVE_LIBC 1 +#ifdef HAVE_LIBC +/* Useful headers */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#ifndef _WIN32_WCE +#define HAVE_SIGNAL_H 1 +#endif + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE__LTOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_SSCANF 1 +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#endif + +/* Enable various audio drivers */ +#ifndef _WIN32_WCE +#define SDL_AUDIO_DRIVER_DSOUND 1 +#endif +#define SDL_AUDIO_DRIVER_WAVEOUT 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#ifdef _WIN32_WCE +#define SDL_CDROM_DISABLED 1 +#else +#define SDL_CDROM_WIN32 1 +#endif + +/* Enable various input drivers */ +#ifdef _WIN32_WCE +#define SDL_JOYSTICK_DISABLED 1 +#else +#define SDL_JOYSTICK_WINMM 1 +#endif + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WIN32 1 + +/* Enable various threading systems */ +#define SDL_THREAD_WIN32 1 + +/* Enable various timer systems */ +#ifdef _WIN32_WCE +#define SDL_TIMER_WINCE 1 +#else +#define SDL_TIMER_WIN32 1 +#endif + +/* Enable various video drivers */ +#ifdef _WIN32_WCE +#define SDL_VIDEO_DRIVER_GAPI 1 +#endif +#ifndef _WIN32_WCE +#define SDL_VIDEO_DRIVER_DDRAW 1 +#endif +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_WINDIB 1 + +/* Enable OpenGL support */ +#ifndef _WIN32_WCE +#define SDL_VIDEO_OPENGL 1 +#define SDL_VIDEO_OPENGL_WGL 1 +#endif + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* _SDL_config_win32_h */ diff --git a/Sources/External/SDL12/SDL_copying.h b/Sources/External/SDL12/SDL_copying.h new file mode 100644 index 0000000..39e122d --- /dev/null +++ b/Sources/External/SDL12/SDL_copying.h @@ -0,0 +1,22 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + diff --git a/Sources/External/SDL12/SDL_cpuinfo.h b/Sources/External/SDL12/SDL_cpuinfo.h new file mode 100644 index 0000000..72acbdd --- /dev/null +++ b/Sources/External/SDL12/SDL_cpuinfo.h @@ -0,0 +1,75 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* CPU feature detection for SDL */ + +#ifndef _SDL_cpuinfo_h +#define _SDL_cpuinfo_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This function returns true if the CPU has the RDTSC instruction + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); + +/* This function returns true if the CPU has MMX features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); + +/* This function returns true if the CPU has MMX Ext. features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void); + +/* This function returns true if the CPU has 3DNow features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); + +/* This function returns true if the CPU has 3DNow! Ext. features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void); + +/* This function returns true if the CPU has SSE features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); + +/* This function returns true if the CPU has SSE2 features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); + +/* This function returns true if the CPU has AltiVec features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_cpuinfo_h */ diff --git a/Sources/External/SDL12/SDL_endian.h b/Sources/External/SDL12/SDL_endian.h new file mode 100644 index 0000000..8f8db4c --- /dev/null +++ b/Sources/External/SDL12/SDL_endian.h @@ -0,0 +1,194 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Functions for reading and writing endian-specific values */ + +#ifndef _SDL_endian_h +#define _SDL_endian_h + +#include "SDL_stdinc.h" + +/* The two types of endianness */ +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 + +#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ +#if defined(__hppa__) || \ + defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ + (defined(__MIPS__) && defined(__MISPEB__)) || \ + defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ + defined(__sparc__) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#endif +#endif /* !SDL_BYTEORDER */ + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Use inline functions for compilers that support them, and static + functions for those that do not. Because these functions become + static for compilers that do not support inline functions, this + header should only be included in files that actually use them. +*/ +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0" : "=Q" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + Uint16 result; + + __asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (x >> 8), "r" (x)); + return result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("rorw #8,%0" : "=d" (x) : "0" (x) : "cc"); + return x; +} +#else +static __inline__ Uint16 SDL_Swap16(Uint16 x) { + return((x<<8)|(x>>8)); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("bswap %0" : "=r" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("bswapl %0" : "=r" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + Uint32 result; + + __asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (x>>24), "r" (x)); + __asm__("rlwimi %0,%2,8,8,15" : "=&r" (result) : "0" (result), "r" (x)); + __asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (x)); + return result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) : "0" (x) : "cc"); + return x; +} +#else +static __inline__ Uint32 SDL_Swap32(Uint32 x) { + return((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24)); +} +#endif + +#ifdef SDL_HAS_64BIT_TYPE +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) +static __inline__ Uint64 SDL_Swap64(Uint64 x) +{ + union { + struct { Uint32 a,b; } s; + Uint64 u; + } v; + v.u = x; + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" + : "=r" (v.s.a), "=r" (v.s.b) + : "0" (v.s.a), "1" (v.s.b)); + return v.u; +} +#elif defined(__GNUC__) && defined(__x86_64__) +static __inline__ Uint64 SDL_Swap64(Uint64 x) +{ + __asm__("bswapq %0" : "=r" (x) : "0" (x)); + return x; +} +#else +static __inline__ Uint64 SDL_Swap64(Uint64 x) +{ + Uint32 hi, lo; + + /* Separate into high and low 32-bit values and swap them */ + lo = (Uint32)(x&0xFFFFFFFF); + x >>= 32; + hi = (Uint32)(x&0xFFFFFFFF); + x = SDL_Swap32(lo); + x <<= 32; + x |= SDL_Swap32(hi); + return(x); +} +#endif +#else +/* This is mainly to keep compilers from complaining in SDL code. + If there is no real 64-bit datatype, then compilers will complain about + the fake 64-bit datatype that SDL provides when it compiles user code. +*/ +#define SDL_Swap64(X) (X) +#endif /* SDL_HAS_64BIT_TYPE */ + + +/* Byteswap item from the specified endianness to the native endianness */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) +#else +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) +#endif + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_endian_h */ diff --git a/Sources/External/SDL12/SDL_error.h b/Sources/External/SDL12/SDL_error.h new file mode 100644 index 0000000..26d6bfa --- /dev/null +++ b/Sources/External/SDL12/SDL_error.h @@ -0,0 +1,61 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Simple error message routines for SDL */ + +#ifndef _SDL_error_h +#define _SDL_error_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Public functions */ +extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); +extern DECLSPEC char * SDLCALL SDL_GetError(void); +extern DECLSPEC void SDLCALL SDL_ClearError(void); + +/* Private error message function - used internally */ +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) +typedef enum { + SDL_ENOMEM, + SDL_EFREAD, + SDL_EFWRITE, + SDL_EFSEEK, + SDL_UNSUPPORTED, + SDL_LASTERROR +} SDL_errorcode; +extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_error_h */ diff --git a/Sources/External/SDL12/SDL_events.h b/Sources/External/SDL12/SDL_events.h new file mode 100644 index 0000000..9fe918c --- /dev/null +++ b/Sources/External/SDL12/SDL_events.h @@ -0,0 +1,337 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Include file for SDL event handling */ + +#ifndef _SDL_events_h +#define _SDL_events_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_active.h" +#include "SDL_keyboard.h" +#include "SDL_mouse.h" +#include "SDL_joystick.h" +#include "SDL_quit.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* General keyboard/mouse state definitions */ +#define SDL_RELEASED 0 +#define SDL_PRESSED 1 + +/* Event enumerations */ +typedef enum { + SDL_NOEVENT = 0, /* Unused (do not remove) */ + SDL_ACTIVEEVENT, /* Application loses/gains visibility */ + SDL_KEYDOWN, /* Keys pressed */ + SDL_KEYUP, /* Keys released */ + SDL_MOUSEMOTION, /* Mouse moved */ + SDL_MOUSEBUTTONDOWN, /* Mouse button pressed */ + SDL_MOUSEBUTTONUP, /* Mouse button released */ + SDL_JOYAXISMOTION, /* Joystick axis motion */ + SDL_JOYBALLMOTION, /* Joystick trackball motion */ + SDL_JOYHATMOTION, /* Joystick hat position change */ + SDL_JOYBUTTONDOWN, /* Joystick button pressed */ + SDL_JOYBUTTONUP, /* Joystick button released */ + SDL_QUIT, /* User-requested quit */ + SDL_SYSWMEVENT, /* System specific event */ + SDL_EVENT_RESERVEDA, /* Reserved for future use.. */ + SDL_EVENT_RESERVEDB, /* Reserved for future use.. */ + SDL_VIDEORESIZE, /* User resized video mode */ + SDL_VIDEOEXPOSE, /* Screen needs to be redrawn */ + SDL_EVENT_RESERVED2, /* Reserved for future use.. */ + SDL_EVENT_RESERVED3, /* Reserved for future use.. */ + SDL_EVENT_RESERVED4, /* Reserved for future use.. */ + SDL_EVENT_RESERVED5, /* Reserved for future use.. */ + SDL_EVENT_RESERVED6, /* Reserved for future use.. */ + SDL_EVENT_RESERVED7, /* Reserved for future use.. */ + /* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ + SDL_USEREVENT = 24, + /* This last event is only for bounding internal arrays + It is the number of bits in the event mask datatype -- Uint32 + */ + SDL_NUMEVENTS = 32 +} SDL_EventType; + +/* Predefined event masks */ +#define SDL_EVENTMASK(X) (1<<(X)) +typedef enum { + SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT), + SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN), + SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP), + SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN)| + SDL_EVENTMASK(SDL_KEYUP), + SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION), + SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), + SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP), + SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION)| + SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)| + SDL_EVENTMASK(SDL_MOUSEBUTTONUP), + SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION), + SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION), + SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION), + SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN), + SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP), + SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION)| + SDL_EVENTMASK(SDL_JOYBALLMOTION)| + SDL_EVENTMASK(SDL_JOYHATMOTION)| + SDL_EVENTMASK(SDL_JOYBUTTONDOWN)| + SDL_EVENTMASK(SDL_JOYBUTTONUP), + SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_VIDEORESIZE), + SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE), + SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), + SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT) +} SDL_EventMask ; +#define SDL_ALLEVENTS 0xFFFFFFFF + +/* Application visibility event structure */ +typedef struct SDL_ActiveEvent { + Uint8 type; /* SDL_ACTIVEEVENT */ + Uint8 gain; /* Whether given states were gained or lost (1/0) */ + Uint8 state; /* A mask of the focus states */ +} SDL_ActiveEvent; + +/* Keyboard event structure */ +typedef struct SDL_KeyboardEvent { + Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */ + Uint8 which; /* The keyboard device index */ + Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ + SDL_keysym keysym; +} SDL_KeyboardEvent; + +/* Mouse motion event structure */ +typedef struct SDL_MouseMotionEvent { + Uint8 type; /* SDL_MOUSEMOTION */ + Uint8 which; /* The mouse device index */ + Uint8 state; /* The current button state */ + Uint16 x, y; /* The X/Y coordinates of the mouse */ + Sint16 xrel; /* The relative motion in the X direction */ + Sint16 yrel; /* The relative motion in the Y direction */ +} SDL_MouseMotionEvent; + +/* Mouse button event structure */ +typedef struct SDL_MouseButtonEvent { + Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ + Uint8 which; /* The mouse device index */ + Uint8 button; /* The mouse button index */ + Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ + Uint16 x, y; /* The X/Y coordinates of the mouse at press time */ +} SDL_MouseButtonEvent; + +/* Joystick axis motion event structure */ +typedef struct SDL_JoyAxisEvent { + Uint8 type; /* SDL_JOYAXISMOTION */ + Uint8 which; /* The joystick device index */ + Uint8 axis; /* The joystick axis index */ + Sint16 value; /* The axis value (range: -32768 to 32767) */ +} SDL_JoyAxisEvent; + +/* Joystick trackball motion event structure */ +typedef struct SDL_JoyBallEvent { + Uint8 type; /* SDL_JOYBALLMOTION */ + Uint8 which; /* The joystick device index */ + Uint8 ball; /* The joystick trackball index */ + Sint16 xrel; /* The relative motion in the X direction */ + Sint16 yrel; /* The relative motion in the Y direction */ +} SDL_JoyBallEvent; + +/* Joystick hat position change event structure */ +typedef struct SDL_JoyHatEvent { + Uint8 type; /* SDL_JOYHATMOTION */ + Uint8 which; /* The joystick device index */ + Uint8 hat; /* The joystick hat index */ + Uint8 value; /* The hat position value: + SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP + SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT + SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN + Note that zero means the POV is centered. + */ +} SDL_JoyHatEvent; + +/* Joystick button event structure */ +typedef struct SDL_JoyButtonEvent { + Uint8 type; /* SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */ + Uint8 which; /* The joystick device index */ + Uint8 button; /* The joystick button index */ + Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ +} SDL_JoyButtonEvent; + +/* The "window resized" event + When you get this event, you are responsible for setting a new video + mode with the new width and height. + */ +typedef struct SDL_ResizeEvent { + Uint8 type; /* SDL_VIDEORESIZE */ + int w; /* New width */ + int h; /* New height */ +} SDL_ResizeEvent; + +/* The "screen redraw" event */ +typedef struct SDL_ExposeEvent { + Uint8 type; /* SDL_VIDEOEXPOSE */ +} SDL_ExposeEvent; + +/* The "quit requested" event */ +typedef struct SDL_QuitEvent { + Uint8 type; /* SDL_QUIT */ +} SDL_QuitEvent; + +/* A user-defined event type */ +typedef struct SDL_UserEvent { + Uint8 type; /* SDL_USEREVENT through SDL_NUMEVENTS-1 */ + int code; /* User defined event code */ + void *data1; /* User defined data pointer */ + void *data2; /* User defined data pointer */ +} SDL_UserEvent; + +/* If you want to use this event, you should include SDL_syswm.h */ +struct SDL_SysWMmsg; +typedef struct SDL_SysWMmsg SDL_SysWMmsg; +typedef struct SDL_SysWMEvent { + Uint8 type; + SDL_SysWMmsg *msg; +} SDL_SysWMEvent; + +/* General event structure */ +typedef union SDL_Event { + Uint8 type; + SDL_ActiveEvent active; + SDL_KeyboardEvent key; + SDL_MouseMotionEvent motion; + SDL_MouseButtonEvent button; + SDL_JoyAxisEvent jaxis; + SDL_JoyBallEvent jball; + SDL_JoyHatEvent jhat; + SDL_JoyButtonEvent jbutton; + SDL_ResizeEvent resize; + SDL_ExposeEvent expose; + SDL_QuitEvent quit; + SDL_UserEvent user; + SDL_SysWMEvent syswm; +} SDL_Event; + + +/* Function prototypes */ + +/* Pumps the event loop, gathering events from the input devices. + This function updates the event queue and internal input device state. + This should only be run in the thread that sets the video mode. +*/ +extern DECLSPEC void SDLCALL SDL_PumpEvents(void); + +/* Checks the event queue for messages and optionally returns them. + If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to + the back of the event queue. + If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front + of the event queue, matching 'mask', will be returned and will not + be removed from the queue. + If 'action' is SDL_GETEVENT, up to 'numevents' events at the front + of the event queue, matching 'mask', will be returned and will be + removed from the queue. + This function returns the number of events actually stored, or -1 + if there was an error. This function is thread-safe. +*/ +typedef enum { + SDL_ADDEVENT, + SDL_PEEKEVENT, + SDL_GETEVENT +} SDL_eventaction; +/* */ +extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, + SDL_eventaction action, Uint32 mask); + +/* Polls for currently pending events, and returns 1 if there are any pending + events, or 0 if there are none available. If 'event' is not NULL, the next + event is removed from the queue and stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event); + +/* Waits indefinitely for the next available event, returning 1, or 0 if there + was an error while waiting for events. If 'event' is not NULL, the next + event is removed from the queue and stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event); + +/* Add an event to the event queue. + This function returns 0 on success, or -1 if the event queue was full + or there was some other error. + */ +extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event); + +/* + This function sets up a filter to process all events before they + change internal state and are posted to the internal event queue. + + The filter is protypted as: +*/ +typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); +/* + If the filter returns 1, then the event will be added to the internal queue. + If it returns 0, then the event will be dropped from the queue, but the + internal state will still be updated. This allows selective filtering of + dynamically arriving events. + + WARNING: Be very careful of what you do in the event filter function, as + it may run in a different thread! + + There is one caveat when dealing with the SDL_QUITEVENT event type. The + event filter is only called when the window manager desires to close the + application window. If the event filter returns 1, then the window will + be closed, otherwise the window will remain open if possible. + If the quit event is generated by an interrupt signal, it will bypass the + internal queue and be delivered to the application at the next event poll. +*/ +extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter); + +/* + Return the current event filter - can be used to "chain" filters. + If there is no event filter set, this function returns NULL. +*/ +extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void); + +/* + This function allows you to set the state of processing certain events. + If 'state' is set to SDL_IGNORE, that event will be automatically dropped + from the event queue and will not event be filtered. + If 'state' is set to SDL_ENABLE, that event will be processed normally. + If 'state' is set to SDL_QUERY, SDL_EventState() will return the + current processing state of the specified event. +*/ +#define SDL_QUERY -1 +#define SDL_IGNORE 0 +#define SDL_DISABLE 0 +#define SDL_ENABLE 1 +extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_events_h */ diff --git a/Sources/External/SDL12/SDL_getenv.h b/Sources/External/SDL12/SDL_getenv.h new file mode 100644 index 0000000..853b9ce --- /dev/null +++ b/Sources/External/SDL12/SDL_getenv.h @@ -0,0 +1,24 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* DEPRECATED */ +#include "SDL_stdinc.h" diff --git a/Sources/External/SDL12/SDL_joystick.h b/Sources/External/SDL12/SDL_joystick.h new file mode 100644 index 0000000..e4f72f1 --- /dev/null +++ b/Sources/External/SDL12/SDL_joystick.h @@ -0,0 +1,167 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Include file for SDL joystick event handling */ + +#ifndef _SDL_joystick_h +#define _SDL_joystick_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* In order to use these functions, SDL_Init() must have been called + with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + for joysticks, and load appropriate drivers. +*/ + +/* The joystick structure used to identify an SDL joystick */ +struct _SDL_Joystick; +typedef struct _SDL_Joystick SDL_Joystick; + + +/* Function prototypes */ +/* + * Count the number of joysticks attached to the system + */ +extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); + +/* + * Get the implementation dependent name of a joystick. + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index); + +/* + * Open a joystick for use - the index passed as an argument refers to + * the N'th joystick on the system. This index is the value which will + * identify this joystick in future joystick events. + * + * This function returns a joystick identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Joystick * SDLCALL SDL_JoystickOpen(int device_index); + +/* + * Returns 1 if the joystick has been opened, or 0 if it has not. + */ +extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index); + +/* + * Get the device index of an opened joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick); + +/* + * Get the number of general axis controls on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick); + +/* + * Get the number of trackballs on a joystick + * Joystick trackballs have only relative motion events associated + * with them and their state cannot be polled. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick); + +/* + * Get the number of POV hats on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick); + +/* + * Get the number of buttons on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick); + +/* + * Update the current state of the open joysticks. + * This is called automatically by the event loop if any joystick + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); + +/* + * Enable/disable joystick event polling. + * If joystick events are disabled, you must call SDL_JoystickUpdate() + * yourself and check the state of the joystick when you want joystick + * information. + * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); + +/* + * Get the current state of an axis control on a joystick + * The state is a value ranging from -32768 to 32767. + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis); + +/* + * Get the current state of a POV hat on a joystick + * The return value is one of the following positions: + */ +#define SDL_HAT_CENTERED 0x00 +#define SDL_HAT_UP 0x01 +#define SDL_HAT_RIGHT 0x02 +#define SDL_HAT_DOWN 0x04 +#define SDL_HAT_LEFT 0x08 +#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) +#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) +#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) +#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) +/* + * The hat indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat); + +/* + * Get the ball axis change since the last poll + * This returns 0, or -1 if you passed it invalid parameters. + * The ball indices start at index 0. + */ +extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); + +/* + * Get the current state of a button on a joystick + * The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button); + +/* + * Close a joystick previously opened with SDL_JoystickOpen() + */ +extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_joystick_h */ diff --git a/Sources/External/SDL12/SDL_keyboard.h b/Sources/External/SDL12/SDL_keyboard.h new file mode 100644 index 0000000..1ad7dca --- /dev/null +++ b/Sources/External/SDL12/SDL_keyboard.h @@ -0,0 +1,121 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Include file for SDL keyboard event handling */ + +#ifndef _SDL_keyboard_h +#define _SDL_keyboard_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_keysym.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Keysym structure + - The scancode is hardware dependent, and should not be used by general + applications. If no hardware scancode is available, it will be 0. + + - The 'unicode' translated character is only available when character + translation is enabled by the SDL_EnableUNICODE() API. If non-zero, + this is a UNICODE character corresponding to the keypress. If the + high 9 bits of the character are 0, then this maps to the equivalent + ASCII character: + char ch; + if ( (keysym.unicode & 0xFF80) == 0 ) { + ch = keysym.unicode & 0x7F; + } else { + An international character.. + } + */ +typedef struct SDL_keysym { + Uint8 scancode; /* hardware specific scancode */ + SDLKey sym; /* SDL virtual keysym */ + SDLMod mod; /* current key modifiers */ + Uint16 unicode; /* translated character */ +} SDL_keysym; + +/* This is the mask which refers to all hotkey bindings */ +#define SDL_ALL_HOTKEYS 0xFFFFFFFF + +/* Function prototypes */ +/* + * Enable/Disable UNICODE translation of keyboard input. + * This translation has some overhead, so translation defaults off. + * If 'enable' is 1, translation is enabled. + * If 'enable' is 0, translation is disabled. + * If 'enable' is -1, the translation state is not changed. + * It returns the previous state of keyboard translation. + */ +extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); + +/* + * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. + * 'delay' is the initial delay in ms between the time when a key is + * pressed, and keyboard repeat begins. + * 'interval' is the time in ms between keyboard repeat events. + */ +#define SDL_DEFAULT_REPEAT_DELAY 500 +#define SDL_DEFAULT_REPEAT_INTERVAL 30 +/* + * If 'delay' is set to 0, keyboard repeat is disabled. + */ +extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); +extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); + +/* + * Get a snapshot of the current state of the keyboard. + * Returns an array of keystates, indexed by the SDLK_* syms. + * Used: + * Uint8 *keystate = SDL_GetKeyState(NULL); + * if ( keystate[SDLK_RETURN] ) ... is pressed. + */ +extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys); + +/* + * Get the current key modifier state + */ +extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); + +/* + * Set the current key modifier state + * This does not change the keyboard state, only the key modifier flags. + */ +extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); + +/* + * Get the name of an SDL virtual keysym + */ +extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_keyboard_h */ diff --git a/Sources/External/SDL12/SDL_keysym.h b/Sources/External/SDL12/SDL_keysym.h new file mode 100644 index 0000000..ff44a03 --- /dev/null +++ b/Sources/External/SDL12/SDL_keysym.h @@ -0,0 +1,311 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_keysym_h +#define _SDL_keysym_h + +/* What we really want is a mapping of every raw key on the keyboard. + To support international keyboards, we use the range 0xA1 - 0xFF + as international virtual keycodes. We'll follow in the footsteps of X11... + The names of the keys + */ + +typedef enum { + /* The keyboard syms have been cleverly chosen to map to ASCII */ + SDLK_UNKNOWN = 0, + SDLK_FIRST = 0, + SDLK_BACKSPACE = 8, + SDLK_TAB = 9, + SDLK_CLEAR = 12, + SDLK_RETURN = 13, + SDLK_PAUSE = 19, + SDLK_ESCAPE = 27, + SDLK_SPACE = 32, + SDLK_EXCLAIM = 33, + SDLK_QUOTEDBL = 34, + SDLK_HASH = 35, + SDLK_DOLLAR = 36, + SDLK_AMPERSAND = 38, + SDLK_QUOTE = 39, + SDLK_LEFTPAREN = 40, + SDLK_RIGHTPAREN = 41, + SDLK_ASTERISK = 42, + SDLK_PLUS = 43, + SDLK_COMMA = 44, + SDLK_MINUS = 45, + SDLK_PERIOD = 46, + SDLK_SLASH = 47, + SDLK_0 = 48, + SDLK_1 = 49, + SDLK_2 = 50, + SDLK_3 = 51, + SDLK_4 = 52, + SDLK_5 = 53, + SDLK_6 = 54, + SDLK_7 = 55, + SDLK_8 = 56, + SDLK_9 = 57, + SDLK_COLON = 58, + SDLK_SEMICOLON = 59, + SDLK_LESS = 60, + SDLK_EQUALS = 61, + SDLK_GREATER = 62, + SDLK_QUESTION = 63, + SDLK_AT = 64, + /* + Skip uppercase letters + */ + SDLK_LEFTBRACKET = 91, + SDLK_BACKSLASH = 92, + SDLK_RIGHTBRACKET = 93, + SDLK_CARET = 94, + SDLK_UNDERSCORE = 95, + SDLK_BACKQUOTE = 96, + SDLK_a = 97, + SDLK_b = 98, + SDLK_c = 99, + SDLK_d = 100, + SDLK_e = 101, + SDLK_f = 102, + SDLK_g = 103, + SDLK_h = 104, + SDLK_i = 105, + SDLK_j = 106, + SDLK_k = 107, + SDLK_l = 108, + SDLK_m = 109, + SDLK_n = 110, + SDLK_o = 111, + SDLK_p = 112, + SDLK_q = 113, + SDLK_r = 114, + SDLK_s = 115, + SDLK_t = 116, + SDLK_u = 117, + SDLK_v = 118, + SDLK_w = 119, + SDLK_x = 120, + SDLK_y = 121, + SDLK_z = 122, + SDLK_DELETE = 127, + /* End of ASCII mapped keysyms */ + + /* International keyboard syms */ + SDLK_WORLD_0 = 160, /* 0xA0 */ + SDLK_WORLD_1 = 161, + SDLK_WORLD_2 = 162, + SDLK_WORLD_3 = 163, + SDLK_WORLD_4 = 164, + SDLK_WORLD_5 = 165, + SDLK_WORLD_6 = 166, + SDLK_WORLD_7 = 167, + SDLK_WORLD_8 = 168, + SDLK_WORLD_9 = 169, + SDLK_WORLD_10 = 170, + SDLK_WORLD_11 = 171, + SDLK_WORLD_12 = 172, + SDLK_WORLD_13 = 173, + SDLK_WORLD_14 = 174, + SDLK_WORLD_15 = 175, + SDLK_WORLD_16 = 176, + SDLK_WORLD_17 = 177, + SDLK_WORLD_18 = 178, + SDLK_WORLD_19 = 179, + SDLK_WORLD_20 = 180, + SDLK_WORLD_21 = 181, + SDLK_WORLD_22 = 182, + SDLK_WORLD_23 = 183, + SDLK_WORLD_24 = 184, + SDLK_WORLD_25 = 185, + SDLK_WORLD_26 = 186, + SDLK_WORLD_27 = 187, + SDLK_WORLD_28 = 188, + SDLK_WORLD_29 = 189, + SDLK_WORLD_30 = 190, + SDLK_WORLD_31 = 191, + SDLK_WORLD_32 = 192, + SDLK_WORLD_33 = 193, + SDLK_WORLD_34 = 194, + SDLK_WORLD_35 = 195, + SDLK_WORLD_36 = 196, + SDLK_WORLD_37 = 197, + SDLK_WORLD_38 = 198, + SDLK_WORLD_39 = 199, + SDLK_WORLD_40 = 200, + SDLK_WORLD_41 = 201, + SDLK_WORLD_42 = 202, + SDLK_WORLD_43 = 203, + SDLK_WORLD_44 = 204, + SDLK_WORLD_45 = 205, + SDLK_WORLD_46 = 206, + SDLK_WORLD_47 = 207, + SDLK_WORLD_48 = 208, + SDLK_WORLD_49 = 209, + SDLK_WORLD_50 = 210, + SDLK_WORLD_51 = 211, + SDLK_WORLD_52 = 212, + SDLK_WORLD_53 = 213, + SDLK_WORLD_54 = 214, + SDLK_WORLD_55 = 215, + SDLK_WORLD_56 = 216, + SDLK_WORLD_57 = 217, + SDLK_WORLD_58 = 218, + SDLK_WORLD_59 = 219, + SDLK_WORLD_60 = 220, + SDLK_WORLD_61 = 221, + SDLK_WORLD_62 = 222, + SDLK_WORLD_63 = 223, + SDLK_WORLD_64 = 224, + SDLK_WORLD_65 = 225, + SDLK_WORLD_66 = 226, + SDLK_WORLD_67 = 227, + SDLK_WORLD_68 = 228, + SDLK_WORLD_69 = 229, + SDLK_WORLD_70 = 230, + SDLK_WORLD_71 = 231, + SDLK_WORLD_72 = 232, + SDLK_WORLD_73 = 233, + SDLK_WORLD_74 = 234, + SDLK_WORLD_75 = 235, + SDLK_WORLD_76 = 236, + SDLK_WORLD_77 = 237, + SDLK_WORLD_78 = 238, + SDLK_WORLD_79 = 239, + SDLK_WORLD_80 = 240, + SDLK_WORLD_81 = 241, + SDLK_WORLD_82 = 242, + SDLK_WORLD_83 = 243, + SDLK_WORLD_84 = 244, + SDLK_WORLD_85 = 245, + SDLK_WORLD_86 = 246, + SDLK_WORLD_87 = 247, + SDLK_WORLD_88 = 248, + SDLK_WORLD_89 = 249, + SDLK_WORLD_90 = 250, + SDLK_WORLD_91 = 251, + SDLK_WORLD_92 = 252, + SDLK_WORLD_93 = 253, + SDLK_WORLD_94 = 254, + SDLK_WORLD_95 = 255, /* 0xFF */ + + /* Numeric keypad */ + SDLK_KP0 = 256, + SDLK_KP1 = 257, + SDLK_KP2 = 258, + SDLK_KP3 = 259, + SDLK_KP4 = 260, + SDLK_KP5 = 261, + SDLK_KP6 = 262, + SDLK_KP7 = 263, + SDLK_KP8 = 264, + SDLK_KP9 = 265, + SDLK_KP_PERIOD = 266, + SDLK_KP_DIVIDE = 267, + SDLK_KP_MULTIPLY = 268, + SDLK_KP_MINUS = 269, + SDLK_KP_PLUS = 270, + SDLK_KP_ENTER = 271, + SDLK_KP_EQUALS = 272, + + /* Arrows + Home/End pad */ + SDLK_UP = 273, + SDLK_DOWN = 274, + SDLK_RIGHT = 275, + SDLK_LEFT = 276, + SDLK_INSERT = 277, + SDLK_HOME = 278, + SDLK_END = 279, + SDLK_PAGEUP = 280, + SDLK_PAGEDOWN = 281, + + /* Function keys */ + SDLK_F1 = 282, + SDLK_F2 = 283, + SDLK_F3 = 284, + SDLK_F4 = 285, + SDLK_F5 = 286, + SDLK_F6 = 287, + SDLK_F7 = 288, + SDLK_F8 = 289, + SDLK_F9 = 290, + SDLK_F10 = 291, + SDLK_F11 = 292, + SDLK_F12 = 293, + SDLK_F13 = 294, + SDLK_F14 = 295, + SDLK_F15 = 296, + + /* Key state modifier keys */ + SDLK_NUMLOCK = 300, + SDLK_CAPSLOCK = 301, + SDLK_SCROLLOCK = 302, + SDLK_RSHIFT = 303, + SDLK_LSHIFT = 304, + SDLK_RCTRL = 305, + SDLK_LCTRL = 306, + SDLK_RALT = 307, + SDLK_LALT = 308, + SDLK_RMETA = 309, + SDLK_LMETA = 310, + SDLK_LSUPER = 311, /* Left "Windows" key */ + SDLK_RSUPER = 312, /* Right "Windows" key */ + SDLK_MODE = 313, /* "Alt Gr" key */ + SDLK_COMPOSE = 314, /* Multi-key compose key */ + + /* Miscellaneous function keys */ + SDLK_HELP = 315, + SDLK_PRINT = 316, + SDLK_SYSREQ = 317, + SDLK_BREAK = 318, + SDLK_MENU = 319, + SDLK_POWER = 320, /* Power Macintosh power key */ + SDLK_EURO = 321, /* Some european keyboards */ + SDLK_UNDO = 322, /* Atari keyboard has Undo */ + + /* Add any other keys here */ + + SDLK_LAST +} SDLKey; + +/* Enumeration of valid key mods (possibly OR'd together) */ +typedef enum { + KMOD_NONE = 0x0000, + KMOD_LSHIFT= 0x0001, + KMOD_RSHIFT= 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LMETA = 0x0400, + KMOD_RMETA = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000 +} SDLMod; + +#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) +#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) +#define KMOD_ALT (KMOD_LALT|KMOD_RALT) +#define KMOD_META (KMOD_LMETA|KMOD_RMETA) + +#endif /* _SDL_keysym_h */ diff --git a/Sources/External/SDL12/SDL_loadso.h b/Sources/External/SDL12/SDL_loadso.h new file mode 100644 index 0000000..ce96449 --- /dev/null +++ b/Sources/External/SDL12/SDL_loadso.h @@ -0,0 +1,74 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent library loading routines */ + +/* Some things to keep in mind: + - These functions only work on C function names. Other languages may + have name mangling and intrinsic language support that varies from + compiler to compiler. + - Make sure you declare your function pointers with the same calling + convention as the actual library function. Your code will crash + mysteriously if you do not do this. + - Avoid namespace collisions. If you load a symbol from the library, + it is not defined whether or not it goes into the global symbol + namespace for the application. If it does and it conflicts with + symbols in your code or other shared libraries, you will not get + the results you expect. :) +*/ + + +#ifndef _SDL_loadso_h +#define _SDL_loadso_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This function dynamically loads a shared object and returns a pointer + * to the object handle (or NULL if there was an error). + * The 'sofile' parameter is a system dependent name of the object file. + */ +extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile); + +/* Given an object handle, this function looks up the address of the + * named function in the shared object and returns it. This address + * is no longer valid after calling SDL_UnloadObject(). + */ +extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name); + +/* Unload a shared object from memory */ +extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_loadso_h */ diff --git a/Sources/External/SDL12/SDL_main.h b/Sources/External/SDL12/SDL_main.h new file mode 100644 index 0000000..cf8b728 --- /dev/null +++ b/Sources/External/SDL12/SDL_main.h @@ -0,0 +1,98 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_main_h +#define _SDL_main_h + +#include "SDL_stdinc.h" + +/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */ + +#if defined(__WIN32__) || \ + (defined(__MWERKS__) && !defined(__BEOS__)) || \ + defined(__MACOS__) || defined(__MACOSX__) || \ + defined(__SYMBIAN32__) || defined(QWS) + +#ifdef __cplusplus +#define C_LINKAGE "C" +#else +#define C_LINKAGE +#endif /* __cplusplus */ + +/* The application's main() function must be called with C linkage, + and should be declared like this: +#ifdef __cplusplus +extern "C" +#endif + int main(int argc, char *argv[]) + { + } + */ +#define main SDL_main + +/* The prototype for the application's main() function */ +extern C_LINKAGE int SDL_main(int argc, char *argv[]); + + +/* From the SDL library code -- needed for registering the app on Win32 */ +#ifdef __WIN32__ + +#include "begin_code.h" +#ifdef __cplusplus +extern "C" { +#endif + +/* This should be called from your WinMain() function, if any */ +extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); +/* This can also be called, but is no longer necessary */ +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); +/* This can also be called, but is no longer necessary (SDL_Quit calls it) */ +extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); +#ifdef __cplusplus +} +#endif +#include "close_code.h" +#endif + +/* From the SDL library code -- needed for registering QuickDraw on MacOS */ +#if defined(__MACOS__) + +#include "begin_code.h" +#ifdef __cplusplus +extern "C" { +#endif + +/* Forward declaration so we don't need to include QuickDraw.h */ +struct QDGlobals; + +/* This should be called from your main() function, if any */ +extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" +#endif + +#endif /* Need to redefine main()? */ + +#endif /* _SDL_main_h */ diff --git a/Sources/External/SDL12/SDL_mouse.h b/Sources/External/SDL12/SDL_mouse.h new file mode 100644 index 0000000..019497f --- /dev/null +++ b/Sources/External/SDL12/SDL_mouse.h @@ -0,0 +1,140 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Include file for SDL mouse event handling */ + +#ifndef _SDL_mouse_h +#define _SDL_mouse_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct WMcursor WMcursor; /* Implementation dependent */ +typedef struct SDL_Cursor { + SDL_Rect area; /* The area of the mouse cursor */ + Sint16 hot_x, hot_y; /* The "tip" of the cursor */ + Uint8 *data; /* B/W cursor data */ + Uint8 *mask; /* B/W cursor mask */ + Uint8 *save[2]; /* Place to save cursor area */ + WMcursor *wm_cursor; /* Window-manager cursor */ +} SDL_Cursor; + +/* Function prototypes */ +/* + * Retrieve the current state of the mouse. + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * current mouse cursor position. You can pass NULL for either x or y. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); + +/* + * Retrieve the current state of the mouse. + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse deltas since the last call to SDL_GetRelativeMouseState(). + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); + +/* + * Set the position of the mouse cursor (generates a mouse motion event) + */ +extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y); + +/* + * Create a cursor using the specified data and mask (in MSB format). + * The cursor width must be a multiple of 8 bits. + * + * The cursor is created in black and white according to the following: + * data mask resulting pixel on screen + * 0 1 White + * 1 1 Black + * 0 0 Transparent + * 1 0 Inverted color if possible, black if not. + * + * Cursors created with this function must be freed with SDL_FreeCursor(). + */ +extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor + (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); + +/* + * Set the currently active cursor to the specified one. + * If the cursor is currently visible, the change will be immediately + * represented on the display. + */ +extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor); + +/* + * Returns the currently active cursor. + */ +extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void); + +/* + * Deallocates a cursor created with SDL_CreateCursor(). + */ +extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor); + +/* + * Toggle whether or not the cursor is shown on the screen. + * The cursor start off displayed, but can be turned off. + * SDL_ShowCursor() returns 1 if the cursor was being displayed + * before the call, or 0 if it was not. You can query the current + * state by passing a 'toggle' value of -1. + */ +extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); + +/* Used as a mask when testing buttons in buttonstate + Button 1: Left mouse button + Button 2: Middle mouse button + Button 3: Right mouse button + Button 4: Mouse wheel up (may also be a real button) + Button 5: Mouse wheel down (may also be a real button) + */ +#define SDL_BUTTON(X) (1 << ((X)-1)) +#define SDL_BUTTON_LEFT 1 +#define SDL_BUTTON_MIDDLE 2 +#define SDL_BUTTON_RIGHT 3 +#define SDL_BUTTON_WHEELUP 4 +#define SDL_BUTTON_WHEELDOWN 5 +#define SDL_BUTTON_X1 6 +#define SDL_BUTTON_X2 7 +#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) +#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) +#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) +#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) +#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mouse_h */ diff --git a/Sources/External/SDL12/SDL_mutex.h b/Sources/External/SDL12/SDL_mutex.h new file mode 100644 index 0000000..0016528 --- /dev/null +++ b/Sources/External/SDL12/SDL_mutex.h @@ -0,0 +1,162 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_mutex_h +#define _SDL_mutex_h + +/* Functions to provide thread synchronization primitives + + These are independent of the other SDL routines. +*/ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Synchronization functions which can time out return this value + if they time out. +*/ +#define SDL_MUTEX_TIMEDOUT 1 + +/* This is the timeout value which corresponds to never time out */ +#define SDL_MUTEX_MAXWAIT (~(Uint32)0) + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* Mutex functions */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* The SDL mutex structure, defined in SDL_mutex.c */ +struct SDL_mutex; +typedef struct SDL_mutex SDL_mutex; + +/* Create a mutex, initialized unlocked */ +extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void); + +/* Lock the mutex (Returns 0, or -1 on error) */ +#define SDL_LockMutex(m) SDL_mutexP(m) +extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex); + +/* Unlock the mutex (Returns 0, or -1 on error) + It is an error to unlock a mutex that has not been locked by + the current thread, and doing so results in undefined behavior. + */ +#define SDL_UnlockMutex(m) SDL_mutexV(m) +extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex); + +/* Destroy a mutex */ +extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* Semaphore functions */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* The SDL semaphore structure, defined in SDL_sem.c */ +struct SDL_semaphore; +typedef struct SDL_semaphore SDL_sem; + +/* Create a semaphore, initialized with value, returns NULL on failure. */ +extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); + +/* Destroy a semaphore */ +extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); + +/* This function suspends the calling thread until the semaphore pointed + * to by sem has a positive count. It then atomically decreases the semaphore + * count. + */ +extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); + +/* Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds, + SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. +*/ +extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); + +/* Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if + the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in + the allotted time, and -1 on error. + On some platforms this function is implemented by looping with a delay + of 1 ms, and so should be avoided if possible. +*/ +extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms); + +/* Atomically increases the semaphore's count (not blocking), returns 0, + or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); + +/* Returns the current count of the semaphore */ +extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* Condition variable functions */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* The SDL condition variable structure, defined in SDL_cond.c */ +struct SDL_cond; +typedef struct SDL_cond SDL_cond; + +/* Create a condition variable */ +extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void); + +/* Destroy a condition variable */ +extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); + +/* Restart one of the threads that are waiting on the condition variable, + returns 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); + +/* Restart all threads that are waiting on the condition variable, + returns 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); + +/* Wait on the condition variable, unlocking the provided mutex. + The mutex must be locked before entering this function! + The mutex is re-locked once the condition variable is signaled. + Returns 0 when it is signaled, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut); + +/* Waits for at most 'ms' milliseconds, and returns 0 if the condition + variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not + signaled in the allotted time, and -1 on error. + On some platforms this function is implemented by looping with a delay + of 1 ms, and so should be avoided if possible. +*/ +extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mutex_h */ diff --git a/Sources/External/SDL12/SDL_name.h b/Sources/External/SDL12/SDL_name.h new file mode 100644 index 0000000..511619a --- /dev/null +++ b/Sources/External/SDL12/SDL_name.h @@ -0,0 +1,11 @@ + +#ifndef _SDLname_h_ +#define _SDLname_h_ + +#if defined(__STDC__) || defined(__cplusplus) +#define NeedFunctionPrototypes 1 +#endif + +#define SDL_NAME(X) SDL_##X + +#endif /* _SDLname_h_ */ diff --git a/Sources/External/SDL12/SDL_opengl.h b/Sources/External/SDL12/SDL_opengl.h new file mode 100644 index 0000000..36c0a30 --- /dev/null +++ b/Sources/External/SDL12/SDL_opengl.h @@ -0,0 +1,6551 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* This is a simple file to encapsulate the OpenGL API headers */ + +#include "SDL_config.h" + +#ifdef __WIN32__ +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +#define NOMINMAX /* Don't defined min() and max() */ +#endif +#include +#endif +#ifndef NO_SDL_GLEXT +#define __glext_h_ /* Don't let gl.h include glext.h */ +#endif +#if defined(__MACOSX__) +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#elif defined(__MACOS__) +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#else +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#endif +#ifndef NO_SDL_GLEXT +#undef __glext_h_ +#endif + +/* This file taken from "GLext.h" from the Jeff Molofee OpenGL tutorials. + It is included here because glext.h is not available on some systems. + If you don't want this version included, simply define "NO_SDL_GLEXT" + */ +#ifndef NO_SDL_GLEXT +#if !defined(__glext_h_) && !defined(GL_GLEXT_LEGACY) +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated 2005/06/20 */ +/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ +#define GL_GLEXT_VERSION 29 + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; /* native character */ +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for handling shader object handles and program/shader text */ +typedef char GLcharARB; /* native character */ +typedef unsigned int GLhandleARB; /* shader object handle */ +#endif + +/* GL types for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendEquation (GLenum); +GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogram (GLenum); +GLAPI void APIENTRY glResetMinmax (GLenum); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glClientActiveTexture (GLenum); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameteri (GLenum, GLint); +GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); +GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos2i (GLint, GLint); +GLAPI void APIENTRY glWindowPos2iv (const GLint *); +GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *); +GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3iv (const GLint *); +GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQuery (GLuint); +GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); +GLAPI void APIENTRY glEndQuery (GLenum); +GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); +GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint); +GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); +GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); +GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); +GLAPI void APIENTRY glAttachShader (GLuint, GLuint); +GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); +GLAPI void APIENTRY glCompileShader (GLuint); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum); +GLAPI void APIENTRY glDeleteProgram (GLuint); +GLAPI void APIENTRY glDeleteShader (GLuint); +GLAPI void APIENTRY glDetachShader (GLuint, GLuint); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); +GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgram (GLuint); +GLAPI GLboolean APIENTRY glIsShader (GLuint); +GLAPI void APIENTRY glLinkProgram (GLuint); +GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); +GLAPI void APIENTRY glUseProgram (GLuint); +GLAPI void APIENTRY glUniform1f (GLint, GLfloat); +GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1i (GLint, GLint); +GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glValidateProgram (GLuint); +GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); +GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); +GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); +GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); +GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); +GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexBlendARB (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); +GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); +GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); +GLAPI void APIENTRY glEndQueryARB (GLenum); +GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); +GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); +GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1iARB (GLint, GLint); +GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogramEXT (GLenum); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_EXT_color_matrix +#define GL_EXT_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint); +GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); +GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); +GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +GLAPI void APIENTRY glDeformSGIX (GLbitfield); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); +GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); +GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum); +GLAPI void APIENTRY glTextureLightEXT (GLenum); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); +GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); +GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); +GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); +GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *); +GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); +GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); +GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); +GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); +GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFinishFenceNV (GLuint); +GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); +GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); +GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); +GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); +GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); +GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); +GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); +GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); +GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif +#endif /* NO_SDL_GLEXT */ diff --git a/Sources/External/SDL12/SDL_platform.h b/Sources/External/SDL12/SDL_platform.h new file mode 100644 index 0000000..1bfee29 --- /dev/null +++ b/Sources/External/SDL12/SDL_platform.h @@ -0,0 +1,100 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Try to get a standard set of platform defines */ + +#ifndef _SDL_platform_h +#define _SDL_platform_h + +#if defined(_AIX) +#undef __AIX__ +#define __AIX__ 1 +#endif +#if defined(__BEOS__) +#undef __BEOS__ +#define __BEOS__ 1 +#endif +#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) +#undef __BSDI__ +#define __BSDI__ 1 +#endif +#if defined(_arch_dreamcast) +#undef __DREAMCAST__ +#define __DREAMCAST__ 1 +#endif +#if defined(__FreeBSD__) || defined(__DragonFly__) +#undef __FREEBSD__ +#define __FREEBSD__ 1 +#endif +#if defined(hpux) || defined(__hpux) || defined(__hpux__) +#undef __HPUX__ +#define __HPUX__ 1 +#endif +#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) +#undef __IRIX__ +#define __IRIX__ 1 +#endif +#if defined(linux) || defined(__linux) || defined(__linux__) +#undef __LINUX__ +#define __LINUX__ 1 +#endif +#if defined(__APPLE__) +#undef __MACOSX__ +#define __MACOSX__ 1 +#elif defined(macintosh) +#undef __MACOS__ +#define __MACOS__ 1 +#endif +#if defined(__NetBSD__) +#undef __NETBSD__ +#define __NETBSD__ 1 +#endif +#if defined(__OpenBSD__) +#undef __OPENBSD__ +#define __OPENBSD__ 1 +#endif +#if defined(__OS2__) +#undef __OS2__ +#define __OS2__ 1 +#endif +#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) +#undef __OSF__ +#define __OSF__ 1 +#endif +#if defined(__QNXNTO__) +#undef __QNXNTO__ +#define __QNXNTO__ 1 +#endif +#if defined(riscos) || defined(__riscos) || defined(__riscos__) +#undef __RISCOS__ +#define __RISCOS__ 1 +#endif +#if defined(__SVR4) +#undef __SOLARIS__ +#define __SOLARIS__ 1 +#endif +#if defined(WIN32) || defined(_WIN32) +#undef __WIN32__ +#define __WIN32__ 1 +#endif + +#endif /* _SDL_platform_h */ diff --git a/Sources/External/SDL12/SDL_quit.h b/Sources/External/SDL12/SDL_quit.h new file mode 100644 index 0000000..fcf40fb --- /dev/null +++ b/Sources/External/SDL12/SDL_quit.h @@ -0,0 +1,50 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Include file for SDL quit event handling */ + +#ifndef _SDL_quit_h +#define _SDL_quit_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/* + An SDL_QUITEVENT is generated when the user tries to close the application + window. If it is ignored or filtered out, the window will remain open. + If it is not ignored or filtered, it is queued normally and the window + is allowed to close. When the window is closed, screen updates will + complete, but have no effect. + + SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) + and SIGTERM (system termination request), if handlers do not already + exist, that generate SDL_QUITEVENT events as well. There is no way + to determine the cause of an SDL_QUITEVENT, but setting a signal + handler in your application will override the default generation of + quit events for that signal. +*/ + +/* There are no functions directly affecting the quit event */ +#define SDL_QuitRequested() \ + (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK)) + +#endif /* _SDL_quit_h */ diff --git a/Sources/External/SDL12/SDL_rwops.h b/Sources/External/SDL12/SDL_rwops.h new file mode 100644 index 0000000..8c17701 --- /dev/null +++ b/Sources/External/SDL12/SDL_rwops.h @@ -0,0 +1,144 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* This file provides a general interface for SDL to read and write + data sources. It can easily be extended to files, memory, etc. +*/ + +#ifndef _SDL_rwops_h +#define _SDL_rwops_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is the read/write operation structure -- very basic */ + +typedef struct SDL_RWops { + /* Seek to 'offset' relative to whence, one of stdio's whence values: + SEEK_SET, SEEK_CUR, SEEK_END + Returns the final offset in the data source. + */ + int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence); + + /* Read up to 'num' objects each of size 'objsize' from the data + source to the area pointed at by 'ptr'. + Returns the number of objects read, or -1 if the read failed. + */ + int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum); + + /* Write exactly 'num' objects each of size 'objsize' from the area + pointed at by 'ptr' to data source. + Returns 'num', or -1 if the write failed. + */ + int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num); + + /* Close and free an allocated SDL_FSops structure */ + int (SDLCALL *close)(struct SDL_RWops *context); + + Uint32 type; + union { +#if defined(__WIN32__) && !defined(__SYMBIAN32__) + struct { + int append; + void *h; + struct { + void *data; + int size; + int left; + } buffer; + } win32io; +#endif +#ifdef HAVE_STDIO_H + struct { + int autoclose; + FILE *fp; + } stdio; +#endif + struct { + Uint8 *base; + Uint8 *here; + Uint8 *stop; + } mem; + struct { + void *data1; + } unknown; + } hidden; + +} SDL_RWops; + + +/* Functions to create SDL_RWops structures from various data sources */ + +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode); + +#ifdef HAVE_STDIO_H +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose); +#endif + +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size); +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size); + +extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void); +extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area); + +#define RW_SEEK_SET 0 /* Seek from the beginning of data */ +#define RW_SEEK_CUR 1 /* Seek relative to current read point */ +#define RW_SEEK_END 2 /* Seek relative to the end of data */ + +/* Macros to easily read and write from an SDL_RWops structure */ +#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) +#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) +#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) +#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) +#define SDL_RWclose(ctx) (ctx)->close(ctx) + + +/* Read an item of the specified endianness and return in native format */ +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src); + +/* Write an item of native format to the specified endianness */ +extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value); +extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_rwops_h */ diff --git a/Sources/External/SDL12/SDL_stdinc.h b/Sources/External/SDL12/SDL_stdinc.h new file mode 100644 index 0000000..e47c21d --- /dev/null +++ b/Sources/External/SDL12/SDL_stdinc.h @@ -0,0 +1,596 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* This is a general header that includes C language support */ + +#ifndef _SDL_stdinc_h +#define _SDL_stdinc_h + +#include "SDL_config.h" + + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#if defined(STDC_HEADERS) +# include +# include +# include +#else +# if defined(HAVE_STDLIB_H) +# include +# elif defined(HAVE_MALLOC_H) +# include +# endif +# if defined(HAVE_STDDEF_H) +# include +# endif +# if defined(HAVE_STDARG_H) +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#if defined(HAVE_INTTYPES_H) +# include +#elif defined(HAVE_STDINT_H) +# include +#endif +#ifdef HAVE_CTYPE_H +# include +#endif +#ifdef HAVE_ICONV_H +# include +#endif + +/* The number of elements in an array */ +#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) +#define SDL_TABLESIZE(table) SDL_arraysize(table) + +/* Basic data types */ +typedef enum SDL_bool { + SDL_FALSE = 0, + SDL_TRUE = 1 +} SDL_bool; + +typedef int8_t Sint8; +typedef uint8_t Uint8; +typedef int16_t Sint16; +typedef uint16_t Uint16; +typedef int32_t Sint32; +typedef uint32_t Uint32; + +#ifdef SDL_HAS_64BIT_TYPE +typedef int64_t Sint64; +#ifndef SYMBIAN32_GCCE +typedef uint64_t Uint64; +#endif +#else +/* This is really just a hack to prevent the compiler from complaining */ +typedef struct { + Uint32 hi; + Uint32 lo; +} Uint64, Sint64; +#endif + +/* Make sure the types really have the right sizes */ +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_dummy_ ## name[(x) * 2 - 1] + +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); + +/* Check to make sure enums are the size of ints, for structure packing. + For both Watcom C/C++ and Borland C/C++ the compiler option that makes + enums having the size of an int must be enabled. + This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). +*/ +/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */ +#ifdef __MWERKS__ +#pragma enumsalwaysint on +#endif + +typedef enum { + DUMMY_ENUM_VALUE +} SDL_DUMMY_ENUM; + +#ifndef __NDS__ +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); +#endif + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_MALLOC +#define SDL_malloc malloc +#else +extern DECLSPEC void * SDLCALL SDL_malloc(size_t size); +#endif + +#ifdef HAVE_CALLOC +#define SDL_calloc calloc +#else +extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size); +#endif + +#ifdef HAVE_REALLOC +#define SDL_realloc realloc +#else +extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size); +#endif + +#ifdef HAVE_FREE +#define SDL_free free +#else +extern DECLSPEC void SDLCALL SDL_free(void *mem); +#endif + +#if defined(HAVE_ALLOCA) && !defined(alloca) +# if defined(HAVE_ALLOCA_H) +# include +# elif defined(__GNUC__) +# define alloca __builtin_alloca +# elif defined(_MSC_VER) +# include +# define alloca _alloca +# elif defined(__WATCOMC__) +# include +# elif defined(__BORLANDC__) +# include +# elif defined(__DMC__) +# include +# elif defined(__AIX__) + #pragma alloca +# elif defined(__MRC__) + void *alloca (unsigned); +# else + char *alloca (); +# endif +#endif +#ifdef HAVE_ALLOCA +#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) +#define SDL_stack_free(data) +#else +#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) +#define SDL_stack_free(data) SDL_free(data) +#endif + +#ifdef HAVE_GETENV +#define SDL_getenv getenv +#else +extern DECLSPEC char * SDLCALL SDL_getenv(const char *name); +#endif + +#ifdef HAVE_PUTENV +#define SDL_putenv putenv +#else +extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); +#endif + +#ifdef HAVE_QSORT +#define SDL_qsort qsort +#else +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, + int (*compare)(const void *, const void *)); +#endif + +#ifdef HAVE_ABS +#define SDL_abs abs +#else +#define SDL_abs(X) ((X) < 0 ? -(X) : (X)) +#endif + +#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) +#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) + +#ifdef HAVE_CTYPE_H +#define SDL_isdigit(X) isdigit(X) +#define SDL_isspace(X) isspace(X) +#define SDL_toupper(X) toupper(X) +#define SDL_tolower(X) tolower(X) +#else +#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9')) +#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n')) +#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X)) +#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X)) +#endif + +#ifdef HAVE_MEMSET +#define SDL_memset memset +#else +extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len); +#endif + +#if defined(__GNUC__) && defined(i386) +#define SDL_memset4(dst, val, len) \ +do { \ + int u0, u1, u2; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; stosl\n\t" \ + : "=&D" (u0), "=&a" (u1), "=&c" (u2) \ + : "0" (dst), "1" (val), "2" ((Uint32)(len)) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memset4 +#define SDL_memset4(dst, val, len) \ +do { \ + unsigned _count = (len); \ + unsigned _n = (_count + 3) / 4; \ + Uint32 *_p = (Uint32 *)(dst); \ + Uint32 _val = (val); \ + switch (_count % 4) { \ + case 0: do { *_p++ = _val; \ + case 3: *_p++ = _val; \ + case 2: *_p++ = _val; \ + case 1: *_p++ = _val; \ + } while ( --_n ); \ + } \ +} while(0) +#endif + +/* We can count on memcpy existing on Mac OS X and being well-tuned. */ +#if defined(__MACH__) && defined(__APPLE__) +#define SDL_memcpy(dst, src, len) memcpy(dst, src, len) +#elif defined(__GNUC__) && defined(i386) +#define SDL_memcpy(dst, src, len) \ +do { \ + int u0, u1, u2; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; movsl\n\t" \ + "testb $2,%b4\n\t" \ + "je 1f\n\t" \ + "movsw\n" \ + "1:\ttestb $1,%b4\n\t" \ + "je 2f\n\t" \ + "movsb\n" \ + "2:" \ + : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ + : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memcpy +#ifdef HAVE_MEMCPY +#define SDL_memcpy memcpy +#elif defined(HAVE_BCOPY) +#define SDL_memcpy(d, s, n) bcopy((s), (d), (n)) +#else +extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); +#endif +#endif + +/* We can count on memcpy existing on Mac OS X and being well-tuned. */ +#if defined(__MACH__) && defined(__APPLE__) +#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4) +#elif defined(__GNUC__) && defined(i386) +#define SDL_memcpy4(dst, src, len) \ +do { \ + int ecx, edi, esi; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; movsl" \ + : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ + : "0" ((unsigned)(len)), "1" (dst), "2" (src) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memcpy4 +#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2) +#endif + +#if defined(__GNUC__) && defined(i386) +#define SDL_revcpy(dst, src, len) \ +do { \ + int u0, u1, u2; \ + char *dstp = (char *)(dst); \ + char *srcp = (char *)(src); \ + int n = (len); \ + if ( n >= 4 ) { \ + __asm__ __volatile__ ( \ + "std\n\t" \ + "rep ; movsl\n\t" \ + : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ + : "0" (n >> 2), \ + "1" (dstp+(n-4)), "2" (srcp+(n-4)) \ + : "memory" ); \ + } \ + switch (n & 3) { \ + case 3: dstp[2] = srcp[2]; \ + case 2: dstp[1] = srcp[1]; \ + case 1: dstp[0] = srcp[0]; \ + break; \ + default: \ + break; \ + } \ +} while(0) +#endif +#ifndef SDL_revcpy +extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len); +#endif + +#ifdef HAVE_MEMMOVE +#define SDL_memmove memmove +#elif defined(HAVE_BCOPY) +#define SDL_memmove(d, s, n) bcopy((s), (d), (n)) +#else +#define SDL_memmove(dst, src, len) \ +do { \ + if ( dst < src ) { \ + SDL_memcpy(dst, src, len); \ + } else { \ + SDL_revcpy(dst, src, len); \ + } \ +} while(0) +#endif + +#ifdef HAVE_MEMCMP +#define SDL_memcmp memcmp +#else +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); +#endif + +#ifdef HAVE_STRLEN +#define SDL_strlen strlen +#else +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); +#endif + +#ifdef HAVE_STRLCPY +#define SDL_strlcpy strlcpy +#else +extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen); +#endif + +#ifdef HAVE_STRLCAT +#define SDL_strlcat strlcat +#else +extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen); +#endif + +#ifdef HAVE_STRDUP +#define SDL_strdup strdup +#else +extern DECLSPEC char * SDLCALL SDL_strdup(const char *string); +#endif + +#ifdef HAVE__STRREV +#define SDL_strrev _strrev +#else +extern DECLSPEC char * SDLCALL SDL_strrev(char *string); +#endif + +#ifdef HAVE__STRUPR +#define SDL_strupr _strupr +#else +extern DECLSPEC char * SDLCALL SDL_strupr(char *string); +#endif + +#ifdef HAVE__STRLWR +#define SDL_strlwr _strlwr +#else +extern DECLSPEC char * SDLCALL SDL_strlwr(char *string); +#endif + +#ifdef HAVE_STRCHR +#define SDL_strchr strchr +#elif defined(HAVE_INDEX) +#define SDL_strchr index +#else +extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c); +#endif + +#ifdef HAVE_STRRCHR +#define SDL_strrchr strrchr +#elif defined(HAVE_RINDEX) +#define SDL_strrchr rindex +#else +extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c); +#endif + +#ifdef HAVE_STRSTR +#define SDL_strstr strstr +#else +extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); +#endif + +#ifdef HAVE_ITOA +#define SDL_itoa itoa +#else +#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) +#endif + +#ifdef HAVE__LTOA +#define SDL_ltoa _ltoa +#else +extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix); +#endif + +#ifdef HAVE__UITOA +#define SDL_uitoa _uitoa +#else +#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) +#endif + +#ifdef HAVE__ULTOA +#define SDL_ultoa _ultoa +#else +extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix); +#endif + +#ifdef HAVE_STRTOL +#define SDL_strtol strtol +#else +extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base); +#endif + +#ifdef HAVE_STRTOUL +#define SDL_strtoul strtoul +#else +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base); +#endif + +#ifdef SDL_HAS_64BIT_TYPE + +#ifdef HAVE__I64TOA +#define SDL_lltoa _i64toa +#else +extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); +#endif + +#ifdef HAVE__UI64TOA +#define SDL_ulltoa _ui64toa +#else +extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); +#endif + +#ifdef HAVE_STRTOLL +#define SDL_strtoll strtoll +#else +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); +#endif + +#ifdef HAVE_STRTOULL +#define SDL_strtoull strtoull +#else +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base); +#endif + +#endif /* SDL_HAS_64BIT_TYPE */ + +#ifdef HAVE_STRTOD +#define SDL_strtod strtod +#else +extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp); +#endif + +#ifdef HAVE_ATOI +#define SDL_atoi atoi +#else +#define SDL_atoi(X) SDL_strtol(X, NULL, 0) +#endif + +#ifdef HAVE_ATOF +#define SDL_atof atof +#else +#define SDL_atof(X) SDL_strtod(X, NULL) +#endif + +#ifdef HAVE_STRCMP +#define SDL_strcmp strcmp +#else +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); +#endif + +#ifdef HAVE_STRNCMP +#define SDL_strncmp strncmp +#else +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); +#endif + +#ifdef HAVE_STRCASECMP +#define SDL_strcasecmp strcasecmp +#elif defined(HAVE__STRICMP) +#define SDL_strcasecmp _stricmp +#else +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); +#endif + +#ifdef HAVE_STRNCASECMP +#define SDL_strncasecmp strncasecmp +#elif defined(HAVE__STRNICMP) +#define SDL_strncasecmp _strnicmp +#else +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen); +#endif + +#ifdef HAVE_SSCANF +#define SDL_sscanf sscanf +#else +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); +#endif + +#ifdef HAVE_SNPRINTF +#define SDL_snprintf snprintf +#else +extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); +#endif + +#ifdef HAVE_VSNPRINTF +#define SDL_vsnprintf vsnprintf +#else +extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); +#endif + +/* The SDL implementation of iconv() returns these error codes */ +#define SDL_ICONV_ERROR (size_t)-1 +#define SDL_ICONV_E2BIG (size_t)-2 +#define SDL_ICONV_EILSEQ (size_t)-3 +#define SDL_ICONV_EINVAL (size_t)-4 + +#ifdef HAVE_ICONV +#define SDL_iconv_t iconv_t +#define SDL_iconv_open iconv_open +#define SDL_iconv_close iconv_close +#else +typedef struct _SDL_iconv_t *SDL_iconv_t; +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode); +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); +#endif +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); +/* This function converts a string between encodings in one pass, returning a + string that must be freed with SDL_free() or NULL on error. +*/ +extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft); +#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_stdinc_h */ diff --git a/Sources/External/SDL12/SDL_syswm.h b/Sources/External/SDL12/SDL_syswm.h new file mode 100644 index 0000000..010dd1b --- /dev/null +++ b/Sources/External/SDL12/SDL_syswm.h @@ -0,0 +1,214 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Include file for SDL custom system window manager hooks */ + +#ifndef _SDL_syswm_h +#define _SDL_syswm_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Your application has access to a special type of event 'SDL_SYSWMEVENT', + which contains window-manager specific information and arrives whenever + an unhandled window event occurs. This event is ignored by default, but + you can enable it with SDL_EventState() +*/ +#ifdef SDL_PROTOTYPES_ONLY +struct SDL_SysWMinfo; +typedef struct SDL_SysWMinfo SDL_SysWMinfo; +#else + +/* This is the structure for custom window manager events */ +#if defined(SDL_VIDEO_DRIVER_X11) +#if defined(__APPLE__) && defined(__MACH__) +/* conflicts with Quickdraw.h */ +#define Cursor X11Cursor +#endif + +#include +#include + +#if defined(__APPLE__) && defined(__MACH__) +/* matches the re-define above */ +#undef Cursor +#endif + +/* These are the various supported subsystems under UNIX */ +typedef enum { + SDL_SYSWM_X11 +} SDL_SYSWM_TYPE; + +/* The UNIX custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union { + XEvent xevent; + } event; +}; + +/* The UNIX custom window manager information structure. + When this structure is returned, it holds information about which + low level system it is using, and will be one of SDL_SYSWM_TYPE. + */ +typedef struct SDL_SysWMinfo { + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union { + struct { + Display *display; /* The X11 display */ + Window window; /* The X11 display window */ + /* These locking functions should be called around + any X11 functions using the display variable, + but not the gfxdisplay variable. + They lock the event thread, so should not be + called around event functions or from event filters. + */ + void (*lock_func)(void); + void (*unlock_func)(void); + + /* Introduced in SDL 1.0.2 */ + Window fswindow; /* The X11 fullscreen window */ + Window wmwindow; /* The X11 managed input window */ + + /* Introduced in SDL 1.2.12 */ + Display *gfxdisplay; /* The X11 display to which rendering is done */ + } x11; + } info; +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_NANOX) +#include + +/* The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/* The windows custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version ; + GR_WINDOW_ID window ; /* The display window */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) +#define WIN32_LEAN_AND_MEAN +#include + +/* The windows custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + HWND hwnd; /* The window for the message */ + UINT msg; /* The type of message */ + WPARAM wParam; /* WORD message parameter */ + LPARAM lParam; /* LONG message parameter */ +}; + +/* The windows custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + HWND window; /* The Win32 display window */ + HGLRC hglrc; /* The OpenGL context, if any */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_RISCOS) + +/* RISC OS custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int eventCode; /* The window for the message */ + int pollBlock[64]; +}; + +/* The RISC OS custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int wimpVersion; /* Wimp version running under */ + int taskHandle; /* The RISC OS task handle */ + int window; /* The RISC OS display window */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_PHOTON) +#include +#include + +/* The QNX custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/* The QNX custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int data; +} SDL_SysWMinfo; + +#else + +/* The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/* The generic custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int data; +} SDL_SysWMinfo; + +#endif /* video driver type */ + +#endif /* SDL_PROTOTYPES_ONLY */ + +/* Function prototypes */ +/* + * This function gives you custom hooks into the window manager information. + * It fills the structure pointed to by 'info' with custom information and + * returns 1 if the function is implemented. If it's not implemented, or + * the version member of the 'info' structure is invalid, it returns 0. + * + * You typically use this function like this: + * SDL_SysWMInfo info; + * SDL_VERSION(&info.version); + * if ( SDL_GetWMInfo(&info) ) { ... } + */ +extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_syswm_h */ diff --git a/Sources/External/SDL12/SDL_thread.h b/Sources/External/SDL12/SDL_thread.h new file mode 100644 index 0000000..403ee46 --- /dev/null +++ b/Sources/External/SDL12/SDL_thread.h @@ -0,0 +1,119 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_thread_h +#define _SDL_thread_h + +/* Header for the SDL thread management routines + + These are independent of the other SDL routines. +*/ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/* Thread synchronization primitives */ +#include "SDL_mutex.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The SDL thread structure, defined in SDL_thread.c */ +struct SDL_Thread; +typedef struct SDL_Thread SDL_Thread; + +/* Create a thread */ +#if ((defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)) && !defined(__SYMBIAN32__) +/* + We compile SDL into a DLL on OS/2. This means, that it's the DLL which + creates a new thread for the calling process with the SDL_CreateThread() + API. There is a problem with this, that only the RTL of the SDL.DLL will + be initialized for those threads, and not the RTL of the calling application! + To solve this, we make a little hack here. + We'll always use the caller's _beginthread() and _endthread() APIs to + start a new thread. This way, if it's the SDL.DLL which uses this API, + then the RTL of SDL.DLL will be used to create the new thread, and if it's + the application, then the RTL of the application will be used. + So, in short: + Always use the _beginthread() and _endthread() of the calling runtime library! +*/ +#define SDL_PASSED_BEGINTHREAD_ENDTHREAD +#ifndef _WIN32_WCE +#include /* This has _beginthread() and _endthread() defined! */ +#endif + +#ifdef __OS2__ +typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg); +typedef void (*pfnSDL_CurrentEndThread)(void); +#elif __GNUC__ +typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall *func)(void *), void *arg, + unsigned, unsigned *threadID); +typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); +#else +typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall *func)(void *), void *arg, + unsigned, unsigned *threadID); +typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); +#endif + +extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); + +#ifdef __OS2__ +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread) +#elif defined(_WIN32_WCE) +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL) +#else +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex) +#endif +#else +extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data); +#endif + +/* Get the 32-bit thread identifier for the current thread */ +extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); + +/* Get the 32-bit thread identifier for the specified thread, + equivalent to SDL_ThreadID() if the specified thread is NULL. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread); + +/* Wait for a thread to finish. + The return code for the thread function is placed in the area + pointed to by 'status', if 'status' is not NULL. + */ +extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status); + +/* Forcefully kill a thread without worrying about its state */ +extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_thread_h */ diff --git a/Sources/External/SDL12/SDL_timer.h b/Sources/External/SDL12/SDL_timer.h new file mode 100644 index 0000000..d21159f --- /dev/null +++ b/Sources/External/SDL12/SDL_timer.h @@ -0,0 +1,115 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_timer_h +#define _SDL_timer_h + +/* Header for the SDL time management routines */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is the OS scheduler timeslice, in milliseconds */ +#define SDL_TIMESLICE 10 + +/* This is the maximum resolution of the SDL timer on all platforms */ +#define TIMER_RESOLUTION 10 /* Experimentally determined */ + +/* Get the number of milliseconds since the SDL library initialization. + * Note that this value wraps if the program runs for more than ~49 days. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); + +/* Wait a specified number of milliseconds before returning */ +extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); + +/* Function prototype for the timer callback function */ +typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval); + +/* Set a callback to run after the specified number of milliseconds has + * elapsed. The callback function is passed the current timer interval + * and returns the next timer interval. If the returned value is the + * same as the one passed in, the periodic alarm continues, otherwise a + * new alarm is scheduled. If the callback returns 0, the periodic alarm + * is cancelled. + * + * To cancel a currently running timer, call SDL_SetTimer(0, NULL); + * + * The timer callback function may run in a different thread than your + * main code, and so shouldn't call any functions from within itself. + * + * The maximum resolution of this timer is 10 ms, which means that if + * you request a 16 ms timer, your callback will run approximately 20 ms + * later on an unloaded system. If you wanted to set a flag signaling + * a frame update at 30 frames per second (every 33 ms), you might set a + * timer for 30 ms: + * SDL_SetTimer((33/10)*10, flag_update); + * + * If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init(). + * + * Under UNIX, you should not use raise or use SIGALRM and this function + * in the same program, as it is implemented using setitimer(). You also + * should not use this function in multi-threaded applications as signals + * to multi-threaded apps have undefined behavior in some implementations. + * + * This function returns 0 if successful, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); + +/* New timer API, supports multiple timers + * Written by Stephane Peter + */ + +/* Function prototype for the new timer callback function. + * The callback function is passed the current timer interval and returns + * the next timer interval. If the returned value is the same as the one + * passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is cancelled. + */ +typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param); + +/* Definition of the timer ID type */ +typedef struct _SDL_TimerID *SDL_TimerID; + +/* Add a new timer to the pool of timers already running. + Returns a timer ID, or NULL when an error occurs. + */ +extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); + +/* Remove one of the multiple timers knowing its ID. + * Returns a boolean value indicating success. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_timer_h */ diff --git a/Sources/External/SDL12/SDL_types.h b/Sources/External/SDL12/SDL_types.h new file mode 100644 index 0000000..853b9ce --- /dev/null +++ b/Sources/External/SDL12/SDL_types.h @@ -0,0 +1,24 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* DEPRECATED */ +#include "SDL_stdinc.h" diff --git a/Sources/External/SDL12/SDL_version.h b/Sources/External/SDL12/SDL_version.h new file mode 100644 index 0000000..9ff0fa8 --- /dev/null +++ b/Sources/External/SDL12/SDL_version.h @@ -0,0 +1,85 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* This header defines the current SDL version */ + +#ifndef _SDL_version_h +#define _SDL_version_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL +*/ +#define SDL_MAJOR_VERSION 1 +#define SDL_MINOR_VERSION 2 +#define SDL_PATCHLEVEL 13 + +typedef struct SDL_version { + Uint8 major; + Uint8 minor; + Uint8 patch; +} SDL_version; + +/* This macro can be used to fill a version structure with the compile-time + * version of the SDL library. + */ +#define SDL_VERSION(X) \ +{ \ + (X)->major = SDL_MAJOR_VERSION; \ + (X)->minor = SDL_MINOR_VERSION; \ + (X)->patch = SDL_PATCHLEVEL; \ +} + +/* This macro turns the version numbers into a numeric value: + (1,2,3) -> (1203) + This assumes that there will never be more than 100 patchlevels +*/ +#define SDL_VERSIONNUM(X, Y, Z) \ + ((X)*1000 + (Y)*100 + (Z)) + +/* This is the version number macro for the current SDL version */ +#define SDL_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +/* This macro will evaluate to true if compiled with SDL at least X.Y.Z */ +#define SDL_VERSION_ATLEAST(X, Y, Z) \ + (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/* This function gets the version of the dynamically linked SDL library. + it should NOT be used to fill a version structure, instead you should + use the SDL_Version() macro. + */ +extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_version_h */ diff --git a/Sources/External/SDL12/SDL_video.h b/Sources/External/SDL12/SDL_video.h new file mode 100644 index 0000000..f6bacce --- /dev/null +++ b/Sources/External/SDL12/SDL_video.h @@ -0,0 +1,891 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Header file for access to the SDL raw framebuffer window */ + +#ifndef _SDL_video_h +#define _SDL_video_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Transparency definitions: These define alpha as the opacity of a surface */ +#define SDL_ALPHA_OPAQUE 255 +#define SDL_ALPHA_TRANSPARENT 0 + +/* Useful data types */ +typedef struct SDL_Rect { + Sint16 x, y; + Uint16 w, h; +} SDL_Rect; + +typedef struct SDL_Color { + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 unused; +} SDL_Color; +#define SDL_Colour SDL_Color + +typedef struct SDL_Palette { + int ncolors; + SDL_Color *colors; +} SDL_Palette; + +/* Everything in the pixel format structure is read-only */ +typedef struct SDL_PixelFormat { + SDL_Palette *palette; + Uint8 BitsPerPixel; + Uint8 BytesPerPixel; + Uint8 Rloss; + Uint8 Gloss; + Uint8 Bloss; + Uint8 Aloss; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; + + /* RGB color key information */ + Uint32 colorkey; + /* Alpha value information (per-surface alpha) */ + Uint8 alpha; +} SDL_PixelFormat; + +/* This structure should be treated as read-only, except for 'pixels', + which, if not NULL, contains the raw pixel data for the surface. +*/ +typedef struct SDL_Surface { + Uint32 flags; /* Read-only */ + SDL_PixelFormat *format; /* Read-only */ + int w, h; /* Read-only */ + Uint16 pitch; /* Read-only */ + void *pixels; /* Read-write */ + int offset; /* Private */ + + /* Hardware-specific surface info */ + struct private_hwdata *hwdata; + + /* clipping information */ + SDL_Rect clip_rect; /* Read-only */ + Uint32 unused1; /* for binary compatibility */ + + /* Allow recursive locks */ + Uint32 locked; /* Private */ + + /* info for fast blit mapping to other surfaces */ + struct SDL_BlitMap *map; /* Private */ + + /* format version, bumped at every change to invalidate blit maps */ + unsigned int format_version; /* Private */ + + /* Reference count -- used when freeing surface */ + int refcount; /* Read-mostly */ +} SDL_Surface; + +/* These are the currently supported flags for the SDL_surface */ +/* Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */ +#define SDL_SWSURFACE 0x00000000 /* Surface is in system memory */ +#define SDL_HWSURFACE 0x00000001 /* Surface is in video memory */ +#define SDL_ASYNCBLIT 0x00000004 /* Use asynchronous blits if possible */ +/* Available for SDL_SetVideoMode() */ +#define SDL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */ +#define SDL_HWPALETTE 0x20000000 /* Surface has exclusive palette */ +#define SDL_DOUBLEBUF 0x40000000 /* Set up double-buffered video mode */ +#define SDL_FULLSCREEN 0x80000000 /* Surface is a full screen display */ +#define SDL_OPENGL 0x00000002 /* Create an OpenGL rendering context */ +#define SDL_OPENGLBLIT 0x0000000A /* Create an OpenGL rendering context and use it for blitting */ +#define SDL_RESIZABLE 0x00000010 /* This video mode may be resized */ +#define SDL_NOFRAME 0x00000020 /* No window caption or edge frame */ +/* Used internally (read-only) */ +#define SDL_HWACCEL 0x00000100 /* Blit uses hardware acceleration */ +#define SDL_SRCCOLORKEY 0x00001000 /* Blit uses a source color key */ +#define SDL_RLEACCELOK 0x00002000 /* Private flag */ +#define SDL_RLEACCEL 0x00004000 /* Surface is RLE encoded */ +#define SDL_SRCALPHA 0x00010000 /* Blit uses source alpha blending */ +#define SDL_PREALLOC 0x01000000 /* Surface uses preallocated memory */ + +/* Evaluates to true if the surface needs to be locked before access */ +#define SDL_MUSTLOCK(surface) \ + (surface->offset || \ + ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0)) + +/* typedef for private surface blitting functions */ +typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, + struct SDL_Surface *dst, SDL_Rect *dstrect); + + +/* Useful for determining the video hardware capabilities */ +typedef struct SDL_VideoInfo { + Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */ + Uint32 wm_available :1; /* Flag: Can you talk to a window manager? */ + Uint32 UnusedBits1 :6; + Uint32 UnusedBits2 :1; + Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */ + Uint32 blit_hw_CC :1; /* Flag: Accelerated blits with Colorkey */ + Uint32 blit_hw_A :1; /* Flag: Accelerated blits with Alpha */ + Uint32 blit_sw :1; /* Flag: Accelerated blits SW --> HW */ + Uint32 blit_sw_CC :1; /* Flag: Accelerated blits with Colorkey */ + Uint32 blit_sw_A :1; /* Flag: Accelerated blits with Alpha */ + Uint32 blit_fill :1; /* Flag: Accelerated color fill */ + Uint32 UnusedBits3 :16; + Uint32 video_mem; /* The total amount of video memory (in K) */ + SDL_PixelFormat *vfmt; /* Value: The format of the video surface */ + int current_w; /* Value: The current video mode width */ + int current_h; /* Value: The current video mode height */ +} SDL_VideoInfo; + + +/* The most common video overlay formats. + For an explanation of these pixel formats, see: + http://www.webartz.com/fourcc/indexyuv.htm + + For information on the relationship between color spaces, see: + http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html + */ +#define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */ +#define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */ +#define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */ +#define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */ +#define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */ + +/* The YUV hardware video overlay */ +typedef struct SDL_Overlay { + Uint32 format; /* Read-only */ + int w, h; /* Read-only */ + int planes; /* Read-only */ + Uint16 *pitches; /* Read-only */ + Uint8 **pixels; /* Read-write */ + + /* Hardware-specific surface info */ + struct private_yuvhwfuncs *hwfuncs; + struct private_yuvhwdata *hwdata; + + /* Special flags */ + Uint32 hw_overlay :1; /* Flag: This overlay hardware accelerated? */ + Uint32 UnusedBits :31; +} SDL_Overlay; + + +/* Public enumeration for setting the OpenGL window attributes. */ +typedef enum { + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_SWAP_CONTROL +} SDL_GLattr; + +/* flags for SDL_SetPalette() */ +#define SDL_LOGPAL 0x01 +#define SDL_PHYSPAL 0x02 + +/* Function prototypes */ + +/* These functions are used internally, and should not be used unless you + * have a specific need to specify the video driver you want to use. + * You should normally use SDL_Init() or SDL_InitSubSystem(). + * + * SDL_VideoInit() initializes the video subsystem -- sets up a connection + * to the window manager, etc, and determines the current video mode and + * pixel format, but does not initialize a window or graphics mode. + * Note that event handling is activated by this routine. + * + * If you use both sound and video in your application, you need to call + * SDL_Init() before opening the sound device, otherwise under Win32 DirectX, + * you won't be able to set full-screen display modes. + */ +extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, Uint32 flags); +extern DECLSPEC void SDLCALL SDL_VideoQuit(void); + +/* This function fills the given character buffer with the name of the + * video driver, and returns a pointer to it if the video driver has + * been initialized. It returns NULL if no driver has been initialized. + */ +extern DECLSPEC char * SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen); + +/* + * This function returns a pointer to the current display surface. + * If SDL is doing format conversion on the display surface, this + * function returns the publicly visible surface, not the real video + * surface. + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_GetVideoSurface(void); + +/* + * This function returns a read-only pointer to information about the + * video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt' + * member of the returned structure will contain the pixel format of the + * "best" video mode. + */ +extern DECLSPEC const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void); + +/* + * Check to see if a particular video mode is supported. + * It returns 0 if the requested mode is not supported under any bit depth, + * or returns the bits-per-pixel of the closest available mode with the + * given width and height. If this bits-per-pixel is different from the + * one used when setting the video mode, SDL_SetVideoMode() will succeed, + * but will emulate the requested bits-per-pixel with a shadow surface. + * + * The arguments to SDL_VideoModeOK() are the same ones you would pass to + * SDL_SetVideoMode() + */ +extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags); + +/* + * Return a pointer to an array of available screen dimensions for the + * given format and video flags, sorted largest to smallest. Returns + * NULL if there are no dimensions available for a particular format, + * or (SDL_Rect **)-1 if any dimension is okay for the given format. + * + * If 'format' is NULL, the mode list will be for the format given + * by SDL_GetVideoInfo()->vfmt + */ +extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags); + +/* + * Set up a video mode with the specified width, height and bits-per-pixel. + * + * If 'bpp' is 0, it is treated as the current display bits per pixel. + * + * If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the + * requested bits-per-pixel, but will return whatever video pixel format is + * available. The default is to emulate the requested pixel format if it + * is not natively available. + * + * If SDL_HWSURFACE is set in 'flags', the video surface will be placed in + * video memory, if possible, and you may have to call SDL_LockSurface() + * in order to access the raw framebuffer. Otherwise, the video surface + * will be created in system memory. + * + * If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle + * updates asynchronously, but you must always lock before accessing pixels. + * SDL will wait for updates to complete before returning from the lock. + * + * If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee + * that the colors set by SDL_SetColors() will be the colors you get. + * Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all + * of the colors exactly the way they are requested, and you should look + * at the video surface structure to determine the actual palette. + * If SDL cannot guarantee that the colors you request can be set, + * i.e. if the colormap is shared, then the video surface may be created + * under emulation in system memory, overriding the SDL_HWSURFACE flag. + * + * If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set + * a fullscreen video mode. The default is to create a windowed mode + * if the current graphics system has a window manager. + * If the SDL library is able to set a fullscreen video mode, this flag + * will be set in the surface that is returned. + * + * If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up + * two surfaces in video memory and swap between them when you call + * SDL_Flip(). This is usually slower than the normal single-buffering + * scheme, but prevents "tearing" artifacts caused by modifying video + * memory while the monitor is refreshing. It should only be used by + * applications that redraw the entire screen on every update. + * + * If SDL_RESIZABLE is set in 'flags', the SDL library will allow the + * window manager, if any, to resize the window at runtime. When this + * occurs, SDL will send a SDL_VIDEORESIZE event to you application, + * and you must respond to the event by re-calling SDL_SetVideoMode() + * with the requested size (or another size that suits the application). + * + * If SDL_NOFRAME is set in 'flags', the SDL library will create a window + * without any title bar or frame decoration. Fullscreen video modes have + * this flag set automatically. + * + * This function returns the video framebuffer surface, or NULL if it fails. + * + * If you rely on functionality provided by certain video flags, check the + * flags of the returned surface to make sure that functionality is available. + * SDL will fall back to reduced functionality if the exact flags you wanted + * are not available. + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_SetVideoMode + (int width, int height, int bpp, Uint32 flags); + +/* + * Makes sure the given list of rectangles is updated on the given screen. + * If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire + * screen. + * These functions should not be called while 'screen' is locked. + */ +extern DECLSPEC void SDLCALL SDL_UpdateRects + (SDL_Surface *screen, int numrects, SDL_Rect *rects); +extern DECLSPEC void SDLCALL SDL_UpdateRect + (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); + +/* + * On hardware that supports double-buffering, this function sets up a flip + * and returns. The hardware will wait for vertical retrace, and then swap + * video buffers before the next video surface blit or lock will return. + * On hardware that doesn not support double-buffering, this is equivalent + * to calling SDL_UpdateRect(screen, 0, 0, 0, 0); + * The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when + * setting the video mode for this function to perform hardware flipping. + * This function returns 0 if successful, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen); + +/* + * Set the gamma correction for each of the color channels. + * The gamma values range (approximately) between 0.1 and 10.0 + * + * If this function isn't supported directly by the hardware, it will + * be emulated using gamma ramps, if available. If successful, this + * function returns 0, otherwise it returns -1. + */ +extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue); + +/* + * Set the gamma translation table for the red, green, and blue channels + * of the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. + * The input is the index into the array, and the output is the 16-bit + * gamma value at that index, scaled to the output color precision. + * + * You may pass NULL for any of the channels to leave it unchanged. + * If the call succeeds, it will return 0. If the display driver or + * hardware does not support gamma translation, or otherwise fails, + * this function will return -1. + */ +extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue); + +/* + * Retrieve the current values of the gamma translation tables. + * + * You must pass in valid pointers to arrays of 256 16-bit quantities. + * Any of the pointers may be NULL to ignore that channel. + * If the call succeeds, it will return 0. If the display driver or + * hardware does not support gamma translation, or otherwise fails, + * this function will return -1. + */ +extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue); + +/* + * Sets a portion of the colormap for the given 8-bit surface. If 'surface' + * is not a palettized surface, this function does nothing, returning 0. + * If all of the colors were set as passed to SDL_SetColors(), it will + * return 1. If not all the color entries were set exactly as given, + * it will return 0, and you should look at the surface palette to + * determine the actual color palette. + * + * When 'surface' is the surface associated with the current display, the + * display colormap will be updated with the requested colors. If + * SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors() + * will always return 1, and the palette is guaranteed to be set the way + * you desire, even if the window colormap has to be warped or run under + * emulation. + */ +extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface, + SDL_Color *colors, int firstcolor, int ncolors); + +/* + * Sets a portion of the colormap for a given 8-bit surface. + * 'flags' is one or both of: + * SDL_LOGPAL -- set logical palette, which controls how blits are mapped + * to/from the surface, + * SDL_PHYSPAL -- set physical palette, which controls how pixels look on + * the screen + * Only screens have physical palettes. Separate change of physical/logical + * palettes is only possible if the screen has SDL_HWPALETTE set. + * + * The return value is 1 if all colours could be set as requested, and 0 + * otherwise. + * + * SDL_SetColors() is equivalent to calling this function with + * flags = (SDL_LOGPAL|SDL_PHYSPAL). + */ +extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags, + SDL_Color *colors, int firstcolor, + int ncolors); + +/* + * Maps an RGB triple to an opaque pixel value for a given pixel format + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGB +(const SDL_PixelFormat * const format, + const Uint8 r, const Uint8 g, const Uint8 b); + +/* + * Maps an RGBA quadruple to a pixel value for a given pixel format + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA +(const SDL_PixelFormat * const format, + const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a); + +/* + * Maps a pixel value into the RGB components for a given pixel format + */ +extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt, + Uint8 *r, Uint8 *g, Uint8 *b); + +/* + * Maps a pixel value into the RGBA components for a given pixel format + */ +extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt, + Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); + +/* + * Allocate and free an RGB surface (must be called after SDL_SetVideoMode) + * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. + * If the depth is greater than 8 bits, the pixel format is set using the + * flags '[RGB]mask'. + * If the function runs out of memory, it will return NULL. + * + * The 'flags' tell what kind of surface to create. + * SDL_SWSURFACE means that the surface should be created in system memory. + * SDL_HWSURFACE means that the surface should be created in video memory, + * with the same format as the display surface. This is useful for surfaces + * that will not change much, to take advantage of hardware acceleration + * when being blitted to the display surface. + * SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with + * this surface, but you must always lock it before accessing the pixels. + * SDL will wait for current blits to finish before returning from the lock. + * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits. + * If the hardware supports acceleration of colorkey blits between + * two surfaces in video memory, SDL will try to place the surface in + * video memory. If this isn't possible or if there is no hardware + * acceleration available, the surface will be placed in system memory. + * SDL_SRCALPHA means that the surface will be used for alpha blits and + * if the hardware supports hardware acceleration of alpha blits between + * two surfaces in video memory, to place the surface in video memory + * if possible, otherwise it will be placed in system memory. + * If the surface is created in video memory, blits will be _much_ faster, + * but the surface format must be identical to the video surface format, + * and the only way to access the pixels member of the surface is to use + * the SDL_LockSurface() and SDL_UnlockSurface() calls. + * If the requested surface actually resides in video memory, SDL_HWSURFACE + * will be set in the flags member of the returned surface. If for some + * reason the surface could not be placed in video memory, it will not have + * the SDL_HWSURFACE flag set, and will be created in system memory instead. + */ +#define SDL_AllocSurface SDL_CreateRGBSurface +extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, + int width, int height, int depth, int pitch, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface); + +/* + * SDL_LockSurface() sets up a surface for directly accessing the pixels. + * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write + * to and read from 'surface->pixels', using the pixel format stored in + * 'surface->format'. Once you are done accessing the surface, you should + * use SDL_UnlockSurface() to release it. + * + * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates + * to 0, then you can read and write to the surface at any time, and the + * pixel format of the surface will not change. In particular, if the + * SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you + * will not need to lock the display surface before accessing it. + * + * No operating system or library calls should be made between lock/unlock + * pairs, as critical system locks may be held during this time. + * + * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. + */ +extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface); +extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); + +/* + * Load a surface from a seekable SDL data source (memory or file.) + * If 'freesrc' is non-zero, the source will be closed after being read. + * Returns the new surface, or NULL if there was an error. + * The new surface should be freed with SDL_FreeSurface(). + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc); + +/* Convenience macro -- load a surface from a file */ +#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) + +/* + * Save a surface to a seekable SDL data source (memory or file.) + * If 'freedst' is non-zero, the source will be closed after being written. + * Returns 0 if successful or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SaveBMP_RW + (SDL_Surface *surface, SDL_RWops *dst, int freedst); + +/* Convenience macro -- save a surface to a file */ +#define SDL_SaveBMP(surface, file) \ + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + +/* + * Sets the color key (transparent pixel) in a blittable surface. + * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), + * 'key' will be the transparent pixel in the source image of a blit. + * SDL_RLEACCEL requests RLE acceleration for the surface if present, + * and removes RLE acceleration if absent. + * If 'flag' is 0, this function clears any current color key. + * This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SetColorKey + (SDL_Surface *surface, Uint32 flag, Uint32 key); + +/* + * This function sets the alpha value for the entire surface, as opposed to + * using the alpha component of each pixel. This value measures the range + * of transparency of the surface, 0 being completely transparent to 255 + * being completely opaque. An 'alpha' value of 255 causes blits to be + * opaque, the source pixels copied to the destination (the default). Note + * that per-surface alpha can be combined with colorkey transparency. + * + * If 'flag' is 0, alpha blending is disabled for the surface. + * If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface. + * OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the + * surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. + * + * The 'alpha' parameter is ignored for surfaces that have an alpha channel. + */ +extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha); + +/* + * Sets the clipping rectangle for the destination surface in a blit. + * + * If the clip rectangle is NULL, clipping will be disabled. + * If the clip rectangle doesn't intersect the surface, the function will + * return SDL_FALSE and blits will be completely clipped. Otherwise the + * function returns SDL_TRUE and blits to the surface will be clipped to + * the intersection of the surface area and the clipping rectangle. + * + * Note that blits are automatically clipped to the edges of the source + * and destination surfaces. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect); + +/* + * Gets the clipping rectangle for the destination surface in a blit. + * 'rect' must be a pointer to a valid rectangle which will be filled + * with the correct values. + */ +extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect); + +/* + * Creates a new surface of the specified format, and then copies and maps + * the given surface to it so the blit of the converted surface will be as + * fast as possible. If this function fails, it returns NULL. + * + * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those + * semantics. You can also pass SDL_RLEACCEL in the flags parameter and + * SDL will try to RLE accelerate colorkey and alpha blits in the resulting + * surface. + * + * This function is used internally by SDL_DisplayFormat(). + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface + (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags); + +/* + * This performs a fast blit from the source surface to the destination + * surface. It assumes that the source and destination rectangles are + * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire + * surface (src or dst) is copied. The final blit rectangles are saved + * in 'srcrect' and 'dstrect' after all clipping is performed. + * If the blit is successful, it returns 0, otherwise it returns -1. + * + * The blit function should not be called on a locked surface. + * + * The blit semantics for surfaces with and without alpha and colorkey + * are defined as follows: + * + * RGBA->RGB: + * SDL_SRCALPHA set: + * alpha-blend (using alpha-channel). + * SDL_SRCCOLORKEY ignored. + * SDL_SRCALPHA not set: + * copy RGB. + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * RGB values of the source colour key, ignoring alpha in the + * comparison. + * + * RGB->RGBA: + * SDL_SRCALPHA set: + * alpha-blend (using the source per-surface alpha value); + * set destination alpha to opaque. + * SDL_SRCALPHA not set: + * copy RGB, set destination alpha to source per-surface alpha value. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * source colour key. + * + * RGBA->RGBA: + * SDL_SRCALPHA set: + * alpha-blend (using the source alpha channel) the RGB values; + * leave destination alpha untouched. [Note: is this correct?] + * SDL_SRCCOLORKEY ignored. + * SDL_SRCALPHA not set: + * copy all of RGBA to the destination. + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * RGB values of the source colour key, ignoring alpha in the + * comparison. + * + * RGB->RGB: + * SDL_SRCALPHA set: + * alpha-blend (using the source per-surface alpha value). + * SDL_SRCALPHA not set: + * copy RGB. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * source colour key. + * + * If either of the surfaces were in video memory, and the blit returns -2, + * the video memory was lost, so it should be reloaded with artwork and + * re-blitted: + while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) { + while ( SDL_LockSurface(image) < 0 ) + Sleep(10); + -- Write image pixels to image->pixels -- + SDL_UnlockSurface(image); + } + * This happens under DirectX 5.0 when the system switches away from your + * fullscreen application. The lock will also fail until you have access + * to the video memory again. + */ +/* You should call SDL_BlitSurface() unless you know exactly how SDL + blitting works internally and how to use the other blit functions. +*/ +#define SDL_BlitSurface SDL_UpperBlit + +/* This is the public blit function, SDL_BlitSurface(), and it performs + rectangle validation and clipping before passing it to SDL_LowerBlit() +*/ +extern DECLSPEC int SDLCALL SDL_UpperBlit + (SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); +/* This is a semi-private blit function and it performs low-level surface + blitting only. +*/ +extern DECLSPEC int SDLCALL SDL_LowerBlit + (SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +/* + * This function performs a fast fill of the given rectangle with 'color' + * The given rectangle is clipped to the destination surface clip area + * and the final fill rectangle is saved in the passed in pointer. + * If 'dstrect' is NULL, the whole surface will be filled with 'color' + * The color should be a pixel of the format used by the surface, and + * can be generated by the SDL_MapRGB() function. + * This function returns 0 on success, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_FillRect + (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); + +/* + * This function takes a surface and copies it to a new surface of the + * pixel format and colors of the video framebuffer, suitable for fast + * blitting onto the display surface. It calls SDL_ConvertSurface() + * + * If you want to take advantage of hardware colorkey or alpha blit + * acceleration, you should set the colorkey and alpha value before + * calling this function. + * + * If the conversion fails or runs out of memory, it returns NULL + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormat(SDL_Surface *surface); + +/* + * This function takes a surface and copies it to a new surface of the + * pixel format and colors of the video framebuffer (if possible), + * suitable for fast alpha blitting onto the display surface. + * The new surface will always have an alpha channel. + * + * If you want to take advantage of hardware colorkey or alpha blit + * acceleration, you should set the colorkey and alpha value before + * calling this function. + * + * If the conversion fails or runs out of memory, it returns NULL + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *surface); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* YUV video surface overlay functions */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* This function creates a video output overlay + Calling the returned surface an overlay is something of a misnomer because + the contents of the display surface underneath the area where the overlay + is shown is undefined - it may be overwritten with the converted YUV data. +*/ +extern DECLSPEC SDL_Overlay * SDLCALL SDL_CreateYUVOverlay(int width, int height, + Uint32 format, SDL_Surface *display); + +/* Lock an overlay for direct access, and unlock it when you are done */ +extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay *overlay); +extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay); + +/* Blit a video overlay to the display surface. + The contents of the video surface underneath the blit destination are + not defined. + The width and height of the destination rectangle may be different from + that of the overlay, but currently only 2x scaling is supported. +*/ +extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect); + +/* Free a video overlay */ +extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* OpenGL support functions. */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Dynamically load an OpenGL library, or the default one if path is NULL + * + * If you do this, you need to retrieve all of the GL functions used in + * your program from the dynamic library using SDL_GL_GetProcAddress(). + */ +extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); + +/* + * Get the address of a GL function + */ +extern DECLSPEC void * SDLCALL SDL_GL_GetProcAddress(const char* proc); + +/* + * Set an attribute of the OpenGL subsystem before intialization. + */ +extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); + +/* + * Get an attribute of the OpenGL subsystem from the windowing + * interface, such as glX. This is of course different from getting + * the values from SDL's internal OpenGL subsystem, which only + * stores the values you request before initialization. + * + * Developers should track the values they pass into SDL_GL_SetAttribute + * themselves if they want to retrieve these values. + */ +extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value); + +/* + * Swap the OpenGL buffers, if double-buffering is supported. + */ +extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); + +/* + * Internal functions that should not be called unless you have read + * and understood the source code for these functions. + */ +extern DECLSPEC void SDLCALL SDL_GL_UpdateRects(int numrects, SDL_Rect* rects); +extern DECLSPEC void SDLCALL SDL_GL_Lock(void); +extern DECLSPEC void SDLCALL SDL_GL_Unlock(void); + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* These functions allow interaction with the window manager, if any. */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Sets/Gets the title and icon text of the display window (UTF-8 encoded) + */ +extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon); +extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon); + +/* + * Sets the icon for the display window. + * This function must be called before the first call to SDL_SetVideoMode(). + * It takes an icon surface, and a mask in MSB format. + * If 'mask' is NULL, the entire icon surface will be used as the icon. + */ +extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); + +/* + * This function iconifies the window, and returns 1 if it succeeded. + * If the function succeeds, it generates an SDL_APPACTIVE loss event. + * This function is a noop and returns 0 in non-windowed environments. + */ +extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void); + +/* + * Toggle fullscreen mode without changing the contents of the screen. + * If the display surface does not require locking before accessing + * the pixel information, then the memory pointers will not change. + * + * If this function was able to toggle fullscreen mode (change from + * running in a window to fullscreen, or vice-versa), it will return 1. + * If it is not implemented, or fails, it returns 0. + * + * The next call to SDL_SetVideoMode() will set the mode fullscreen + * attribute based on the flags parameter - if SDL_FULLSCREEN is not + * set, then the display will be windowed by default where supported. + * + * This is currently only implemented in the X11 video driver. + */ +extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface); + +/* + * This function allows you to set and query the input grab state of + * the application. It returns the new input grab state. + */ +typedef enum { + SDL_GRAB_QUERY = -1, + SDL_GRAB_OFF = 0, + SDL_GRAB_ON = 1, + SDL_GRAB_FULLSCREEN /* Used internally */ +} SDL_GrabMode; +/* + * Grabbing means that the mouse is confined to the application window, + * and nearly all keyboard input is passed directly to the application, + * and not interpreted by a window manager, if any. + */ +extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode); + +/* Not in public API at the moment - do not use! */ +extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ diff --git a/Sources/External/SDL12/begin_code.h b/Sources/External/SDL12/begin_code.h new file mode 100644 index 0000000..d1ddaa6 --- /dev/null +++ b/Sources/External/SDL12/begin_code.h @@ -0,0 +1,156 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* This file sets things up for C dynamic library function definitions, + static inlined functions, and structures aligned at 4-byte alignment. + If you don't like ugly C preprocessor code, don't look at this file. :) +*/ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +/* Some compilers use a special export keyword */ +#ifndef DECLSPEC +# if defined(__BEOS__) +# if defined(__GNUC__) +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC __declspec(export) +# endif +# elif defined(__WIN32__) +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# elif defined(__OS2__) +# ifdef __WATCOMC__ +# ifdef BUILD_SDL +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC +# endif +# else +# define DECLSPEC +# endif +# else +# if defined(__GNUC__) && __GNUC__ >= 4 +# define DECLSPEC __attribute__ ((visibility("default"))) +# else +# define DECLSPEC +# endif +# endif +#endif + +/* By default SDL uses the C calling convention */ +#ifndef SDLCALL +#if defined(__WIN32__) && !defined(__GNUC__) +#define SDLCALL __cdecl +#else +#ifdef __OS2__ +/* But on OS/2, we use the _System calling convention */ +/* to be compatible with every compiler */ +#define SDLCALL _System +#else +#define SDLCALL +#endif +#endif +#endif /* SDLCALL */ + +#ifdef __SYMBIAN32__ +#ifndef EKA2 +#undef DECLSPEC +#define DECLSPEC +#elif !defined(__WINS__) +#undef DECLSPEC +#define DECLSPEC __declspec(dllexport) +#endif /* !EKA2 */ +#endif /* __SYMBIAN32__ */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#pragma pack(push,4) +#elif (defined(__MWERKS__) && defined(__MACOS__)) +#pragma options align=mac68k4byte +#pragma enumsalwaysint on +#endif /* Compiler needs structure packing set */ + +/* Set up compiler-specific options for inlining functions */ +#ifndef SDL_INLINE_OKAY +#ifdef __GNUC__ +#define SDL_INLINE_OKAY +#else +/* Add any special compiler-specific cases here */ +#if defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) || defined(__EABI__) +#ifndef __inline__ +#define __inline__ __inline +#endif +#define SDL_INLINE_OKAY +#else +#if !defined(__MRC__) && !defined(_SGI_SOURCE) +#ifndef __inline__ +#define __inline__ inline +#endif +#define SDL_INLINE_OKAY +#endif /* Not a funky compiler */ +#endif /* Visual C++ */ +#endif /* GNU C */ +#endif /* SDL_INLINE_OKAY */ + +/* If inlining isn't supported, remove "__inline__", turning static + inlined functions into static functions (resulting in code bloat + in all files which include the offending header files) +*/ +#ifndef SDL_INLINE_OKAY +#define __inline__ +#endif + +/* Apparently this is needed by several Windows compilers */ +#if !defined(__MACH__) +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ +#endif /* ! Mac OS X - breaks precompiled headers */ diff --git a/Sources/External/SDL12/close_code.h b/Sources/External/SDL12/close_code.h new file mode 100644 index 0000000..afbb650 --- /dev/null +++ b/Sources/External/SDL12/close_code.h @@ -0,0 +1,41 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* This file reverses the effects of begin_code.h and should be included + after you finish any function and structure declarations in your headers +*/ + +#undef _begin_code_h + +/* Reset structure packing at previous byte alignment */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#if (defined(__MWERKS__) && defined(__MACOS__)) +#pragma options align=reset +#pragma enumsalwaysint reset +#else +#pragma pack(pop) +#endif +#endif /* Compiler needs structure packing set */ + diff --git a/Sources/GameGUIMP/DlgConsole.cpp b/Sources/GameGUIMP/DlgConsole.cpp index 63390e0..3988d17 100644 --- a/Sources/GameGUIMP/DlgConsole.cpp +++ b/Sources/GameGUIMP/DlgConsole.cpp @@ -58,7 +58,7 @@ BOOL CDlgConsole::OnInitDialog() // set default console text //m_ctrlEditConsole.SetWindowText( "Default input string"); - m_ctrlEditConsole.SetWindowText( CString(_pGame->gam_strConsoleInputBuffer)); + m_ctrlEditConsole.SetWindowText( (const char*)_pGame->gam_strConsoleInputBuffer); /* // create application windows font for console @@ -101,7 +101,7 @@ BOOL CDlgConsole::OnInitDialog() // get completion name for that symbol CTString strSymbol = itss->GetCompletionString(); // add string to console - m_ctrConsoleSymbolsCombo.AddString( CString(strSymbol)); + m_ctrConsoleSymbolsCombo.AddString( strSymbol); } // select first combo member m_ctrConsoleSymbolsCombo.SetCurSel( 0); diff --git a/Sources/GameGUIMP/EditConsole.cpp b/Sources/GameGUIMP/EditConsole.cpp index d022667..17454c3 100644 --- a/Sources/GameGUIMP/EditConsole.cpp +++ b/Sources/GameGUIMP/EditConsole.cpp @@ -53,7 +53,7 @@ void CEditConsole::SetTextFromConsole(void) CDlgConsole *pdlgParent = (CDlgConsole *) GetParent(); CEdit *pwndOutput = (CEdit *) pdlgParent->GetDlgItem( IDC_CONSOLE_OUTPUT); - pwndOutput->SetWindowText( CString(strNew)); + pwndOutput->SetWindowText( strNew); pwndOutput->LineScroll(ctLines-1); FreeMemory(strNew); diff --git a/Sources/GameMP/Camera.cpp b/Sources/GameMP/Camera.cpp index 0ea87fa..21c98fa 100644 --- a/Sources/GameMP/Camera.cpp +++ b/Sources/GameMP/Camera.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdafx.h" +#include "StdAfx.h" #include "Camera.h" class CCameraPos { @@ -21,7 +21,7 @@ CCameraPos _cp1; CCameraPos _cp; // camera control -extern INDEX cam_bRecord = FALSE; +INDEX cam_bRecord = FALSE; static INDEX cam_bMoveForward = FALSE; static INDEX cam_bMoveBackward = FALSE; static INDEX cam_bMoveLeft = FALSE; @@ -35,7 +35,7 @@ static INDEX cam_bZoomOut = FALSE; static INDEX cam_bZoomDefault = FALSE; static INDEX cam_bResetToPlayer = FALSE; static INDEX cam_bSnapshot = FALSE; -static INDEX cam_fSpeed = 1.0f; +static INDEX cam_fSpeed = 1; // camera functions void CAM_Init(void) diff --git a/Sources/GameMP/CompMessage.cpp b/Sources/GameMP/CompMessage.cpp index fabb6e6..52a61c3 100644 --- a/Sources/GameMP/CompMessage.cpp +++ b/Sources/GameMP/CompMessage.cpp @@ -160,7 +160,7 @@ void CCompMessage::PrepareMessage(INDEX ctCharsPerLine) // if failed } catch (char *strError) { // report warning - CPrintF("Cannot load message'%s': %s\n", (const CTString &)cm_fnmFileName, strError); + CPrintF("Cannot load message'%s': %s\n", (const char *) (const CTString &)cm_fnmFileName, strError); // do nothing else return; } @@ -208,7 +208,7 @@ CTString CCompMessage::GetLine(INDEX iLine) } // find end of line CTString strLine = strText; - char *pchEndOfLine = (char*)strchr(strLine, '\n'); + char *pchEndOfLine = strchr(strLine, '\n'); // if found if (pchEndOfLine!=NULL) { // cut there diff --git a/Sources/GameMP/CompModels.cpp b/Sources/GameMP/CompModels.cpp index 4c516d0..d77bd7a 100644 --- a/Sources/GameMP/CompModels.cpp +++ b/Sources/GameMP/CompModels.cpp @@ -2,14 +2,18 @@ #include "StdAfx.h" #include "LCDDrawing.h" + +#ifdef DECL_DLL +#undef DECL_DLL +#endif #define DECL_DLL #include "EntitiesMP/Common/Particles.h" -#include "Models/Enemies/Headman/Headman.h" +#include "Models/Enemies/Headman/headman.h" #include "Models/Enemies/Eyeman/Eyeman.h" #include "Models/Enemies/Boneman/Boneman.h" -#include "Models/Enemies/Werebull/Werebull.h" -#include "Models/Enemies/Scorpman/Scorpman.h" +#include "Models/Enemies/WereBull/WereBull.h" +#include "Models/Enemies/SCORPMAN/scorpman.h" #include "Models/Enemies/Walker/Walker.h" #include "Models/Enemies/Woman/Woman.h" #include "Models/Enemies/Gizmo/Gizmo.h" @@ -20,7 +24,7 @@ #include "ModelsMP/Enemies/Guffy/Guffy.h" #include "ModelsMP/Enemies/Grunt/Grunt.h" #include "ModelsMP/Enemies/Demon/Demon.h" -#include "ModelsMP/Enemies/ChainsawFreak/Freak.h" +#include "ModelsMP/Enemies/ChainSawFreak/Freak.h" #include "ModelsMP/Enemies/CannonStatic/Turret.h" #include "ModelsMP/Enemies/CannonRotating/Turret.h" #include "ModelsMP/Enemies/CannonRotating/RotatingMechanism.h" @@ -35,14 +39,14 @@ #include "Models/Weapons/Colt/ColtItem.h" #include "Models/Weapons/SingleShotgun/SingleShotgunItem.h" #include "Models/Weapons/DoubleShotgun/DoubleShotgunItem.h" -#include "Models/Weapons/Minigun/MinigunItem.h" -#include "Models/Weapons/Tommygun/TommygunItem.h" +#include "Models/Weapons/MiniGun/MiniGunItem.h" +#include "Models/Weapons/TommyGun/TommyGunItem.h" #include "Models/Weapons/RocketLauncher/RocketLauncherItem.h" #include "Models/Weapons/GrenadeLauncher/GrenadeLauncherItem.h" #include "Models/Weapons/Laser/LaserItem.h" #include "Models/Weapons/Cannon/Cannon.h" #include "ModelsMP/Weapons/Sniper/SniperItem.h" -#include "ModelsMP/Weapons/ChainSaw/ChainSawItem.h" +#include "ModelsMP/Weapons/ChainSaw/ChainsawItem.h" #include "ModelsMP/Weapons/ChainSaw/BladeForPlayer.h" #include "ModelsMP/Weapons/Flamer/FlamerItem.h" @@ -70,7 +74,7 @@ static BOOL _bModelOK = FALSE; extern FLOAT _fMsgAppearFade; -CModelObject *AddAttachment_t(CModelObject *pmoParent, INDEX iPosition, +static CModelObject *AddAttachment_t(CModelObject *pmoParent, INDEX iPosition, const CTFileName &fnmModel, INDEX iAnim, const CTFileName &fnmTexture, const CTFileName &fnmReflection=CTFILENAME(""), @@ -897,7 +901,7 @@ extern void SetupCompModel_t(const CTString &strName) _fFloorY = -1.0f; } else { - ThrowF_t(TRANS("Unknown model '%s'"), strName); + ThrowF_t(TRANS("Unknown model '%s'"), (const char *) strName); } } @@ -915,7 +919,7 @@ void RenderMessageModel(CDrawPort *pdp, const CTString &strModel) // if failed } catch(char *strError) { // report error - CPrintF("Cannot setup model '%s':\n%s\n", strModel, strError); + CPrintF("Cannot setup model '%s':\n%s\n", (const char *) strModel, strError); // do nothing return; } diff --git a/Sources/GameMP/Computer.cpp b/Sources/GameMP/Computer.cpp index c84e37c..a223240 100644 --- a/Sources/GameMP/Computer.cpp +++ b/Sources/GameMP/Computer.cpp @@ -4,6 +4,10 @@ #include "LCDDrawing.h" #include "CompMessage.h" +#ifdef PLATFORM_UNIX +#include +#endif + extern CGame *_pGame; static const FLOAT tmComputerFade = 1.0f; // how many seconds it takes computer to fade in/out @@ -11,11 +15,11 @@ static FLOAT fComputerFadeValue = 0.0f; // faded value of computer (0..1) static CTimerValue tvComputerLast; static CTimerValue _tvMessageAppear; static CPlayer *_ppenPlayer = NULL; -extern FLOAT _fMsgAppearFade = 0.0f; -extern FLOAT _fMsgAppearDelta = 0.0f; +FLOAT _fMsgAppearFade = 0.0f; +FLOAT _fMsgAppearDelta = 0.0f; // player statistics are set here -extern CTString _strStatsDetails = ""; +CTString _strStatsDetails = ""; // mouse cursor position static PIX2D _vpixMouse; @@ -89,7 +93,7 @@ static COLOR MouseOverColor(const PIXaabbox2D &box, COLOR colNone, COLOR colOff, COLOR colOn) { if (box>=_vpixMouse) { - return LCDBlinkingColor(colOff, colOn); + return _pGame->LCDBlinkingColor(colOff, colOn); } else { return colNone; } @@ -113,7 +117,7 @@ static PIXaabbox2D GetSliderBox(INDEX iFirst, INDEX iVisible, INDEX iTotal, PIX pixFull = boxFull.Size()(2); PIX pixSize = PIX(pixFull*fSize); pixSize = ClampDn(pixSize, boxFull.Size()(1)); - PIX pixTop = pixFull*(FLOAT(iFirst)/iTotal)+boxFull.Min()(2); + PIX pixTop = (PIX) (pixFull*(FLOAT(iFirst)/iTotal)+boxFull.Min()(2)); PIX pixI0 = boxFull.Min()(1); PIX pixI1 = boxFull.Max()(1); return PIXaabbox2D(PIX2D(pixI0, pixTop), PIX2D(pixI1, pixTop+pixSize)); @@ -221,7 +225,7 @@ void LastUnreadMessage(void) } } if (!bFound) { - _iActiveMessage = ClampDn(_acmMessages.Count()-1, 0); + _iActiveMessage = ClampDn((long) _acmMessages.Count()-1, (long) 0); } SyncScrollWithActive(); } @@ -440,33 +444,33 @@ static void UpdateSize(CDrawPort *pdp) // remember font size CFontData *pfd = _pfdConsoleFont; - _pixCharSizeI = pfd->fd_pixCharWidth + pfd->fd_pixCharSpacing; - _pixCharSizeJ = pfd->fd_pixCharHeight + pfd->fd_pixLineSpacing; - _pixCharSize2I = _pixCharSizeI*_fScaling2; - _pixCharSize2J = _pixCharSizeJ*_fScaling2; - _pixCharSizeI = _pixCharSizeI*_fScaling; - _pixCharSizeJ = _pixCharSizeJ*_fScaling; + _pixCharSizeI = (PIX) (pfd->fd_pixCharWidth + pfd->fd_pixCharSpacing); + _pixCharSizeJ = (PIX) (pfd->fd_pixCharHeight + pfd->fd_pixLineSpacing); + _pixCharSize2I = (PIX) (_pixCharSizeI*_fScaling2); + _pixCharSize2J = (PIX) (_pixCharSizeJ*_fScaling2); + _pixCharSizeI = (PIX) (_pixCharSizeI*_fScaling); + _pixCharSizeJ = (PIX) (_pixCharSizeJ*_fScaling); - _pixMarginI = 5*_fScaling2; - _pixMarginJ = 5*_fScaling2; - PIX pixBoxMarginI = 10*_fScaling2; - PIX pixBoxMarginJ = 10*_fScaling2; + _pixMarginI = (PIX) (5*_fScaling2); + _pixMarginJ = (PIX) (5*_fScaling2); + PIX pixBoxMarginI = (PIX) (10*_fScaling2); + PIX pixBoxMarginJ = (PIX) (10*_fScaling2); - PIX pixJ0Dn = pixBoxMarginJ; - PIX pixJ1Up = pixJ0Dn+_pixCharSize2J+_pixMarginI*2; - PIX pixJ1Dn = pixJ1Up+pixBoxMarginJ; - PIX pixJ2Up = pixJ1Dn+_pixCharSize2J*6*2+pixBoxMarginJ; - PIX pixJ2Dn = pixJ2Up+pixBoxMarginJ; - PIX pixJ3Up = _pixSizeJ-pixBoxMarginJ; + PIX pixJ0Dn = (PIX) (pixBoxMarginJ); + PIX pixJ1Up = (PIX) (pixJ0Dn+_pixCharSize2J+_pixMarginI*2); + PIX pixJ1Dn = (PIX) (pixJ1Up+pixBoxMarginJ); + PIX pixJ2Up = (PIX) (pixJ1Dn+_pixCharSize2J*6*2+pixBoxMarginJ); + PIX pixJ2Dn = (PIX) (pixJ2Up+pixBoxMarginJ); + PIX pixJ3Up = (PIX) (_pixSizeJ-pixBoxMarginJ); - PIX pixI0Rt = pixBoxMarginI; - PIX pixI1Lt = pixI0Rt+_pixCharSize2I*20+pixBoxMarginI; - PIX pixI1Rt = pixI1Lt+pixBoxMarginI; - PIX pixI2Lt = _pixSizeI/2-pixBoxMarginI/2; - PIX pixI2Rt = _pixSizeI/2+pixBoxMarginI/2; - PIX pixI4Lt = _pixSizeI-pixBoxMarginI; - PIX pixI3Rt = pixI4Lt-pixBoxMarginI*2-_pixCharSize2I*10; - PIX pixI3Lt = pixI3Rt-pixBoxMarginI; + PIX pixI0Rt = (PIX) (pixBoxMarginI); + PIX pixI1Lt = (PIX) (pixI0Rt+_pixCharSize2I*20+pixBoxMarginI); + PIX pixI1Rt = (PIX) (pixI1Lt+pixBoxMarginI); + PIX pixI2Lt = (PIX) (_pixSizeI/2-pixBoxMarginI/2); + PIX pixI2Rt = (PIX) (_pixSizeI/2+pixBoxMarginI/2); + PIX pixI4Lt = (PIX) (_pixSizeI-pixBoxMarginI); + PIX pixI3Rt = (PIX) (pixI4Lt-pixBoxMarginI*2-_pixCharSize2I*10); + PIX pixI3Lt = (PIX) (pixI3Rt-pixBoxMarginI); // calculate box sizes _boxTitle = PIXaabbox2D( PIX2D(0, pixJ0Dn-1), PIX2D(pixI3Lt, pixJ1Up)); @@ -517,10 +521,10 @@ void PrintButton(CDrawPort *pdp, INDEX iButton) if (!dpButton.Lock()) { return; } - LCDSetDrawport(&dpButton); + _pGame->LCDSetDrawport(&dpButton); _pGame->LCDRenderCompGrid(); - LCDRenderClouds2(); - LCDScreenBoxOpenLeft(_colBoxes); + _pGame->LCDRenderClouds2(); + _pGame->LCDScreenBoxOpenLeft(_colBoxes); SetFont2(&dpButton); @@ -567,7 +571,7 @@ void PrintTitle(CDrawPort *pdp) SetFont2(pdp); CTString strTitle; strTitle.PrintF(TRANS("NETRICSA v2.01 - personal version for: %s"), - _ppenPlayer->GetPlayerName()); + (const char *) _ppenPlayer->GetPlayerName()); pdp->PutText( strTitle, _pixMarginI*3, _pixMarginJ-2*_fScaling2+1, _colMedium); } @@ -600,20 +604,20 @@ void PrintMessageList(CDrawPort *pdp) col = _colLight; } if (GetMsgListBox(i-_iFirstMessageOnScreen)>=_vpixMouse) { - col = LCDBlinkingColor(_colLight, _colMedium); + col = _pGame->LCDBlinkingColor(_colLight, _colMedium); } pdp->PutText( _acmMessages[i].cm_strSubject, pixTextX, pixYLine, col); pixYLine+=_pixCharSizeJ; } PIXaabbox2D boxSliderSpace = GetMsgSliderSpace(); - LCDDrawBox(0,0,boxSliderSpace, _colBoxes); + _pGame->LCDDrawBox(0,0,boxSliderSpace, _colBoxes); PIXaabbox2D boxSlider = GetMsgSliderBox(); COLOR col = _colBoxes; PIXaabbox2D boxSliderTrans = boxSlider; boxSliderTrans+=_boxMsgList.Min(); if (boxSliderTrans>=_vpixMouse) { - col = LCDBlinkingColor(_colLight, _colDark); + col = _pGame->LCDBlinkingColor(_colLight, _colDark); } pdp->Fill( boxSlider.Min()(1)+2, boxSlider.Min()(2)+2, boxSlider.Size()(1)-4, boxSlider.Size()(2)-4, col); @@ -686,13 +690,13 @@ void PrintMessageText(CDrawPort *pdp) } PIXaabbox2D boxSliderSpace = GetTextSliderSpace(); - LCDDrawBox(0,0,boxSliderSpace, _colBoxes); + _pGame->LCDDrawBox(0,0,boxSliderSpace, _colBoxes); PIXaabbox2D boxSlider = GetTextSliderBox(); COLOR col = _colBoxes; PIXaabbox2D boxSliderTrans = boxSlider; boxSliderTrans+=_boxMsgText.Min(); if (boxSliderTrans>=_vpixMouse) { - col = LCDBlinkingColor(_colLight, _colDark); + col = _pGame->LCDBlinkingColor(_colLight, _colDark); } pdp->Fill( boxSlider.Min()(1)+2, boxSlider.Min()(2)+2, boxSlider.Size()(1)-4, boxSlider.Size()(2)-4, col); @@ -710,7 +714,7 @@ void RenderMessagePicture(CDrawPort *pdp) // if failed } catch(char *strError) { // report error - CPrintF("Cannot load '%s':\n%s\n", (CTString&)cm.cm_fnmPicture, strError); + CPrintF("Cannot load '%s':\n%s\n", (const char *) (CTString&)cm.cm_fnmPicture, strError); // do nothing return; } @@ -748,7 +752,7 @@ void RenderMessageStats(CDrawPort *pdp) // clear bcg pdp->Fill( 1, 1, pixSizeI-2, pixSizeJ-2, C_BLACK|CT_OPAQUE); // render the map if not fading - COLOR colFade = LCDFadedColor(C_WHITE|255); + COLOR colFade = _pGame->LCDFadedColor(C_WHITE|255); if( (colFade&255) == 255) { RenderMap( pdp, ulLevelMask, NULL); } @@ -769,8 +773,8 @@ void RenderMessageImage(CDrawPort *pdp) // if no message if (_acmMessages.Count()==0 || fComputerFadeValue<0.99f) { // render empty - LCDRenderClouds2(); - LCDScreenBox(_colBoxes); + _pGame->LCDRenderClouds2(); + _pGame->LCDScreenBox(_colBoxes); return; } CCompMessage &cm = _acmMessages[_iActiveMessage]; @@ -778,8 +782,8 @@ void RenderMessageImage(CDrawPort *pdp) if (cm.cm_itImage == CCompMessage::IT_STATISTICS) { _pGame->LCDRenderCompGrid(); } - LCDRenderClouds2(); - LCDScreenBox(_colBoxes); + _pGame->LCDRenderClouds2(); + _pGame->LCDScreenBox(_colBoxes); // if no image if (cm.cm_itImage == CCompMessage::IT_NONE) { @@ -1149,6 +1153,10 @@ void CGame::ComputerRender(CDrawPort *pdp) fComputerFadeValue = 0.0f; _pGame->gm_csComputerState = CS_OFF; ComputerOff(); + + if (_pInput != NULL) // rcg02042003 hack for SDL vs. Win32. + _pInput->ClearRelativeMouseMotion(); + cmp_ppenPlayer = NULL; // exit computer return; @@ -1312,4 +1320,8 @@ void CGame::ComputerForceOff() _pGame->gm_csComputerState = CS_OFF; fComputerFadeValue = 0.0f; _ppenPlayer = NULL; + + if (_pInput != NULL) // rcg02042003 hack for SDL vs. Win32. + _pInput->ClearRelativeMouseMotion(); } + diff --git a/Sources/GameMP/Console.cpp b/Sources/GameMP/Console.cpp index 4e1dfd8..ea9bae2 100644 --- a/Sources/GameMP/Console.cpp +++ b/Sources/GameMP/Console.cpp @@ -110,6 +110,10 @@ void CGame::ConsoleRender(CDrawPort *pdp) // stop fConsoleFadeValue = 0.0f; _pGame->gm_csConsoleState = CS_OFF; + + if (_pInput != NULL) // rcg02042003 hack for SDL vs. Win32. + _pInput->ClearRelativeMouseMotion(); + // if not in network if (!_pNetwork->IsNetworkEnabled()) { // don't show last lines on screen after exiting console @@ -146,7 +150,7 @@ void CGame::ConsoleRender(CDrawPort *pdp) //LCDRenderGrid(); LCDRenderClouds2(); dpConsole.DrawLine( 0, pixSizeJ-1, pixSizeI, pixSizeJ-1, LCDFadedColor(SE_COL_BLUE_NEUTRAL|255)); - const COLOR colFill = (colDark & ~CT_AMASK) | 0x2F; + const ULONG colFill = (colDark & ~CT_AMASK) | 0x2F; dpConsole.Fill( 0, pixSizeJ-pixLineSpacing*1.6f, pixSizeI, pixLineSpacing*1.6f, colFill); // setup font @@ -170,7 +174,7 @@ void CGame::ConsoleRender(CDrawPort *pdp) if( ((ULONG)(_pTimer->GetRealTimeTick()*2)) & 1) { CTString strCursor="_"; FLOAT fTextScalingX = dpConsole.dp_fTextScaling * dpConsole.dp_fTextAspect; - PIX pixCellSize = _pfdConsoleFont->fd_pixCharWidth * fTextScalingX + dpConsole.dp_pixTextCharSpacing; + PIX pixCellSize = (PIX) (_pfdConsoleFont->fd_pixCharWidth * fTextScalingX + dpConsole.dp_pixTextCharSpacing); PIX pixCursorX = pixTextX + (iCursorPos+strlen(strPrompt))*pixCellSize; dpConsole.PutText( strCursor, pixCursorX, pixYLine+2, colDark); } @@ -291,7 +295,7 @@ void DoCheat(const CTString &strCommand, const CTString &strVar) { _pShell->SetINDEX(strVar, !_pShell->GetINDEX(strVar)); BOOL bNew = _pShell->GetINDEX(strVar); - CPrintF("%s: %s\n", strCommand, bNew?"ON":"OFF"); + CPrintF("%s: %s\n", (const char *) strCommand, bNew?"ON":"OFF"); } static void Key_Return(void) @@ -354,13 +358,13 @@ static void Key_Return(void) // parse editing line } else if( strEditingLine[0]=='/') { // add to output and execute - CPrintF( "-> %s\n", strEditingLine); + CPrintF( "-> %s\n", (const char *) strEditingLine); strEditingLine+=";"; _pShell->Execute(strEditingLine+1); } else if( !_pGame->gm_bGameOn) { // add to output and execute - CPrintF( "-> %s\n", strEditingLine); + CPrintF( "-> %s\n", (const char *) strEditingLine); strEditingLine+=";"; _pShell->Execute(strEditingLine); } @@ -423,7 +427,7 @@ static void Key_Tab( BOOL bShift) // can we print last found symbol ? if( strLastMatched!="") { if( !bFirstFound) CPrintF( " -\n"); - CPrintF( " %s\n", strLastMatched); + CPrintF( " %s\n", (const char *) strLastMatched); bFirstFound = TRUE; } strLastMatched = strSymbol; @@ -431,7 +435,7 @@ static void Key_Tab( BOOL bShift) } }} // print last symbol - if( ctSymbolsFound>1) CPrintF( " %s\n", strLastMatched); + if( ctSymbolsFound>1) CPrintF( " %s\n", (const char *) strLastMatched); } // for each of symbols in the shell diff --git a/Sources/GameMP/Controls.cpp b/Sources/GameMP/Controls.cpp index a11aec8..59f0829 100644 --- a/Sources/GameMP/Controls.cpp +++ b/Sources/GameMP/Controls.cpp @@ -5,7 +5,7 @@ * Copyright (c) 1997-1999, CroTeam. All rights reserved. */ -#include "stdafx.h" +#include "StdAfx.h" extern CGame *_pGame; @@ -311,13 +311,13 @@ void CControls::Save_t( CTFileName fnFile) FOREACHINLIST( CButtonAction, ba_lnNode, ctrl_lhButtonActions, itba) { strLine.PrintF("Button\n Name: TTRS %s\n Key1: %s\n Key2: %s", - itba->ba_strName, - _pInput->GetButtonName( itba->ba_iFirstKey), - _pInput->GetButtonName( itba->ba_iSecondKey) ); + (const char *) itba->ba_strName, + (const char *) _pInput->GetButtonName( itba->ba_iFirstKey), + (const char *) _pInput->GetButtonName( itba->ba_iSecondKey) ); strmFile.PutLine_t( strLine); // export pressed command - strLine.PrintF(" Pressed: %s", itba->ba_strCommandLineWhenPressed); + strLine.PrintF(" Pressed: %s", (const char *) itba->ba_strCommandLineWhenPressed); {for( INDEX iLetter = 0; strLine[ iLetter] != 0; iLetter++) { // delete EOL-s @@ -329,7 +329,7 @@ void CControls::Save_t( CTFileName fnFile) strmFile.PutLine_t( strLine); // export released command - strLine.PrintF(" Released: %s", itba->ba_strCommandLineWhenReleased); + strLine.PrintF(" Released: %s", (const char *) itba->ba_strCommandLineWhenReleased); {for( INDEX iLetter = 0; strLine[ iLetter] != 0; iLetter++) { // delete EOL-s @@ -365,13 +365,13 @@ void CControls::Save_t( CTFileName fnFile) strLine.PrintF("Axis \"%s\" \"%s\" %g %g %s %s %s", - _pGame->gm_astrAxisNames[iAxis], - _pInput->GetAxisName(ctrl_aaAxisActions[iAxis].aa_iAxisAction), + (const char *) _pGame->gm_astrAxisNames[iAxis], + (const char *) _pInput->GetAxisName(ctrl_aaAxisActions[iAxis].aa_iAxisAction), ctrl_aaAxisActions[ iAxis].aa_fSensitivity, ctrl_aaAxisActions[ iAxis].aa_fDeadZone, - strIfInverted, - strIfRelative, - strIfSmooth); + (const char *) strIfInverted, + (const char *) strIfRelative, + (const char *) strIfSmooth); strmFile.PutLine_t( strLine); } diff --git a/Sources/GameMP/Game.cpp b/Sources/GameMP/Game.cpp index d374a8a..76ec7f9 100644 --- a/Sources/GameMP/Game.cpp +++ b/Sources/GameMP/Game.cpp @@ -3,23 +3,27 @@ // Game.cpp : Defines the initialization routines for the DLL. // -#include "stdafx.h" -#include "Game.h" -#include // for _mkdir() +#include "StdAfx.h" +#include "GameMP/Game.h" #include #include #include + +#ifdef PLATFORM_WIN32 +#include // for _mkdir() #include +#endif + #include #include #include #include "Camera.h" #include "LCDDrawing.h" -extern FLOAT con_fHeightFactor = 0.5f; -extern FLOAT con_tmLastLines = 5.0f; -extern INDEX con_bTalk = 0; -CTimerValue _tvMenuQuickSave(0I64); +FLOAT con_fHeightFactor = 0.5f; +FLOAT con_tmLastLines = 5.0f; +INDEX con_bTalk = 0; +CTimerValue _tvMenuQuickSave((__int64) 0); // used filenames CTFileName fnmPersistentSymbols = CTString("Scripts\\PersistentSymbols.ini"); @@ -44,15 +48,32 @@ static CStaticStackArray _actTriangles; // world, model, particle, total // one and only Game object -extern CGame *_pGame = NULL; +// rcg11162001 This will resolve to the main binary under Linux, so it's +// okay. It's just another copy of the same otherwise. +#ifdef PLATFORM_UNIX +extern CGame *_pGame; +#else +CGame *_pGame = NULL; +#endif -extern "C" __declspec (dllexport) CGame *GAME_Create(void) +extern "C" +{ + +#ifdef PLATFORM_WIN32 +#define EXPORTABLE __declspec (dllexport) +#else +#define EXPORTABLE +#endif + +EXPORTABLE CGame *GAME_Create(void) { _pGame = new CGame; return _pGame; } +} // extern "C" + // recorded profiling stats static CTimerValue _tvDemoStarted; static CTimerValue _tvLastFrame; @@ -63,51 +84,50 @@ static BOOL _bProfiling = FALSE; static INDEX _ctProfileRecording = 0; static FLOAT gam_iRecordHighScore = -1.0f; +FLOAT gam_afAmmoQuantity[5] = {2.0f, 2.0f, 1.0f, 1.0f , 2.0f }; +FLOAT gam_afDamageStrength[5] = {0.25f, 0.5f, 1.0f, 1.5f , 2.0f }; +FLOAT gam_afEnemyAttackSpeed[5] = {0.75f, 0.75f, 1.0f, 2.0f , 2.0f }; +FLOAT gam_afEnemyMovementSpeed[5] = {1.0f , 1.0f , 1.0f, 1.25f, 1.25f}; +FLOAT gam_fManaTransferFactor = 0.5f; +FLOAT gam_fExtraEnemyStrength = 0; +FLOAT gam_fExtraEnemyStrengthPerPlayer = 0; +INDEX gam_iCredits = -1; // number of credits for respawning +FLOAT gam_tmSpawnInvulnerability = 3; +INDEX gam_iScoreLimit = 100000; +INDEX gam_iFragLimit = 20; +INDEX gam_iTimeLimit = 0; +INDEX gam_bWeaponsStay = TRUE; +INDEX gam_bAmmoStays = TRUE; +INDEX gam_bHealthArmorStays = TRUE; +INDEX gam_bAllowHealth = TRUE; +INDEX gam_bAllowArmor = TRUE; +INDEX gam_bInfiniteAmmo = FALSE; +INDEX gam_bRespawnInPlace = TRUE; +INDEX gam_bPlayEntireGame = TRUE; +INDEX gam_bFriendlyFire = FALSE; +INDEX gam_ctMaxPlayers = 8; +INDEX gam_bWaitAllPlayers = FALSE; +INDEX gam_iInitialMana = 100; +INDEX gam_bQuickLoad = FALSE; +INDEX gam_bQuickSave = FALSE; +INDEX gam_iQuickSaveSlots = 8; -extern FLOAT gam_afAmmoQuantity[5] = {2.0f, 2.0f, 1.0f, 1.0f , 2.0f }; -extern FLOAT gam_afDamageStrength[5] = {0.25f, 0.5f, 1.0f, 1.5f , 2.0f }; -extern FLOAT gam_afEnemyAttackSpeed[5] = {0.75f, 0.75f, 1.0f, 2.0f , 2.0f }; -extern FLOAT gam_afEnemyMovementSpeed[5] = {1.0f , 1.0f , 1.0f, 1.25f, 1.25f}; -extern FLOAT gam_fManaTransferFactor = 0.5f; -extern FLOAT gam_fExtraEnemyStrength = 0; -extern FLOAT gam_fExtraEnemyStrengthPerPlayer = 0; -extern INDEX gam_iCredits = -1; // number of credits for respawning -extern FLOAT gam_tmSpawnInvulnerability = 3; -extern INDEX gam_iScoreLimit = 100000; -extern INDEX gam_iFragLimit = 20; -extern INDEX gam_iTimeLimit = 0; -extern INDEX gam_bWeaponsStay = TRUE; -extern INDEX gam_bAmmoStays = TRUE; -extern INDEX gam_bHealthArmorStays = TRUE; -extern INDEX gam_bAllowHealth = TRUE; -extern INDEX gam_bAllowArmor = TRUE; -extern INDEX gam_bInfiniteAmmo = FALSE; -extern INDEX gam_bRespawnInPlace = TRUE; -extern INDEX gam_bPlayEntireGame = TRUE; -extern INDEX gam_bFriendlyFire = FALSE; -extern INDEX gam_ctMaxPlayers = 8; -extern INDEX gam_bWaitAllPlayers = FALSE; -extern INDEX gam_iInitialMana = 100; -extern INDEX gam_bQuickLoad = FALSE; -extern INDEX gam_bQuickSave = FALSE; -extern INDEX gam_iQuickSaveSlots = 8; +INDEX gam_iQuickStartDifficulty = 1; +INDEX gam_iQuickStartMode = 0; +INDEX gam_bQuickStartMP = 0; -extern INDEX gam_iQuickStartDifficulty = 1; -extern INDEX gam_iQuickStartMode = 0; -extern INDEX gam_bQuickStartMP = 0; +INDEX gam_bEnableAdvancedObserving = 0; +INDEX gam_iObserverConfig = 0; +INDEX gam_iObserverOffset = 0; -extern INDEX gam_bEnableAdvancedObserving = 0; -extern INDEX gam_iObserverConfig = 0; -extern INDEX gam_iObserverOffset = 0; +INDEX gam_iStartDifficulty = 1; +INDEX gam_iStartMode = 0; +CTString gam_strGameSpyExtras = ""; -extern INDEX gam_iStartDifficulty = 1; -extern INDEX gam_iStartMode = 0; -extern CTString gam_strGameAgentExtras = ""; +INDEX gam_iBlood = 2; // 0=none, 1=green, 2=red, 3=hippie +INDEX gam_bGibs = TRUE; -extern INDEX gam_iBlood = 2; // 0=none, 1=green, 2=red, 3=hippie -extern INDEX gam_bGibs = TRUE; - -extern INDEX gam_bUseExtraEnemies = TRUE; +INDEX gam_bUseExtraEnemies = TRUE; static INDEX hud_iEnableStats = 1; static FLOAT hud_fEnableFPS = 1; @@ -127,8 +147,8 @@ static INDEX ctl_iCurrentPlayerLocal = -1; static INDEX ctl_iCurrentPlayer = -1; static FLOAT gam_fChatSoundVolume = 0.25f; -extern BOOL _bUserBreakEnabled = FALSE; extern BOOL map_bIsFirstEncounter = FALSE; +BOOL _bUserBreakEnabled = FALSE; // make sure that console doesn't show last lines if not playing in network void MaybeDiscardLastLines(void) @@ -173,7 +193,7 @@ static void DumpDemoProfile(void) strm.FPrintF_t( strFragment); strm.FPrintF_t( strAnalyzed); // done! - CPrintF( TRANS("Demo profile data dumped to '%s'.\n"), strFileName); + CPrintF( TRANS("Demo profile data dumped to '%s'.\n"), (const char *) strFileName); } catch (char *strError) { // something went wrong :( @@ -901,77 +921,77 @@ void CGame::InitInternal( void) // add game timer handler _pTimer->AddHandler(&m_gthGameTimerHandler); // add shell variables - _pShell->DeclareSymbol("user void RecordProfile(void);", &RecordProfile); - _pShell->DeclareSymbol("user void SaveScreenShot(void);", &SaveScreenShot); - _pShell->DeclareSymbol("user void DumpProfileToConsole(void);", &DumpProfileToConsole); - _pShell->DeclareSymbol("user void DumpProfileToFile(void);", &DumpProfileToFile); - _pShell->DeclareSymbol("user INDEX hud_iStats;", &hud_iStats); - _pShell->DeclareSymbol("user INDEX hud_bShowResolution;", &hud_bShowResolution); - _pShell->DeclareSymbol("persistent user INDEX hud_bShowTime;", &hud_bShowTime); - _pShell->DeclareSymbol("persistent user INDEX hud_bShowClock;", &hud_bShowClock); - _pShell->DeclareSymbol("user INDEX dem_bOnScreenDisplay;", &dem_bOSD); - _pShell->DeclareSymbol("user INDEX dem_bPlay;", &dem_bPlay); - _pShell->DeclareSymbol("user INDEX dem_bPlayByName;", &dem_bPlayByName); - _pShell->DeclareSymbol("user INDEX dem_bProfile;", &dem_bProfile); - _pShell->DeclareSymbol("user INDEX dem_iAnimFrame;", &dem_iAnimFrame); - _pShell->DeclareSymbol("user CTString dem_strPostExec;", &dem_strPostExec); - _pShell->DeclareSymbol("persistent user INDEX dem_iProfileRate;", &dem_iProfileRate); - _pShell->DeclareSymbol("persistent user INDEX hud_bShowNetGraph;", &hud_bShowNetGraph); - _pShell->DeclareSymbol("FLOAT gam_afEnemyMovementSpeed[5];", &gam_afEnemyMovementSpeed); - _pShell->DeclareSymbol("FLOAT gam_afEnemyAttackSpeed[5];", &gam_afEnemyAttackSpeed); - _pShell->DeclareSymbol("FLOAT gam_afDamageStrength[5];", &gam_afDamageStrength); - _pShell->DeclareSymbol("FLOAT gam_afAmmoQuantity[5];", &gam_afAmmoQuantity); - _pShell->DeclareSymbol("persistent user FLOAT gam_fManaTransferFactor;", &gam_fManaTransferFactor); - _pShell->DeclareSymbol("persistent user FLOAT gam_fExtraEnemyStrength ;", &gam_fExtraEnemyStrength ); - _pShell->DeclareSymbol("persistent user FLOAT gam_fExtraEnemyStrengthPerPlayer;", &gam_fExtraEnemyStrengthPerPlayer ); - _pShell->DeclareSymbol("persistent user INDEX gam_iInitialMana;", &gam_iInitialMana); - _pShell->DeclareSymbol("persistent user INDEX gam_iScoreLimit;", &gam_iScoreLimit); - _pShell->DeclareSymbol("persistent user INDEX gam_iFragLimit;", &gam_iFragLimit); - _pShell->DeclareSymbol("persistent user INDEX gam_iTimeLimit;", &gam_iTimeLimit); - _pShell->DeclareSymbol("persistent user INDEX gam_ctMaxPlayers;", &gam_ctMaxPlayers); - _pShell->DeclareSymbol("persistent user INDEX gam_bWaitAllPlayers;", &gam_bWaitAllPlayers); - _pShell->DeclareSymbol("persistent user INDEX gam_bFriendlyFire;", &gam_bFriendlyFire); - _pShell->DeclareSymbol("persistent user INDEX gam_bPlayEntireGame;", &gam_bPlayEntireGame); - _pShell->DeclareSymbol("persistent user INDEX gam_bWeaponsStay;", &gam_bWeaponsStay); + _pShell->DeclareSymbol("user void RecordProfile(void);", (void *)&RecordProfile); + _pShell->DeclareSymbol("user void SaveScreenShot(void);", (void *)&SaveScreenShot); + _pShell->DeclareSymbol("user void DumpProfileToConsole(void);", (void *)&DumpProfileToConsole); + _pShell->DeclareSymbol("user void DumpProfileToFile(void);", (void *)&DumpProfileToFile); + _pShell->DeclareSymbol("user INDEX hud_iStats;", (void *)&hud_iStats); + _pShell->DeclareSymbol("user INDEX hud_bShowResolution;", (void *)&hud_bShowResolution); + _pShell->DeclareSymbol("persistent user INDEX hud_bShowTime;", (void *)&hud_bShowTime); + _pShell->DeclareSymbol("persistent user INDEX hud_bShowClock;", (void *)&hud_bShowClock); + _pShell->DeclareSymbol("user INDEX dem_bOnScreenDisplay;", (void *)&dem_bOSD); + _pShell->DeclareSymbol("user INDEX dem_bPlay;", (void *)&dem_bPlay); + _pShell->DeclareSymbol("user INDEX dem_bPlayByName;", (void *)&dem_bPlayByName); + _pShell->DeclareSymbol("user INDEX dem_bProfile;", (void *)&dem_bProfile); + _pShell->DeclareSymbol("user INDEX dem_iAnimFrame;", (void *)&dem_iAnimFrame); + _pShell->DeclareSymbol("user CTString dem_strPostExec;", (void *)&dem_strPostExec); + _pShell->DeclareSymbol("persistent user INDEX dem_iProfileRate;", (void *)&dem_iProfileRate); + _pShell->DeclareSymbol("persistent user INDEX hud_bShowNetGraph;", (void *)&hud_bShowNetGraph); + _pShell->DeclareSymbol("FLOAT gam_afEnemyMovementSpeed[5];", (void *)&gam_afEnemyMovementSpeed); + _pShell->DeclareSymbol("FLOAT gam_afEnemyAttackSpeed[5];", (void *)&gam_afEnemyAttackSpeed); + _pShell->DeclareSymbol("FLOAT gam_afDamageStrength[5];", (void *)&gam_afDamageStrength); + _pShell->DeclareSymbol("FLOAT gam_afAmmoQuantity[5];", (void *)&gam_afAmmoQuantity); + _pShell->DeclareSymbol("persistent user FLOAT gam_fManaTransferFactor;", (void *)&gam_fManaTransferFactor); + _pShell->DeclareSymbol("persistent user FLOAT gam_fExtraEnemyStrength ;", (void *)&gam_fExtraEnemyStrength ); + _pShell->DeclareSymbol("persistent user FLOAT gam_fExtraEnemyStrengthPerPlayer;", (void *)&gam_fExtraEnemyStrengthPerPlayer ); + _pShell->DeclareSymbol("persistent user INDEX gam_iInitialMana;", (void *)&gam_iInitialMana); + _pShell->DeclareSymbol("persistent user INDEX gam_iScoreLimit;", (void *)&gam_iScoreLimit); + _pShell->DeclareSymbol("persistent user INDEX gam_iFragLimit;", (void *)&gam_iFragLimit); + _pShell->DeclareSymbol("persistent user INDEX gam_iTimeLimit;", (void *)&gam_iTimeLimit); + _pShell->DeclareSymbol("persistent user INDEX gam_ctMaxPlayers;", (void *)&gam_ctMaxPlayers); + _pShell->DeclareSymbol("persistent user INDEX gam_bWaitAllPlayers;", (void *)&gam_bWaitAllPlayers); + _pShell->DeclareSymbol("persistent user INDEX gam_bFriendlyFire;", (void *)&gam_bFriendlyFire); + _pShell->DeclareSymbol("persistent user INDEX gam_bPlayEntireGame;", (void *)&gam_bPlayEntireGame); + _pShell->DeclareSymbol("persistent user INDEX gam_bWeaponsStay;", (void *)&gam_bWeaponsStay); - _pShell->DeclareSymbol("persistent user INDEX gam_bAmmoStays ;", &gam_bAmmoStays ); - _pShell->DeclareSymbol("persistent user INDEX gam_bHealthArmorStays;", &gam_bHealthArmorStays); - _pShell->DeclareSymbol("persistent user INDEX gam_bAllowHealth ;", &gam_bAllowHealth ); - _pShell->DeclareSymbol("persistent user INDEX gam_bAllowArmor ;", &gam_bAllowArmor ); - _pShell->DeclareSymbol("persistent user INDEX gam_bInfiniteAmmo ;", &gam_bInfiniteAmmo ); - _pShell->DeclareSymbol("persistent user INDEX gam_bRespawnInPlace ;", &gam_bRespawnInPlace ); + _pShell->DeclareSymbol("persistent user INDEX gam_bAmmoStays ;", (void *)&gam_bAmmoStays ); + _pShell->DeclareSymbol("persistent user INDEX gam_bHealthArmorStays;", (void *)&gam_bHealthArmorStays); + _pShell->DeclareSymbol("persistent user INDEX gam_bAllowHealth ;", (void *)&gam_bAllowHealth ); + _pShell->DeclareSymbol("persistent user INDEX gam_bAllowArmor ;", (void *)&gam_bAllowArmor ); + _pShell->DeclareSymbol("persistent user INDEX gam_bInfiniteAmmo ;", (void *)&gam_bInfiniteAmmo ); + _pShell->DeclareSymbol("persistent user INDEX gam_bRespawnInPlace ;", (void *)&gam_bRespawnInPlace ); - _pShell->DeclareSymbol("persistent user INDEX gam_iCredits;", &gam_iCredits); - _pShell->DeclareSymbol("persistent user FLOAT gam_tmSpawnInvulnerability;", &gam_tmSpawnInvulnerability); + _pShell->DeclareSymbol("persistent user INDEX gam_iCredits;", (void *)&gam_iCredits); + _pShell->DeclareSymbol("persistent user FLOAT gam_tmSpawnInvulnerability;", (void *)&gam_tmSpawnInvulnerability); - _pShell->DeclareSymbol("persistent user INDEX gam_iBlood;", &gam_iBlood); - _pShell->DeclareSymbol("persistent user INDEX gam_bGibs;", &gam_bGibs); + _pShell->DeclareSymbol("persistent user INDEX gam_iBlood;", (void *)&gam_iBlood); + _pShell->DeclareSymbol("persistent user INDEX gam_bGibs;", (void *)&gam_bGibs); - _pShell->DeclareSymbol("persistent user INDEX gam_bUseExtraEnemies;", &gam_bUseExtraEnemies); + _pShell->DeclareSymbol("persistent user INDEX gam_bUseExtraEnemies;", (void *)&gam_bUseExtraEnemies); - _pShell->DeclareSymbol("user INDEX gam_bQuickLoad;", &gam_bQuickLoad); - _pShell->DeclareSymbol("user INDEX gam_bQuickSave;", &gam_bQuickSave); - _pShell->DeclareSymbol("user INDEX gam_iQuickSaveSlots;", &gam_iQuickSaveSlots); - _pShell->DeclareSymbol("user INDEX gam_iQuickStartDifficulty;", &gam_iQuickStartDifficulty); - _pShell->DeclareSymbol("user INDEX gam_iQuickStartMode;", &gam_iQuickStartMode); - _pShell->DeclareSymbol("user INDEX gam_bQuickStartMP;", &gam_bQuickStartMP); - _pShell->DeclareSymbol("persistent user INDEX gam_iStartDifficulty;", &gam_iStartDifficulty); - _pShell->DeclareSymbol("persistent user INDEX gam_iStartMode;", &gam_iStartMode); - _pShell->DeclareSymbol("persistent user CTString gam_strGameAgentExtras;", &gam_strGameAgentExtras); - _pShell->DeclareSymbol("persistent user CTString gam_strCustomLevel;", &gam_strCustomLevel); - _pShell->DeclareSymbol("persistent user CTString gam_strSessionName;", &gam_strSessionName); - _pShell->DeclareSymbol("persistent user CTString gam_strJoinAddress;", &gam_strJoinAddress); - _pShell->DeclareSymbol("persistent user INDEX gam_bEnableAdvancedObserving;", &gam_bEnableAdvancedObserving); - _pShell->DeclareSymbol("user INDEX gam_iObserverConfig;", &gam_iObserverConfig); - _pShell->DeclareSymbol("user INDEX gam_iObserverOffset;", &gam_iObserverOffset); + _pShell->DeclareSymbol("user INDEX gam_bQuickLoad;", (void *)&gam_bQuickLoad); + _pShell->DeclareSymbol("user INDEX gam_bQuickSave;", (void *)&gam_bQuickSave); + _pShell->DeclareSymbol("user INDEX gam_iQuickSaveSlots;", (void *)&gam_iQuickSaveSlots); + _pShell->DeclareSymbol("user INDEX gam_iQuickStartDifficulty;", (void *)&gam_iQuickStartDifficulty); + _pShell->DeclareSymbol("user INDEX gam_iQuickStartMode;", (void *)&gam_iQuickStartMode); + _pShell->DeclareSymbol("user INDEX gam_bQuickStartMP;", (void *)&gam_bQuickStartMP); + _pShell->DeclareSymbol("persistent user INDEX gam_iStartDifficulty;", (void *)&gam_iStartDifficulty); + _pShell->DeclareSymbol("persistent user INDEX gam_iStartMode;", (void *)&gam_iStartMode); + _pShell->DeclareSymbol("persistent user CTString gam_strGameAgentExtras;", (void *)&gam_strGameAgentExtras); + _pShell->DeclareSymbol("persistent user CTString gam_strCustomLevel;", (void *)&gam_strCustomLevel); + _pShell->DeclareSymbol("persistent user CTString gam_strSessionName;", (void *)&gam_strSessionName); + _pShell->DeclareSymbol("persistent user CTString gam_strJoinAddress;", (void *)&gam_strJoinAddress); + _pShell->DeclareSymbol("persistent user INDEX gam_bEnableAdvancedObserving;", (void *)&gam_bEnableAdvancedObserving); + _pShell->DeclareSymbol("user INDEX gam_iObserverConfig;", (void *)&gam_iObserverConfig); + _pShell->DeclareSymbol("user INDEX gam_iObserverOffset;", (void *)&gam_iObserverOffset); - _pShell->DeclareSymbol("INDEX gam_iRecordHighScore;", &gam_iRecordHighScore); + _pShell->DeclareSymbol("INDEX gam_iRecordHighScore;", (void *)&gam_iRecordHighScore); - _pShell->DeclareSymbol("persistent user FLOAT con_fHeightFactor;", &con_fHeightFactor); - _pShell->DeclareSymbol("persistent user FLOAT con_tmLastLines;", &con_tmLastLines); - _pShell->DeclareSymbol("user INDEX con_bTalk;", &con_bTalk); - _pShell->DeclareSymbol("user void ReportDemoProfile(void);", &ReportDemoProfile); - _pShell->DeclareSymbol("user void DumpDemoProfile(void);", &DumpDemoProfile); + _pShell->DeclareSymbol("persistent user FLOAT con_fHeightFactor;", (void *)&con_fHeightFactor); + _pShell->DeclareSymbol("persistent user FLOAT con_tmLastLines;", (void *)&con_tmLastLines); + _pShell->DeclareSymbol("user INDEX con_bTalk;", (void *)&con_bTalk); + _pShell->DeclareSymbol("user void ReportDemoProfile(void);", (void *)&ReportDemoProfile); + _pShell->DeclareSymbol("user void DumpDemoProfile(void);", (void *)&DumpDemoProfile); extern CTString GetGameAgentRulesInfo(void); extern CTString GetGameTypeName(INDEX); extern CTString GetGameTypeNameCfunc(void* pArgs); @@ -980,26 +1000,26 @@ void CGame::InitInternal( void) extern ULONG GetSpawnFlagsForGameTypeCfunc(void* pArgs); extern BOOL IsMenuEnabled(const CTString &); extern BOOL IsMenuEnabledCfunc(void* pArgs); - _pShell->DeclareSymbol("user CTString GetGameAgentRulesInfo(void);", &GetGameAgentRulesInfo); - _pShell->DeclareSymbol("user CTString GetGameTypeName(INDEX);", &GetGameTypeNameCfunc); - _pShell->DeclareSymbol("user CTString GetCurrentGameTypeName(void);", &GetCurrentGameTypeName); - _pShell->DeclareSymbol("user INDEX GetSpawnFlagsForGameType(INDEX);", &GetSpawnFlagsForGameTypeCfunc); - _pShell->DeclareSymbol("user INDEX IsMenuEnabled(CTString);", &IsMenuEnabledCfunc); - _pShell->DeclareSymbol("user void Say(CTString);", &Say); - _pShell->DeclareSymbol("user void SayFromTo(INDEX, INDEX, CTString);", &SayFromTo); + _pShell->DeclareSymbol("user CTString GetGameAgentRulesInfo(void);", (void *)&GetGameAgentRulesInfo); + _pShell->DeclareSymbol("user CTString GetGameTypeName(INDEX);", (void *)&GetGameTypeNameCfunc); + _pShell->DeclareSymbol("user CTString GetCurrentGameTypeName(void);", (void *)&GetCurrentGameTypeName); + _pShell->DeclareSymbol("user INDEX GetSpawnFlagsForGameType(INDEX);", (void *)&GetSpawnFlagsForGameTypeCfunc); + _pShell->DeclareSymbol("user INDEX IsMenuEnabled(CTString);", (void *)&IsMenuEnabledCfunc); + _pShell->DeclareSymbol("user void Say(CTString);", (void *)&Say); + _pShell->DeclareSymbol("user void SayFromTo(INDEX, INDEX, CTString);", (void *)&SayFromTo); - _pShell->DeclareSymbol("CTString GetGameTypeNameSS(INDEX);", &GetGameTypeName); - _pShell->DeclareSymbol("INDEX GetSpawnFlagsForGameTypeSS(INDEX);", &GetSpawnFlagsForGameType); - _pShell->DeclareSymbol("INDEX IsMenuEnabledSS(CTString);", &IsMenuEnabled); + _pShell->DeclareSymbol("CTString GetGameTypeNameSS(INDEX);", (void *)&GetGameTypeName); + _pShell->DeclareSymbol("INDEX GetSpawnFlagsForGameTypeSS(INDEX);", (void *)&GetSpawnFlagsForGameType); + _pShell->DeclareSymbol("INDEX IsMenuEnabledSS(CTString);", (void *)&IsMenuEnabled); - _pShell->DeclareSymbol("user const INDEX ctl_iCurrentPlayerLocal;", &ctl_iCurrentPlayerLocal); - _pShell->DeclareSymbol("user const INDEX ctl_iCurrentPlayer;", &ctl_iCurrentPlayer); + _pShell->DeclareSymbol("user const INDEX ctl_iCurrentPlayerLocal;", (void *)&ctl_iCurrentPlayerLocal); + _pShell->DeclareSymbol("user const INDEX ctl_iCurrentPlayer;", (void *)&ctl_iCurrentPlayer); - _pShell->DeclareSymbol("user FLOAT gam_fChatSoundVolume;", &gam_fChatSoundVolume); + _pShell->DeclareSymbol("user FLOAT gam_fChatSoundVolume;", (void *)&gam_fChatSoundVolume); - _pShell->DeclareSymbol("user void PlaySound(INDEX, CTString, FLOAT, FLOAT, INDEX);", &PlayScriptSound); - _pShell->DeclareSymbol("user void StopSound(INDEX);", &StopScriptSound); - _pShell->DeclareSymbol("user INDEX IsSoundPlaying(INDEX);", &IsScriptSoundPlaying); + _pShell->DeclareSymbol("user void PlaySound(INDEX, CTString, FLOAT, FLOAT, INDEX);", (void *)&PlayScriptSound); + _pShell->DeclareSymbol("user void StopSound(INDEX);", (void *)&StopScriptSound); + _pShell->DeclareSymbol("user INDEX IsSoundPlaying(INDEX);", (void *)&IsScriptSoundPlaying); CAM_Init(); @@ -1157,7 +1177,7 @@ BOOL CGame::NewGame(const CTString &strSessionName, const CTFileName &fnWorld, return TRUE; } -BOOL CGame::JoinGame(CNetworkSession &session) +BOOL CGame::JoinGame(const CNetworkSession &session) { CEnableUserBreak eub; gam_iObserverConfig = 0; @@ -1212,7 +1232,7 @@ BOOL CGame::LoadGame(const CTFileName &fnGame) // start the new session try { _pNetwork->Load_t( fnGame); - CPrintF(TRANS("Loaded game: %s\n"), fnGame); + CPrintF(TRANS("Loaded game: %s\n"), (const char *) fnGame); } catch (char *strError) { // stop network provider _pNetwork->StopProvider(); @@ -1262,7 +1282,7 @@ BOOL CGame::StartDemoPlay(const CTFileName &fnDemo) // start the new session try { _pNetwork->StartDemoPlay_t( fnDemo); - CPrintF(TRANS("Started playing demo: %s\n"), fnDemo); + CPrintF(TRANS("Started playing demo: %s\n"), (const char *) fnDemo); } catch (char *strError) { // stop network provider _pNetwork->StopProvider(); @@ -1306,7 +1326,7 @@ BOOL CGame::StartDemoRec(const CTFileName &fnDemo) // save demo recording try { _pNetwork->StartDemoRec_t( fnDemo); - CPrintF(TRANS("Started recording demo: %s\n"), fnDemo); + CPrintF(TRANS("Started recording demo: %s\n"), (const char *) fnDemo); // save a thumbnail SaveThumbnail(fnDemo.NoExt()+"Tbn.tex"); return TRUE; @@ -1342,12 +1362,12 @@ BOOL CGame::SaveGame(const CTFileName &fnGame) // save new session try { _pNetwork->Save_t( fnGame); - CPrintF(TRANS("Saved game: %s\n"), fnGame); + CPrintF(TRANS("Saved game: %s\n"), (const char *) fnGame); SaveThumbnail(fnGame.NoExt()+"Tbn.tex"); return TRUE; } catch (char *strError) { // and display error - CPrintF(TRANS("Cannot save game: %s\n"), strError); + CPrintF(TRANS("Cannot save game: %s\n"), (const char *) strError); return FALSE; } } @@ -1448,13 +1468,28 @@ SLONG CGame::PackHighScoreTable(void) // copy the value and the string memcpy(pub, str, sizeof(str)); pub += MAX_HIGHSCORENAME+1; - memcpy(pub, &gm_ahseHighScores[i].hse_gdDifficulty, sizeof(INDEX)); + + INDEX ival; + FLOAT fval; + + ival = gm_ahseHighScores[i].hse_gdDifficulty; + BYTESWAP(ival); + memcpy(pub, &ival, sizeof(INDEX)); pub += sizeof(INDEX); - memcpy(pub, &gm_ahseHighScores[i].hse_tmTime, sizeof(FLOAT)); + + fval = gm_ahseHighScores[i].hse_tmTime; + BYTESWAP(fval); + memcpy(pub, &fval, sizeof(FLOAT)); pub += sizeof(FLOAT); - memcpy(pub, &gm_ahseHighScores[i].hse_ctKills, sizeof(INDEX)); + + ival = gm_ahseHighScores[i].hse_ctKills; + BYTESWAP(ival); + memcpy(pub, &ival, sizeof(INDEX)); pub += sizeof(INDEX); - memcpy(pub, &gm_ahseHighScores[i].hse_ctScore, sizeof(INDEX)); + + ival = gm_ahseHighScores[i].hse_ctScore; + BYTESWAP(ival); + memcpy(pub, &ival, sizeof(INDEX)); pub += sizeof(INDEX); } // just copy it for now @@ -1473,12 +1508,16 @@ void CGame::UnpackHighScoreTable(SLONG slSize) gm_ahseHighScores[i].hse_strPlayer = (const char*)pub; pub += MAX_HIGHSCORENAME+1; memcpy(&gm_ahseHighScores[i].hse_gdDifficulty, pub, sizeof(INDEX)); + BYTESWAP(gm_ahseHighScores[i].hse_gdDifficulty); pub += sizeof(INDEX); memcpy(&gm_ahseHighScores[i].hse_tmTime , pub, sizeof(FLOAT)); + BYTESWAP(gm_ahseHighScores[i].hse_tmTime); pub += sizeof(FLOAT); memcpy(&gm_ahseHighScores[i].hse_ctKills , pub, sizeof(INDEX)); + BYTESWAP(gm_ahseHighScores[i].hse_ctKills); pub += sizeof(INDEX); memcpy(&gm_ahseHighScores[i].hse_ctScore , pub, sizeof(INDEX)); + BYTESWAP(gm_ahseHighScores[i].hse_ctScore); pub += sizeof(INDEX); } @@ -1537,7 +1576,7 @@ void CGame::Load_t( void) strmFile>>gm_aiMenuLocalPlayers[2]; strmFile>>gm_aiMenuLocalPlayers[3]; - strmFile.Read_t( &gm_MenuSplitScreenCfg, sizeof( enum SplitScreenCfg)); + strmFile>>(INDEX&)gm_MenuSplitScreenCfg; // read high-score table SLONG slHSSize; @@ -1758,7 +1797,7 @@ static void PrintStats( CDrawPort *pdpDrawPort) // display resolution info (if needed) if( hud_bShowResolution) { CTString strRes; - strRes.PrintF( "%dx%dx%s", slDPWidth, slDPHeight, _pGfx->gl_dmCurrentDisplayMode.DepthString()); + strRes.PrintF( "%dx%dx%s", slDPWidth, slDPHeight, (const char *) _pGfx->gl_dmCurrentDisplayMode.DepthString()); pdpDrawPort->SetFont( _pfdDisplayFont); pdpDrawPort->SetTextScaling( fTextScale); pdpDrawPort->SetTextAspect( 1.0f); @@ -1810,7 +1849,7 @@ static void PrintStats( CDrawPort *pdpDrawPort) ctLines = ClampUp( ctLines, (INDEX)(slDPHeight*0.7f)); FLOAT f192oLines = 192.0f / (FLOAT)ctLines; const FLOAT fMaxWidth = slDPWidth *0.1f; - const PIX pixJ = slDPHeight *0.9f; + const PIX pixJ = (PIX) (slDPHeight *0.9f); // draw canvas pdpDrawPort->Fill( slDPWidth-1-fMaxWidth, pixJ-ctLines+1, fMaxWidth, ctLines, SE_COL_BLUE_DARK_HV|64); pdpDrawPort->DrawBorder( slDPWidth-2-fMaxWidth, pixJ-ctLines, fMaxWidth+2, ctLines+2, C_WHITE |192); @@ -2264,18 +2303,18 @@ void CGame::GameRedrawView( CDrawPort *pdpDrawPort, ULONG ulFlags) strIndicator = TRANS("Game finished"); } else if (_pNetwork->IsPaused() || _pNetwork->GetLocalPause()) { strIndicator = TRANS("Paused"); - } else if (_tvMenuQuickSave.tv_llValue!=0I64 && + } else if (_tvMenuQuickSave.tv_llValue!=0 && (_pTimer->GetHighPrecisionTimer()-_tvMenuQuickSave).GetSeconds()<3) { strIndicator = TRANS("Use F6 for QuickSave during game!"); } else if (_pNetwork->ga_sesSessionState.ses_strMOTD!="") { CTString strMotd = _pNetwork->ga_sesSessionState.ses_strMOTD; static CTString strLastMotd = ""; - static CTimerValue tvLastMotd(0I64); + static CTimerValue tvLastMotd((__int64) 0); if (strLastMotd!=strMotd) { tvLastMotd = _pTimer->GetHighPrecisionTimer(); strLastMotd = strMotd; } - if (tvLastMotd.tv_llValue!=0I64 && (_pTimer->GetHighPrecisionTimer()-tvLastMotd).GetSeconds()<3) { + if (tvLastMotd.tv_llValue!=((__int64) 0) && (_pTimer->GetHighPrecisionTimer()-tvLastMotd).GetSeconds()<3) { strIndicator = strMotd; } } @@ -2373,7 +2412,9 @@ void CGame::GameRedrawView( CDrawPort *pdpDrawPort, ULONG ulFlags) bSaveScreenShot = FALSE; CTFileName fnmExpanded; ExpandFilePath(EFP_WRITE, CTString("ScreenShots"), fnmExpanded); - _mkdir(fnmExpanded); + + // rcg01052002 This is done in Stream.cpp, now. --ryan. + //_mkdir(fnmExpanded); // create a name for screenshot CTFileName fnmScreenShot; @@ -2396,7 +2437,7 @@ void CGame::GameRedrawView( CDrawPort *pdpDrawPort, ULONG ulFlags) try { // save screen shot as TGA iiImageInfo.SaveTGA_t( fnmScreenShot); - if( dem_iAnimFrame<0) CPrintF( TRANS("screen shot: %s\n"), (CTString&)fnmScreenShot); + if( dem_iAnimFrame<0) CPrintF( TRANS("screen shot: %s\n"), (const char *) (CTString&)fnmScreenShot); } // if failed catch (char *strError) { @@ -2426,8 +2467,8 @@ void CGame::RecordHighScore(void) INDEX ctScore = penpl->m_psGameStats.ps_iScore; // find entry with lower score - INDEX iLess=0; - for(; iLessga_World.GetName(), 0), strTimeline); + strDescription.PrintF( "%s - %s", (const char *) TranslateConst(_pNetwork->ga_World.GetName(), 0), (const char *) strTimeline); if (bWithInfo) { CPlayer *penPlayer = (CPlayer *)&*CEntity::GetPlayerEntity(0); @@ -2537,7 +2578,7 @@ INDEX FixQuicksaveDir(const CTFileName &fnmDir, INDEX ctMax) { // list the directory CDynamicStackArray afnmDir; - MakeDirList(afnmDir, fnmDir, "*.sav", 0); + MakeDirList(afnmDir, fnmDir, CTString("*.sav"), 0); CListHead lh; INDEX iMaxNo = -1; @@ -2564,7 +2605,7 @@ INDEX FixQuicksaveDir(const CTFileName &fnmDir, INDEX ctMax) } // sort the list - lh.Sort(qsort_CompareQuickSaves_FileUp, offsetof(QuickSave, qs_lnNode)); + lh.Sort(qsort_CompareQuickSaves_FileUp, _offsetof(QuickSave, qs_lnNode)); INDEX ctCount = lh.Count(); // delete all old ones while number of files is too large @@ -2743,7 +2784,7 @@ static FLOAT _tmNow_SE; static ULONG _ulA_SE; static BOOL _bPopup; -void TiledTextureSE( PIXaabbox2D &_boxScreen, FLOAT fStretch, MEX2D &vScreen, MEXaabbox2D &boxTexture) +void TiledTextureSE( PIXaabbox2D &_boxScreen, FLOAT fStretch, const MEX2D &vScreen, MEXaabbox2D &boxTexture) { PIX pixW = _boxScreen.Size()(1); PIX pixH = _boxScreen.Size()(2); @@ -2777,11 +2818,11 @@ void CGame::LCDInit(void) } catch (char *strError) { FatalError("%s\n", strError); } - ::LCDInit(); + ::_LCDInit(); } void CGame::LCDEnd(void) { - ::LCDEnd(); + ::_LCDEnd(); } void CGame::LCDPrepare(FLOAT fFade) { @@ -2789,7 +2830,7 @@ void CGame::LCDPrepare(FLOAT fFade) _tmNow_SE = (FLOAT)_pTimer->GetHighPrecisionTimer().GetSeconds(); _ulA_SE = NormFloatToByte(fFade); - ::LCDPrepare(fFade); + ::_LCDPrepare(fFade); } void CGame::LCDSetDrawport(CDrawPort *pdp) { @@ -2804,31 +2845,31 @@ void CGame::LCDSetDrawport(CDrawPort *pdp) _bPopup = TRUE; } - ::LCDSetDrawport(pdp); + ::_LCDSetDrawport(pdp); } void CGame::LCDDrawBox(PIX pixUL, PIX pixDR, PIXaabbox2D &box, COLOR col) { col = SE_COL_BLUE_NEUTRAL|255; - ::LCDDrawBox(pixUL, pixDR, box, col); + ::_LCDDrawBox(pixUL, pixDR, box, col); } void CGame::LCDScreenBox(COLOR col) { col = SE_COL_BLUE_NEUTRAL|255; - ::LCDScreenBox(col); + ::_LCDScreenBox(col); } void CGame::LCDScreenBoxOpenLeft(COLOR col) { col = SE_COL_BLUE_NEUTRAL|255; - ::LCDScreenBoxOpenLeft(col); + ::_LCDScreenBoxOpenLeft(col); } void CGame::LCDScreenBoxOpenRight(COLOR col) { col = SE_COL_BLUE_NEUTRAL|255; - ::LCDScreenBoxOpenRight(col); + ::_LCDScreenBoxOpenRight(col); } void CGame::LCDRenderClouds1(void) { @@ -2844,7 +2885,7 @@ void CGame::LCDRenderClouds1(void) INDEX iYM = iYU + iSize; INDEX iYB = iYM + iSize; INDEX iXL = 420; - INDEX iXR = iXL + iSize*_pdp_SE->dp_fWideAdjustment; + INDEX iXR = (INDEX) (iXL + iSize*_pdp_SE->dp_fWideAdjustment); box = PIXaabbox2D( PIX2D( iXL*_pdp_SE->GetWidth()/640, iYU*_pdp_SE->GetHeight()/480) , PIX2D( iXR*_pdp_SE->GetWidth()/640, iYM*_pdp_SE->GetHeight()/480)); @@ -2930,7 +2971,7 @@ void CGame::LCDDrawPointer(PIX pixI, PIX pixJ) _pdp_SE->PutTexture( &_toPointer, PIXaabbox2D( PIX2D(pixI, pixJ), PIX2D(pixI+pixSizeI, pixJ+pixSizeJ)), LCDFadedColor(C_WHITE|255)); - //::LCDDrawPointer(pixI, pixJ); + //::_LCDDrawPointer(pixI, pixJ); } COLOR CGame::LCDGetColor(COLOR colDefault, const char *strName) { @@ -2981,17 +3022,18 @@ COLOR CGame::LCDGetColor(COLOR colDefault, const char *strName) } else if (!strcmp(strName, "bcg fill")) { colDefault = SE_COL_BLUE_DARK|255; } - return ::LCDGetColor(colDefault, strName); + return ::_LCDGetColor(colDefault, strName); } COLOR CGame::LCDFadedColor(COLOR col) { - return ::LCDFadedColor(col); + return ::_LCDFadedColor(col); } COLOR CGame::LCDBlinkingColor(COLOR col0, COLOR col1) { - return ::LCDBlinkingColor(col0, col1); + return ::_LCDBlinkingColor(col0, col1); } + // menu interface functions void CGame::MenuPreRenderMenu(const char *strMenuName) { diff --git a/Sources/GameMP/Game.h b/Sources/GameMP/Game.h index f483dd8..c515e9a 100644 --- a/Sources/GameMP/Game.h +++ b/Sources/GameMP/Game.h @@ -3,6 +3,9 @@ #ifndef __GAME_H #define __GAME_H 1 +#ifdef PLATFORM_UNIX +#include +#endif #include #include @@ -253,7 +256,7 @@ public: // game start/end functions virtual BOOL NewGame(const CTString &strSessionName, const CTFileName &fnWorld, class CSessionProperties &sp); - virtual BOOL JoinGame(CNetworkSession &session); + virtual BOOL JoinGame(const CNetworkSession &session); virtual BOOL LoadGame(const CTFileName &fnGame); virtual BOOL SaveGame(const CTFileName &fnGame); virtual void StopGame(void); diff --git a/Sources/GameMP/LCDDrawing.cpp b/Sources/GameMP/LCDDrawing.cpp index 7d02f69..6015d89 100644 --- a/Sources/GameMP/LCDDrawing.cpp +++ b/Sources/GameMP/LCDDrawing.cpp @@ -6,14 +6,16 @@ static CTextureObject _toPointer; static CTextureObject _toBcgClouds; static CTextureObject _toBcgGrid; -CDrawPort *_pdp = NULL; static PIX _pixSizeI; static PIX _pixSizeJ; static PIXaabbox2D _boxScreen; static FLOAT _tmNow; static ULONG _ulA; -extern void LCDInit(void) +// rcg11162001 Made static to fix duplicate symbol resolution issue. +static CDrawPort *_pdp = NULL; + +extern void _LCDInit(void) { try { _toBcgClouds.SetData_t(CTFILENAME("Textures\\General\\Background6.tex")); @@ -24,21 +26,21 @@ extern void LCDInit(void) } } -extern void LCDEnd(void) +extern void _LCDEnd(void) { _toBcgClouds.SetData(NULL); _toBcgGrid.SetData(NULL); _toPointer.SetData(NULL); } -extern void LCDPrepare(FLOAT fFade) +extern void _LCDPrepare(FLOAT fFade) { // get current time and alpha value _tmNow = (FLOAT)_pTimer->GetHighPrecisionTimer().GetSeconds(); _ulA = NormFloatToByte(fFade); } -extern void LCDSetDrawport(CDrawPort *pdp) +extern void _LCDSetDrawport(CDrawPort *pdp) { _pdp = pdp; _pixSizeI = _pdp->GetWidth(); @@ -46,7 +48,7 @@ extern void LCDSetDrawport(CDrawPort *pdp) _boxScreen = PIXaabbox2D ( PIX2D(0,0), PIX2D(_pixSizeI, _pixSizeJ)); } -void TiledTexture( PIXaabbox2D &_boxScreen, FLOAT fStretch, MEX2D &vScreen, MEXaabbox2D &boxTexture) +void TiledTexture( PIXaabbox2D &_boxScreen, FLOAT fStretch, const MEX2D &vScreen, MEXaabbox2D &boxTexture) { PIX pixW = _boxScreen.Size()(1); PIX pixH = _boxScreen.Size()(2); @@ -54,7 +56,7 @@ void TiledTexture( PIXaabbox2D &_boxScreen, FLOAT fStretch, MEX2D &vScreen, MEXa boxTexture+=vScreen; } -extern void LCDDrawBox(PIX pixUL, PIX pixDR, PIXaabbox2D &box, COLOR col) +extern void _LCDDrawBox(PIX pixUL, PIX pixDR, PIXaabbox2D &box, COLOR col) { // up _pdp->DrawLine( @@ -74,7 +76,7 @@ extern void LCDDrawBox(PIX pixUL, PIX pixDR, PIXaabbox2D &box, COLOR col) box.Max()(1)+pixDR, box.Max()(2)+pixDR+1, col); } -extern void LCDScreenBoxOpenLeft(COLOR col) +extern void _LCDScreenBoxOpenLeft(COLOR col) { // up _pdp->DrawLine( @@ -90,7 +92,7 @@ extern void LCDScreenBoxOpenLeft(COLOR col) _boxScreen.Max()(1)-1, _boxScreen.Max()(2)-1+1, col); } -extern void LCDScreenBoxOpenRight(COLOR col) +extern void _LCDScreenBoxOpenRight(COLOR col) { // up _pdp->DrawLine( @@ -106,12 +108,12 @@ extern void LCDScreenBoxOpenRight(COLOR col) _boxScreen.Min()(1), _boxScreen.Max()(2)-1+1, col); } -extern void LCDScreenBox(COLOR col) +extern void _LCDScreenBox(COLOR col) { - LCDDrawBox(0,-1, _boxScreen, col); + _LCDDrawBox(0,-1, _boxScreen, col); } -extern void LCDRenderClouds1(void) +extern void _LCDRenderClouds1(void) { MEXaabbox2D boxBcgClouds1; TiledTexture(_boxScreen, 1.3f*_pdp->GetWidth()/640.0f, @@ -122,7 +124,7 @@ extern void LCDRenderClouds1(void) _pdp->PutTexture(&_toBcgClouds, _boxScreen, boxBcgClouds1, C_dGREEN|_ulA>>1); } -extern void LCDRenderClouds2(void) +extern void _LCDRenderClouds2(void) { MEXaabbox2D boxBcgClouds2; TiledTexture(_boxScreen, 0.5f*_pdp->GetWidth()/640.0f, @@ -130,7 +132,7 @@ extern void LCDRenderClouds2(void) _pdp->PutTexture(&_toBcgClouds, _boxScreen, boxBcgClouds2, C_BLACK|(_ulA>>1)); } -extern void LCDRenderClouds2Light(void) +extern void _LCDRenderClouds2Light(void) { MEXaabbox2D boxBcgClouds2; TiledTexture(_boxScreen, 1.7f*_pdp->GetWidth()/640.0f, @@ -138,7 +140,7 @@ extern void LCDRenderClouds2Light(void) _pdp->PutTexture(&_toBcgClouds, _boxScreen, boxBcgClouds2, C_BLACK|(_ulA>>1)); } -extern void LCDRenderGrid(void) +extern void _LCDRenderGrid(void) { MEXaabbox2D boxBcgGrid; TiledTexture(_boxScreen, 1.0f, MEX2D(0,0), boxBcgGrid); @@ -146,7 +148,7 @@ extern void LCDRenderGrid(void) } /* -extern void LCDRenderClouds1(void) +extern void _LCDRenderClouds1(void) { MEXaabbox2D boxBcgClouds1 = MEXaabbox2D(MEX2D(0,0), MEX2D(256,512)); MEXaabbox2D boxBcgClouds2 = MEXaabbox2D(MEX2D(0,0), MEX2D(512,256)); @@ -156,21 +158,21 @@ extern void LCDRenderClouds1(void) _pdp->PutTexture( &_toBcgClouds, _boxScreen, boxBcgClouds2, C_dGREEN|(_ulA>>1)); } -extern void LCDRenderClouds2(void) +extern void _LCDRenderClouds2(void) { MEXaabbox2D boxBcgClouds = MEXaabbox2D(MEX2D(0,0), MEX2D(512,512)); boxBcgClouds += MEX2D(2,10); _pdp->PutTexture( &_toBcgClouds, _boxScreen, boxBcgClouds, C_BLACK|(_ulA>>1)); } -extern void LCDRenderClouds2Light(void) +extern void _LCDRenderClouds2Light(void) { MEXaabbox2D boxBcgClouds2; TiledTexture( _boxScreen, 1.3f, MEX2D(2,10), boxBcgClouds2); _pdp->PutTexture( &_toBcgClouds, _boxScreen, boxBcgClouds2, C_BLACK|(_ulA>>1)); } -extern void LCDRenderGrid(void) +extern void _LCDRenderGrid(void) { MEXaabbox2D boxBcgGrid; TiledTexture( _boxScreen, 1.0f, MEX2D(8,8), boxBcgGrid); @@ -178,22 +180,22 @@ extern void LCDRenderGrid(void) } */ -extern COLOR LCDGetColor(COLOR colDefault, const char *strName) +extern COLOR _LCDGetColor(COLOR colDefault, const char *strName) { return colDefault;//||((colDefault&0xFF0000)<<8); } -extern COLOR LCDFadedColor(COLOR col) +extern COLOR _LCDFadedColor(COLOR col) { return MulColors(C_WHITE|_ulA, col); } -extern COLOR LCDBlinkingColor(COLOR col0, COLOR col1) +extern COLOR _LCDBlinkingColor(COLOR col0, COLOR col1) { return LerpColor( col0, col1, sin(_tmNow*10.0f)*0.5f+0.5f); } -extern void LCDDrawPointer(PIX pixI, PIX pixJ) +extern void _LCDDrawPointer(PIX pixI, PIX pixJ) { CDisplayMode dmCurrent; _pGfx->GetCurrentDisplayMode(dmCurrent); @@ -210,5 +212,6 @@ extern void LCDDrawPointer(PIX pixI, PIX pixJ) pixI-=1; pixJ-=1; _pdp->PutTexture( &_toPointer, PIXaabbox2D( PIX2D(pixI, pixJ), PIX2D(pixI+pixSizeI, pixJ+pixSizeJ)), - LCDFadedColor(C_WHITE|255)); + _LCDFadedColor(C_WHITE|255)); } + diff --git a/Sources/GameMP/LCDDrawing.h b/Sources/GameMP/LCDDrawing.h index 751968b..3c972d7 100644 --- a/Sources/GameMP/LCDDrawing.h +++ b/Sources/GameMP/LCDDrawing.h @@ -6,23 +6,23 @@ #pragma once #endif -extern void LCDInit(void); -extern void LCDEnd(void); -extern void LCDPrepare(FLOAT fFade); -extern void LCDSetDrawport(CDrawPort *pdp); -extern void LCDDrawBox(PIX pixUL, PIX pixDR, PIXaabbox2D &box, COLOR col); -extern void LCDScreenBox(COLOR col); -extern void LCDScreenBoxOpenLeft(COLOR col); -extern void LCDScreenBoxOpenRight(COLOR col); -extern void LCDRenderClouds1(void); -extern void LCDRenderClouds2(void); -extern void LCDRenderClouds2Light(void); -extern void LCDRenderGrid(void); -extern void LCDDrawPointer(PIX pixI, PIX pixJ); -extern COLOR LCDGetColor(COLOR colDefault, const char *strName); -extern COLOR LCDFadedColor(COLOR col); -extern COLOR LCDBlinkingColor(COLOR col0, COLOR col1); - +extern void _LCDInit(void); +extern void _LCDEnd(void); +extern void _LCDPrepare(FLOAT fFade); +extern void _LCDSetDrawport(CDrawPort *pdp); +extern void _LCDDrawBox(PIX pixUL, PIX pixDR, PIXaabbox2D &box, COLOR col); +extern void _LCDScreenBox(COLOR col); +extern void _LCDScreenBoxOpenLeft(COLOR col); +extern void _LCDScreenBoxOpenRight(COLOR col); +extern void _LCDRenderClouds1(void); +extern void _LCDRenderClouds2(void); +extern void _LCDRenderClouds2Light(void); +extern void _LCDRenderGrid(void); +extern void _LCDDrawPointer(PIX pixI, PIX pixJ); +extern COLOR _LCDGetColor(COLOR colDefault, const char *strName); +extern COLOR _LCDFadedColor(COLOR col); +extern COLOR _LCDBlinkingColor(COLOR col0, COLOR col1); #endif /* include-once check. */ + diff --git a/Sources/GameMP/LoadingHook.cpp b/Sources/GameMP/LoadingHook.cpp index 4791b6a..494d73f 100644 --- a/Sources/GameMP/LoadingHook.cpp +++ b/Sources/GameMP/LoadingHook.cpp @@ -1,7 +1,7 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdafx.h" +#include "StdAfx.h" #include "LCDDrawing.h" #include @@ -65,7 +65,7 @@ static void LoadingHook_t(CProgressHookInfo *pphi) #endif // measure time since last call - static CTimerValue tvLast(0I64); + static CTimerValue tvLast((__int64) 0); CTimerValue tvNow = _pTimer->GetHighPrecisionTimer(); // if not first or final update, and not enough time passed @@ -163,7 +163,8 @@ static void LoadingHook_t(CProgressHookInfo *pphi) dpHook.SetTextAspect( 1.0f); // print status text setlocale(LC_ALL, ""); - CTString strDesc(0, "%s", pphi->phi_strDescription); strupr((char*)(const char*)strDesc); + CTString strDesc(0, "%s", (const char *) pphi->phi_strDescription); + strupr((char*)(const char*)strDesc); setlocale(LC_ALL, "C"); CTString strPerc(0, "%3.0f%%", pphi->phi_fCompleted*100); //dpHook.PutText(strDesc, pixCharSizeI/2, pixSizeJ-pixBarSizeJ-2-pixCharSizeJ, C_GREEN|255); @@ -175,12 +176,12 @@ static void LoadingHook_t(CProgressHookInfo *pphi) } /* - //LCDPrepare(1.0f); - //LCDSetDrawport(&dpHook); + //_pGame->LCDPrepare(1.0f); + //_pGame->LCDSetDrawport(&dpHook); // fill the box with background dirt and grid - //LCDRenderClouds1(); - //LCDRenderGrid(); + //_pGame->LCDRenderClouds1(); + //_pGame->LCDRenderGrid(); // draw progress bar PIX pixBarCentI = pixBoxSizeI*1/2; @@ -198,15 +199,15 @@ static void LoadingHook_t(CProgressHookInfo *pphi) (pixBarMaxI-pixBarMinI)*pphi->phi_fCompleted, pixBarMaxJ-pixBarMinJ, C_GREEN|255); // put more dirt - LCDRenderClouds2Light(); + _pGame->LCDRenderClouds2Light(); // draw borders COLOR colBorders = LerpColor(C_GREEN, C_BLACK, 200); - LCDDrawBox(0,-1, PIXaabbox2D( + _pGame->LCDDrawBox(0,-1, PIXaabbox2D( PIX2D(pixBarMinI, pixBarMinJ), PIX2D(pixBarMaxI, pixBarMaxJ)), colBorders|255); - LCDDrawBox(0,-1, PIXaabbox2D( + _pGame->LCDDrawBox(0,-1, PIXaabbox2D( PIX2D(0,0), PIX2D(dpBox.GetWidth(), dpBox.GetHeight())), colBorders|255); @@ -216,7 +217,7 @@ static void LoadingHook_t(CProgressHookInfo *pphi) dpBox.SetTextAspect( 1.0f); // print status text CTString strRes; - strRes.PrintF( "%s", pphi->phi_strDescription); + strRes.PrintF( "%s", (const char *) pphi->phi_strDescription); //strupr((char*)(const char*)strRes); dpBox.PutTextC( strRes, 160, 17, C_GREEN|255); strRes.PrintF( "%3.0f%%", pphi->phi_fCompleted*100); diff --git a/Sources/GameMP/Map.cpp b/Sources/GameMP/Map.cpp index ef01472..721c83b 100644 --- a/Sources/GameMP/Map.cpp +++ b/Sources/GameMP/Map.cpp @@ -569,8 +569,8 @@ void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi) _toMapBcgRU = &_toMapBcgRUFE; } - PIX pixdpw = pdp->GetWidth(); - PIX pixdph = pdp->GetHeight(); + PIX pixdpw = (PIX) pdp->GetWidth(); + PIX pixdph = (PIX) pdp->GetHeight(); PIX imgw = 512; PIX imgh = 480; FLOAT fStretch = 0.25f; @@ -584,34 +584,34 @@ void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi) fStretch = 0.5f; } - // calculate LU offset so picture would be centerd in dp - PIX pixSX = (pixdpw-imgw*fStretch)/2; + // calculate LU offset so picture would be centered in dp + PIX pixSX = (PIX) ((pixdpw-imgw*fStretch)/2); PIX pixSY = Max( PIX((pixdph-imgh*fStretch)/2), PIX(0)); PIX pixC1S = pixSX; // column 1 start pixel PIX pixR1S = pixSY; // raw 1 start pixel - PIX pixC1E = pixSX+256*fStretch; // column 1 end pixel - PIX pixR1E = pixSY+256*fStretch; // raw 1 end pixel - PIX pixC2S = pixC1E-fStretch; // column 2 start pixel - PIX pixR2S = pixR1E-fStretch; // raw 2 start pixel - PIX pixC2E = pixC2S+256*fStretch; // column 2 end pixel - PIX pixR2E = pixR2S+256*fStretch; // raw 2 end pixel + PIX pixC1E = (PIX) (pixSX+256*fStretch); // column 1 end pixel + PIX pixR1E = (PIX) (pixSY+256*fStretch); // raw 1 end pixel + PIX pixC2S = (PIX) (pixC1E-fStretch); // column 2 start pixel + PIX pixR2S = (PIX) (pixR1E-fStretch); // raw 2 start pixel + PIX pixC2E = (PIX) (pixC2S+256*fStretch); // column 2 end pixel + PIX pixR2E = (PIX) (pixR2S+256*fStretch); // raw 2 end pixel if (ulLevelMask == 0x00000001 && !map_bIsFirstEncounter) { // render the book - PIX pixX = aIconCoords[0][0]*fStretch+pixC1S; - PIX pixY = aIconCoords[0][1]*fStretch+pixR1S; + PIX pixX = (PIX) (aIconCoords[0][0]*fStretch+pixC1S); + PIX pixY = (PIX) (aIconCoords[0][1]*fStretch+pixR1S); CTextureObject *pto = &atoIcons[0]; pdp->PutTexture( pto, PIXaabbox2D( PIX2D(pixC1S,pixR1S), PIX2D(pixC2E,pixR2E)), C_WHITE|255); } else { // render pale map bcg - pdp->PutTexture( _toMapBcgLU, PIXaabbox2D( PIX2D(pixC1S,pixR1S), PIX2D(pixC1E,pixR1E)), C_WHITE|255); - pdp->PutTexture( _toMapBcgRU, PIXaabbox2D( PIX2D(pixC2S,pixR1S), PIX2D(pixC2E,pixR1E)), C_WHITE|255); - pdp->PutTexture( _toMapBcgLD, PIXaabbox2D( PIX2D(pixC1S,pixR2S), PIX2D(pixC1E,pixR2E)), C_WHITE|255); - pdp->PutTexture( _toMapBcgRD, PIXaabbox2D( PIX2D(pixC2S,pixR2S), PIX2D(pixC2E,pixR2E)), C_WHITE|255); + pdp->PutTexture( &_toMapBcgLU, PIXaabbox2D( PIX2D(pixC1S,pixR1S), PIX2D(pixC1E,pixR1E)), C_WHITE|255); + pdp->PutTexture( &_toMapBcgRU, PIXaabbox2D( PIX2D(pixC2S,pixR1S), PIX2D(pixC2E,pixR1E)), C_WHITE|255); + pdp->PutTexture( &_toMapBcgLD, PIXaabbox2D( PIX2D(pixC1S,pixR2S), PIX2D(pixC1E,pixR2E)), C_WHITE|255); + pdp->PutTexture( &_toMapBcgRD, PIXaabbox2D( PIX2D(pixC2S,pixR2S), PIX2D(pixC2E,pixR2E)), C_WHITE|255); // render icons for( INDEX iIcon=(!map_bIsFirstEncounter); iIconGetData())->GetPixWidth()*fStretch; - PIX pixImgH = ((CTextureData *)pto->GetData())->GetPixHeight()*fStretch; + PIX pixImgW = (PIX) (((CTextureData *)pto->GetData())->GetPixWidth()*fStretch); + PIX pixImgH = (PIX) (((CTextureData *)pto->GetData())->GetPixHeight()*fStretch); pdp->PutTexture( pto, PIXaabbox2D( PIX2D(pixX, pixY), PIX2D(pixX+pixImgW, pixY+pixImgH)), C_WHITE|255); } } @@ -643,8 +643,8 @@ void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi) { for( INDEX iDot=0; iDot<10; iDot++) { - PIX pixDotX=pixC1S+aPathDots[iPath][iDot][0]*fStretch; - PIX pixDotY=pixR1S+aPathDots[iPath][iDot][1]*fStretch; + PIX pixDotX=(PIX) (pixC1S+aPathDots[iPath][iDot][0]*fStretch); + PIX pixDotY=(PIX) (pixR1S+aPathDots[iPath][iDot][1]*fStretch); if(aPathDots[iPath][iDot][0]==-1) break; pdp->PutTexture( &_toPathDot, PIXaabbox2D( PIX2D(pixDotX, pixDotY), PIX2D(pixDotX+8*fStretch, pixDotY+8*fStretch)), (map_bIsFirstEncounter ? C_WHITE : C_BLACK)|255); @@ -675,8 +675,8 @@ void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi) } } - PIX pixhtcx = pixC1S+iPosX*fStretch; - PIX pixhtcy = pixR1S+iPosY*fStretch; + PIX pixhtcx = (PIX) (pixC1S+iPosX*fStretch); + PIX pixhtcy = (PIX) (pixR1S+iPosY*fStretch); if(map_bIsFirstEncounter) { pixhtcx = pixC1S+116*fStretch; @@ -687,8 +687,8 @@ void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi) for( INDEX iProgresDot=0; iProgresDot<16; iProgresDot+=1) { if(map_bIsFirstEncounter) { - PIX pixDotX=pixC1S+(48+iProgresDot*8)*fStretch; - PIX pixDotY=pixR1S+249*fStretch; + PIX pixDotX=(PIX) (pixC1S+(48+iProgresDot*8)*fStretch); + PIX pixDotY=(PIX) (pixR1S+249*fStretch); COLOR colDot = C_WHITE|255; if(iProgresDot>pphi->phi_fCompleted*16) { @@ -697,8 +697,8 @@ void RenderMap( CDrawPort *pdp, ULONG ulLevelMask, CProgressHookInfo *pphi) pdp->PutTexture( &_toPathDot, PIXaabbox2D( PIX2D(pixDotX, pixDotY), PIX2D(pixDotX+8*fStretch, pixDotY+8*fStretch)), colDot); } else { - PIX pixDotX=pixC1S+((iPosX-68)+iProgresDot*8)*fStretch; - PIX pixDotY=pixR1S+(iPosY+19)*fStretch; + PIX pixDotX=(PIX) (pixC1S+((iPosX-68)+iProgresDot*8)*fStretch); + PIX pixDotY=(PIX) (pixR1S+(iPosY+19)*fStretch); COLOR colDot = colText|255; if(iProgresDot>pphi->phi_fCompleted*16) { diff --git a/Sources/GameMP/SessionProperties.cpp b/Sources/GameMP/SessionProperties.cpp index 1ecddd2..b650d4d 100644 --- a/Sources/GameMP/SessionProperties.cpp +++ b/Sources/GameMP/SessionProperties.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdafx.h" +#include "StdAfx.h" #include "Game.h" extern FLOAT gam_afEnemyMovementSpeed[5]; diff --git a/Sources/GameMP/SessionProperties.h b/Sources/GameMP/SessionProperties.h index 074f8ae..468bd55 100644 --- a/Sources/GameMP/SessionProperties.h +++ b/Sources/GameMP/SessionProperties.h @@ -83,6 +83,7 @@ public: CUniversalSessionProperties() { ASSERT(sizeof(CSessionProperties)<=NET_MAXSESSIONPROPERTIES); ASSERT(sizeof(CUniversalSessionProperties)==NET_MAXSESSIONPROPERTIES); + memset(usp_aubDummy, '\0', sizeof (usp_aubDummy)); } operator CSessionProperties&(void) { return usp_sp; } }; diff --git a/Sources/GameMP/WEDInterface.cpp b/Sources/GameMP/WEDInterface.cpp index 5531a54..f689081 100644 --- a/Sources/GameMP/WEDInterface.cpp +++ b/Sources/GameMP/WEDInterface.cpp @@ -50,7 +50,7 @@ void UpdateInputEnabledState(CViewPort *pvp) } // automaticaly manage pause toggling -void UpdatePauseState(void) +static void UpdatePauseState(void) { BOOL bShouldPause = _pGame->gm_csConsoleState ==CS_ON || _pGame->gm_csConsoleState ==CS_TURNINGON || _pGame->gm_csConsoleState ==CS_TURNINGOFF || @@ -63,7 +63,12 @@ void UpdatePauseState(void) void CGame::QuickTest(const CTFileName &fnMapName, CDrawPort *pdp, CViewPort *pvp) { - UINT uiMessengerMsg = RegisterWindowMessageA("Croteam Messenger: Incoming Message"); +#ifdef PLATFORM_WIN32 + UINT uiMessengerMsg = RegisterWindowMessage("Croteam Messenger: Incoming Message"); +#else + UINT uiMessengerMsg = 0x7337d00d; +#endif + EnableLoadingHook(pdp); // quick start game with the world @@ -153,7 +158,12 @@ void CGame::QuickTest(const CTFileName &fnMapName, _pNetwork->TogglePause(); } if(msg.message==WM_KEYDOWN && + // !!! FIXME: rcg11162001 This sucks. + #ifdef PLATFORM_UNIX + (msg.unicode == '~' + #else (MapVirtualKey(msg.wParam, 0)==41 // scan code for '~' + #endif ||msg.wParam==VK_F1)) { if (_pGame->gm_csConsoleState==CS_OFF || _pGame->gm_csConsoleState==CS_TURNINGOFF) { _pGame->gm_csConsoleState = CS_TURNINGON; diff --git a/Sources/Makefile b/Sources/Makefile new file mode 100644 index 0000000..da1a041 --- /dev/null +++ b/Sources/Makefile @@ -0,0 +1,879 @@ + +# !!! FIXME: Make this more robust. MUCH more robust. +# !!! FIXME: ...or at least comment the rest of these options... + +# icc is intel's compiler. gcc is, well.., gcc. +# Intel compiler < version 6.0 probably won't work. +#CC := icc +#LINKER := icc +CC := gcc +CXX := g++ +LINKER := g++ +LIBLINKER := g++ + +#arch := $(shell uname -m) + +os := $(shell uname -s) +ifeq ($(strip $(os)),Darwin) + macosx := true +else + macosx := false +endif + +#debug := false +debug := true + +#DO NOT SHIP WITH PROFILING ENABLED! +# You will probably need to set static_link := true below, too. +# (This seems to be broken right now. Thanks, gcc.) +profile := false +#profile := true + +# DO NOT SHIP WITH THIS! +# In fact, you almost should never set this to true. +# (What a surprise, this doesn't work either. Thanks, gcc.) +soft_float := false +#soft_float := true + +#use_mmx_intrinsics := true +use_mmx_intrinsics := false + + +#use_efence := true +use_efence := false +EFENCELIB := /usr/lib/libefence.a + +USE_ASM := -DUSE_I386_ASM +#USE_ASM := -DUSE_PORTABLE_C + +# Build everything as a single-threaded program. +# Note that SDL and other libraries may spin threads of their own, but +# generally it's safe to assume those threads are independent of the game +# and won't cause race conditions. The ones that do, like the SDL timer +# thread, are taken into account with this option. +# +# In multithreaded mode, The Serious Engine and SeriousSam only spin one +# thread: the timer thread, which runs a "todo list" every 1/20 seconds. +# Single threaded mode makes periodic calls to a function that determines if +# it is time to run the todo list, and immediately returns if not. In such a +# mode, we don't have to concern ourselves with race conditions, mutex +# contention, and thread local storage, but could have serious problems +# ("queue lag") if the timer-checking function doesn't get called regularly. +# Lag isn't a concern in-game, since the main loop has such a call, but it +# isn't hard to get into a blocking loop (map loading, etc) that causes a +# queue lag. Generally, these just need to be flushed out, but if they +# haven't been...well, You Have Been Warned. +single_threaded := true +#single_threaded := false + +# (You should probably should leave this set to true.) +netstructs_packed := true +#netstructs_packed := false + +# Set this to statically link the main binary with the game and entities +# objects. Without this, game and entities are separate shared libraries that +# are dlopen()'d at runtime. Enabling this is just for debugging purposes, +# mostly. SDL and other LGPL'd code is statically linked in the main binary +# regardless of this option (a binaryname.dynamic version is also built to +# satisfy LGPL requirements, again, regardless of this option). +#static_link := $(debug) +#static_link := true +static_link := false + + +# Set this to true to use the MSVC inline assembly with the intel compiler. +# (Setting is ignored when building with something other than "icc".) +use_msvc_asm := true +#use_msvc_asm := false + + +# Set this to make a binary that refuses to run 30 days after it was compiled. +# (after SeriousSam/SeriousSam.cpp was compiled, specifically.) +#expiring_beta := $(debug) +#expiring_beta := true +expiring_beta := false + + +# Use this to automate the moving of binaries and updated source to another +# system for remote debugging. USE WITH CAUTION, since source and +# unofficial binaries will be going over a wire. Setting permit_scp to false +# completely removes the "make scp" rule from the Makefile at build time. +permit_scp := true +scp_bin := scp +scp_user := icculus +scp_host := liza +scp_dir := Croteam/ssam/Bin +scp_src_dir := projects/ssam + +BINDIR := bin +SRCDIR := . + +# SDL directory for static linking. +SDLDIR := /usr/local/lib + +INSTALLDIR := $(HOME)/Croteam/ssam/Bin +ifeq ($(strip $(debug)),true) + INSTALLDIR := $(strip $(INSTALLDIR))/Debug + scp_dir := $(strip $(scp_dir))/Debug +endif + +# You need the Netwide Assembler (NASM) to build this on Intel systems. +# http://nasm.sf.net/ +# Intel Mac OS X needs at least nasm 0.98.40, which is CVS-only at the +# time of this writing, since it adds x86 Mach-O object file support. +ASM := nasm + +ifeq ($(strip $(macosx)),true) + ASMOBJFMT := macho + ASMFLAGS += --prefix _ +else + ASMOBJFMT := elf +endif + +EXE_EXT := + +#-----------------------------------------------------------------------------# +# Rules. +#-----------------------------------------------------------------------------# +CLEANUP = $(wildcard *.exe) $(wildcard *.obj) \ + $(wildcard $(BINDIR)/*.exe) $(wildcard $(BINDIR)/*.obj) \ + $(wildcard *~) $(wildcard *.err) \ + $(wildcard .\#*) core + +ENGINEBASESRCS := Engine/Base/Anim.cpp Engine/Base/CRC.cpp \ + Engine/Base/CRCTable.cpp Engine/Base/Changeable.cpp \ + Engine/Base/Console.cpp Engine/Base/Directory.cpp \ + Engine/Base/ErrorReporting.cpp Engine/Base/FileName.cpp \ + Engine/Base/Input.cpp Engine/Base/Lists.cpp \ + Engine/Base/Memory.cpp Engine/Base/Profiling.cpp \ + Engine/Base/ProgressHook.cpp Engine/Base/Protection.cpp \ + Engine/Base/Relations.cpp \ + Engine/Base/ReplaceFile.cpp Engine/Base/Serial.cpp \ + Engine/Base/Shell.cpp Engine/Base/ShellTypes.cpp \ + Engine/Base/Statistics.cpp \ + Engine/Base/Stream.cpp \ + Engine/Base/Timer.cpp Engine/Base/Translation.cpp \ + Engine/Base/Unzip.cpp Engine/Base/Updateable.cpp \ + Engine/Base/CTString.cpp \ + Engine/Base/Scanner.cpp \ + Engine/Base/Parser.cpp \ + Engine/Base/IFeel.cpp \ + Engine/Base/Unix/UnixFileSystem.cpp \ + Engine/Base/Unix/UnixDynamicLoader.cpp \ + Engine/Base/SDL/SDLTimer.cpp \ + Engine/Base/SDL/SDLInput.cpp \ + Engine/Base/SDL/SDLEvents.cpp + +ifeq ($(strip $(single_threaded)),true) + ENGINEBASESRCS += Engine/Base/NullSynchronization.cpp +else + ENGINEBASESRCS += Engine/Base/Unix/UnixSynchronization.cpp + ENGINEBASESRCS += Engine/Base/SDL/SDLThreadLocalStorage.cpp +endif + +# Do we need this? How reliant on the registry is the engine? We could fake +# these calls easily enough if need be. +#ENGINEBASESRCS += Engine/Base/Registry.cpp + +# Stuff that probably shouldn't be compiled at all... +#ENGINEBASESRCS += Engine/Base/StackDump.cpp + +# Engine/Base/Synchronization.cpp is now Engine/Base/SDL/SDLSynchronization.cpp +# in Linux, and Engine/Base/Win32/Win32Synchronization.cpp for Windows. + +ENGINEBRUSHESSRCS := Engine/Brushes/Brush.cpp Engine/Brushes/BrushIO.cpp \ + Engine/Brushes/BrushShadows.cpp \ + Engine/Brushes/BrushTriangularize.cpp \ + Engine/Brushes/BrushArchive.cpp \ + Engine/Brushes/BrushImport.cpp \ + Engine/Brushes/BrushMip.cpp \ + Engine/Brushes/BrushPolygon.cpp \ + Engine/Brushes/BrushExport.cpp \ + Engine/Brushes/BrushSector.cpp + +ENGINEENTITYSRCS := Engine/Entities/Entity.cpp \ + Engine/Entities/NearestPolygon.cpp \ + Engine/Entities/EntityProperties.cpp \ + Engine/Entities/PlayerCharacter.cpp \ + Engine/Entities/EntityClass.cpp \ + Engine/Entities/FieldBSPTesting.cpp \ + Engine/Entities/EntityCollision.cpp \ + Engine/Entities/EntityCopying.cpp \ + Engine/Entities/LastPositions.cpp + +ENGINEMATHSRCS := Engine/Math/Projection_Isometric.cpp \ + Engine/Math/Object3D.cpp \ + Engine/Math/Projection_Parallel.cpp \ + Engine/Math/Projection_Perspective.cpp \ + Engine/Math/Float.cpp \ + Engine/Math/Object3D_CSG.cpp \ + Engine/Math/Projection_Simple.cpp \ + Engine/Math/Projection_Simple_DOUBLE.cpp \ + Engine/Math/Functions.cpp \ + Engine/Math/ObjectSector.cpp \ + Engine/Math/Placement.cpp \ + Engine/Math/TextureMapping.cpp \ + Engine/Math/Geometry.cpp \ + Engine/Math/Projection.cpp \ + Engine/Math/Geometry_DOUBLE.cpp + +# This uses that "Exploration 3D library. Hopefully we can just skip this file. +#ENGINEMATHSRCS += Engine/Math/Object3D_IO.cpp + +ENGINEMODELSSRCS := Engine/Models/Model.cpp \ + Engine/Models/RenderModel_View.cpp \ + Engine/Models/Normals.cpp \ + Engine/Models/VertexGetting.cpp \ + Engine/Models/RenderModel.cpp \ + Engine/Models/MipMaker.cpp \ + Engine/Models/ModelProfile.cpp \ + Engine/Models/RenderModel_Mask.cpp + +# I don't think this is needed for the client or server, and it needs symbols +# from Object3D_IO.cpp, which needs stuff from that win32 library... +#ENGINEMODELSSRCS += Engine/Models/EditModel.cpp + + +ENGINELIGHTSRCS := Engine/Light/LayerMaker.cpp \ + Engine/Light/LayerMixer.cpp \ + Engine/Light/LightSource.cpp + +ENGINEGRAPHICSSRCS := Engine/Graphics/Adapter.cpp \ + Engine/Graphics/Raster.cpp \ + Engine/Graphics/GfxLibrary.cpp \ + Engine/Graphics/Benchmark.cpp \ + Engine/Graphics/GfxProfile.cpp \ + Engine/Graphics/Color.cpp \ + Engine/Graphics/ShadowMap.cpp \ + Engine/Graphics/DepthCheck.cpp \ + Engine/Graphics/Texture.cpp \ + Engine/Graphics/DisplayMode.cpp \ + Engine/Graphics/Gfx_OpenGL.cpp \ + Engine/Graphics/Gfx_OpenGL_Textures.cpp \ + Engine/Graphics/TextureEffects.cpp \ + Engine/Graphics/DrawPort.cpp \ + Engine/Graphics/Gfx_wrapper.cpp \ + Engine/Graphics/DrawPort_Particles.cpp \ + Engine/Graphics/Graphics.cpp \ + Engine/Graphics/ViewPort.cpp \ + Engine/Graphics/DrawPort_RenderScene.cpp \ + Engine/Graphics/ImageInfo.cpp \ + Engine/Graphics/Fog.cpp \ + Engine/Graphics/MultiMonitor.cpp \ + Engine/Graphics/Font.cpp \ + Engine/Graphics/Shader.cpp \ + Engine/Graphics/Stereo.cpp \ + Engine/Graphics/SDL/SDLOpenGL.cpp \ + Engine/Graphics/SDL/SDLAdapter.cpp + +ENGINENETWORKSRCS := Engine/Network/ActionBuffer.cpp \ + Engine/Network/NetworkMessage.cpp \ + Engine/Network/Server.cpp \ + Engine/Network/GameSpy.cpp \ + Engine/Network/Buffer.cpp \ + Engine/Network/NetworkProfile.cpp \ + Engine/Network/GameSpyEnum.cpp \ + Engine/Network/SessionState.cpp \ + Engine/Network/GameSpyKeys.cpp \ + Engine/Network/PlayerBuffer.cpp \ + Engine/Network/MessageDispatcher.cpp \ + Engine/Network/PlayerSource.cpp \ + Engine/Network/Compression.cpp \ + Engine/Network/Network.cpp \ + Engine/Network/PlayerTarget.cpp \ + Engine/Network/CPacket.cpp \ + Engine/Network/ClientInterface.cpp \ + Engine/Network/CommunicationInterface.cpp \ + Engine/Network/Diff.cpp + + +ENGINEGAMESPYSRCS := Engine/gamespy/darray.c \ + Engine/gamespy/gqueryreporting.c \ + Engine/gamespy/gserver.c \ + Engine/gamespy/gserverlist.c \ + Engine/gamespy/hashtable.c \ + Engine/gamespy/nonport.c + +ENGINETERRAINSRCS := Engine/Terrain/ArrayHolder.cpp \ + Engine/Terrain/Terrain.cpp \ + Engine/Terrain/TerrainArchive.cpp \ + Engine/Terrain/TerrainEditing.cpp \ + Engine/Terrain/TerrainLayer.cpp \ + Engine/Terrain/TerrainMisc.cpp \ + Engine/Terrain/TerrainRayCasting.cpp \ + Engine/Terrain/TerrainRender.cpp \ + Engine/Terrain/TerrainTile.cpp + + +# this code is included in Engine/gamespy/gqueryreporting, too... +#ENGINEGAMESPYSRCS += Engine/gamespy/gutil.c + +ENGINERENDERINGSRCS := Engine/Rendering/Render.cpp \ + Engine/Rendering/RenderProfile.cpp \ + Engine/Rendering/SelectOnRender.cpp + +ENGINESKASRCS := Engine/Ska/AnimSet.cpp \ + Engine/Ska/RMRender.cpp \ + Engine/Ska/Skeleton.cpp \ + Engine/Ska/ModelInstance.cpp \ + Engine/Ska/StringTable.cpp \ + Engine/Ska/Mesh.cpp \ + Engine/Ska/RMRenderMask.cpp \ + Engine/Ska/smcPars.cpp \ + Engine/Ska/smcScan.cpp + +ENGINESOUNDSRCS := Engine/Sound/SoundDecoder.cpp \ + Engine/Sound/SoundObject.cpp \ + Engine/Sound/SoundLibrary.cpp \ + Engine/Sound/SoundProfile.cpp \ + Engine/Sound/SoundData.cpp \ + Engine/Sound/Wave.cpp \ + Engine/Sound/SoundMixer.cpp + +ifeq ($(strip $(USE_ASM)),-DUSE_I386_ASM) + ENGINESOUNDSRCS += Engine/Sound/SoundMixer386.asm +endif + +ENGINETEMPLATESSRCS := Engine/Templates/Stock_CAnimData.cpp \ + Engine/Templates/Stock_CAnimSet.cpp \ + Engine/Templates/Stock_CEntityClass.cpp \ + Engine/Templates/Stock_CMesh.cpp \ + Engine/Templates/Stock_CModelData.cpp \ + Engine/Templates/Stock_CSkeleton.cpp \ + Engine/Templates/Stock_CSoundData.cpp \ + Engine/Templates/Stock_CTextureData.cpp \ + Engine/Templates/Stock_CShader.cpp \ + Engine/Templates/NameTable_CTFileName.cpp \ + Engine/Templates/NameTable_CTranslationPair.cpp \ + Engine/Templates/BSP.cpp + +ENGINEWORLDSRCS := Engine/World/WorldCSG.cpp \ + Engine/World/PhysicsProfile.cpp \ + Engine/World/WorldCollision.cpp \ + Engine/World/WorldIO.cpp \ + Engine/World/WorldRayCasting.cpp \ + Engine/World/World.cpp \ + Engine/World/WorldCollisionGrid.cpp \ + Engine/World/WorldEditingProfile.cpp + +ENGINEZLIBSRCS := Engine/zlib/inflate.c \ + Engine/zlib/adler32.c \ + Engine/zlib/infblock.c \ + Engine/zlib/inffast.c \ + Engine/zlib/inftrees.c \ + Engine/zlib/trees.c \ + Engine/zlib/compress.c \ + Engine/zlib/zutil.c \ + Engine/zlib/deflate.c \ + Engine/zlib/infcodes.c \ + Engine/zlib/infutil.c \ + Engine/zlib/uncompr.c + + +ENGINESRCS := Engine/Engine.cpp \ + $(ENGINEBASESRCS) \ + $(ENGINEBRUSHESSRCS) \ + $(ENGINEENTITYSRCS) \ + $(ENGINEGRAPHICSSRCS) \ + $(ENGINELIGHTSRCS) \ + $(ENGINEMATHSRCS) \ + $(ENGINEMODELSSRCS) \ + $(ENGINENETWORKSRCS) \ + $(ENGINETERRAINSRCS) \ + $(ENGINERENDERINGSRCS) \ + $(ENGINESKASRCS) \ + $(ENGINESOUNDSRCS) \ + $(ENGINETEMPLATESSRCS) \ + $(ENGINEWORLDSRCS) \ + $(ENGINEGAMESPYSRCS) \ + $(ENGINEZLIBSRCS) + +OBJS1 := $(ENGINESRCS:.c=.o) +OBJS2 := $(OBJS1:.cpp=.o) +OBJS3 := $(OBJS2:.asm=.o) +ENGINEOBJS := $(foreach f,$(OBJS3),$(BINDIR)/$(f)) +ENGINESRCS := $(foreach f,$(ENGINESRCS),$(SRCDIR)/$(f)) + +SHADERSSRCS := Shaders/AddShader.cpp \ + Shaders/AddShaderDS.cpp \ + Shaders/BaseShader.cpp \ + Shaders/BaseShaderDS.cpp \ + Shaders/BaseTransparent.cpp \ + Shaders/BaseTransparentDS.cpp \ + Shaders/ColorShader.cpp \ + Shaders/Common.cpp \ + Shaders/DetailShader.cpp \ + Shaders/DisplaceShader.cpp \ + Shaders/InvisibleShader.cpp \ + Shaders/MultiLayerShader.cpp \ + Shaders/Reflection.cpp \ + Shaders/ReflectionDS.cpp \ + Shaders/ReftectionAndSpecular.cpp \ + Shaders/ReftectionAndSpecularDS.cpp \ + Shaders/Specular.cpp \ + Shaders/SpecularDS.cpp \ + Shaders/StdH.cpp \ + Shaders/Translucent.cpp + +OBJS1 := $(SHADERSSRCS:.c=.o) +OBJS2 := $(OBJS1:.cpp=.o) +OBJS3 := $(OBJS2:.asm=.o) +SHADERSOBJS := $(foreach f,$(OBJS3),$(BINDIR)/$(f)) +SHADERSSRCS := $(foreach f,$(SHADERSSRCS),$(SRCDIR)/$(f)) + + +GAMESRCS := Game/Camera.cpp Game/CompMessage.cpp Game/CompModels.cpp \ + Game/Computer.cpp Game/Console.cpp Game/Controls.cpp \ + Game/Game.cpp Game/LCDDrawing.cpp Game/LoadingHook.cpp \ + Game/Map.cpp Game/SessionProperties.cpp Game/WEDInterface.cpp + +OBJS1 := $(GAMESRCS:.c=.o) +OBJS2 := $(OBJS1:.cpp=.o) +OBJS3 := $(OBJS2:.asm=.o) +GAMEOBJS := $(foreach f,$(OBJS3),$(BINDIR)/$(f)) +GAMESRCS := $(foreach f,$(GAMESRCS),$(SRCDIR)/$(f)) + + +GAMEMPSRCS := GameMP/Camera.cpp GameMP/CompMessage.cpp GameMP/CompModels.cpp \ + GameMP/Computer.cpp GameMP/Console.cpp GameMP/Controls.cpp \ + GameMP/Game.cpp GameMP/LCDDrawing.cpp GameMP/LoadingHook.cpp \ + GameMP/Map.cpp GameMP/SessionProperties.cpp GameMP/WEDInterface.cpp + +OBJS1 := $(GAMEMPSRCS:.c=.o) +OBJS2 := $(OBJS1:.cpp=.o) +OBJS3 := $(OBJS2:.asm=.o) +GAMEMPOBJS := $(foreach f,$(OBJS3),$(BINDIR)/$(f)) +GAMEMPSRCS := $(foreach f,$(GAMEMPSRCS),$(SRCDIR)/$(f)) + +ENTITYFILES := $(wildcard Entities/*.es) +ENTITYHEADERS := $(ENTITYFILES:.es=.h) +ENTITYTABLES := $(ENTITYFILES:.es=_tables.h) +ENTITYSRCS := $(ENTITYHEADERS:.h=.cpp) + +ENTITYCOMMONSRCS := Entities/Common/Common.cpp Entities/Common/Particles.cpp \ + Entities/Common/PathFinding.cpp Entities/Common/HUD.cpp + +# These file are empty right now. ? +#ENTITYCOMMONSRCS += Entities/Common/Stats.cpp +#ENTITYCOMMONSRCS += Entities/Common/Debris.cpp + +ENTITYHEADERS := $(foreach f,$(ENTITYHEADERS),$(SRCDIR)/$(f)) + +OBJS1 := $(ENTITYSRCS:.cpp=.o) $(ENTITYCOMMONSRCS:.cpp=.o) +ENTITYOBJS := $(foreach f,$(OBJS1),$(BINDIR)/$(f)) +ENTITYSRCS := $(foreach f,$(ENTITYSRCS),$(SRCDIR)/$(f)) + + +ENTITYMPFILES := $(wildcard EntitiesMP/*.es) +ENTITYMPHEADERS := $(ENTITYMPFILES:.es=.h) +ENTITYMPTABLES := $(ENTITYMPFILES:.es=_tables.h) +ENTITYMPSRCS := $(ENTITYMPHEADERS:.h=.cpp) + +ENTITYMPCOMMONSRCS := EntitiesMP/Common/Common.cpp \ + EntitiesMP/Common/Particles.cpp \ + EntitiesMP/Common/EmanatingParticles.cpp \ + EntitiesMP/Common/PathFinding.cpp \ + EntitiesMP/Common/HUD.cpp + +# These file are empty right now. ? +#ENTITYMPCOMMONSRCS += EntitiesMP/Common/Stats.cpp +#ENTITYMPCOMMONSRCS += EntitiesMP/Common/Debris.cpp + +ENTITYMPHEADERS := $(foreach f,$(ENTITYMPHEADERS),$(SRCDIR)/$(f)) + +OBJS1 := $(ENTITYMPSRCS:.cpp=.o) $(ENTITYMPCOMMONSRCS:.cpp=.o) +ENTITYMPOBJS := $(foreach f,$(OBJS1),$(BINDIR)/$(f)) +ENTITYMPSRCS := $(foreach f,$(ENTITYMPSRCS),$(SRCDIR)/$(f)) + +# These are done separately, after ENTITYOBJS is initialized, because it +# should only be linked into the main binary. +ENGINEENTITYFILES := $(wildcard Engine/Classes/*.es) +ENGINEENTITYHEADERS := $(ENGINEENTITYFILES:.es=.h) +ENGINEENTITYTABLES := $(ENGINEENTITYFILES:.es=_tables.h) +ENGINEENTITYSRCS := $(ENGINEENTITYHEADERS:.h=.cpp) +OBJS1 := $(ENGINEENTITYSRCS:.cpp=.o) +ENGINEENTITYOBJS := $(foreach f,$(OBJS1),$(BINDIR)/$(f)) +ENGINEENTITYSRCS := $(foreach f,$(ENGINEENTITYSRCS),$(SRCDIR)/$(f)) + +ENTITYFILES += $(ENGINEENTITYFILES) +ENTITYHEADERS += $(ENGINEENTITYHEADERS) +ENTITYTABLES += $(ENGINEENTITYTABLES) +ENTITYSRCS += $(ENGINEENTITYSRCS) + +ENTITYMPFILES += $(ENGINEENTITYFILES) +ENTITYMPHEADERS += $(ENGINEENTITYHEADERS) +ENTITYMPTABLES += $(ENGINEENTITYTABLES) +ENTITYMPSRCS += $(ENGINEENTITYSRCS) + +ifeq ($(strip $(macosx)),true) + DLLEXT := dylib +else + DLLEXT := so +endif +ifeq ($(strip $(debug)),true) + ENTITYDLL := $(BINDIR)/libEntitiesD.$(DLLEXT) + ENTITYMPDLL := $(BINDIR)/libEntitiesMPD.$(DLLEXT) + GAMEDLL := $(BINDIR)/libGameD.$(DLLEXT) + GAMEMPDLL := $(BINDIR)/libGameMPD.$(DLLEXT) + SHADERSDLL := $(BINDIR)/libShadersD.$(DLLEXT) +else + ENTITYDLL := $(BINDIR)/libEntities.$(DLLEXT) + ENTITYMPDLL := $(BINDIR)/libEntitiesMP.$(DLLEXT) + GAMEDLL := $(BINDIR)/libGame.$(DLLEXT) + GAMEMPDLL := $(BINDIR)/libGameMP.$(DLLEXT) + SHADERSDLL := $(BINDIR)/libShaders.$(DLLEXT) +endif + +ECCEXE := $(BINDIR)/ecc-bin +ECCSRCS := Ecc/Main.cpp Ecc/Parser.cpp Ecc/Scanner.cpp +OBJS1 := $(ECCSRCS:.c=.o) +OBJS2 := $(OBJS1:.cpp=.o) +OBJS3 := $(OBJS2:.asm=.o) +ECCOBJS := $(foreach f,$(OBJS3),$(BINDIR)/$(f)) +ECCSRCS := $(foreach f,$(ECCSRCS),$(SRCDIR)/$(f)) + +DEDICATEDEXE := $(BINDIR)/ssamded-bin.static +DEDICATEDEXE_DYNAMIC := $(BINDIR)/ssamded-bin +DEDICATEDSRCS := DedicatedServer/DedicatedServer.cpp +OBJS1 := $(DEDICATEDSRCS:.c=.o) +OBJS2 := $(OBJS1:.cpp=.o) +OBJS3 := $(OBJS2:.asm=.o) +DEDICATEDOBJS := $(foreach f,$(OBJS3),$(BINDIR)/$(f)) +DEDICATEDSRCS := $(foreach f,$(DEDICATEDSRCS),$(SRCDIR)/$(f)) + +SERIOUSSAMEXE := $(BINDIR)/ssam-bin.static +SERIOUSSAMEXE_DYNAMIC := $(BINDIR)/ssam-bin +SERIOUSSAMSRCS := SeriousSam/LevelInfo.cpp SeriousSam/CmdLine.cpp \ + SeriousSam/SeriousSam.cpp SeriousSam/VarList.cpp \ + SeriousSam/Credits.cpp SeriousSam/Menu.cpp \ + SeriousSam/GLSettings.cpp SeriousSam/MenuGadgets.cpp \ + SeriousSam/LCDDrawing.cpp SeriousSam/MenuPrinting.cpp \ + SeriousSam/SplashScreen.cpp SeriousSam/MainWindow.cpp + +OBJS1 := $(SERIOUSSAMSRCS:.c=.o) +OBJS2 := $(OBJS1:.cpp=.o) +OBJS3 := $(OBJS2:.asm=.o) +SERIOUSSAMOBJS := $(foreach f,$(OBJS3),$(BINDIR)/$(f)) +SERIOUSSAMSRCS := $(foreach f,$(SERIOUSSAMSRCS),$(SRCDIR)/$(f)) + +ifeq ($(strip $(static_link)),true) +DEDICATEDEXTRAOBJS := $(ENTITYOBJS) $(GAMEOBJS) +SERIOUSSAMEXTRAOBJS := $(ENTITYOBJS) $(GAMEOBJS) $(SHADERSOBJS) +CFLAGS += -DSTATICALLY_LINKED +endif + +#INSTALLABLES := $(DEDICATEDEXE) $(SERIOUSSAMEXE) $(DEDICATEDEXE_DYNAMIC) $(SERIOUSSAMEXE_DYNAMIC) $(ECCEXE) +#INSTALLABLES := $(SERIOUSSAMEXE) +INSTALLABLES := $(SERIOUSSAMEXE_DYNAMIC) $(DEDICATEDEXE_DYNAMIC) +ifneq ($(strip $(static_link)),true) + INSTALLABLES += $(ENTITYDLL) $(ENTITYMPDLL) $(GAMEDLL) $(GAMEMPDLL) $(SHADERSDLL) +endif + +# !!! FIXME: Get -Wall in here, some day. +CFLAGS += -IExternal/SDL12 +CFLAGS += $(USE_ASM) -I$(SRCDIR) -D_REENTRANT -DPLATFORM_UNIX -D_MT +ifeq ($(strip $(macosx)),true) + CFLAGS += -DPLATFORM_MACOSX + CXXFLAGS += -Wno-invalid-offsetof +endif + +ifeq ($(strip $(CC)),icc) + # intel c++ options... + CFLAGS += $(USE_ASM) -I$(SRCDIR) -I/opt/intel/compiler60/ia32/include -D_REENTRANT -DPLATFORM_UNIX -D_MT -fp -Kc++eh -Krtti + + ifeq ($(strip $(use_msvc_asm)),true) + CFLAGS += -use_msasm -D__MSVC_INLINE__ + else + CFLAGS += -D__GNU_INLINE__ + endif + +else + # gcc options... + # !!! FIXME: Get -Wall in here, some day. + # !!! FIXME: Get -Werror back in here for gcc3, some day. + CFLAGS += $(USE_ASM) -I$(SRCDIR) -D_REENTRANT -fsigned-char -DPLATFORM_UNIX + CXXFLAGS += -Wno-non-template-friend -fexceptions -frtti + CFLAGS += -D_MT -fno-omit-frame-pointer +endif + +ifeq ($(strip $(soft_float)),true) + CFLAGS += -msoft-float + LDFLAGS += -msoft-float +endif + +ifeq ($(strip $(single_threaded)),true) + CFLAGS += -DSINGLE_THREADED +endif + +ifeq ($(strip $(netstructs_packed)),true) + CFLAGS += -DNETSTRUCTS_PACKED +endif + +ifeq ($(strip $(expiring_beta)),true) + CFLAGS += -DBETAEXPIRE=$(shell date +%s) +endif + +ifeq ($(strip $(profile)),true) + CFLAGS += -DPROFILING_ENABLED -pg +endif + +ifeq ($(strip $(use_efence)),false) + EFENCELIB := +endif + + +NOINLINE := -O0 + +# (you can always strip the binaries later...) +CFLAGS += -g +ASMFLAGS += -g +LDFLAGS += -g + +ifeq ($(strip $(debug)),true) + CFLAGS += -DDEBUG -O0 +else + ifeq ($(strip $(CC)),icc) + OPTFLAG := -O3 + CFLAGS += -xMi -tpp6 -rcd + else + #OPTFLAG := -O0 + #OPTFLAG := -O2 + OPTFLAG := -O3 -ffast-math -falign-loops=16 -fno-math-errno + ifneq ($(strip $(macosx)),true) + OPTFLAG += -march=pentium -mcpu=pentiumpro + else + ifeq ($(strip $(static_link)),true) + OPTFLAG += -mdynamic-no-pic + endif + endif + endif + CFLAGS += -DNDEBUG -D_NDEBUG $(OPTFLAG) +endif + +ifeq ($(strip $(CC)),icc) + PICFLAG := -KPIC +else + PICFLAG := -fPIC +endif +DLLLDFLAGS := $(PICFLAG) $(LDFLAGS) +ifeq ($(strip $(macosx)),true) + DLLLDFLAGS += -dynamiclib -undefined dynamic_lookup +else + DLLLDFLAGS += -shared +endif + +#STATIC_SDL_LDFLAGS := -L/usr/X11R6/lib $(SDLDIR)/libSDL.a /usr/lib/libasound.a /usr/X11R6/lib/libxme.a /usr/local/lib/libesd.a -lpthread -lX11 -lXext -lXxf86dga -lXxf86vm -lXv -lXinerama +#-Wl,-Bstatic $(SDLDIR)/libSDL.a /usr/lib/libesd.a -Wl,-Bdynamic -lpthread -lX11 -lXext -lXxf86dga -lXxf86vm -lXv -lXinerama + +#DYNAMIC_SDL_LDFLAGS := $(shell sdl-config --libs) +DYNAMIC_SDL_LDFLAGS := +ifeq ($(strip $(macosx)),true) + DYNAMIC_SDL_LDFLAGS := lib/macosx_x86/libSDL-1.2.0.dylib bin/libSDLmain.a +else + DYNAMIC_SDL_LDFLAGS := lib/linux_x86/libSDL-1.2.so.0 +endif + +ifeq ($(strip $(macosx)),true) + LDFLAGS := -framework Cocoa -framework OpenGL +else + LDFLAGS += -rdynamic -lm -ldl +endif + +CFLAGS += $(shell sdl-config --cflags) + +ifneq ($(strip $(USE_ASM)),-DUSE_PORTABLE_C) +# CFLAGS += -O2 -fasm + ASMFLAGS += -f $(ASMOBJFMT) $(ASMDEFS) +else +endif + +ifeq ($(strip $(use_mmx_intrinsics)),true) + CFLAGS += -mmmx -DUSE_MMX_INTRINSICS=1 +endif + +CXXFLAGS += $(CFLAGS) + + +# Entity rules... +%.h : %.es $(ECCEXE) + $(ECCEXE) $< + @touch $@ + +$(BINDIR)/Entities/%.o: $(SRCDIR)/Entities/%.cpp + $(CXX) -c -o $@ $< -I$(dir $<)StdH $(CXXFLAGS) + +$(BINDIR)/EntitiesMP/%.o: $(SRCDIR)/EntitiesMP/%.cpp + $(CXX) -c -o $@ $< -I$(dir $<)StdH $(CXXFLAGS) + +$(BINDIR)/Engine/Classes/%.o: $(SRCDIR)/Engine/Classes/%.cpp + $(CXX) -c -o $@ $< -I$(dir $<)StdH $(CXXFLAGS) + + +# Rules for turning source files into .o files + +$(BINDIR)/%.o: $(SRCDIR)/%.cpp + $(CXX) -c -o $@ $< $(CXXFLAGS) + +$(BINDIR)/%.o: $(SRCDIR)/%.c + $(CC) -c -o $@ $< $(CFLAGS) + +$(BINDIR)/%.o: $(SRCDIR)/%.asm + $(ASM) $(ASMFLAGS) -o $@ $< + +.PHONY: all dedicated clean distclean ecc entities entitiesmp gamedll gamempdll install ssam + +all: $(BINDIR) ecc ssam dedicated + +#dedicated: $(BINDIR) $(DEDICATEDEXE) $(DEDICATEDEXE_DYNAMIC) +dedicated: $(BINDIR) $(DEDICATEDEXE_DYNAMIC) +ecc: $(BINDIR) $(ECCEXE) +#ssam: $(BINDIR) $(SERIOUSSAMEXE) $(SERIOUSSAMEXE_DYNAMIC) +ssam: $(BINDIR) $(SERIOUSSAMEXE_DYNAMIC) +entities: ecc $(ENTITYHEADERS) +entitiesmp: ecc $(ENTITYMPHEADERS) +gamedll: $(BINDIR) $(GAMEDLL) +gamempdll: $(BINDIR) $(GAMEMPDLL) + +install: all + cp $(INSTALLABLES) $(INSTALLDIR) + +ifeq ($(strip $(permit_scp)),true) +scp: + @scripts/scp.pl $(scp_user) $(scp_host) $(scp_src_dir) $(scp_bin) + $(scp_bin) $(INSTALLABLES) $(strip $(scp_user))@$(strip $(scp_host)):$(strip $(scp_dir)) +endif + +ifeq ($(strip $(macosx)),true) +SDLMAINLIB := bin/libSDLmain.a +$(SDLMAINLIB) : lib/macosx_x86/libSDLmain.a $(BINDIR) + cp $< $@ + ranlib $@ +endif + +$(ENTITYDLL): $(ENTITYHEADERS) $(ENTITYOBJS) + $(LIBLINKER) $(DLLLDFLAGS) -o $(ENTITYDLL) $(ENTITYOBJS) $(EFENCELIB) + +$(ENTITYMPDLL): $(ENTITYMPHEADERS) $(ENTITYMPOBJS) + $(LIBLINKER) $(DLLLDFLAGS) -o $(ENTITYMPDLL) $(ENTITYMPOBJS) $(EFENCELIB) + +$(GAMEDLL): $(GAMEOBJS) + $(LIBLINKER) $(DLLLDFLAGS) -o $(GAMEDLL) $(GAMEOBJS) $(EFENCELIB) + +$(GAMEMPDLL): $(GAMEMPOBJS) + $(LIBLINKER) $(DLLLDFLAGS) -o $(GAMEMPDLL) $(GAMEMPOBJS) $(EFENCELIB) + +$(SHADERSDLL): $(SHADERSOBJS) + $(LIBLINKER) $(DLLLDFLAGS) -o $(SHADERSDLL) $(SHADERSOBJS) $(EFENCELIB) + +$(SRCDIR)/Ecc/Scanner.cpp: $(SRCDIR)/Ecc/Scanner.l $(SRCDIR)/Ecc/Parser.cpp + flex -o$(SRCDIR)/Ecc/Scanner.cpp $(SRCDIR)/Ecc/Scanner.l + +$(SRCDIR)/Ecc/Parser.cpp: $(SRCDIR)/Ecc/Parser.y + bison -o$(SRCDIR)/Ecc/Parser.cpp $(SRCDIR)/Ecc/Parser.y -d + if [ -f $(SRCDIR)/Ecc/Parser.hpp ]; then mv $(SRCDIR)/Ecc/Parser.hpp $(SRCDIR)/Ecc/Parser.h ; fi + if [ -f $(SRCDIR)/Ecc/Parser.cpp.h ]; then mv $(SRCDIR)/Ecc/Parser.cpp.h $(SRCDIR)/Ecc/Parser.h ; fi + +$(SRCDIR)/Engine/Base/Scanner.cpp: $(SRCDIR)/Engine/Base/Scanner.l $(SRCDIR)/Engine/Base/Parser.cpp + flex -o$(SRCDIR)/Engine/Base/Scanner.cpp $(SRCDIR)/Engine/Base/Scanner.l + +$(SRCDIR)/Engine/Base/Parser.cpp: $(SRCDIR)/Engine/Base/Parser.y + bison -o$(SRCDIR)/Engine/Base/Parser.cpp $(SRCDIR)/Engine/Base/Parser.y -d + if [ -f $(SRCDIR)/Engine/Base/Parser.hpp ]; then mv $(SRCDIR)/Engine/Base/Parser.hpp $(SRCDIR)/Engine/Base/Parser.h ; fi + if [ -f $(SRCDIR)/Engine/Base/Parser.cpp.h ]; then mv $(SRCDIR)/Engine/Base/Parser.cpp.h $(SRCDIR)/Engine/Base/Parser.h ; fi + +$(SRCDIR)/Engine/Ska/smcScan.cpp: $(SRCDIR)/Engine/Ska/smcScan.l $(SRCDIR)/Engine/Ska/smcPars.cpp + flex -o$(SRCDIR)/Engine/Ska/smcScan.cpp $(SRCDIR)/Engine/Ska/smcScan.l + +$(SRCDIR)/Engine/Ska/smcPars.cpp: $(SRCDIR)/Engine/Ska/smcPars.y + bison -o$(SRCDIR)/Engine/Ska/smcPars.cpp $(SRCDIR)/Engine/Ska/smcPars.y -d + if [ -f $(SRCDIR)/Engine/Ska/smcPars.hpp ]; then mv $(SRCDIR)/Engine/Ska/smcPars.hpp $(SRCDIR)/Engine/Ska/smcPars.h ; fi + if [ -f $(SRCDIR)/Engine/Ska/smcPars.cpp.h ]; then mv $(SRCDIR)/Engine/Ska/smcPars.cpp.h $(SRCDIR)/Engine/Ska/smcPars.h ; fi + +ifeq ($(strip $(static_link)),true) + ENTITYDLL := + ENTITYMPDLL := + GAMEDLL := + GAMEMPDLL := + SHADERSDLL := +endif + +$(ECCEXE): $(SRCDIR)/Ecc/Scanner.cpp $(SRCDIR)/Ecc/Parser.cpp $(ECCOBJS) + $(LINKER) $(LDFLAGS) -o $(ECCEXE) $(ECCOBJS) #$(EFENCELIB) + +$(DEDICATEDEXE): $(ENTITYDLL) $(ENTITYMPDLL) $(GAMEDLL) $(GAMEMPDLL) $(ENGINEENTITYHEADERS) $(ENGINEENTITYOBJS) $(DEDICATEDOBJS) $(ENGINEOBJS) $(DEDICATEDEXTRAOBJS) $(SDLMAINLIB) + $(LINKER) $(LDFLAGS) -o $(DEDICATEDEXE) $(DEDICATEDOBJS) $(ENGINEOBJS) $(ENGINEENTITYOBJS) $(DEDICATEDEXTRAOBJS) $(EFENCELIB) $(STATIC_SDL_LDFLAGS) + +$(DEDICATEDEXE_DYNAMIC): $(ENTITYDLL) $(ENTITYMPDLL) $(GAMEDLL) $(GAMEMPDLL) $(ENGINEENTITYHEADERS) $(ENGINEENTITYOBJS) $(DEDICATEDOBJS) $(ENGINEOBJS) $(DEDICATEDEXTRAOBJS) $(SDLMAINLIB) + $(LINKER) $(LDFLAGS) -o $(DEDICATEDEXE_DYNAMIC) $(DEDICATEDOBJS) $(ENGINEOBJS) $(ENGINEENTITYOBJS) $(DEDICATEDEXTRAOBJS) $(EFENCELIB) $(DYNAMIC_SDL_LDFLAGS) + +$(SERIOUSSAMEXE): $(ENTITYDLL) $(ENTITYMPDLL) $(GAMEDLL) $(GAMEMPDLL) $(SHADERSDLL) $(ENGINEENTITYHEADERS) $(ENGINEENTITYOBJS) $(SERIOUSSAMOBJS) $(ENGINEOBJS) $(SERIOUSSAMEXTRAOBJS) $(SDLMAINLIB) + $(LINKER) $(LDFLAGS) -o $(SERIOUSSAMEXE) $(SERIOUSSAMOBJS) $(ENGINEOBJS) $(ENGINEENTITYOBJS) $(SERIOUSSAMEXTRAOBJS) $(EFENCELIB) $(STATIC_SDL_LDFLAGS) + +$(SERIOUSSAMEXE_DYNAMIC): $(ENTITYDLL) $(ENTITYMPDLL) $(GAMEDLL) $(GAMEMPDLL) $(SHADERSDLL) $(ENGINEENTITYHEADERS) $(ENGINEENTITYOBJS) $(SERIOUSSAMOBJS) $(ENGINEOBJS) $(SERIOUSSAMEXTRAOBJS) $(SDLMAINLIB) + $(LINKER) $(LDFLAGS) -o $(SERIOUSSAMEXE_DYNAMIC) $(SERIOUSSAMOBJS) $(ENGINEOBJS) $(ENGINEENTITYOBJS) $(SERIOUSSAMEXTRAOBJS) $(EFENCELIB) $(DYNAMIC_SDL_LDFLAGS) + +$(BINDIR) : + mkdir -p $(BINDIR) + mkdir -p $(BINDIR)/Engine + mkdir -p $(BINDIR)/Engine/Base + mkdir -p $(BINDIR)/Engine/Base/Unix + mkdir -p $(BINDIR)/Engine/Base/SDL + mkdir -p $(BINDIR)/Engine/Brushes + mkdir -p $(BINDIR)/Engine/Classes + mkdir -p $(BINDIR)/Engine/Entities + mkdir -p $(BINDIR)/Engine/Graphics + mkdir -p $(BINDIR)/Engine/Graphics/SDL + mkdir -p $(BINDIR)/Engine/Light + mkdir -p $(BINDIR)/Engine/Math + mkdir -p $(BINDIR)/Engine/Models + mkdir -p $(BINDIR)/Engine/Network + mkdir -p $(BINDIR)/Engine/Rendering + mkdir -p $(BINDIR)/Engine/Ska + mkdir -p $(BINDIR)/Engine/Sound + mkdir -p $(BINDIR)/Engine/Templates + mkdir -p $(BINDIR)/Engine/World + mkdir -p $(BINDIR)/Engine/Terrain + mkdir -p $(BINDIR)/Engine/gamespy + mkdir -p $(BINDIR)/Engine/zlib + mkdir -p $(BINDIR)/DedicatedServer + mkdir -p $(BINDIR)/Entities + mkdir -p $(BINDIR)/Entities/Common + mkdir -p $(BINDIR)/EntitiesMP + mkdir -p $(BINDIR)/EntitiesMP/Common + mkdir -p $(BINDIR)/Ecc + mkdir -p $(BINDIR)/Game + mkdir -p $(BINDIR)/GameMP + mkdir -p $(BINDIR)/GameGUI + mkdir -p $(BINDIR)/GameGUIMP + mkdir -p $(BINDIR)/Test + mkdir -p $(BINDIR)/Tutorial + mkdir -p $(BINDIR)/RCon + mkdir -p $(BINDIR)/SeriousSam + mkdir -p $(BINDIR)/Shaders + +distclean: clean + +clean: + rm -f $(CLEANUP) + rm -f $(ENTITYHEADERS) + rm -f $(ENTITYSRCS) + rm -f $(ENTITYTABLES) + rm -f $(ENTITYMPHEADERS) + rm -f $(ENTITYMPSRCS) + rm -f $(ENTITYMPTABLES) + rm -rf $(BINDIR) + rm -f $(SRCDIR)/Ecc/Scanner.cpp + rm -f $(SRCDIR)/Ecc/Parser.cpp + rm -f $(SRCDIR)/Ecc/Parser.h + rm -f $(SRCDIR)/Engine/Base/Scanner.cpp + rm -f $(SRCDIR)/Engine/Base/Parser.cpp + rm -f $(SRCDIR)/Engine/Base/Parser.h + rm -f $(SRCDIR)/Engine/Ska/smcScan.cpp + rm -f $(SRCDIR)/Engine/Ska/smcPars.h + rm -f $(SRCDIR)/Engine/Ska/smcPars.cpp + +listentities: + @echo $(ENTITYFILES) + +# end of Makefile ... + diff --git a/Sources/Modeler/ColoredButton.cpp b/Sources/Modeler/ColoredButton.cpp index 18b0131..3d7718f 100644 --- a/Sources/Modeler/ColoredButton.cpp +++ b/Sources/Modeler/ColoredButton.cpp @@ -147,7 +147,7 @@ void CColoredButton::OnClicked() { if( m_iColorIndex != -1) return; // colored button can call eather custom palette window for choosing colors (where variable - // to receive result color is pointed with _pcolColorToSet) eather trough MFC-provided + // to recieve result color is pointed with _pcolColorToSet) either trough MFC-provided // color picker ASSERT( m_ptPickerType != PT_CUSTOM); COLORREF TmpColor = CLRF_CLR( m_colColor); diff --git a/Sources/SeriousSam/CDCheck.h b/Sources/SeriousSam/CDCheck.h index ae09a68..283d08e 100644 --- a/Sources/SeriousSam/CDCheck.h +++ b/Sources/SeriousSam/CDCheck.h @@ -1,3 +1,4 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ #define CD_CHECK 1 + diff --git a/Sources/SeriousSam/CmdLine.cpp b/Sources/SeriousSam/CmdLine.cpp index bf46e62..dc949af 100644 --- a/Sources/SeriousSam/CmdLine.cpp +++ b/Sources/SeriousSam/CmdLine.cpp @@ -1,19 +1,19 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "SeriousSam/StdH.h" #include #include "CmdLine.h" -extern CTString cmd_strWorld = ""; // world to load -extern INDEX cmd_iGoToMarker = -1; // marker to go to -extern CTString cmd_strScript = ""; // script to execute -extern CTString cmd_strServer = ""; // server to connect to -extern INDEX cmd_iPort = -1; // port to connect to -extern CTString cmd_strPassword = ""; // network password -extern CTString cmd_strOutput = ""; // output from parsing command line -extern BOOL cmd_bServer = FALSE; // set to run as server -extern BOOL cmd_bQuickJoin = FALSE; // do not ask for players and network settings +CTString cmd_strWorld = ""; // world to load +INDEX cmd_iGoToMarker = -1; // marker to go to +CTString cmd_strScript = ""; // script to execute +CTString cmd_strServer = ""; // server to connect to +INDEX cmd_iPort = -1; // port to connect to +CTString cmd_strPassword = ""; // network password +CTString cmd_strOutput = ""; // output from parsing command line +BOOL cmd_bServer = FALSE; // set to run as server +BOOL cmd_bQuickJoin = FALSE; // do not ask for players and network settings static CTString _strCmd; @@ -31,7 +31,7 @@ CTString GetNextParam(void) // if the first char is quote if (_strCmd[0]=='"') { // find first next quote - const char *pchClosingQuote = strchr(_strCmd+1, '"'); + char *pchClosingQuote = strchr(_strCmd+1, '"'); // if not found if (pchClosingQuote==NULL) { // error in command line @@ -79,7 +79,7 @@ CTString GetNextParam(void) void ParseCommandLine(CTString strCmd) { cmd_strOutput = ""; - cmd_strOutput+=CTString(0, TRANS("Command line: '%s'\n"), strCmd); + cmd_strOutput+=CTString(0, TRANS("Command line: '%s'\n"), (const char *) strCmd); // if no command line if (strlen(strCmd) == 0) { // do nothing @@ -130,7 +130,7 @@ void ParseCommandLine(CTString strCmd) } else if (strWord=="+logfile") { _strLogFile = GetNextParam(); } else { - cmd_strOutput+=CTString(0, TRANS(" Unknown option: '%s'\n"), strWord); + cmd_strOutput+=CTString(0, TRANS(" Unknown option: '%s'\n"), (const char *) strWord); } } } diff --git a/Sources/SeriousSam/Credits.cpp b/Sources/SeriousSam/Credits.cpp index f99dad5..e166670 100644 --- a/Sources/SeriousSam/Credits.cpp +++ b/Sources/SeriousSam/Credits.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "SeriousSam/StdH.h" #include #include "Credits.h" @@ -134,14 +134,14 @@ FLOAT Credits_Render(CDrawPort *pdp) pixH = dpWide.GetHeight(); fResolutionScaling = (FLOAT)pixW / 640.0f; dpWide.SetFont( _pfdDisplayFont); - pixLineHeight = floor(20*fResolutionScaling); + pixLineHeight = (PIX) (floor(20*fResolutionScaling)); const FLOAT fLinesPerSecond = _fSpeed; FLOAT fOffset = fTime*fLinesPerSecond; INDEX ctLinesOnScreen = pixH/pixLineHeight; - INDEX iLine1 = fOffset; + INDEX iLine1 = (INDEX) fOffset; - pixJ = iLine1*pixLineHeight-fOffset*pixLineHeight; + pixJ = (PIX) (iLine1*pixLineHeight-fOffset*pixLineHeight); iLine1-=ctLinesOnScreen; INDEX ctLines = _astrCredits.Count(); diff --git a/Sources/SeriousSam/GLSettings.cpp b/Sources/SeriousSam/GLSettings.cpp index ccd78f4..4041917 100644 --- a/Sources/SeriousSam/GLSettings.cpp +++ b/Sources/SeriousSam/GLSettings.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "stdh.h" +#include "SeriousSam/StdH.h" // list of settings data static CListHead _lhSettings; @@ -16,12 +16,10 @@ public: BOOL Matches( const CTString &strRenderer) const; }; - // last valid settings info static CTString _strLastRenderer; -extern CTString _strPreferencesDescription = ""; -extern INDEX _iLastPreferences = 1; - +CTString _strPreferencesDescription = ""; +INDEX _iLastPreferences = 1; // check if this entry matches given info BOOL CSettingsEntry::Matches( const CTString &strRenderer) const @@ -87,8 +85,8 @@ void InitGLSettings(void) _strLastRenderer= "none"; _iLastPreferences = 1; - _pShell->DeclareSymbol("persistent CTString sam_strLastRenderer;", &_strLastRenderer); - _pShell->DeclareSymbol("persistent INDEX sam_iLastSetup;", &_iLastPreferences); + _pShell->DeclareSymbol("persistent CTString sam_strLastRenderer;", (void *) &_strLastRenderer); + _pShell->DeclareSymbol("persistent INDEX sam_iLastSetup;", (void *) &_iLastPreferences); } @@ -109,7 +107,7 @@ extern void ApplyGLSettings(BOOL bForce) { CPrintF( TRANS("\nAutomatic 3D-board preferences adjustment...\n")); CDisplayAdapter &da = _pGfx->gl_gaAPI[_pGfx->gl_eCurrentAPI].ga_adaAdapter[_pGfx->gl_iCurrentAdapter]; - CPrintF( TRANS("Detected: %s - %s - %s\n"), da.da_strVendor, da.da_strRenderer, da.da_strVersion); + CPrintF( TRANS("Detected: %s - %s - %s\n"), (const char *) da.da_strVendor, (const char *) da.da_strRenderer, (const char *) da.da_strVersion); // get new settings CSettingsEntry *pse = GetGLSettings( da.da_strRenderer); @@ -122,7 +120,10 @@ extern void ApplyGLSettings(BOOL bForce) } // report - CPrintF(TRANS("Matching: %s (%s)\n"), pse->se_strRenderer, pse->se_strDescription); + CPrintF(TRANS("Matching: %s (%s)\n"), + (const char *) pse->se_strRenderer, + (const char *) pse->se_strDescription); + _strPreferencesDescription = pse->se_strDescription; if (!bForce) { @@ -139,12 +140,12 @@ extern void ApplyGLSettings(BOOL bForce) // clamp rendering preferences (just to be on the safe side) sam_iVideoSetup = Clamp( sam_iVideoSetup, 0L, 3L); - CPrintF(TRANS("Mode: %s\n"), RenderingPreferencesDescription(sam_iVideoSetup)); + CPrintF(TRANS("Mode: %s\n"), (const char *) RenderingPreferencesDescription(sam_iVideoSetup)); // if not in custom mode if (sam_iVideoSetup<3) { // execute the script CTString strCmd; - strCmd.PrintF("include \"Scripts\\GLSettings\\%s\"", CTString(pse->se_fnmScript)); + strCmd.PrintF("include \"Scripts\\GLSettings\\%s\"", (const char *) (CTString(pse->se_fnmScript))); _pShell->Execute(strCmd); // refresh textures _pShell->Execute("RefreshTextures();"); diff --git a/Sources/SeriousSam/LCDDrawing.cpp b/Sources/SeriousSam/LCDDrawing.cpp index d933f2c..16ab13b 100644 --- a/Sources/SeriousSam/LCDDrawing.cpp +++ b/Sources/SeriousSam/LCDDrawing.cpp @@ -1,8 +1,10 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "Stdh.h" +#include "SeriousSam/StdH.h" #include "LCDDrawing.h" +// !!! FIXME : lose this, just use _pGame->LCD*() directly! +#ifdef PLATFORM_WIN32 extern void LCDInit(void) { _pGame->LCDInit(); @@ -76,3 +78,6 @@ extern void LCDDrawPointer(PIX pixI, PIX pixJ) { _pGame->LCDDrawPointer(pixI, pixJ); } +#endif + + diff --git a/Sources/SeriousSam/LCDDrawing.h b/Sources/SeriousSam/LCDDrawing.h index 5e336df..9471fe3 100644 --- a/Sources/SeriousSam/LCDDrawing.h +++ b/Sources/SeriousSam/LCDDrawing.h @@ -6,6 +6,8 @@ #pragma once #endif +// !!! FIXME : Lose this! +#ifdef PLATFORM_WIN32 extern void LCDInit(void); extern void LCDEnd(void); extern void LCDPrepare(FLOAT fFade); @@ -21,7 +23,8 @@ extern void LCDDrawPointer(PIX pixI, PIX pixJ); extern COLOR LCDGetColor(COLOR colDefault, const char *strName); extern COLOR LCDFadedColor(COLOR col); extern COLOR LCDBlinkingColor(COLOR col0, COLOR col1); - +#endif #endif /* include-once check. */ + diff --git a/Sources/SeriousSam/LevelInfo.cpp b/Sources/SeriousSam/LevelInfo.cpp index 2b3c80d..f684423 100644 --- a/Sources/SeriousSam/LevelInfo.cpp +++ b/Sources/SeriousSam/LevelInfo.cpp @@ -1,8 +1,11 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "SeriousSam/StdH.h" #include "LevelInfo.h" + +#ifdef PLATFORM_WIN32 #include +#endif CListHead _lhAutoDemos; CListHead _lhAllLevels; @@ -91,7 +94,7 @@ void LoadLevelsList(void) // list the levels directory with subdirs CDynamicStackArray afnmDir; - MakeDirList(afnmDir, CTString("Levels\\"), "*.wld", DLI_RECURSIVE|DLI_SEARCHCD); + MakeDirList(afnmDir, CTString("Levels\\"), CTString("*.wld"), DLI_RECURSIVE|DLI_SEARCHCD); // for each file in the directory for (INDEX i=0; i afnmDir; - MakeDirList(afnmDir, CTString("Demos\\"), "Demos\\Auto-*.dem", DLI_RECURSIVE); + MakeDirList(afnmDir, CTString("Demos\\"), CTString("Demos\\auto-*.dem"), DLI_RECURSIVE); // for each file in the directory for (INDEX i=0; igl_iCurrentDepth != 0) + { + color_depth[0] = _pGfx->gl_iCurrentDepth; + color_depth[1] = -1; + } // if + + for (i = 0; color_depth[i] > 0; i++) + { + int bits = (color_depth[i] >= 24) ? 8 : 5; + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, bits); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, bits); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, bits); + if (SDL_SetVideoMode(pixSizeI, pixSizeJ, color_depth[i], flags) != NULL) + break; + CPrintF("SDL_SetVideoMode() failed at %d-bit color! Reason: %s\n", color_depth[i], SDL_GetError()); + } // for + + SDL_WM_GrabInput(SDL_GRAB_OFF); + + if (color_depth[i] > 0) + _pGfx->gl_iCurrentDepth = color_depth[i]; + else + { + SDL_Quit(); + FatalError("Failed to create GL context.\n"); + } // else + + _hwndMain = (void *) 0x0001; + SE_UpdateWindowHandle( _hwndMain); +} // CreateSDLWindow +#endif + void ResetMainWindowNormal(void) { +#ifdef PLATFORM_WIN32 ShowWindow( _hwndMain, SW_HIDE); // add edges and title bar to window size so client area would have size that we requested RECT rWindow, rClient; @@ -177,12 +250,14 @@ void ResetMainWindowNormal(void) // set new window size and show it SetWindowPos( _hwndMain, NULL, pixPosX,pixPosY, pixWidth,pixHeight, SWP_NOZORDER); ShowWindow( _hwndMain, SW_SHOW); +#endif } // open the main application window for windowed mode void OpenMainWindowNormal( PIX pixSizeI, PIX pixSizeJ) { +#ifdef PLATFORM_WIN32 ASSERT(_hwndMain==NULL); // create a window, invisible initially @@ -207,12 +282,21 @@ void OpenMainWindowNormal( PIX pixSizeI, PIX pixSizeJ) _pixLastSizeI = pixSizeI; _pixLastSizeJ = pixSizeJ; ResetMainWindowNormal(); + +#else + _pixLastSizeI = pixSizeI; + _pixLastSizeJ = pixSizeJ; + // set window title + sprintf( achWindowTitle, TRANS("Serious Sam (Window %dx%d)"), pixSizeI, pixSizeJ); + CreateSDLWindow(pixSizeI, pixSizeJ, achWindowTitle, "ssam", 0); +#endif } // open the main application window for fullscreen mode void OpenMainWindowFullScreen( PIX pixSizeI, PIX pixSizeJ) { +#ifdef PLATFORM_WIN32 ASSERT( _hwndMain==NULL); // create a window, invisible initially _hwndMain = CreateWindowExA( @@ -234,12 +318,19 @@ void OpenMainWindowFullScreen( PIX pixSizeI, PIX pixSizeJ) sprintf( achWindowTitle, TRANS("Serious Sam (FullScreen %dx%d)"), pixSizeI, pixSizeJ); SetWindowTextA( _hwndMain, achWindowTitle); ShowWindow( _hwndMain, SW_SHOWNORMAL); + +#else + // set window title + sprintf( achWindowTitle, TRANS("Serious Sam (FullScreen %dx%d)"), pixSizeI, pixSizeJ); + CreateSDLWindow(pixSizeI, pixSizeJ, achWindowTitle, "ssam", SDL_FULLSCREEN); +#endif } // open the main application window invisible void OpenMainWindowInvisible(void) { +#ifdef PLATFORM_WIN32 ASSERT(_hwndMain==NULL); // create a window, invisible initially _hwndMain = CreateWindowExA( @@ -266,4 +357,11 @@ void OpenMainWindowInvisible(void) // set window title sprintf( achWindowTitle, "Serious Sam"); SetWindowTextA( _hwndMain, achWindowTitle); + +#else + + STUBBED("Need SDL invisible window or something"); + +#endif } + diff --git a/Sources/SeriousSam/Menu.cpp b/Sources/SeriousSam/Menu.cpp index f4f7a8f..794a866 100644 --- a/Sources/SeriousSam/Menu.cpp +++ b/Sources/SeriousSam/Menu.cpp @@ -1,10 +1,14 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "SeriousSam/StdH.h" #include #include #include + +#ifdef PLATFORM_WIN32 #include +#endif + #include "MainWindow.h" #include #include @@ -42,6 +46,52 @@ static INDEX sam_old_iVideoSetup; // 0==speed, 1==normal, 2==quality, 3==custom ENGINE_API extern INDEX snd_iFormat; + +// !!! FIXME: gcc3 linker pukes without this. lame. +// !!! FIXME: Wonder why gcc2 didn't... +#if !STATICALLY_LINKED +CButtonAction::CButtonAction(void) +{ + ba_iFirstKey = KID_NONE; + ba_iSecondKey = KID_NONE; + ba_bFirstKeyDown = FALSE; + ba_bSecondKeyDown = FALSE; +} + +// Assignment operator. +CButtonAction &CButtonAction ::operator=(CButtonAction &baOriginal) +{ + ba_iFirstKey = baOriginal.ba_iFirstKey; + ba_iSecondKey = baOriginal.ba_iSecondKey; + ba_strName = baOriginal.ba_strName; + ba_strCommandLineWhenPressed = baOriginal.ba_strCommandLineWhenPressed; + ba_strCommandLineWhenReleased = baOriginal.ba_strCommandLineWhenReleased; + ba_bFirstKeyDown = FALSE; + ba_bSecondKeyDown = FALSE; + + return *this; +} + +void CButtonAction::Read_t( CTStream &istrm) +{ + istrm>>ba_iFirstKey; + istrm>>ba_iSecondKey; + istrm>>ba_strName; + istrm>>ba_strCommandLineWhenPressed; + istrm>>ba_strCommandLineWhenReleased; +} + +void CButtonAction::Write_t( CTStream &ostrm) +{ + ostrm<ClearRelativeMouseMotion(); } @@ -872,7 +933,7 @@ void ModConnectConfirm(void) return; } - CPrintF(TRANS("Server is running a different MOD (%s).\nYou need to reload to connect.\n"), _fnmModSelected); + CPrintF(TRANS("Server is running a different MOD (%s).\nYou need to reload to connect.\n"), (const char *) _fnmModSelected); _pConfimedYes = &ModConnect; _pConfimedNo = NULL; mgConfirmLabel.mg_strText = TRANS("CHANGE THE MOD?"); @@ -1175,7 +1236,7 @@ void JoinNetworkGame(void) if (_strModURLSelected="") { _strModURLSelected = "http://www.croteam.com/mods/Old"; } - _strModServerSelected.PrintF("%s:%s", _pGame->gam_strJoinAddress, _pShell->GetValue("net_iPort")); + _strModServerSelected.PrintF("%s:%s", (const char *) _pGame->gam_strJoinAddress, (const char *) _pShell->GetValue("net_iPort")); ModConnectConfirm(); } _gmRunningGameMode = GM_NONE; @@ -2119,7 +2180,7 @@ void InitGameTypes(void) // if none if (pss==NULL) { // error - astrGameTypeRadioTexts[0] = ""; + astrGameTypeRadioTexts[0] = "<\?\?\?>"; ctGameTypeRadioTexts = 1; return; } @@ -2433,7 +2494,7 @@ void MenuUpdateMouseFocus(void) extern CDrawPort *pdp; if( sam_bWideScreen) { const PIX pixHeight = pdp->GetHeight(); - pt.y -= (pixHeight/0.75f-pixHeight)/2; + pt.y -= (LONG) ((pixHeight/0.75f-pixHeight)/2); } _pixCursorPosI += pt.x-_pixCursorExternPosI; _pixCursorPosJ = _pixCursorExternPosJ; @@ -2531,8 +2592,8 @@ void RenderMouseCursor(CDrawPort *pdp) // don't render cursor return; } - LCDSetDrawport(pdp); - LCDDrawPointer(_pixCursorPosI, _pixCursorPosJ); + _pGame->LCDSetDrawport(pdp); + _pGame->LCDDrawPointer(_pixCursorPosI, _pixCursorPosJ); } @@ -2588,13 +2649,13 @@ BOOL DoMenu( CDrawPort *pdp) UBYTE ubH4 = (INDEX)(tmNow*35.4f) & 255; // clear screen with background texture - LCDPrepare(1.0f); - LCDSetDrawport(&dpMenu); + _pGame->LCDPrepare(1.0f); + _pGame->LCDSetDrawport(&dpMenu); // do not allow game to show through dpMenu.Fill(C_BLACK|255); - LCDRenderClouds1(); - LCDRenderGrid(); - LCDRenderClouds2(); + _pGame->LCDRenderClouds1(); + _pGame->LCDRenderGrid(); + _pGame->LCDRenderClouds2(); FLOAT fScaleW = (FLOAT)pixW / 640.0f; FLOAT fScaleH = (FLOAT)pixH / 480.0f; @@ -2605,49 +2666,63 @@ BOOL DoMenu( CDrawPort *pdp) if( _ptoLogoODI!=NULL) { CTextureData &td = (CTextureData&)*_ptoLogoODI->GetData(); #define LOGOSIZE 50 - const PIX pixLogoWidth = LOGOSIZE * dpMenu.dp_fWideAdjustment; - const PIX pixLogoHeight = LOGOSIZE* td.GetHeight() / td.GetWidth(); - pixI0 = (640-pixLogoWidth -16)*fScaleW; - pixJ0 = (480-pixLogoHeight-16)*fScaleH; - pixI1 = pixI0+ pixLogoWidth *fScaleW; - pixJ1 = pixJ0+ pixLogoHeight*fScaleH; + const PIX pixLogoWidth = (PIX) (LOGOSIZE * dpMenu.dp_fWideAdjustment); + const PIX pixLogoHeight = (PIX) (LOGOSIZE* td.GetHeight() / td.GetWidth()); + pixI0 = (PIX) ((640-pixLogoWidth -16)*fScaleW); + pixJ0 = (PIX) ((480-pixLogoHeight-16)*fScaleH); + pixI1 = (PIX) (pixI0+ pixLogoWidth *fScaleW); + pixJ1 = (PIX) (pixJ0+ pixLogoHeight*fScaleH); dpMenu.PutTexture( _ptoLogoODI, PIXaabbox2D( PIX2D( pixI0, pixJ0),PIX2D( pixI1, pixJ1))); #undef LOGOSIZE } if( _ptoLogoCT!=NULL) { CTextureData &td = (CTextureData&)*_ptoLogoCT->GetData(); #define LOGOSIZE 50 - const PIX pixLogoWidth = LOGOSIZE * dpMenu.dp_fWideAdjustment; - const PIX pixLogoHeight = LOGOSIZE* td.GetHeight() / td.GetWidth(); - pixI0 = 12*fScaleW; - pixJ0 = (480-pixLogoHeight-16)*fScaleH; - pixI1 = pixI0+ pixLogoWidth *fScaleW; - pixJ1 = pixJ0+ pixLogoHeight*fScaleH; + const PIX pixLogoWidth = (PIX) (LOGOSIZE * dpMenu.dp_fWideAdjustment); + const PIX pixLogoHeight = (PIX) (LOGOSIZE* td.GetHeight() / td.GetWidth()); + pixI0 = (PIX) (12*fScaleW); + pixJ0 = (PIX) ((480-pixLogoHeight-16)*fScaleH); + pixI1 = (PIX) (pixI0+ pixLogoWidth *fScaleW); + pixJ1 = (PIX) (pixJ0+ pixLogoHeight*fScaleH); dpMenu.PutTexture( _ptoLogoCT, PIXaabbox2D( PIX2D( pixI0, pixJ0),PIX2D( pixI1, pixJ1))); #undef LOGOSIZE } { FLOAT fResize = Min(dpMenu.GetWidth()/640.0f, dpMenu.GetHeight()/480.0f); - PIX pixSizeI = 256*fResize; - PIX pixSizeJ = 64*fResize; - PIX pixCenterI = dpMenu.GetWidth()/2; - PIX pixHeightJ = 10*fResize; + PIX pixSizeI = (PIX) (256*fResize); + PIX pixSizeJ = (PIX) (64*fResize); + PIX pixCenterI = (PIX) (dpMenu.GetWidth()/2); + PIX pixHeightJ = (PIX) (10*fResize); dpMenu.PutTexture(&_toLogoMenuA, PIXaabbox2D( PIX2D( pixCenterI-pixSizeI, pixHeightJ),PIX2D( pixCenterI, pixHeightJ+pixSizeJ))); dpMenu.PutTexture(&_toLogoMenuB, PIXaabbox2D( PIX2D( pixCenterI, pixHeightJ),PIX2D( pixCenterI+pixSizeI, pixHeightJ+pixSizeJ))); } + + } else if (pgmCurrentMenu==&gmServersMenu) { + if( _ptoLogoGSpy!=NULL) { + CTextureData &td = (CTextureData&)*_ptoLogoGSpy->GetData(); + #define LOGOSIZE 120 + const PIX pixLogoWidth = (PIX) (LOGOSIZE * dpMenu.dp_fWideAdjustment); + const PIX pixLogoHeight = (PIX) (LOGOSIZE* td.GetHeight() / td.GetWidth()); + pixI0 = (PIX) ((640-pixLogoWidth -50)*fScaleW); + pixJ0 = (PIX) ((480-pixLogoHeight-40)*fScaleH); + pixI1 = (PIX) (pixI0+ pixLogoWidth *fScaleW); + pixJ1 = (PIX) (pixJ0+ pixLogoHeight*fScaleH); + dpMenu.PutTexture( _ptoLogoGSpy, PIXaabbox2D( PIX2D( pixI0, pixJ0),PIX2D( pixI1, pixJ1))); + #undef LOGOSIZE + } } else if (pgmCurrentMenu==&gmAudioOptionsMenu) { if( _ptoLogoEAX!=NULL) { CTextureData &td = (CTextureData&)*_ptoLogoEAX->GetData(); const INDEX iSize = 95; - const PIX pixLogoWidth = iSize * dpMenu.dp_fWideAdjustment; - const PIX pixLogoHeight = iSize * td.GetHeight() / td.GetWidth(); - pixI0 = (640-pixLogoWidth - 35)*fScaleW; - pixJ0 = (480-pixLogoHeight - 7)*fScaleH; - pixI1 = pixI0+ pixLogoWidth *fScaleW; - pixJ1 = pixJ0+ pixLogoHeight*fScaleH; + const PIX pixLogoWidth = (PIX) (iSize * dpMenu.dp_fWideAdjustment); + const PIX pixLogoHeight = (PIX) (iSize * td.GetHeight() / td.GetWidth()); + pixI0 = (PIX) ((640-pixLogoWidth - 35)*fScaleW); + pixJ0 = (PIX) ((480-pixLogoHeight - 7)*fScaleH); + pixI1 = (PIX) (pixI0+ pixLogoWidth *fScaleW); + pixJ1 = (PIX) (pixJ0+ pixLogoHeight*fScaleH); dpMenu.PutTexture( _ptoLogoEAX, PIXaabbox2D( PIX2D( pixI0, pixJ0),PIX2D( pixI1, pixJ1))); } } @@ -2657,21 +2732,21 @@ BOOL DoMenu( CDrawPort *pdp) // if there is a thumbnail if( _bThumbnailOn) { const FLOAT fThumbScaleW = fScaleW * dpMenu.dp_fWideAdjustment; - PIX pixOfs = 8*fScaleW; - pixI0 = 8*fScaleW; - pixJ0 = (240-THUMBW/2)*fScaleH; - pixI1 = pixI0+ THUMBW*fThumbScaleW; - pixJ1 = pixJ0+ THUMBH*fScaleH; + PIX pixOfs = (PIX) (8*fScaleW); + pixI0 = (PIX) (8*fScaleW); + pixJ0 = (PIX) ((240-THUMBW/2)*fScaleH); + pixI1 = (PIX) (pixI0+ THUMBW*fThumbScaleW); + pixJ1 = (PIX) (pixJ0+ THUMBH*fScaleH); if( _toThumbnail.GetData()!=NULL) { // show thumbnail with shadow and border dpMenu.Fill( pixI0+pixOfs, pixJ0+pixOfs, THUMBW*fThumbScaleW, THUMBH*fScaleH, C_BLACK|128); dpMenu.PutTexture( &_toThumbnail, PIXaabbox2D( PIX2D( pixI0, pixJ0), PIX2D( pixI1, pixJ1)), C_WHITE|255); - dpMenu.DrawBorder( pixI0,pixJ0, THUMBW*fThumbScaleW,THUMBH*fScaleH, LCDGetColor(C_mdGREEN|255, "thumbnail border")); + dpMenu.DrawBorder( pixI0,pixJ0, THUMBW*fThumbScaleW,THUMBH*fScaleH, _pGame->LCDGetColor(C_mdGREEN|255, "thumbnail border")); } else { dpMenu.SetFont( _pfdDisplayFont); dpMenu.SetTextScaling( fScaleW); dpMenu.SetTextAspect( 1.0f); - dpMenu.PutTextCXY( TRANS("no thumbnail"), (pixI0+pixI1)/2, (pixJ0+pixJ1)/2, LCDGetColor(C_GREEN|255, "no thumbnail")); + dpMenu.PutTextCXY( TRANS("no thumbnail"), (pixI0+pixI1)/2, (pixJ0+pixJ1)/2, _pGame->LCDGetColor(C_GREEN|255, "no thumbnail")); } } @@ -2701,12 +2776,12 @@ BOOL DoMenu( CDrawPort *pdp) PIXaabbox2D box = FloatBoxToPixBox(&dpMenu, BoxPopup()); CDrawPort dpPopup(pdp, box); dpPopup.Lock(); - LCDSetDrawport(&dpPopup); + _pGame->LCDSetDrawport(&dpPopup); dpPopup.Fill(C_BLACK|255); - LCDRenderClouds1(); - LCDRenderGrid(); - //LCDRenderClouds2(); - LCDScreenBox(LCDGetColor(C_GREEN|255, "popup box")); + _pGame->LCDRenderClouds1(); + _pGame->LCDRenderGrid(); + //_pGame->LCDRenderClouds2(); + _pGame->LCDScreenBox(_pGame->LCDGetColor(C_GREEN|255, "popup box")); dpPopup.Unlock(); dpMenu.Lock(); } @@ -2714,13 +2789,13 @@ BOOL DoMenu( CDrawPort *pdp) // no entity is under cursor initially _pmgUnderCursor = NULL; - BOOL bStilInMenus = FALSE; + BOOL bStillInMenus = FALSE; _pGame->MenuPreRenderMenu(pgmCurrentMenu->gm_strName); // for each menu gadget FOREACHINLIST( CMenuGadget, mg_lnNode, pgmCurrentMenu->gm_lhGadgets, itmg) { // if gadget is visible if( itmg->mg_bVisible) { - bStilInMenus = TRUE; + bStillInMenus = TRUE; itmg->Render( &dpMenu); if (FloatBoxToPixBox(&dpMenu, itmg->mg_boxOnScreen)>=PIX2D(_pixCursorPosI, _pixCursorPosJ)) { _pmgUnderCursor = itmg; @@ -2766,7 +2841,7 @@ BOOL DoMenu( CDrawPort *pdp) // print the tip SetFontMedium(&dpMenu); dpMenu.PutTextC(strTip, - pixW*0.5f, pixH*0.92f, LCDGetColor(C_WHITE|255, "tool tip")); + pixW*0.5f, pixH*0.92f, _pGame->LCDGetColor(C_WHITE|255, "tool tip")); } _pGame->ConsolePrintLastLines(&dpMenu); @@ -2776,7 +2851,7 @@ BOOL DoMenu( CDrawPort *pdp) dpMenu.Unlock(); pdp->Lock(); - return bStilInMenus; + return bStillInMenus; } void MenuBack(void) @@ -3502,7 +3577,7 @@ void CInGameMenu::StartMenu(void) if (_gmRunningGameMode==GM_SINGLE_PLAYER) { CPlayerCharacter &pc = _pGame->gm_apcPlayers[ _pGame->gm_iSinglePlayer]; - mgInGameLabel1.mg_strText.PrintF( TRANS("Player: %s"), pc.GetNameForPrinting()); + mgInGameLabel1.mg_strText.PrintF( TRANS("Player: %s"), (const char *) pc.GetNameForPrinting()); mgInGameLabel2.mg_strText = ""; } else { @@ -3673,7 +3748,7 @@ void CSinglePlayerMenu::StartMenu(void) CGameMenu::StartMenu(); CPlayerCharacter &pc = _pGame->gm_apcPlayers[ _pGame->gm_iSinglePlayer]; - mgSinglePlayerLabel.mg_strText.PrintF( TRANS("Player: %s\n"), pc.GetNameForPrinting()); + mgSinglePlayerLabel.mg_strText.PrintF( TRANS("Player: %s\n"), (const char *) pc.GetNameForPrinting()); } // ------------------------ CSinglePlayerNewMenu implementation @@ -3896,7 +3971,7 @@ void CPlayerProfileMenu::Initialize_t(void) gm_lhGadgets.AddTail( mgPlayerNameLabel.mg_lnNode); // setup of player name button is done on start menu - mgPlayerName.mg_strText = ""; + mgPlayerName.mg_strText = "<\?\?\?>"; mgPlayerName.mg_ctMaxStringLen = 25; mgPlayerName.mg_boxOnScreen = BoxPlayerEdit(1.25); mgPlayerName.mg_bfsFontSize = BFS_MEDIUM; @@ -3914,7 +3989,7 @@ void CPlayerProfileMenu::Initialize_t(void) gm_lhGadgets.AddTail( mgPlayerTeamLabel.mg_lnNode); // setup of player name button is done on start menu - mgPlayerTeam.mg_strText = ""; + mgPlayerTeam.mg_strText = "<\?\?\?>"; mgPlayerName.mg_ctMaxStringLen = 25; mgPlayerTeam.mg_boxOnScreen = BoxPlayerEdit(2.25f); mgPlayerTeam.mg_bfsFontSize = BFS_MEDIUM; @@ -4201,7 +4276,7 @@ void CControlsMenu::StartMenu(void) ControlsMenuOn(); - mgControlsNameLabel.mg_strText.PrintF(TRANS("CONTROLS FOR: %s"), _pGame->gm_apcPlayers[iPlayer].GetNameForPrinting()); + mgControlsNameLabel.mg_strText.PrintF(TRANS("CONTROLS FOR: %s"), (const char *) _pGame->gm_apcPlayers[iPlayer].GetNameForPrinting()); ObtainActionSettings(); CGameMenu::StartMenu(); @@ -4222,7 +4297,7 @@ void CControlsMenu::ObtainActionSettings(void) mgControlsSensitivity.mg_iMinPos = 0; mgControlsSensitivity.mg_iMaxPos = 50; - mgControlsSensitivity.mg_iCurPos = ctrls.ctrl_fSensitivity/2; + mgControlsSensitivity.mg_iCurPos = (INDEX) (ctrls.ctrl_fSensitivity/2); mgControlsSensitivity.ApplyCurrentPosition(); mgControlsInvertTrigger.mg_iSelected = ctrls.ctrl_bInvertLook ? 1 : 0; @@ -4340,7 +4415,7 @@ void CLoadSaveMenu::StartMenu(void) // list the directory CDynamicStackArray afnmDir; - MakeDirList(afnmDir, gm_fnmDirectory, "", 0); + MakeDirList(afnmDir, gm_fnmDirectory, CTString(""), 0); gm_iLastFile = -1; // for each file in the directory @@ -4364,16 +4439,16 @@ void CLoadSaveMenu::StartMenu(void) default: ASSERT(FALSE); case LSSORT_NONE: break; case LSSORT_NAMEUP: - gm_lhFileInfos.Sort(qsort_CompareFileInfos_NameUp, offsetof(CFileInfo, fi_lnNode)); + gm_lhFileInfos.Sort(qsort_CompareFileInfos_NameUp, _offsetof(CFileInfo, fi_lnNode)); break; case LSSORT_NAMEDN: - gm_lhFileInfos.Sort(qsort_CompareFileInfos_NameDn, offsetof(CFileInfo, fi_lnNode)); + gm_lhFileInfos.Sort(qsort_CompareFileInfos_NameDn, _offsetof(CFileInfo, fi_lnNode)); break; case LSSORT_FILEUP: - gm_lhFileInfos.Sort(qsort_CompareFileInfos_FileUp, offsetof(CFileInfo, fi_lnNode)); + gm_lhFileInfos.Sort(qsort_CompareFileInfos_FileUp, _offsetof(CFileInfo, fi_lnNode)); break; case LSSORT_FILEDN: - gm_lhFileInfos.Sort(qsort_CompareFileInfos_FileDn, offsetof(CFileInfo, fi_lnNode)); + gm_lhFileInfos.Sort(qsort_CompareFileInfos_FileDn, _offsetof(CFileInfo, fi_lnNode)); break; } @@ -4483,7 +4558,7 @@ BOOL CLoadSaveMenu::ParseFile(const CTFileName &fnm, CTString &strName) INDEX iCtl = -1; strName.ScanF("Controls%d", &iCtl); if (iCtl>=0 && iCtl<=7) { - strName.PrintF(TRANS("From player: %s"), _pGame->gm_apcPlayers[iCtl].GetNameForPrinting()); + strName.PrintF(TRANS("From player: %s"), (const char *) (_pGame->gm_apcPlayers[iCtl].GetNameForPrinting())); } } } @@ -4682,12 +4757,12 @@ void CCustomizeAxisMenu::ObtainActionSettings(void) mgAxisSensitivity.mg_iMinPos = 0; mgAxisSensitivity.mg_iMaxPos = 50; - mgAxisSensitivity.mg_iCurPos = ctrls.ctrl_aaAxisActions[ iSelectedAction].aa_fSensitivity/2; + mgAxisSensitivity.mg_iCurPos = (INDEX) (ctrls.ctrl_aaAxisActions[ iSelectedAction].aa_fSensitivity/2); mgAxisSensitivity.ApplyCurrentPosition(); mgAxisDeadzone.mg_iMinPos = 0; mgAxisDeadzone.mg_iMaxPos = 50; - mgAxisDeadzone.mg_iCurPos = ctrls.ctrl_aaAxisActions[ iSelectedAction].aa_fDeadZone/2; + mgAxisDeadzone.mg_iCurPos = (INDEX) (ctrls.ctrl_aaAxisActions[ iSelectedAction].aa_fDeadZone/2); mgAxisDeadzone.ApplyCurrentPosition(); mgAxisInvertTrigger.mg_iSelected = ctrls.ctrl_aaAxisActions[ iSelectedAction].aa_bInvert ? 1 : 0; @@ -4825,33 +4900,33 @@ static void FillResolutionsList(void) if( mgFullScreenTrigger.mg_iSelected==0) { // always has fixed resolutions, but not greater than desktop static PIX apixWidths[][2] = { - 320, 240, - 400, 300, - 512, 384, - 640, 240, - 640, 480, - 720, 540, - 800, 300, - 800, 600, - 960, 720, - 1024, 384, - 1024, 768, - 1152, 864, - 1280, 480, - 1280, 960, - 1600, 600, - 1600,1200, - 1920, 720, - 1920,1440, - 2048, 786, - 2048,1536, + { 320, 240 }, + { 400, 300 }, + { 512, 384 }, + { 640, 240 }, + { 640, 480 }, + { 720, 540 }, + { 800, 300 }, + { 800, 600 }, + { 960, 720 }, + { 1024, 384 }, + { 1024, 768 }, + { 1152, 864 }, + { 1280, 480 }, + { 1280, 960 }, + { 1600, 600 }, + { 1600, 1200 }, + { 1920, 720 }, + { 1920, 1440 }, + { 2048, 786 }, + { 2048, 1536 } }; _ctResolutions = ARRAYCOUNT(apixWidths); _astrResolutionTexts = new CTString [_ctResolutions]; _admResolutionModes = new CDisplayMode[_ctResolutions]; extern PIX _pixDesktopWidth; - INDEX iRes=0; - for( ; iRes<_ctResolutions; iRes++) { + INDEX iRes; + for( iRes=0; iRes<_ctResolutions; iRes++) { if( apixWidths[iRes][0]>_pixDesktopWidth) break; SetResolutionInList( iRes, apixWidths[iRes][0], apixWidths[iRes][1]); } @@ -4916,11 +4991,11 @@ static void UpdateVideoOptionsButtons(INDEX iSelected) FillAdaptersList(); // show or hide buttons - mgDisplayAPITrigger.mg_bEnabled = bOGLEnabled #ifdef SE1_D3D - && bD3DEnabled -#endif // SE1_D3D - ; + mgDisplayAPITrigger.mg_bEnabled = bOGLEnabled && bD3DEnabled; +#else + mgDisplayAPITrigger.mg_bEnabled = bOGLEnabled; +#endif mgDisplayAdaptersTrigger.mg_bEnabled = _ctAdapters>1; mgVideoOptionsApply.mg_bEnabled = _bVideoOptionsChanged; // determine which should be visible @@ -4930,7 +5005,12 @@ static void UpdateVideoOptionsButtons(INDEX iSelected) mgFullScreenTrigger.mg_iSelected = 1; mgFullScreenTrigger.ApplyCurrentSelection(); } + +#ifdef PLATFORM_UNIX + mgBitsPerPixelTrigger.mg_bEnabled = FALSE; +#else mgBitsPerPixelTrigger.mg_bEnabled = TRUE; +#endif if( mgFullScreenTrigger.mg_iSelected==0) { mgBitsPerPixelTrigger.mg_bEnabled = FALSE; mgBitsPerPixelTrigger.mg_iSelected = DepthToSwitch(DD_DEFAULT); @@ -5696,8 +5776,8 @@ void CNetworkStartMenu::EndMenu(void) INDEX FindUnusedPlayer(void) { INDEX *ai = _pGame->gm_aiMenuLocalPlayers; - INDEX iPlayer=0; - for(; iPlayer<8; iPlayer++) { + INDEX iPlayer; + for(iPlayer=0; iPlayer<8; iPlayer++) { BOOL bUsed = FALSE; for (INDEX iLocal=0; iLocal<4; iLocal++) { if (ai[iLocal] == iPlayer) { @@ -5813,14 +5893,14 @@ void SelectPlayersFillMenu(void) if (apmg[img]==NULL) { continue; } - INDEX imgPred=(img+8-1)%8; - for (; imgPred!=img; imgPred = (imgPred+8-1)%8) { + INDEX imgPred; + for (imgPred=(img+8-1)%8; imgPred!=img; imgPred = (imgPred+8-1)%8) { if (apmg[imgPred]!=NULL) { break; } } - INDEX imgSucc=(img+1)%8; - for (; imgSucc!=img; imgSucc = (imgSucc+1)%8) { + INDEX imgSucc; + for (imgSucc=(img+1)%8; imgSucc!=img; imgSucc = (imgSucc+1)%8) { if (apmg[imgSucc]!=NULL) { break; } diff --git a/Sources/SeriousSam/MenuGadgets.cpp b/Sources/SeriousSam/MenuGadgets.cpp index 45aef34..5f294eb 100644 --- a/Sources/SeriousSam/MenuGadgets.cpp +++ b/Sources/SeriousSam/MenuGadgets.cpp @@ -1,10 +1,10 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "SeriousSam/StdH.h" #include -#include #include "MenuPrinting.h" #include +#include #include "LevelInfo.h" #include "VarList.h" @@ -18,10 +18,11 @@ CMenuGadget *_pmgLastActivatedGadget = NULL; extern CSoundData *_psdPress; extern PIX _pixCursorPosI; extern PIX _pixCursorPosJ; -extern BOOL _bDefiningKey = FALSE; -extern BOOL _bEditingString = FALSE; extern INDEX sam_bWideScreen; +BOOL _bDefiningKey = FALSE; +BOOL _bEditingString = FALSE; + CMenuGadget::CMenuGadget( void) { @@ -101,17 +102,17 @@ void CMenuGadget::OnMouseOver(PIX pixI, PIX pixJ) COLOR CMenuGadget::GetCurrentColor(void) { // use normal colors - COLOR colUnselected = LCDGetColor(C_GREEN, "unselected"); - COLOR colSelected = LCDGetColor(C_WHITE, "selected"); + COLOR colUnselected = _pGame->LCDGetColor(C_GREEN, "unselected"); + COLOR colSelected = _pGame->LCDGetColor(C_WHITE, "selected"); // if disabled if (!mg_bEnabled) { // use a bit darker colors - colUnselected = LCDGetColor(C_dGREEN, "disabled unselected"); - colSelected = LCDGetColor(C_GRAY, "disabled selected"); + colUnselected = _pGame->LCDGetColor(C_dGREEN, "disabled unselected"); + colSelected = _pGame->LCDGetColor(C_GRAY, "disabled selected"); // if label if (mg_bLabel) { // use white - colUnselected = colSelected = LCDGetColor(C_WHITE, "label"); + colUnselected = colSelected = _pGame->LCDGetColor(C_WHITE, "label"); } } // use unselected color @@ -138,7 +139,7 @@ void CMGTitle::Render( CDrawPort *pdp) PIX pixI = box.Center()(1); PIX pixJ = box.Min()(2); - pdp->PutTextC( mg_strText, pixI, pixJ, LCDGetColor(C_WHITE|CT_OPAQUE, "title")); + pdp->PutTextC( mg_strText, pixI, pixJ, _pGame->LCDGetColor(C_WHITE|CT_OPAQUE, "title")); } CMGButton::CMGButton( void) @@ -202,14 +203,14 @@ void CMGButton::Render( CDrawPort *pdp) PIXaabbox2D box = FloatBoxToPixBox(pdp, mg_boxOnScreen); COLOR col = GetCurrentColor(); if(mg_bEditing) { - col = LCDGetColor(C_GREEN|0xFF, "editing"); + col = _pGame->LCDGetColor(C_GREEN|0xFF, "editing"); } COLOR colRectangle = col; if( mg_bHighlighted) { - col = LCDGetColor(C_WHITE|0xFF, "hilited"); + col = _pGame->LCDGetColor(C_WHITE|0xFF, "hilited"); if( !mg_bFocused) { - colRectangle = LCDGetColor(C_WHITE|0xFF, "hilited rectangle"); + colRectangle = _pGame->LCDGetColor(C_WHITE|0xFF, "hilited rectangle"); } } if (mg_bMental) { @@ -244,10 +245,10 @@ void CMGButton::Render( CDrawPort *pdp) PIX pixWidth = box.Size()(1)+1; PIX pixHeight = box.Size()(2); if (mg_strLabel!="") { - pixLeft = box.Min()(1)+box.Size()(1)*0.55f; - pixWidth = box.Size()(1)*0.45f+1; + pixLeft = (PIX) (box.Min()(1)+box.Size()(1)*0.55f); + pixWidth = (PIX) (box.Size()(1)*0.45f+1); } - pdp->Fill( pixLeft, pixUp, pixWidth, pixHeight, LCDGetColor(C_dGREEN|0x40, "edit fill")); + pdp->Fill( pixLeft, pixUp, pixWidth, pixHeight, _pGame->LCDGetColor(C_dGREEN|0x40, "edit fill")); } @@ -255,9 +256,9 @@ void CMGButton::Render( CDrawPort *pdp) // print text if (mg_strLabel!="") { - PIX pixIL = box.Min()(1)+box.Size()(1)*0.45f; - PIX pixIR = box.Min()(1)+box.Size()(1)*0.55f; - PIX pixJ = box.Min()(2); + PIX pixIL = (PIX) (box.Min()(1)+box.Size()(1)*0.45f); + PIX pixIR = (PIX) (box.Min()(1)+box.Size()(1)*0.55f); + PIX pixJ = (PIX) (box.Min()(2)); pdp->PutTextR( mg_strLabel, pixIL, pixJ, col); pdp->PutText( mg_strText, pixIR, pixJ, col); @@ -284,13 +285,13 @@ void CMGButton::Render( CDrawPort *pdp) if( mg_bEditing && (((ULONG)(_pTimer->GetRealTimeTick()*2))&1)) { PIX pixX = box.Min()(1) + GetCharOffset( pdp, iCursor); if (mg_strLabel!="") { - pixX += box.Size()(1)*0.55f; + pixX += (PIX) (box.Size()(1)*0.55f); } - PIX pixY = box.Min()(2); + PIX pixY = (PIX) (box.Min()(2)); if (!pdp->dp_FontData->fd_bFixedWidth) { - pixY -= pdp->dp_fTextScaling *2; + pixY -= (PIX) (pdp->dp_fTextScaling *2); } - pdp->PutText( "|", pixX, pixY, LCDGetColor(C_WHITE|0xFF, "editing cursor")); + pdp->PutText( "|", pixX, pixY, _pGame->LCDGetColor(C_WHITE|0xFF, "editing cursor")); } } @@ -298,7 +299,7 @@ void CMGButton::Render( CDrawPort *pdp) PIX CMGButton::GetCharOffset( CDrawPort *pdp, INDEX iCharNo) { if (pdp->dp_FontData->fd_bFixedWidth) { - return (pdp->dp_FontData->fd_pixCharWidth+pdp->dp_pixTextCharSpacing)*(iCharNo-0.5f); + return ((PIX) ((pdp->dp_FontData->fd_pixCharWidth+pdp->dp_pixTextCharSpacing)*(iCharNo-0.5f))); } CTString strCut(mg_strText); strCut.TrimLeft( strlen(mg_strText)-iCharNo); @@ -329,11 +330,11 @@ void CMGModel::Render( CDrawPort *pdp) dpModel.Lock(); dpModel.FillZBuffer(1.0f); - LCDSetDrawport(&dpModel); + _pGame->LCDSetDrawport(&dpModel); // clear menu here dpModel.Fill(C_BLACK|255); - LCDRenderClouds1(); - LCDRenderClouds2(); + _pGame->LCDRenderClouds1(); + _pGame->LCDRenderClouds2(); // prepare projection CRenderModel rmRenderModel; @@ -392,13 +393,13 @@ void CMGModel::Render( CDrawPort *pdp) mg_moModel.RenderModel( rmRenderModel); EndModelRenderingView(); - LCDScreenBox(LCDGetColor(C_GREEN, "model box")|GetCurrentColor()); + _pGame->LCDScreenBox(_pGame->LCDGetColor(C_GREEN, "model box")|GetCurrentColor()); dpModel.Unlock(); pdp->Unlock(); pdp->Lock(); - LCDSetDrawport(pdp); + _pGame->LCDSetDrawport(pdp); // print the model name { @@ -606,9 +607,9 @@ void CMGHighScore::Render( CDrawPort *pdp) { SetFontMedium(pdp); - COLOR colHeader = LCDGetColor(C_GREEN|255, "hiscore header"); - COLOR colData = LCDGetColor(C_mdGREEN|255, "hiscore data"); - COLOR colLastSet = LCDGetColor(C_mlGREEN|255, "hiscore last set"); + COLOR colHeader = _pGame->LCDGetColor(C_GREEN|255, "hiscore header"); + COLOR colData = _pGame->LCDGetColor(C_mdGREEN|255, "hiscore data"); + COLOR colLastSet = _pGame->LCDGetColor(C_mlGREEN|255, "hiscore last set"); INDEX iLastSet = _pGame->gm_iLastSetHighScore; CTString strText; @@ -654,14 +655,14 @@ void CMGHighScore::Render( CDrawPort *pdp) strHighScores[i+1][5].PrintF("%9d", _pGame->gm_ahseHighScores[i].hse_ctScore); }} - PIX pixJ = pdp->GetHeight()*0.25f; + PIX pixJ = (PIX) (pdp->GetHeight()*0.25f); {for (INDEX iRow=0; iRowGetWidth()*afI[iColumn]; + PIX pixI = (PIX) (pdp->GetWidth()*afI[iColumn]); if (iColumn==1) { pdp->PutText(strHighScores[iRow][iColumn], pixI, pixJ, col); } else { @@ -669,9 +670,9 @@ void CMGHighScore::Render( CDrawPort *pdp) } }} if (iRow==0) { - pixJ+=pdp->GetHeight()*0.06f; + pixJ+=(PIX) (pdp->GetHeight()*0.06f); } else { - pixJ+=pdp->GetHeight()*0.04f; + pixJ+=(PIX) (pdp->GetHeight()*0.04f); } }} } @@ -744,9 +745,9 @@ void CMGTrigger::Render( CDrawPort *pdp) SetFontMedium(pdp); PIXaabbox2D box = FloatBoxToPixBox(pdp, mg_boxOnScreen); - PIX pixIL = box.Min()(1)+box.Size()(1)*0.45f; - PIX pixIR = box.Min()(1)+box.Size()(1)*0.55f; - PIX pixJ = box.Min()(2); + PIX pixIL = (PIX) (box.Min()(1)+box.Size()(1)*0.45f); + PIX pixIR = (PIX) (box.Min()(1)+box.Size()(1)*0.55f); + PIX pixJ = (PIX) (box.Min()(2)); COLOR col = GetCurrentColor(); if (!mg_bVisual || mg_strValue=="") { @@ -832,7 +833,7 @@ BOOL CMGSlider::OnKeyDown( int iVKey) FLOAT fRatio = FLOAT(_pixCursorPosI-boxSlider.Min()(1))/boxSlider.Size()(1); fRatio = (fRatio-0.01f)/(0.99f-0.01f); fRatio = Clamp(fRatio, 0.0f, 1.0f); - mg_iCurPos = fRatio*(mg_iMaxPos-mg_iMinPos) + mg_iMinPos; + mg_iCurPos = (INDEX) (fRatio*(mg_iMaxPos-mg_iMinPos) + mg_iMinPos); ApplyCurrentPosition(); return TRUE; } @@ -845,10 +846,10 @@ PIXaabbox2D CMGSlider::GetSliderBox(void) { extern CDrawPort *pdp; PIXaabbox2D box = FloatBoxToPixBox(pdp, mg_boxOnScreen); - PIX pixIR = box.Min()(1)+box.Size()(1)*0.55f; - PIX pixJ = box.Min()(2); - PIX pixJSize = box.Size()(2)*0.95f; - PIX pixISizeR = box.Size()(1)*0.45f; + PIX pixIR = (PIX) (box.Min()(1)+box.Size()(1)*0.55f); + PIX pixJ = (PIX) (box.Min()(2)); + PIX pixJSize = (PIX) (box.Size()(2)*0.95f); + PIX pixISizeR = (PIX) (box.Size()(1)*0.45f); if( sam_bWideScreen) pixJSize++; return PIXaabbox2D( PIX2D(pixIR+1, pixJ+1), PIX2D(pixIR+pixISizeR-2, pixJ+pixJSize-2)); } @@ -861,19 +862,19 @@ void CMGSlider::Render( CDrawPort *pdp) // get geometry COLOR col = GetCurrentColor(); PIXaabbox2D box = FloatBoxToPixBox(pdp, mg_boxOnScreen); - PIX pixIL = box.Min()(1)+box.Size()(1)*0.45f; - PIX pixIR = box.Min()(1)+box.Size()(1)*0.55f; - PIX pixJ = box.Min()(2); - PIX pixJSize = box.Size()(2)*0.95f; - PIX pixISizeR = box.Size()(1)*0.45f; + PIX pixIL = (PIX) (box.Min()(1)+box.Size()(1)*0.45f); + PIX pixIR = (PIX) (box.Min()(1)+box.Size()(1)*0.55f); + PIX pixJ = (PIX) (box.Min()(2)); + PIX pixJSize = (PIX) (box.Size()(2)*0.95f); + PIX pixISizeR = (PIX) (box.Size()(1)*0.45f); if( sam_bWideScreen) pixJSize++; // print text left of slider pdp->PutTextR( mg_strText, pixIL, pixJ, col); // draw box around slider - LCDDrawBox(0, -1, PIXaabbox2D( PIX2D(pixIR+1, pixJ), PIX2D(pixIR+pixISizeR-2, pixJ+pixJSize-2)), - LCDGetColor(C_GREEN|255, "slider box")); + PIXaabbox2D aabbox( PIX2D(pixIR+1, pixJ), PIX2D(pixIR+pixISizeR-2, pixJ+pixJSize-2)); + _pGame->LCDDrawBox(0, -1, aabbox, _pGame->LCDGetColor(C_GREEN|255, "slider box")); // draw filled part of slider pdp->Fill( pixIR+2, pixJ+1, (pixISizeR-5)*mg_fFactor, (pixJSize-4), col); @@ -908,10 +909,10 @@ PIXaabbox2D CMGVarButton::GetSliderBox(void) { extern CDrawPort *pdp; PIXaabbox2D box = FloatBoxToPixBox(pdp, mg_boxOnScreen); - PIX pixIR = box.Min()(1)+box.Size()(1)*0.55f; - PIX pixJ = box.Min()(2); - PIX pixISize = box.Size()(1)*0.13f; - PIX pixJSize = box.Size()(2); + PIX pixIR = (PIX) (box.Min()(1)+box.Size()(1)*0.55f); + PIX pixJ = (PIX) (box.Min()(2)); + PIX pixISize = (PIX) (box.Size()(1)*0.13f); + PIX pixJSize = (PIX) (box.Size()(2)); return PIXaabbox2D( PIX2D(pixIR, pixJ+1), PIX2D(pixIR+pixISize-4, pixJ+pixJSize-6)); } @@ -933,7 +934,7 @@ BOOL CMGVarButton::OnKeyDown(int iVKey) // if mouse is within if( boxSlider>=PIX2D(_pixCursorPosI, _pixCursorPosJ)) { // set new position exactly where mouse pointer is - mg_pvsVar->vs_iValue = (FLOAT)(_pixCursorPosI-boxSlider.Min()(1))/boxSlider.Size()(1) * (mg_pvsVar->vs_ctValues); + mg_pvsVar->vs_iValue = (INDEX) ((FLOAT)(_pixCursorPosI-boxSlider.Min()(1))/boxSlider.Size()(1) * (mg_pvsVar->vs_ctValues)); _bVarChanged = TRUE; } // handled @@ -998,15 +999,15 @@ void CMGVarButton::Render( CDrawPort *pdp) SetFontMedium(pdp); PIXaabbox2D box = FloatBoxToPixBox(pdp, mg_boxOnScreen); - PIX pixIL = box.Min()(1)+box.Size()(1)*0.45f; - PIX pixIR = box.Min()(1)+box.Size()(1)*0.55f; - PIX pixIC = box.Center()(1); - PIX pixJ = box.Min()(2); + PIX pixIL = (PIX) (box.Min()(1)+box.Size()(1)*0.45f); + PIX pixIR = (PIX) (box.Min()(1)+box.Size()(1)*0.55f); + PIX pixIC = (PIX) (box.Center()(1)); + PIX pixJ = (PIX) (box.Min()(2)); if (mg_pvsVar->vs_bSeparator) { mg_bEnabled = FALSE; - COLOR col = LCDGetColor(C_WHITE|255, "separator"); + COLOR col = _pGame->LCDGetColor(C_WHITE|255, "separator"); CTString strText = mg_pvsVar->vs_strName; pdp->PutTextC(strText, pixIC, pixJ, col); } @@ -1024,10 +1025,10 @@ void CMGVarButton::Render( CDrawPort *pdp) // need slider? if( mg_pvsVar->vs_iSlider>0) { // draw box around slider - PIX pixISize = box.Size()(1)*0.13f; - PIX pixJSize = box.Size()(2); - LCDDrawBox( 0,-1, PIXaabbox2D( PIX2D(pixIR, pixJ+1), PIX2D(pixIR+pixISize-4, pixJ+pixJSize-6)), - LCDGetColor(C_GREEN|255, "slider box")); + PIX pixISize = (PIX) (box.Size()(1)*0.13f); + PIX pixJSize = (PIX) (box.Size()(2)); + PIXaabbox2D aabbox( PIX2D(pixIR, pixJ+1), PIX2D(pixIR+pixISize-4, pixJ+pixJSize-6)); + _pGame->LCDDrawBox( 0, -1, aabbox, _pGame->LCDGetColor(C_GREEN|255, "slider box")); // draw filled part of slider if( mg_pvsVar->vs_iSlider==1) { // fill slider @@ -1040,7 +1041,7 @@ void CMGVarButton::Render( CDrawPort *pdp) pdp->Fill( pixIR+1+(mg_pvsVar->vs_iValue*fUnitWidth), pixJ+2, fUnitWidth, pixJSize-9, col); } // move text printout to the right of slider - pixIR += box.Size()(1)*0.15f; + pixIR += (PIX) (box.Size()(1)*0.15f); } } // write right text @@ -1257,7 +1258,7 @@ void CMGFileButton::Render( CDrawPort *pdp) PIX pixI = box.Min()(1); PIX pixJ = box.Min()(2); - COLOR col = LCDGetColor(C_mlGREEN|255, "file info"); + COLOR col = _pGame->LCDGetColor(C_mlGREEN|255, "file info"); pdp->PutText( mg_strInfo, pixI, pixJ, col); } } @@ -1323,7 +1324,7 @@ int CompareSessions(const void *pv0, const void *pv1) switch(_iSort) { case 0: iResult = stricmp(ns0.ns_strSession, ns1.ns_strSession); break; case 1: iResult = stricmp(ns0.ns_strWorld, ns1.ns_strWorld); break; - case 2: iResult = Sgn(ns0.ns_tmPing-ns1.ns_tmPing); break; + case 2: iResult = (int) (Sgn(ns0.ns_tmPing-ns1.ns_tmPing)); break; case 3: iResult = Sgn(ns0.ns_ctPlayers-ns1.ns_ctPlayers); break; case 4: iResult = stricmp(ns0.ns_strGameType, ns1.ns_strGameType); break; case 5: iResult = stricmp(ns0.ns_strMod, ns1.ns_strMod ); break; @@ -1379,7 +1380,7 @@ void SortAndFilterServers(void) _lhServers.AddTail(pnsNew->ns_lnNode); }} - _lhServers.Sort(CompareSessions, offsetof(CNetworkSession, ns_lnNode)); + _lhServers.Sort(CompareSessions, _offsetof(CNetworkSession, ns_lnNode)); } void CMGServerList::Render(CDrawPort *pdp) @@ -1431,11 +1432,11 @@ void CMGServerList::Render(CDrawPort *pdp) apixSeparatorI[1] = apixSeparatorI[2]-pixSizeMapName-pixLineSize; PIX pixSizeServerName = apixSeparatorI[1]-apixSeparatorI[0]-pixLineSize; - PIX pixTopJ = pixDPSizeJ*0.15f; - PIX pixBottomJ = pixDPSizeJ*0.82f; + PIX pixTopJ = (PIX) (pixDPSizeJ*0.15f); + PIX pixBottomJ = (PIX) (pixDPSizeJ*0.82f); - PIX pixFilterTopJ = pixTopJ+pixLineSize*3+pixCharSizeJ+pixLineSize*3; - PIX pixListTopJ = pixFilterTopJ+pixLineSize+pixCharSizeJ+pixLineSize; + PIX pixFilterTopJ = (PIX) (pixTopJ+pixLineSize*3+pixCharSizeJ+pixLineSize*3); + PIX pixListTopJ = (PIX) (pixFilterTopJ+pixLineSize+pixCharSizeJ+pixLineSize); INDEX ctSessionsOnScreen = (pixBottomJ-pixListTopJ)/pixCharSizeJ; pixBottomJ = pixListTopJ + pixCharSizeJ*ctSessionsOnScreen + pixLineSize*2; @@ -1538,12 +1539,12 @@ static PIXaabbox2D GetSliderBox(INDEX iFirst, INDEX iVisible, INDEX iTotal, return boxFull; } FLOAT fSize = ClampUp(FLOAT(iVisible)/iTotal, 1.0f); - PIX pixFull = boxFull.Size()(2); - PIX pixSize = PIX(pixFull*fSize); + PIX pixFull = (PIX) (boxFull.Size()(2)); + PIX pixSize = (PIX) (pixFull*fSize); pixSize = ClampDn(pixSize, boxFull.Size()(1)); - PIX pixTop = pixFull*(FLOAT(iFirst)/iTotal)+boxFull.Min()(2); - PIX pixI0 = boxFull.Min()(1); - PIX pixI1 = boxFull.Max()(1); + PIX pixTop = (PIX) (pixFull*(FLOAT(iFirst)/iTotal)+boxFull.Min()(2)); + PIX pixI0 = (PIX) (boxFull.Min()(1)); + PIX pixI1 = (PIX) (boxFull.Max()(1)); return PIXaabbox2D(PIX2D(pixI0, pixTop), PIX2D(pixI1, pixTop+pixSize)); } @@ -1709,7 +1710,7 @@ void CMGChangePlayer::SetPlayerText(void) if (iPlayer<0 || iPlayer>7) { mg_strText = "????"; } else { - mg_strText.PrintF(TRANS("Player %d: %s\n"), mg_iLocalPlayer+1, pc.GetNameForPrinting()); + mg_strText.PrintF(TRANS("Player %d: %s\n"), mg_iLocalPlayer+1, (const char *) pc.GetNameForPrinting()); } } @@ -1904,9 +1905,9 @@ void CMGKeyDefinition::Render( CDrawPort *pdp) SetFontMedium(pdp); PIXaabbox2D box = FloatBoxToPixBox(pdp, mg_boxOnScreen); - PIX pixIL = box.Min()(1)+box.Size()(1)*0.45f; - PIX pixIR = box.Min()(1)+box.Size()(1)*0.55f; - PIX pixJ = box.Min()(2); + PIX pixIL = (PIX) (box.Min()(1)+box.Size()(1)*0.45f); + PIX pixIR = (PIX) (box.Min()(1)+box.Size()(1)*0.55f); + PIX pixJ = (PIX) (box.Min()(2)); COLOR col = GetCurrentColor(); pdp->PutTextR( mg_strLabel, pixIL, pixJ, col); diff --git a/Sources/SeriousSam/MenuPrinting.cpp b/Sources/SeriousSam/MenuPrinting.cpp index f74abb3..af6b517 100644 --- a/Sources/SeriousSam/MenuPrinting.cpp +++ b/Sources/SeriousSam/MenuPrinting.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "SeriousSam/StdH.h" #include "MenuPrinting.h" diff --git a/Sources/SeriousSam/SeriousSam.cpp b/Sources/SeriousSam/SeriousSam.cpp index 2211f75..82baad7 100644 --- a/Sources/SeriousSam/SeriousSam.cpp +++ b/Sources/SeriousSam/SeriousSam.cpp @@ -1,10 +1,22 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "SeriousSam/StdH.h" + +#ifdef PLATFORM_WIN32 #include +#include +#endif + +// !!! FIXME: rcg01082002 Do something with these. +#ifdef PLATFORM_UNIX + #include + #if !PLATFORM_MACOSX + #include + #endif +#endif + #include #include -#include #include #include #define DECL_DLL @@ -12,47 +24,48 @@ #include "resource.h" #include "SplashScreen.h" #include "MainWindow.h" -#include "GlSettings.h" +#include "GLSettings.h" #include "LevelInfo.h" #include "LCDDrawing.h" #include "CmdLine.h" #include "Credits.h" -extern CGame *_pGame = NULL; +CGame *_pGame = NULL; // application state variables -extern BOOL _bRunning = TRUE; -extern BOOL _bQuitScreen = TRUE; -extern BOOL bMenuActive = FALSE; -extern BOOL bMenuRendering = FALSE; +BOOL _bRunning = TRUE; +BOOL _bQuitScreen = TRUE; +BOOL bMenuActive = FALSE; +BOOL bMenuRendering = FALSE; extern BOOL _bDefiningKey; static BOOL _bReconsiderInput = FALSE; -extern PIX _pixDesktopWidth = 0; // desktop width when started (for some tests) + +PIX _pixDesktopWidth = 0; // desktop width when started (for some tests) static INDEX sam_iMaxFPSActive = 500; static INDEX sam_iMaxFPSInactive = 10; static INDEX sam_bPauseOnMinimize = TRUE; // auto-pause when window has been minimized -extern INDEX sam_bWideScreen = FALSE; -extern FLOAT sam_fPlayerOffset = 0.0f; +INDEX sam_bWideScreen = FALSE; +FLOAT sam_fPlayerOffset = 0.0f; // display mode settings -extern INDEX sam_bFullScreenActive = FALSE; -extern INDEX sam_iScreenSizeI = 1024; // current size of the window -extern INDEX sam_iScreenSizeJ = 768; // current size of the window -extern INDEX sam_iDisplayDepth = 0; // 0==default, 1==16bit, 2==32bit -extern INDEX sam_iDisplayAdapter = 0; -extern INDEX sam_iGfxAPI = 0; // 0==OpenGL -extern INDEX sam_bFirstStarted = FALSE; -extern FLOAT sam_tmDisplayModeReport = 5.0f; -extern INDEX sam_bShowAllLevels = FALSE; -extern INDEX sam_bMentalActivated = FALSE; +INDEX sam_bFullScreenActive = TRUE; +INDEX sam_iScreenSizeI = 640; // current size of the window +INDEX sam_iScreenSizeJ = 480; // current size of the window +INDEX sam_iDisplayDepth = 0; // 0==default, 1==16bit, 2==32bit +INDEX sam_iDisplayAdapter = 0; +INDEX sam_iGfxAPI = 0; // 0==OpenGL +INDEX sam_bFirstStarted = TRUE; +FLOAT sam_tmDisplayModeReport = 5.0f; +INDEX sam_bShowAllLevels = FALSE; +INDEX sam_bMentalActivated = FALSE; // network settings -extern CTString sam_strNetworkSettings = ""; +CTString sam_strNetworkSettings = ""; // command line -extern CTString sam_strCommandLine = ""; +CTString sam_strCommandLine = ""; // 0...app started for the first time // 1...all ok @@ -61,54 +74,54 @@ static INDEX _iDisplayModeChangeFlag = 0; static TIME _tmDisplayModeChanged = 100.0f; // when display mode was last changed // rendering preferences for automatic settings -extern INDEX sam_iVideoSetup = 1; // 0==speed, 1==normal, 2==quality, 3==custom +INDEX sam_iVideoSetup = 1; // 0==speed, 1==normal, 2==quality, 3==custom // automatic adjustment of audio quality -extern BOOL sam_bAutoAdjustAudio = TRUE; +BOOL sam_bAutoAdjustAudio = TRUE; -extern INDEX sam_bAutoPlayDemos = TRUE; +INDEX sam_bAutoPlayDemos = TRUE; static INDEX _bInAutoPlayLoop = TRUE; // menu calling -extern INDEX sam_bMenuSave = FALSE; -extern INDEX sam_bMenuLoad = FALSE; -extern INDEX sam_bMenuControls = FALSE; -extern INDEX sam_bMenuHiScore = FALSE; -extern INDEX sam_bToggleConsole = FALSE; -extern INDEX sam_iStartCredits = FALSE; +INDEX sam_bMenuSave = FALSE; +INDEX sam_bMenuLoad = FALSE; +INDEX sam_bMenuControls = FALSE; +INDEX sam_bMenuHiScore = FALSE; +INDEX sam_bToggleConsole = FALSE; +INDEX sam_iStartCredits = FALSE; // for mod re-loading -extern CTFileName _fnmModToLoad = CTString(""); -extern CTString _strModServerJoin = CTString(""); -extern CTString _strURLToVisit = CTString(""); +CTFileName _fnmModToLoad = CTString(""); +CTString _strModServerJoin = CTString(""); +CTString _strURLToVisit = CTString(""); // state variables fo addon execution // 0 - nothing // 1 - start (invoke console) // 2 - console invoked, waiting for one redraw -extern INDEX _iAddonExecState = 0; -extern CTFileName _fnmAddonToExec = CTString(""); +INDEX _iAddonExecState = 0; +CTFileName _fnmAddonToExec = CTString(""); // logo textures static CTextureObject _toLogoCT; static CTextureObject _toLogoODI; static CTextureObject _toLogoEAX; -extern CTextureObject *_ptoLogoCT = NULL; -extern CTextureObject *_ptoLogoODI = NULL; -extern CTextureObject *_ptoLogoEAX = NULL; +CTextureObject *_ptoLogoCT = NULL; +CTextureObject *_ptoLogoODI = NULL; +CTextureObject *_ptoLogoEAX = NULL; extern CTString sam_strVersion = "1.10"; extern CTString sam_strModName = TRANS("- O P E N S O U R C E -"); #if _SE_DEMO - extern CTString sam_strFirstLevel = "Levels\\KarnakDemo.wld"; + CTString sam_strFirstLevel = "Levels\\KarnakDemo.wld"; #else - extern CTString sam_strFirstLevel = "Levels\\LevelsMP\\1_0_InTheLastEpisode.wld.wld"; + CTString sam_strFirstLevel = "Levels\\LevelsMP\\1_0_InTheLastEpisode.wld"; #endif -extern CTString sam_strIntroLevel = "Levels\\LevelsMP\\Intro.wld"; -extern CTString sam_strGameName = "serioussamse"; +CTString sam_strIntroLevel = "Levels\\LevelsMP\\Intro.wld"; +CTString sam_strGameName = "serioussamse"; -extern CTString sam_strTechTestLevel = "Levels\\LevelsMP\\TechTest.wld"; -extern CTString sam_strTrainingLevel = "Levels\\KarnakDemo.wld"; +CTString sam_strTechTestLevel = "Levels\\LevelsMP\\TechTest.wld"; +CTString sam_strTrainingLevel = "Levels\\KarnakDemo.wld"; ENGINE_API extern INDEX snd_iFormat; @@ -135,7 +148,7 @@ static void ApplyRenderingPreferences(void) ApplyGLSettings(TRUE); } -extern void ApplyVideoMode(void) +void ApplyVideoMode(void) { StartNewMode( (GfxAPIType)sam_iGfxAPI, sam_iDisplayAdapter, sam_iScreenSizeI, sam_iScreenSizeJ, (enum DisplayDepth)sam_iDisplayDepth, sam_bFullScreenActive); @@ -154,38 +167,53 @@ static void QuitGame(void) } // check if another app is already running -static HANDLE _hLock = NULL; +// !!! FIXME: rcg01042002 Actually, I've abstracted this code, but it didn't +// !!! FIXME: rcg01042002 really seem to care if there was another copy +// !!! FIXME: rcg01042002 running before anyhow. What SHOULD be done is +// !!! FIXME: rcg01042002 we should see if the lockfile exists, and if not +// !!! FIXME: rcg01042002 create it and write our process ID in it. Then, if +// !!! FIXME: rcg01042002 another copy of Serious Sam is run, it sees the +// !!! FIXME: rcg01042002 file exists, opens it for reading, gets the process +// !!! FIXME: rcg01042002 ID, and sees if that process is still running. If +// !!! FIXME: rcg01042002 so, the second copy of the game should abort. +// !!! FIXME: rcg01042002 If the process ID isn't running, recreate the file +// !!! FIXME: rcg01042002 and THEN give the warning about not shutting down +// !!! FIXME: rcg01042002 properly last time. At exit, delete the file. +// !!! FIXME: rcg01042002 This is all platform independent except for the +// !!! FIXME: rcg01042002 method of determining the current process ID and +// !!! FIXME: rcg01042002 determining if a given process ID is still running, +// !!! FIXME: rcg01042002 and those are easy abstractions. static CTFileName _fnmLock; +static FILE *_hLock = NULL; + static void DirectoryLockOn(void) { // create lock filename - _fnmLock = _fnmApplicationPath+"SeriousSam.loc"; + _fnmLock = _fnmUserDir + "SeriousSam.loc"; // try to open lock file - _hLock = CreateFileA( - _fnmLock, - GENERIC_WRITE, - 0/*no sharing*/, - NULL, // pointer to security attributes - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL|FILE_FLAG_DELETE_ON_CLOSE, // file attributes - NULL); - // if failed - if (_hLock==NULL || GetLastError()!=0) { - // report warning + + if (_pFileSystem->Exists(_fnmLock)) CPrintF(TRANS("WARNING: SeriousSam didn't shut down properly last time!\n")); + + _hLock = fopen(_fnmLock, "w"); + if (_hLock == NULL) { + FatalError(TRANS("Failed to create lockfile %s! (%s)"), + (const char *) _fnmLock, strerror(errno)); } } + static void DirectoryLockOff(void) { // if lock is open if (_hLock!=NULL) { - // close it - CloseHandle(_hLock); + fclose(_hLock); + _hLock == NULL; } + unlink(_fnmLock); } -void End(void); +void End(void); // automaticaly manage input enable/disable toggling static BOOL _bInputEnabled = FALSE; @@ -217,7 +245,7 @@ void UpdateInputEnabledState(void) // automaticaly manage pause toggling -void UpdatePauseState(void) +static void UpdatePauseState(void) { BOOL bShouldPause = (_gmRunningGameMode==GM_SINGLE_PLAYER) && (bMenuActive || _pGame->gm_csConsoleState ==CS_ON || _pGame->gm_csConsoleState ==CS_TURNINGON || _pGame->gm_csConsoleState ==CS_TURNINGOFF || @@ -243,7 +271,7 @@ void LimitFrameRate(void) iMaxFPS = ClampDn(iMaxFPS, 60L); // never go very slow if dedicated server } TIME tmWantedDelta = 1.0f / iMaxFPS; - if( tmCurrentDeltaSleep( (tmWantedDelta-tmCurrentDelta)*1000.0f); // remember new time tvLast = _pTimer->GetHighPrecisionTimer(); @@ -269,7 +297,7 @@ void StartNextDemo(void) _lhAutoDemos.AddTail(pli->li_lnNode); // if intro - if (pli->li_fnLevel==sam_strIntroLevel) { + if (pli->li_fnLevel==CTFileName(sam_strIntroLevel)) { // start intro _gmRunningGameMode = GM_NONE; _pGame->gm_aiStartLocalPlayers[0] = 0; @@ -336,11 +364,18 @@ void TrimString(char *str) // run web browser and view an url void RunBrowser(const char *strUrl) { +#ifdef PLATFORM_WIN32 int iResult = (int)ShellExecuteA( _hwndMain, "OPEN", strUrl, NULL, NULL, SW_SHOWMAXIMIZED); if (iResult<32) { // should report error? NOTHING; } + +#else + + STUBBED("Should spawn browser here"); + +#endif } void LoadAndForceTexture(CTextureObject &to, CTextureObject *&pto, const CTFileName &fnm) @@ -358,28 +393,41 @@ void LoadAndForceTexture(CTextureObject &to, CTextureObject *&pto, const CTFileN } } +#if (!defined PLATFORM_WIN32) +static char *argv0 = NULL; +#endif + void InitializeGame(void) { try { - #ifndef NDEBUG - #define GAMEDLL (_fnmApplicationExe.FileDir()+"Game"+_strModExt+"D.dll") + #ifdef STATICALLY_LINKED + #define fnmExpanded NULL + CPrintF(TRANS("Loading game library '%s'...\n"), "(statically linked)"); #else - #define GAMEDLL (_fnmApplicationExe.FileDir()+"Game"+_strModExt+".dll") + CTFileName fnmDLL; + #ifndef NDEBUG + fnmDLL = "Bin\\Debug\\Game"+_strModExt+"D.dll"; + #else + fnmDLL = "Bin\\Game"+_strModExt+".dll"; + #endif + + fnmDLL = CDynamicLoader::ConvertLibNameToPlatform(fnmDLL); + CTFileName fnmExpanded; + ExpandFilePath(EFP_READ | EFP_NOZIPS,fnmDLL,fnmExpanded); + CPrintF(TRANS("Loading game library '%s'...\n"), (const char *)fnmExpanded); #endif - CTFileName fnmExpanded; - ExpandFilePath(EFP_READ, CTString(GAMEDLL), fnmExpanded); + + const char *err; + CDynamicLoader *hGame = CDynamicLoader::GetInstance(fnmExpanded); + if ((err = hGame->GetError()) != NULL) { + ThrowF_t("%s", err); + } + CGame* (*GAME_Create)(void) = (CGame* (*)(void))hGame->FindSymbol("GAME_Create"); + if ((err = hGame->GetError()) != NULL) { + ThrowF_t("%s", err); + } - CPrintF(TRANS("Loading game library '%s'...\n"), (const char *)fnmExpanded); - HMODULE hGame = LoadLibraryA(fnmExpanded); - if (hGame==NULL) { - ThrowF_t("%s", GetWindowsError(GetLastError())); - } - CGame* (*GAME_Create)(void) = (CGame* (*)(void))GetProcAddress(hGame, "GAME_Create"); - if (GAME_Create==NULL) { - ThrowF_t("%s", GetWindowsError(GetLastError())); - } _pGame = GAME_Create(); - } catch (char *strError) { FatalError("%s", strError); } @@ -392,8 +440,15 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine) _hInstance = hInstance; ShowSplashScreen(hInstance); +// !!! FIXME: This needs to be done before DetermineDesktopWidth(), but I +// !!! FIXME: don't really want this here. +#ifdef PLATFORM_UNIX + if (SDL_Init(SDL_INIT_VIDEO) == -1) + FatalError("SDL_Init(SDL_INIT_VIDEO) failed. Reason: [%s].", SDL_GetError()); +#endif + // remember desktop width - _pixDesktopWidth = ::GetSystemMetrics(SM_CXSCREEN); + _pixDesktopWidth = DetermineDesktopWidth(); // prepare main window MainWindow_Init(); @@ -402,12 +457,19 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine) // parse command line before initializing engine ParseCommandLine(strCmdLine); +#ifdef PLATFORM_WIN32 + char argv0[MAX_PATH]; + memset(argv0, '\0', sizeof (argv0)); + GetModuleFileName(NULL, argv0, sizeof (argv0) - 1); +#endif + // initialize engine - SE_InitEngine(sam_strGameName); + SE_InitEngine(argv0, sam_strGameName); + SE_LoadDefaultFonts(); // now print the output of command line parsing - CPrintF("%s", cmd_strOutput); + CPrintF("%s", (const char *) cmd_strOutput); // lock the directory DirectoryLockOn(); @@ -425,52 +487,49 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine) _pShell->Execute( "con_bNoWarnings=1;"); // declare shell symbols - _pShell->DeclareSymbol("user void PlayDemo(CTString);", &PlayDemo); - _pShell->DeclareSymbol("persistent INDEX sam_bFullScreen;", &sam_bFullScreenActive); - _pShell->DeclareSymbol("persistent INDEX sam_iScreenSizeI;", &sam_iScreenSizeI); - _pShell->DeclareSymbol("persistent INDEX sam_iScreenSizeJ;", &sam_iScreenSizeJ); - _pShell->DeclareSymbol("persistent INDEX sam_iDisplayDepth;", &sam_iDisplayDepth); - _pShell->DeclareSymbol("persistent INDEX sam_iDisplayAdapter;", &sam_iDisplayAdapter); - _pShell->DeclareSymbol("persistent INDEX sam_iGfxAPI;", &sam_iGfxAPI); - _pShell->DeclareSymbol("persistent INDEX sam_bFirstStarted;", &sam_bFirstStarted); - _pShell->DeclareSymbol("persistent INDEX sam_bAutoAdjustAudio;", &sam_bAutoAdjustAudio); - _pShell->DeclareSymbol("persistent user INDEX sam_bWideScreen;", &sam_bWideScreen); - _pShell->DeclareSymbol("persistent user FLOAT sam_fPlayerOffset;", &sam_fPlayerOffset); - _pShell->DeclareSymbol("persistent user INDEX sam_bAutoPlayDemos;", &sam_bAutoPlayDemos); - _pShell->DeclareSymbol("persistent user INDEX sam_iMaxFPSActive;", &sam_iMaxFPSActive); - _pShell->DeclareSymbol("persistent user INDEX sam_iMaxFPSInactive;", &sam_iMaxFPSInactive); - _pShell->DeclareSymbol("persistent user INDEX sam_bPauseOnMinimize;", &sam_bPauseOnMinimize); - _pShell->DeclareSymbol("persistent user FLOAT sam_tmDisplayModeReport;", &sam_tmDisplayModeReport); - _pShell->DeclareSymbol("persistent user CTString sam_strNetworkSettings;", &sam_strNetworkSettings); - _pShell->DeclareSymbol("persistent user CTString sam_strIntroLevel;", &sam_strIntroLevel); - _pShell->DeclareSymbol("persistent user CTString sam_strGameName;", &sam_strGameName); - _pShell->DeclareSymbol("user CTString sam_strVersion;", &sam_strVersion); - _pShell->DeclareSymbol("user CTString sam_strFirstLevel;", &sam_strFirstLevel); - _pShell->DeclareSymbol("user CTString sam_strModName;", &sam_strModName); - _pShell->DeclareSymbol("persistent INDEX sam_bShowAllLevels;", &sam_bShowAllLevels); - _pShell->DeclareSymbol("persistent INDEX sam_bMentalActivated;", &sam_bMentalActivated); + _pShell->DeclareSymbol("user void PlayDemo(CTString);", (void *) &PlayDemo); + _pShell->DeclareSymbol("persistent INDEX sam_bFullScreen;", (void *) &sam_bFullScreenActive); + _pShell->DeclareSymbol("persistent INDEX sam_iScreenSizeI;", (void *) &sam_iScreenSizeI); + _pShell->DeclareSymbol("persistent INDEX sam_iScreenSizeJ;", (void *) &sam_iScreenSizeJ); + _pShell->DeclareSymbol("persistent INDEX sam_iDisplayDepth;", (void *) &sam_iDisplayDepth); + _pShell->DeclareSymbol("persistent INDEX sam_iDisplayAdapter;", (void *) &sam_iDisplayAdapter); + _pShell->DeclareSymbol("persistent INDEX sam_iGfxAPI;", (void *) &sam_iGfxAPI); + _pShell->DeclareSymbol("persistent INDEX sam_bFirstStarted;", (void *) &sam_bFirstStarted); + _pShell->DeclareSymbol("persistent INDEX sam_bAutoAdjustAudio;", (void *) &sam_bAutoAdjustAudio); + _pShell->DeclareSymbol("persistent user INDEX sam_bWideScreen;", (void *) &sam_bWideScreen); + _pShell->DeclareSymbol("persistent user FLOAT sam_fPlayerOffset;", (void *) &sam_fPlayerOffset); + _pShell->DeclareSymbol("persistent user INDEX sam_bAutoPlayDemos;", (void *) &sam_bAutoPlayDemos); + _pShell->DeclareSymbol("persistent user INDEX sam_iMaxFPSActive;", (void *) &sam_iMaxFPSActive); + _pShell->DeclareSymbol("persistent user INDEX sam_iMaxFPSInactive;", (void *) &sam_iMaxFPSInactive); + _pShell->DeclareSymbol("persistent user INDEX sam_bPauseOnMinimize;", (void *) &sam_bPauseOnMinimize); + _pShell->DeclareSymbol("persistent user FLOAT sam_tmDisplayModeReport;", (void *) &sam_tmDisplayModeReport); + _pShell->DeclareSymbol("persistent user CTString sam_strNetworkSettings;", (void *) &sam_strNetworkSettings); + _pShell->DeclareSymbol("persistent user CTString sam_strIntroLevel;", (void *) &sam_strIntroLevel); + _pShell->DeclareSymbol("persistent user CTString sam_strGameName;", (void *) &sam_strGameName); + _pShell->DeclareSymbol("user CTString sam_strVersion;", (void *) &sam_strVersion); + _pShell->DeclareSymbol("user CTString sam_strFirstLevel;", (void *) &sam_strFirstLevel); + _pShell->DeclareSymbol("user CTString sam_strModName;", (void *) &sam_strModName); + _pShell->DeclareSymbol("persistent INDEX sam_bShowAllLevels;", (void *) &sam_bShowAllLevels); + _pShell->DeclareSymbol("persistent INDEX sam_bMentalActivated;", (void *) &sam_bMentalActivated); - _pShell->DeclareSymbol("user CTString sam_strTechTestLevel;", &sam_strTechTestLevel); - _pShell->DeclareSymbol("user CTString sam_strTrainingLevel;", &sam_strTrainingLevel); - - _pShell->DeclareSymbol("user void Quit(void);", &QuitGame); + _pShell->DeclareSymbol("user void Quit(void);", (void *) &QuitGame); - _pShell->DeclareSymbol("persistent user INDEX sam_iVideoSetup;", &sam_iVideoSetup); - _pShell->DeclareSymbol("user void ApplyRenderingPreferences(void);", &ApplyRenderingPreferences); - _pShell->DeclareSymbol("user void ApplyVideoMode(void);", &ApplyVideoMode); - _pShell->DeclareSymbol("user void Benchmark(void);", &BenchMark); + _pShell->DeclareSymbol("persistent user INDEX sam_iVideoSetup;", (void *) &sam_iVideoSetup); + _pShell->DeclareSymbol("user void ApplyRenderingPreferences(void);", (void *) &ApplyRenderingPreferences); + _pShell->DeclareSymbol("user void ApplyVideoMode(void);", (void *) &ApplyVideoMode); + _pShell->DeclareSymbol("user void Benchmark(void);", (void *) &BenchMark); - _pShell->DeclareSymbol("user INDEX sam_bMenuSave;", &sam_bMenuSave); - _pShell->DeclareSymbol("user INDEX sam_bMenuLoad;", &sam_bMenuLoad); - _pShell->DeclareSymbol("user INDEX sam_bMenuControls;", &sam_bMenuControls); - _pShell->DeclareSymbol("user INDEX sam_bMenuHiScore;", &sam_bMenuHiScore); - _pShell->DeclareSymbol("user INDEX sam_bToggleConsole;",&sam_bToggleConsole); - _pShell->DeclareSymbol("INDEX sam_iStartCredits;", &sam_iStartCredits); + _pShell->DeclareSymbol("user INDEX sam_bMenuSave;", (void *) &sam_bMenuSave); + _pShell->DeclareSymbol("user INDEX sam_bMenuLoad;", (void *) &sam_bMenuLoad); + _pShell->DeclareSymbol("user INDEX sam_bMenuControls;", (void *) &sam_bMenuControls); + _pShell->DeclareSymbol("user INDEX sam_bMenuHiScore;", (void *) &sam_bMenuHiScore); + _pShell->DeclareSymbol("user INDEX sam_bToggleConsole;",(void *) &sam_bToggleConsole); + _pShell->DeclareSymbol("INDEX sam_iStartCredits;", (void *) &sam_iStartCredits); InitializeGame(); _pNetwork->md_strGameID = sam_strGameName; - LCDInit(); + _pGame->LCDInit(); if( sam_bFirstStarted) { InfoMessage("%s", TRANS( @@ -489,9 +548,9 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine) // execute script given on command line if (cmd_strScript!="") { - CPrintF("Command line script: '%s'\n", cmd_strScript); + CPrintF("Command line script: '%s'\n", (const char *) cmd_strScript); CTString strCmd; - strCmd.PrintF("include \"%s\"", cmd_strScript); + strCmd.PrintF("include \"%s\"", (const char *) cmd_strScript); _pShell->Execute(strCmd); } @@ -503,8 +562,8 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine) // !! NOTE !! Re-enable these to allow mod support. //LoadStringVar(CTString("Data\\Var\\Sam_Version.var"), sam_strVersion); //LoadStringVar(CTString("Data\\Var\\ModName.var"), sam_strModName); - CPrintF(TRANS("Serious Sam version: %s\n"), sam_strVersion); - CPrintF(TRANS("Active mod: %s\n"), sam_strModName); + CPrintF(TRANS("Serious Sam version: %s\n"), (const char *) sam_strVersion); + CPrintF(TRANS("Active mod: %s\n"), (const char *) sam_strModName); InitializeMenus(); // if there is a mod @@ -547,7 +606,7 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine) _pShell->SetINDEX("net_iPort", cmd_iPort); strPort.PrintF(":%d", cmd_iPort); } - CPrintF(TRANS("Command line connection: '%s%s'\n"), cmd_strServer, strPort); + CPrintF(TRANS("Command line connection: '%s%s'\n"), (const char *) cmd_strServer, (const char *) strPort); // go to join menu _pGame->gam_strJoinAddress = cmd_strServer; if (cmd_bQuickJoin) { @@ -558,7 +617,7 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine) } // if starting world from command line } else if (cmd_strWorld!="") { - CPrintF(TRANS("Command line world: '%s'\n"), cmd_strWorld); + CPrintF(TRANS("Command line world: '%s'\n"), (const char *) cmd_strWorld); // try to start the game with that level try { if (cmd_iGoToMarker>=0) { @@ -576,7 +635,7 @@ BOOL Init( HINSTANCE hInstance, int nCmdShow, CTString strCmdLine) StartSinglePlayerGame(); } } catch (char *strError) { - CPrintF(TRANS("Cannot start '%s': '%s'\n"), cmd_strWorld, strError); + CPrintF(TRANS("Cannot start '%s': '%s'\n"), (const char *) cmd_strWorld, strError); } // if no relevant starting at command line } else { @@ -603,7 +662,7 @@ void End(void) MainWindow_End(); DestroyMenus(); _pGame->End(); - LCDEnd(); + _pGame->LCDEnd(); // unlock the directory DirectoryLockOff(); SE_EndEngine(); @@ -630,16 +689,16 @@ void PrintDisplayModeInfo(void) // get resolution CTString strRes; extern CTString _strPreferencesDescription; - strRes.PrintF( "%dx%dx%s", slDPWidth, slDPHeight, _pGfx->gl_dmCurrentDisplayMode.DepthString()); + strRes.PrintF( "%dx%dx%s", slDPWidth, slDPHeight, (const char *) _pGfx->gl_dmCurrentDisplayMode.DepthString()); if( dm.IsDualHead()) strRes += TRANS(" DualMonitor"); if( dm.IsWideScreen()) strRes += TRANS(" WideScreen"); if( _pGfx->gl_eCurrentAPI==GAT_OGL) strRes += " (OpenGL)"; -#ifdef SE1_D3D +#ifdef PLATFORM_WIN32 else if( _pGfx->gl_eCurrentAPI==GAT_D3D) strRes += " (Direct3D)"; -#endif // SE1_D3D +#endif CTString strDescr; - strDescr.PrintF("\n%s (%s)\n", _strPreferencesDescription, RenderingPreferencesDescription(sam_iVideoSetup)); + strDescr.PrintF("\n%s (%s)\n", (const char *) _strPreferencesDescription, (const char *) RenderingPreferencesDescription(sam_iVideoSetup)); strRes+=strDescr; // tell if application is started for the first time, or failed to set mode if( _iDisplayModeChangeFlag==0) { @@ -652,12 +711,16 @@ void PrintDisplayModeInfo(void) pdp->SetFont( _pfdDisplayFont); pdp->SetTextScaling( fTextScale); pdp->SetTextAspect( 1.0f); - pdp->PutText( strRes, slDPWidth*0.05f, slDPHeight*0.85f, LCDGetColor(C_GREEN|255, "display mode")); + pdp->PutText( strRes, slDPWidth*0.05f, slDPHeight*0.85f, _pGame->LCDGetColor(C_GREEN|255, "display mode")); } // do the main game loop and render screen void DoGame(void) { + #ifdef SINGLE_THREADED + _pTimer->HandleTimerHandlers(); + #endif + // set flag if not in game if( !_pGame->gm_bGameOn) _gmRunningGameMode = GM_NONE; @@ -714,7 +777,7 @@ void DoGame(void) dpScroller.Unlock(); pdp->Lock(); } else { - pdp->Fill( LCDGetColor(C_dGREEN|CT_OPAQUE, "bcg fill")); + pdp->Fill( _pGame->LCDGetColor(C_dGREEN|CT_OPAQUE, "bcg fill")); } // do menu @@ -827,7 +890,12 @@ void QuitScreenLoop(void) return; } } - //Sleep(5); + + //_pTimer->Sleep(5); + + #ifdef SINGLE_THREADED + _pTimer->HandleTimerHandlers(); + #endif } } @@ -863,6 +931,7 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int } // system commands (also send by the application itself) +#ifdef PLATFORM_WIN32 if( msg.message==WM_SYSCOMMAND) { switch( msg.wParam & ~0x0F) { @@ -916,11 +985,18 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int break; } } +#endif // toggle full-screen on alt-enter if( msg.message==WM_SYSKEYDOWN && msg.wParam==VK_RETURN && !IsIconic(_hwndMain)) { +// !!! FIXME: This can be more efficient under Linux with +// !!! FIXME: SDL_WM_ToggleFullScreen(), since the GL context is just +// !!! FIXME: reused there... --ryan. StartNewMode( (GfxAPIType)sam_iGfxAPI, sam_iDisplayAdapter, sam_iScreenSizeI, sam_iScreenSizeJ, (enum DisplayDepth)sam_iDisplayDepth, !sam_bFullScreenActive); + + if (_pInput != NULL) // rcg02042003 hack for SDL vs. Win32. + _pInput->ClearRelativeMouseMotion(); } // if application should stop @@ -930,6 +1006,7 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int _bQuitScreen = FALSE; } +#ifdef PLATFORM_WIN32 // if application is deactivated or minimized if( (msg.message==WM_ACTIVATE && (LOWORD(msg.wParam)==WA_INACTIVE || HIWORD(msg.wParam))) || msg.message==WM_CANCELMODE @@ -950,6 +1027,7 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int // enable input back again if needed _bReconsiderInput = TRUE; } +#endif if (msg.message==WM_KEYDOWN && msg.wParam==VK_ESCAPE && (_gmRunningGameMode==GM_DEMO || _gmRunningGameMode==GM_INTRO)) { @@ -958,6 +1036,8 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int } if (_pGame->gm_csConsoleState==CS_TALK && msg.message==WM_KEYDOWN && msg.wParam==VK_ESCAPE) { + if (_pInput != NULL) // rcg02042003 hack for SDL vs. Win32. + _pInput->ClearRelativeMouseMotion(); _pGame->gm_csConsoleState = CS_OFF; msg.message=WM_NULL; } @@ -1021,7 +1101,12 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int } } else if (msg.message==WM_KEYUP) { // special handler for talk (not to invoke return key bind) - if( msg.wParam==VK_RETURN && _pGame->gm_csConsoleState==CS_TALK) _pGame->gm_csConsoleState = CS_OFF; + if( msg.wParam==VK_RETURN && _pGame->gm_csConsoleState==CS_TALK) + { + if (_pInput != NULL) // rcg02042003 hack for SDL vs. Win32. + _pInput->ClearRelativeMouseMotion(); + _pGame->gm_csConsoleState = CS_OFF; + } } else if (msg.message==WM_CHAR) { _pGame->ConsoleChar(msg); } @@ -1064,7 +1149,12 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int // if toggling console BOOL bConsoleKey = sam_bToggleConsole || msg.message==WM_KEYDOWN && + // !!! FIXME: rcg11162001 This sucks. + #ifdef PLATFORM_UNIX + (msg.wParam == SDLK_BACKQUOTE + #else (MapVirtualKey(msg.wParam, 0)==41 // scan code for '~' + #endif || msg.wParam==VK_F1 || (msg.wParam==VK_ESCAPE && _iAddonExecState==3)); if(bConsoleKey && !_bDefiningKey) { @@ -1097,6 +1187,7 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int _pNetwork->TogglePause(); } +#ifdef PLATFORM_WIN32 // if command sent from external application if (msg.message==WM_COMMAND) { // if teleport player @@ -1107,6 +1198,7 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int PostMessage(NULL, WM_SYSCOMMAND, SC_RESTORE, 0); } } +#endif // if demo is playing if (_gmRunningGameMode==GM_DEMO || @@ -1115,8 +1207,14 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int BOOL bEscape = (msg.message==WM_KEYDOWN && msg.wParam==VK_ESCAPE); // check if console-invoke key is pressed BOOL bTilde = (msg.message==WM_KEYDOWN && - (msg.wParam==VK_F1 || MapVirtualKey(msg.wParam, 0)==41));// scan code for '~' - + (msg.wParam==VK_F1 || + // !!! FIXME: ugly. + #ifdef PLATFORM_UNIX + msg.wParam == SDLK_BACKQUOTE + #else + MapVirtualKey(msg.wParam, 0)==41 // scan code for '~' + #endif + )); // check if any key is pressed BOOL bAnyKey = ( (msg.message==WM_KEYDOWN && (msg.wParam==VK_SPACE || msg.wParam==VK_RETURN))|| @@ -1197,8 +1295,14 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int void CheckModReload(void) { +#ifdef PLATFORM_WIN32 if (_fnmModToLoad!="") { - CTString strCommand = _fnmApplicationExe.FileDir()+"SeriousSam.exe"; +#ifndef NDEBUG + CTString strDebug = "Debug\\"; +#else + CTString strDebug = ""; +#endif + CTString strCommand = _fnmApplicationPath+"Bin\\"+strDebug+"SeriousSam.exe"; //+mod "+_fnmModToLoad.FileName()+"\""; CTString strMod = _fnmModToLoad.FileName(); const char *argv[7]; @@ -1214,15 +1318,22 @@ void CheckModReload(void) } _execv(strCommand, argv); } +#else + STUBBED("reload ourself?"); +#endif } void CheckTeaser(void) { - CTFileName fnmTeaser = _fnmApplicationExe.FileDir()+CTString("AfterSam.exe"); +#ifdef PLATFORM_WIN32 + CTFileName fnmTeaser = _fnmApplicationPath+CTString("Bin\\AfterSam.exe"); if (fopen(fnmTeaser, "r")!=NULL) { Sleep(500); _execl(fnmTeaser, "\""+fnmTeaser+"\"", NULL); } +#else + STUBBED("load teaser"); +#endif } void CheckBrowser(void) @@ -1233,8 +1344,7 @@ void CheckBrowser(void) } - -int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, +int CommonMainline( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int iResult; @@ -1252,6 +1362,111 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, } + +#ifdef PLATFORM_WIN32 + +int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nCmdShow) +{ + return(CommonMainline(hInstance, hPrevInstance, lpCmdLine, nCmdShow)); +} + +#else + + +// !!! FIXME: rcg01052002 This should really get dumped to the game's +// !!! FIXME: rcg01052002 console so it's in the log file, too. +#ifdef BETAEXPIRE +static inline void check_beta(void) +{ + bool bail = false; + + setbuf(stderr, NULL); + fprintf(stderr, "\n\n\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + + if ( time(NULL) > (BETAEXPIRE + 30 * 24 * 60 * 60) ) { + fprintf(stderr, + "Sorry, but this beta of the game has expired, and will no\n" + " longer run. This is to prevent tech support on out-of-date\n" + " and prerelease versions of the game. Please go to\n" + " http://www.croteam.com/ for information on getting a release\n" + " version that does not expire.\n"); + bail = true; + } else { + fprintf(stderr, " Warning: This is a beta version of SERIOUS SAM.\n"); + } + + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "\n\n\n"); + + if (bail) { + _exit(0); + } +} // check_beta +#endif + + +// !!! FIXME: rcg01102002 This should really get dumped to the game's +// !!! FIXME: rcg01102002 console so it's in the log file, too. +#ifdef PROFILING_ENABLED +static inline void warn_profiling(void) +{ + setbuf(stderr, NULL); + fprintf(stderr, "\n\n\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, " Warning: Profiling is enabled in this binary!\n"); + fprintf(stderr, " DO NOT SHIP A BINARY WITH THIS ENABLED!\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "*********************************************************\n"); + fprintf(stderr, "\n\n\n"); +} // check_beta +#endif + + + +int main(int argc, char **argv) +{ + #ifdef BETAEXPIRE + // !!! FIXME: This is Unix-centric (at least, non-win32) if put in main(). + check_beta(); + #endif + + #ifdef PROFILING_ENABLED + // !!! FIXME: This is Unix-centric (at least, non-win32) if put in main(). + warn_profiling(); + #endif + + argv0 = argv[0]; + + CTString cmdLine; + for (int i = 1; i < argc; i++) { + cmdLine += " \""; + cmdLine += argv[i]; + cmdLine += "\""; + } + + return(CommonMainline(NULL, NULL, (char *) ((const char *) cmdLine), 0)); +} + +#endif + + // try to start a new display mode BOOL TryToSetDisplayMode( enum GfxAPIType eGfxAPI, INDEX iAdapter, PIX pixSizeI, PIX pixSizeJ, enum DisplayDepth eColorDepth, BOOL bFullScreenMode) @@ -1259,7 +1474,7 @@ BOOL TryToSetDisplayMode( enum GfxAPIType eGfxAPI, INDEX iAdapter, PIX pixSizeI, CDisplayMode dmTmp; dmTmp.dm_ddDepth = eColorDepth; CPrintF( TRANS(" Starting display mode: %dx%dx%s (%s)\n"), - pixSizeI, pixSizeJ, dmTmp.DepthString(), + pixSizeI, pixSizeJ, (const char *) dmTmp.DepthString(), bFullScreenMode ? TRANS("fullscreen") : TRANS("window")); // mark to start ignoring window size/position messages until settled down @@ -1325,7 +1540,7 @@ BOOL TryToSetDisplayMode( enum GfxAPIType eGfxAPI, INDEX iAdapter, PIX pixSizeI, // initial screen fill and swap, just to get context running BOOL bSuccess = FALSE; if( pdp!=NULL && pdp->Lock()) { - pdp->Fill( LCDGetColor( C_dGREEN|CT_OPAQUE, "bcg fill")); + pdp->Fill(_pGame->LCDGetColor(C_dGREEN|CT_OPAQUE, "bcg fill")); pdp->Unlock(); pvpViewPort->SwapBuffers(); bSuccess = TRUE; diff --git a/Sources/SeriousSam/SplashScreen.cpp b/Sources/SeriousSam/SplashScreen.cpp index afc6843..e4e6b9a 100644 --- a/Sources/SeriousSam/SplashScreen.cpp +++ b/Sources/SeriousSam/SplashScreen.cpp @@ -1,10 +1,11 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "SeriousSam/StdH.h" #include "resource.h" #define NAME "Splash" +#ifdef PLATFORM_WIN32 static HBITMAP _hbmSplash = NULL; static BITMAP _bmSplash; static HBITMAP _hbmSplashMask = NULL; @@ -36,10 +37,12 @@ static long FAR PASCAL SplashWindowProc( HWND hWnd, UINT message, } return DefWindowProc(hWnd, message, wParam, lParam); } +#endif void ShowSplashScreen(HINSTANCE hInstance) { - +// !!! FIXME: wire this up for SDL? +#ifdef PLATFORM_WIN32 _hbmSplash = LoadBitmapA(hInstance, (char*)IDB_SPLASH); if (_hbmSplash==NULL) { return; @@ -97,14 +100,17 @@ void ShowSplashScreen(HINSTANCE hInstance) GetClientRect(hwnd, &rect); InvalidateRect(hwnd, &rect, TRUE); UpdateWindow(hwnd); +#endif } void HideSplashScreen(void) { +#ifdef PLATFORM_WIN32 if (hwnd==NULL) { return; } DestroyWindow(hwnd); DeleteObject(_hbmSplash); DeleteObject(_hbmSplashMask); -} \ No newline at end of file +#endif +} diff --git a/Sources/SeriousSam/StdH.cpp b/Sources/SeriousSam/StdH.cpp index a0fb0be..5f95e43 100644 --- a/Sources/SeriousSam/StdH.cpp +++ b/Sources/SeriousSam/StdH.cpp @@ -1,3 +1,4 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" \ No newline at end of file +#include "SeriousSam/StdH.h" + diff --git a/Sources/SeriousSam/StdH.h b/Sources/SeriousSam/StdH.h index 41b6065..24c5f1b 100644 --- a/Sources/SeriousSam/StdH.h +++ b/Sources/SeriousSam/StdH.h @@ -1,5 +1,12 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ +#ifndef SE_INCL_SERIOUSSAM_STDH_H +#define SE_INCL_SERIOUSSAM_STDH_H + +#ifdef PRAGMA_ONCE +#pragma once +#endif + #include #include #include @@ -17,6 +24,7 @@ #include #include #include +#include #include #undef DECL_DLL @@ -24,4 +32,7 @@ #include "SeriousSam.h" #include "Menu.h" -#include "MenuGadgets.h" \ No newline at end of file +#include "MenuGadgets.h" + +#endif + diff --git a/Sources/SeriousSam/VarList.cpp b/Sources/SeriousSam/VarList.cpp index 350a055..b13b7b4 100644 --- a/Sources/SeriousSam/VarList.cpp +++ b/Sources/SeriousSam/VarList.cpp @@ -1,15 +1,15 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "SeriousSam/StdH.h" #include "VarList.h" CListHead _lhVarSettings; -CTString _strFile; -INDEX _ctLines; +static CTString _strFile; +static INDEX _ctLines; -CTString GetNonEmptyLine_t(CTStream &strm) +static CTString GetNonEmptyLine_t(CTStream &strm) { FOREVER { if(strm.AtEOF()) { @@ -39,7 +39,7 @@ void TranslateLine(CTString &str) str.TrimSpacesLeft(); } -void FixupFileName_t(CTString &strFnm) +static void FixupFileName_t(CTString &strFnm) { strFnm.TrimSpacesLeft(); strFnm.TrimSpacesRight(); @@ -207,7 +207,7 @@ void FlushVarSettings(BOOL bApply) for(INDEX i=0; iExecute(strCmd); } } diff --git a/Sources/Shaders/AddShader.cpp b/Sources/Shaders/AddShader.cpp index 8e3cea4..35be835 100644 --- a/Sources/Shaders/AddShader.cpp +++ b/Sources/Shaders/AddShader.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #define TEXTURE_COUNT 1 #define UVMAPS_COUNT 1 diff --git a/Sources/Shaders/AddShaderDS.cpp b/Sources/Shaders/AddShaderDS.cpp index 637e5da..1b7868b 100644 --- a/Sources/Shaders/AddShaderDS.cpp +++ b/Sources/Shaders/AddShaderDS.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #define TEXTURE_COUNT 1 #define UVMAPS_COUNT 1 diff --git a/Sources/Shaders/BaseShader.cpp b/Sources/Shaders/BaseShader.cpp index fb95d4b..586a15b 100644 --- a/Sources/Shaders/BaseShader.cpp +++ b/Sources/Shaders/BaseShader.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #define TEXTURE_COUNT 1 #define UVMAPS_COUNT 1 diff --git a/Sources/Shaders/BaseShaderDS.cpp b/Sources/Shaders/BaseShaderDS.cpp index d96dd86..e1bac47 100644 --- a/Sources/Shaders/BaseShaderDS.cpp +++ b/Sources/Shaders/BaseShaderDS.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #define TEXTURE_COUNT 1 #define UVMAPS_COUNT 1 diff --git a/Sources/Shaders/BaseTransparent.cpp b/Sources/Shaders/BaseTransparent.cpp index de94e04..6b14530 100644 --- a/Sources/Shaders/BaseTransparent.cpp +++ b/Sources/Shaders/BaseTransparent.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #define TEXTURE_COUNT 1 #define UVMAPS_COUNT 1 diff --git a/Sources/Shaders/BaseTransparentDS.cpp b/Sources/Shaders/BaseTransparentDS.cpp index 9fa7742..43861ee 100644 --- a/Sources/Shaders/BaseTransparentDS.cpp +++ b/Sources/Shaders/BaseTransparentDS.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #define TEXTURE_COUNT 1 #define UVMAPS_COUNT 1 diff --git a/Sources/Shaders/ColorShader.cpp b/Sources/Shaders/ColorShader.cpp index 84867a5..6bf7122 100644 --- a/Sources/Shaders/ColorShader.cpp +++ b/Sources/Shaders/ColorShader.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" static const INDEX ctTextures = 0; static const INDEX ctUvmaps = 0; diff --git a/Sources/Shaders/Common.cpp b/Sources/Shaders/Common.cpp index 6fe28b8..6aa0483 100644 --- a/Sources/Shaders/Common.cpp +++ b/Sources/Shaders/Common.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #include void DoSpecularLayer(INDEX iSpeculaTexture,INDEX iSpecularColor) @@ -8,7 +8,7 @@ void DoSpecularLayer(INDEX iSpeculaTexture,INDEX iSpecularColor) GFXVertex4 *paVertices = shaGetVertexArray(); GFXNormal *paNormals = shaGetNormalArray(); INDEX ctVertices = shaGetVertexCount(); - FLOAT3D &vLightDir = -shaGetLightDirection().Normalize(); + FLOAT3D vLightDir = -shaGetLightDirection().Normalize(); COLOR colLight = ByteSwap(shaGetLightColor()); COLOR colAmbient = ByteSwap(shaGetAmbientColor()); GFXTexCoord *ptcUVMap = shaGetNewTexCoordArray(); @@ -35,8 +35,8 @@ void DoSpecularLayer(INDEX iSpeculaTexture,INDEX iSpecularColor) // for each vertex - INDEX ivx=0; - for(;ivx>CT_ASHIFT); - colSrfSpec.r = ClampUp( (colSrfSpec.r *slLR)>>8, 255L); - colSrfSpec.g = ClampUp( (colSrfSpec.g *slLG)>>8, 255L); - colSrfSpec.b = ClampUp( (colSrfSpec.b *slLB)>>8, 255L); + colSrfSpec.ub.r = ClampUp( (colSrfSpec.ub.r *slLR)>>8, 255L); + colSrfSpec.ub.g = ClampUp( (colSrfSpec.ub.g *slLG)>>8, 255L); + colSrfSpec.ub.b = ClampUp( (colSrfSpec.ub.b *slLB)>>8, 255L); GFXColor *pcolSpec = shaGetNewColorArray(); GFXColor *pcolBase = shaGetColorArray();; @@ -67,10 +67,10 @@ void DoSpecularLayer(INDEX iSpeculaTexture,INDEX iSpecularColor) // for each vertex in the surface for(ivx=0;ivx>8) - | (((colSrfSpec.g)*slShade)&0x0000FF00) - |((((colSrfSpec.b)*slShade)<<8)&0x00FF0000); + const SLONG slShade = pcolBase[ivx].ub.a; + pcolSpec[ivx].ul.abgr = (((colSrfSpec.ub.r)*slShade)>>8) + | (((colSrfSpec.ub.g)*slShade)&0x0000FF00) + |((((colSrfSpec.ub.b)*slShade)<<8)&0x00FF0000); } @@ -122,15 +122,15 @@ void DoReflectionLayer(INDEX iReflectionTexture,INDEX iReflectionColor,BOOL bFul // map reflected vector to texture // NOTE: using X and Z axes, so that singularity gets on -Y axis (where it will least probably be seen) const FLOAT f1oFM = 0.5f / sqrt(2+2*fRVy); - ptcUVMap[ivx].s = fRVx*f1oFM +0.5f; - ptcUVMap[ivx].t = fRVz*f1oFM +0.5f; + ptcUVMap[ivx].st.s = fRVx*f1oFM +0.5f; + ptcUVMap[ivx].st.t = fRVz*f1oFM +0.5f; } GFXColor *pcolReflection = shaGetNewColorArray(); // get model reflection color GFXColor colSrfRefl; - colSrfRefl.abgr = ByteSwap(shaGetColor(iReflectionColor)); + colSrfRefl.ul.abgr = ByteSwap(shaGetColor(iReflectionColor)); colSrfRefl.AttenuateA((shaGetModelColor()&CT_AMASK)>>CT_ASHIFT); if(bFullBright) { diff --git a/Sources/Shaders/DetailShader.cpp b/Sources/Shaders/DetailShader.cpp index f0c5645..95ef5cf 100644 --- a/Sources/Shaders/DetailShader.cpp +++ b/Sources/Shaders/DetailShader.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #undef TEXTURE_COUNT #undef UVMAPS_COUNT @@ -86,8 +86,8 @@ SHADER_MAIN(Detail) if(ctTexCoords>0) { for(INDEX itxc=0;itxc0) { for(INDEX itxc=0;itxc0 && ptxcOld!=NULL) { for(INDEX itxc=0;itxc0 && ptxcOld!=NULL) { for(INDEX itxc=0; itxc #include diff --git a/Sources/Shaders/ReflectionDS.cpp b/Sources/Shaders/ReflectionDS.cpp index 020e61e..0ea483b 100644 --- a/Sources/Shaders/ReflectionDS.cpp +++ b/Sources/Shaders/ReflectionDS.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #include #include diff --git a/Sources/Shaders/ReftectionAndSpecular.cpp b/Sources/Shaders/ReftectionAndSpecular.cpp index cc2addc..a5cc4f0 100644 --- a/Sources/Shaders/ReftectionAndSpecular.cpp +++ b/Sources/Shaders/ReftectionAndSpecular.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #include #include diff --git a/Sources/Shaders/ReftectionAndSpecularDS.cpp b/Sources/Shaders/ReftectionAndSpecularDS.cpp index 936c357..cc9029e 100644 --- a/Sources/Shaders/ReftectionAndSpecularDS.cpp +++ b/Sources/Shaders/ReftectionAndSpecularDS.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #include #include diff --git a/Sources/Shaders/Specular.cpp b/Sources/Shaders/Specular.cpp index 64b648a..23d6109 100644 --- a/Sources/Shaders/Specular.cpp +++ b/Sources/Shaders/Specular.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #include #include diff --git a/Sources/Shaders/SpecularDS.cpp b/Sources/Shaders/SpecularDS.cpp index 4c1ab11..c94b8d4 100644 --- a/Sources/Shaders/SpecularDS.cpp +++ b/Sources/Shaders/SpecularDS.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #include #include diff --git a/Sources/Shaders/StdH.cpp b/Sources/Shaders/StdH.cpp index a0fb0be..cc22912 100644 --- a/Sources/Shaders/StdH.cpp +++ b/Sources/Shaders/StdH.cpp @@ -1,3 +1,4 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" \ No newline at end of file +#include "Shaders/StdH.h" + diff --git a/Sources/Shaders/StdH.h b/Sources/Shaders/StdH.h index cccb432..295599b 100644 --- a/Sources/Shaders/StdH.h +++ b/Sources/Shaders/StdH.h @@ -6,4 +6,7 @@ /* rcg10042001 protect against Visual C-isms. */ #ifdef _MSC_VER #define DECL_DLL _declspec(dllexport) +#else +#define DECL_DLL #endif + diff --git a/Sources/Shaders/Translucent.cpp b/Sources/Shaders/Translucent.cpp index 1032fcb..9507117 100644 --- a/Sources/Shaders/Translucent.cpp +++ b/Sources/Shaders/Translucent.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include "Shaders/StdH.h" #define TEXTURE_COUNT 1 #define UVMAPS_COUNT 1